diff --git a/.prettierignore b/.prettierignore index 8bef7917d..ddaeab9fa 100644 --- a/.prettierignore +++ b/.prettierignore @@ -62,3 +62,6 @@ grammars/ # auto generated code model files packages/http-client-csharp/generator/TestProjects/**/tspCodeModel.json + +# auto generated api view properties files +packages/http-client-java/generator/http-client-generator-test/src/main/**/*.json diff --git a/cspell.yaml b/cspell.yaml index a0341e936..0baedbba2 100644 --- a/cspell.yaml +++ b/cspell.yaml @@ -27,6 +27,7 @@ words: - cobertura - codehaus - codeql + - collisons - Contoso - CORGE - createsorreplacesresource @@ -74,6 +75,7 @@ words: - LINUXNEXTVMIMAGE - LINUXOS - LINUXVMIMAGE + - lropaging - lzutf - MACVMIMAGE - mgmt @@ -123,9 +125,9 @@ words: - sint - snakeyaml - srnagar - - statment - sses - ssvs + - statment - strs - syncpack - TCGC @@ -178,6 +180,7 @@ ignorePaths: - common/scripts/* - "**/ThirdPartyNotices.txt" - packages/compiler/test/formatter/scenarios/** + - packages/http-client-java/generator/http-client-generator-test/** - pnpm-lock.yaml - "**/*.mp4" - .git/** diff --git a/packages/http-client-java/Setup.ps1 b/packages/http-client-java/Setup.ps1 index 0c4b59e86..a3931d026 100644 --- a/packages/http-client-java/Setup.ps1 +++ b/packages/http-client-java/Setup.ps1 @@ -11,5 +11,5 @@ if ($RebuildJar) { # re-build http-client-java npm install -npm run clean && npm run build:emitter +npm run clean && npm run build diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index 64323ba8e..e3fbd8329 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -41,16 +41,12 @@ import { VirtualParameter, } from "@autorest/codemodel"; import { KnownMediaType } from "@azure-tools/codegen"; -import { - getLroMetadata, - getPagedResult, - isPollingLocation, -} from "@azure-tools/typespec-azure-core"; import { SdkArrayType, SdkBodyModelPropertyType, + SdkBodyParameter, SdkBuiltInType, - SdkClient, + SdkClientType, SdkConstantType, SdkContext, SdkDateTimeType, @@ -58,28 +54,27 @@ import { SdkDurationType, SdkEnumType, SdkEnumValueType, + SdkHeaderParameter, + SdkHttpOperation, + SdkHttpResponse, + SdkLroPagingServiceMethod, + SdkLroServiceMethod, + SdkMethod, SdkModelPropertyType, SdkModelType, + SdkPathParameter, + SdkQueryParameter, + SdkServiceMethod, SdkType, SdkUnionType, + UsageFlags, createSdkContext, getAllModels, - getClientNameOverride, getClientType, - getCrossLanguageDefinitionId, - getDefaultApiVersion, - getHttpOperationExamples, - getHttpOperationWithCache, getWireName, isApiVersion, - isInternal, isSdkBuiltInKind, isSdkIntKind, - listClients, - listOperationGroups, - listOperationsInOperationGroup, - shouldGenerateConvenient, - shouldGenerateProtocol, } from "@azure-tools/typespec-client-generator-core"; import { EmitContext, @@ -89,53 +84,45 @@ import { Namespace, Operation, Program, - Scalar, Type, TypeNameOptions, Union, getDoc, getEffectiveModelType, - getEncode, - getFriendlyName, getNamespaceFullName, getOverloadedOperation, - getProjectedName, getSummary, getVisibility, isArrayModelType, - isErrorModel, isRecordModelType, - isVoidType, listServices, } from "@typespec/compiler"; import { Authentication, HttpOperation, - HttpOperationBody, - HttpOperationMultipartBody, - HttpOperationParameter, - HttpOperationResponse, - HttpServer, + HttpStatusCodeRange, HttpStatusCodesEntry, Visibility, getAuthentication, getHeaderFieldName, - getHeaderFieldOptions, getPathParamName, getQueryParamName, - getQueryParamOptions, - getServers, - getStatusCodeDescription, + isBody, + isBodyRoot, isHeader, + isMultipartBodyProperty, isPathParam, isQueryParam, } from "@typespec/http"; -import { getResourceOperation, getSegment } from "@typespec/rest"; -import { Version, getAddedOnVersions, getVersion } from "@typespec/versioning"; +import { getSegment } from "@typespec/rest"; +import { getAddedOnVersions } from "@typespec/versioning"; import { fail } from "assert"; import pkg from "lodash"; -import { pathToFileURL } from "url"; -import { Client as CodeModelClient, CrossLanguageDefinition } from "./common/client.js"; +import { + Client as CodeModelClient, + CrossLanguageDefinition, + EncodedSchema, +} from "./common/client.js"; import { CodeModel } from "./common/code-model.js"; import { LongRunningMetadata } from "./common/long-running-metadata.js"; import { Operation as CodeModelOperation, ConvenienceApi, Request } from "./common/operation.js"; @@ -148,6 +135,7 @@ import { EmitterOptions } from "./emitter.js"; import { createPollOperationDetailsSchema, getFileDetailsSchema } from "./external-schemas.js"; import { ClientContext } from "./models.js"; import { + CONTENT_TYPE_KEY, ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, cloneOperationParameter, @@ -167,19 +155,15 @@ import { getNonNullSdkType, getUnionDescription, getUsage, - hasScalarAsBase, - isArmCommonType, - isModelReferredInTemplate, - isNullableType, isStable, modelIs, pushDistinct, } from "./type-utils.js"; import { - getJavaNamespace, getNamespace, logWarning, pascalCase, + removeClientSuffix, stringArrayContainsIgnoreCase, trace, } from "./utils.js"; @@ -203,7 +187,7 @@ export class CodeModelBuilder { readonly typeUnionRefCache = new Map(); // Union means it ref a Union type, null means it does not ref any Union, undefined means type visited but not completed // current apiVersion name to generate code - private apiVersion: Version | undefined; + private apiVersion: string | undefined; public constructor(program1: Program, context: EmitContext) { this.options = context.options; @@ -228,7 +212,7 @@ export class CodeModelBuilder { this.namespace = getNamespaceFullName(serviceNamespace) || "Azure.Client"; // java namespace - const javaNamespace = getJavaNamespace(this.namespace); + const javaNamespace = this.getJavaNamespace(this.namespace); const namespace1 = this.namespace; this.typeNameOptions = { @@ -262,7 +246,9 @@ export class CodeModelBuilder { } public async build(): Promise { - this.sdkContext = await createSdkContext(this.emitterContext, "@typespec/http-client-java"); + this.sdkContext = await createSdkContext(this.emitterContext, "@typespec/http-client-java", { + versioning: { previewStringRegex: /$/ }, + }); // include all versions and do the filter by ourselves // auth // TODO: it is not very likely, but different client could have different auth @@ -277,9 +263,9 @@ export class CodeModelBuilder { this.options["group-etag-headers"] = false; } - const clients = this.processClients(); + this.processClients(); - this.processModels(clients); + this.processModels(); this.processSchemaUsage(); @@ -292,67 +278,40 @@ export class CodeModelBuilder { return this.codeModel; } - private processHost(server: HttpServer | undefined): Parameter[] { + private processHostParameters(sdkPathParameters: SdkPathParameter[]): Parameter[] { const hostParameters: Parameter[] = []; - if (server && !this.isArmSynthesizedServer(server)) { - server.parameters.forEach((it) => { - let parameter; + let parameter; + sdkPathParameters.forEach((arg) => { + if (arg.isApiVersionParam) { + parameter = this.createApiVersionParameter(arg.name, ParameterLocation.Uri); + } else { + const schema = this.processSchemaFromSdkType(arg.type, arg.name); + this.trackSchemaUsage(schema, { + usage: [SchemaContext.Input, SchemaContext.Output /*SchemaContext.Public*/], + }); + parameter = new Parameter(arg.name, arg.description ?? "", schema, { + implementation: ImplementationLocation.Client, + origin: "modelerfour:synthesized/host", + required: true, + protocol: { + http: new HttpParameter(ParameterLocation.Uri), + }, + language: { + default: { + serializedName: arg.name, + }, + }, + // TODO: deprecate this logic of string/url for x-ms-skip-url-encoding + extensions: { + "x-ms-skip-url-encoding": schema instanceof UriSchema, + }, + clientDefaultValue: arg.clientDefaultValue, + }); + } + hostParameters.push(this.codeModel.addGlobalParameter(parameter)); + }); - if (isApiVersion(this.sdkContext, it)) { - parameter = this.createApiVersionParameter(it.name, ParameterLocation.Uri); - } else { - const sdkType = getClientType(this.sdkContext, it.type); - const schema = this.processSchemaFromSdkType(sdkType, it.name); - this.trackSchemaUsage(schema, { - usage: [SchemaContext.Input, SchemaContext.Output /*SchemaContext.Public*/], - }); - parameter = new Parameter(this.getName(it), this.getDoc(it), schema, { - implementation: ImplementationLocation.Client, - origin: "modelerfour:synthesized/host", - required: !it.optional, - protocol: { - http: new HttpParameter(ParameterLocation.Uri), - }, - language: { - default: { - serializedName: it.name, - }, - }, - extensions: { - "x-ms-skip-url-encoding": schema instanceof UriSchema, - }, - // // make the logic same as TCGC, which takes the server-side default of host as client-side default - // clientDefaultValue: getDefaultValue(it.defaultValue), - }); - } - - hostParameters.push(this.codeModel.addGlobalParameter(parameter)); - }); - return hostParameters; - } else { - // use "endpoint" - hostParameters.push( - this.codeModel.addGlobalParameter( - new Parameter("endpoint", "Server parameter", this.stringSchema, { - implementation: ImplementationLocation.Client, - origin: "modelerfour:synthesized/host", - required: true, - protocol: { - http: new HttpParameter(ParameterLocation.Uri), - }, - language: { - default: { - serializedName: "endpoint", - }, - }, - extensions: { - "x-ms-skip-url-encoding": true, - }, - }) - ) - ); - return hostParameters; - } + return hostParameters; } private processAuth(auth: Authentication) { @@ -416,18 +375,7 @@ export class CodeModelBuilder { return !this.options["flavor"] || this.options["flavor"].toLocaleLowerCase() === "azure"; } - private isInternal(context: SdkContext, operation: Operation): boolean { - const access = getAccess(operation); - if (access) { - return access === "internal"; - } else { - // TODO: deprecate "internal" - // eslint-disable-next-line deprecation/deprecation - return isInternal(context, operation); - } - } - - private processModels(clients: SdkClient[]) { + private processModels() { const processedSdkModels: Set = new Set(); // lambda to mark model as public @@ -533,14 +481,32 @@ export class CodeModelBuilder { } } - private processClients(): SdkClient[] { - const clients = listClients(this.sdkContext); + private processClients() { // preprocess group-etag-headers this.options["group-etag-headers"] = this.options["group-etag-headers"] ?? true; - for (const client of clients) { - const codeModelClient = new CodeModelClient(client.name, this.getDoc(client.type), { - summary: this.getSummary(client.type), + const sdkPackage = this.sdkContext.sdkPackage; + for (const client of sdkPackage.clients) { + let clientName = client.name; + let javaNamespace = this.getJavaNamespace(this.namespace); + const clientFullName = client.name; + const clientNameSegments = clientFullName.split("."); + if (clientNameSegments.length > 1) { + clientName = clientNameSegments.at(-1)!; + const clientSubNamespace = clientNameSegments.slice(0, -1).join("."); + javaNamespace = this.getJavaNamespace(this.namespace + "." + clientSubNamespace); + } + + const codeModelClient = new CodeModelClient(clientName, client.details ?? "", { + summary: client.description, + language: { + default: { + namespace: this.namespace, + }, + java: { + namespace: javaNamespace, + }, + }, // at present, use global security definition security: this.codeModel.security, @@ -548,15 +514,12 @@ export class CodeModelBuilder { codeModelClient.crossLanguageDefinitionId = client.crossLanguageDefinitionId; // versioning - const versioning = getVersion(this.program, client.service); - if (versioning && versioning.getVersions()) { - // @versioned in versioning + const versions = client.apiVersions; + if (versions && versions.length > 0) { if (!this.sdkContext.apiVersion || ["all", "latest"].includes(this.sdkContext.apiVersion)) { - this.apiVersion = getDefaultApiVersion(this.sdkContext, client.service); + this.apiVersion = versions[versions.length - 1]; } else { - this.apiVersion = versioning - .getVersions() - .find((it: Version) => it.value === this.sdkContext.apiVersion); + this.apiVersion = versions.find((it: string) => it === this.sdkContext.apiVersion); if (!this.apiVersion) { throw new Error("Unrecognized api-version: " + this.sdkContext.apiVersion); } @@ -565,105 +528,155 @@ export class CodeModelBuilder { codeModelClient.apiVersions = []; for (const version of this.getFilteredApiVersions( this.apiVersion, - versioning.getVersions(), + versions, this.options["service-version-exclude-preview"] )) { const apiVersion = new ApiVersion(); - apiVersion.version = version.value; + apiVersion.version = version; codeModelClient.apiVersions.push(apiVersion); } } - // server + // client initialization let baseUri = "{endpoint}"; - const servers = getServers(this.program, client.service); - if (servers && servers.length === 1 && !this.isArmSynthesizedServer(servers[0])) { - baseUri = servers[0].url; - } - const hostParameters = this.processHost(servers?.length === 1 ? servers[0] : undefined); - codeModelClient.addGlobalParameters(hostParameters); + let hostParameters: Parameter[] = []; + client.initialization.properties.forEach((initializationProperty) => { + if (initializationProperty.kind === "endpoint") { + let sdkPathParameters: SdkPathParameter[] = []; + if (initializationProperty.type.kind === "union") { + if (initializationProperty.type.values.length === 2) { + // only get the sdkPathParameters from the endpoint whose serverUrl is not {"endpoint"} + for (const endpointType of initializationProperty.type.values) { + if (endpointType.kind === "endpoint" && endpointType.serverUrl !== "{endpoint}") { + sdkPathParameters = endpointType.templateArguments; + baseUri = endpointType.serverUrl; + } + } + } else if (initializationProperty.type.values.length > 2) { + throw new Error("Multiple server url defined for one client is not supported yet."); + } + } else if (initializationProperty.type.kind === "endpoint") { + sdkPathParameters = initializationProperty.type.templateArguments; + baseUri = initializationProperty.type.serverUrl; + } + + hostParameters = this.processHostParameters(sdkPathParameters); + codeModelClient.addGlobalParameters(hostParameters); + } + }); + const clientContext = new ClientContext( baseUri, hostParameters, codeModelClient.globalParameters!, codeModelClient.apiVersions ); - clientContext.preProcessOperations(this.sdkContext, client); - const operationGroups = listOperationGroups(this.sdkContext, client, true); - - const operationWithoutGroup = listOperationsInOperationGroup(this.sdkContext, client); + // preprocess operation groups and operations + // operations without operation group + const serviceMethodsWithoutSubClient = this.listServiceMethodsUnderClient(client); let codeModelGroup = new OperationGroup(""); - for (const operation of operationWithoutGroup) { - if (!this.needToSkipProcessingOperation(operation, clientContext)) { - codeModelGroup.addOperation(this.processOperation("", operation, clientContext)); + for (const serviceMethod of serviceMethodsWithoutSubClient) { + if (!this.needToSkipProcessingOperation(serviceMethod.__raw, clientContext)) { + codeModelGroup.addOperation(this.processOperation(serviceMethod, clientContext, "")); } } if (codeModelGroup.operations?.length > 0) { codeModelClient.operationGroups.push(codeModelGroup); } - for (const operationGroup of operationGroups) { - const operations = listOperationsInOperationGroup(this.sdkContext, operationGroup); + // operations under operation groups + const subClients = this.listSubClientsUnderClient(client, true, true); + for (const subClient of subClients) { + const serviceMethods = this.listServiceMethodsUnderClient(subClient); // operation group with no operation is skipped - if (operations.length > 0) { - const groupPath = operationGroup.groupPath.split("."); - let operationGroupName: string; - if (groupPath.length > 1) { - // groupPath should be in format of "OpenAIClient.Chat.Completions" - operationGroupName = groupPath.slice(1).join(""); - } else { - // protection - operationGroupName = operationGroup.type.name; - } - codeModelGroup = new OperationGroup(operationGroupName); - for (const operation of operations) { - if (!this.needToSkipProcessingOperation(operation, clientContext)) { + if (serviceMethods.length > 0) { + codeModelGroup = new OperationGroup(subClient.name); + for (const serviceMethod of serviceMethods) { + if (!this.needToSkipProcessingOperation(serviceMethod.__raw, clientContext)) { codeModelGroup.addOperation( - this.processOperation(operationGroupName, operation, clientContext) + this.processOperation(serviceMethod, clientContext, subClient.name) ); } } codeModelClient.operationGroups.push(codeModelGroup); } } - this.codeModel.clients.push(codeModelClient); - } - // postprocess for ServiceVersion - let apiVersionSameForAllClients = true; - let sharedApiVersions = undefined; - for (const client of this.codeModel.clients) { - const apiVersions = client.apiVersions; - if (!apiVersions) { - // client does not have apiVersions - apiVersionSameForAllClients = false; - } else if (!sharedApiVersions) { - // first client, set it to sharedApiVersions - sharedApiVersions = apiVersions; - } else { - apiVersionSameForAllClients = isEqual(sharedApiVersions, apiVersions); - } - if (!apiVersionSameForAllClients) { - break; - } - } - if (apiVersionSameForAllClients) { - const serviceVersion = getServiceVersion(this.codeModel); - for (const client of this.codeModel.clients) { - client.serviceVersion = serviceVersion; - } - } else { + // postprocess for ServiceVersion + let apiVersionSameForAllClients = true; + let sharedApiVersions = undefined; for (const client of this.codeModel.clients) { const apiVersions = client.apiVersions; - if (apiVersions) { - client.serviceVersion = getServiceVersion(client); + if (!apiVersions) { + // client does not have apiVersions + apiVersionSameForAllClients = false; + } else if (!sharedApiVersions) { + // first client, set it to sharedApiVersions + sharedApiVersions = apiVersions; + } else { + apiVersionSameForAllClients = isEqual(sharedApiVersions, apiVersions); + } + if (!apiVersionSameForAllClients) { + break; + } + } + if (apiVersionSameForAllClients) { + const serviceVersion = getServiceVersion(this.codeModel); + for (const client of this.codeModel.clients) { + client.serviceVersion = serviceVersion; + } + } else { + for (const client of this.codeModel.clients) { + const apiVersions = client.apiVersions; + if (apiVersions) { + client.serviceVersion = getServiceVersion(client); + } } } } + } - return clients; + private listSubClientsUnderClient( + client: SdkClientType, + includeNestedOperationGroups: boolean, + isRootClient: boolean + ): SdkClientType[] { + const operationGroups: SdkClientType[] = []; + for (const method of client.methods) { + if (method.kind === "clientaccessor") { + const subClient = method.response; + if (!isRootClient) { + // if it is not root client, append the parent client's name + subClient.name = + removeClientSuffix(client.name) + removeClientSuffix(pascalCase(subClient.name)); + } + operationGroups.push(subClient); + if (includeNestedOperationGroups) { + for (const operationGroup of this.listSubClientsUnderClient( + subClient, + includeNestedOperationGroups, + false + )) { + operationGroups.push(operationGroup); + } + } + } + } + return operationGroups; + } + + private listServiceMethodsUnderClient( + client: SdkClientType + ): SdkServiceMethod[] { + const methods: SdkServiceMethod[] = []; + for (const method of client.methods) { + if (method.kind !== "clientaccessor") { + methods.push(method); + } + } + return methods; } /** @@ -675,10 +688,10 @@ export class CodeModelBuilder { * @returns filtered api-versions */ private getFilteredApiVersions( - pinnedApiVersion: Version | undefined, - versions: Version[], + pinnedApiVersion: string | undefined, + versions: string[], excludePreview: boolean = false - ): Version[] { + ): string[] { if (!pinnedApiVersion) { return versions; } @@ -687,24 +700,15 @@ export class CodeModelBuilder { .filter((version) => !excludePreview || !isStable(pinnedApiVersion) || isStable(version)); } - /** - * `@armProviderNamespace` currently will add a default server if not defined globally: - * https://github.com/Azure/typespec-azure/blob/8b8d7c05f168d9305a09691c4fedcb88f4a57652/packages/typespec-azure-resource-manager/src/namespace.ts#L121-L128 - * TODO: if the synthesized server has the right hostParameter, we can use that instead - * - * @param server returned by getServers - * @returns whether it's synthesized by `@armProviderNamespace` - */ - private isArmSynthesizedServer(server: HttpServer): boolean { - return this.isArm() && (!server.parameters || server.parameters.size === 0); - } - private needToSkipProcessingOperation( - operation: Operation, + operation: Operation | undefined, clientContext: ClientContext ): boolean { // don't generate protocol and convenience method for overloaded operations // issue link: https://github.com/Azure/autorest.java/issues/1958#issuecomment-1562558219 we will support generate overload methods for non-union type in future (TODO issue: https://github.com/Azure/autorest.java/issues/2160) + if (operation === undefined) { + return true; + } if (getOverloadedOperation(this.program, operation)) { this.trace( `Operation '${operation.name}' is temporary skipped, as it is an overloaded operation` @@ -721,15 +725,21 @@ export class CodeModelBuilder { return Boolean(this.options["advanced-versioning"]); } - private getOperationExample(operation: HttpOperation): Record | undefined { - const httpOperationExamples = getHttpOperationExamples(this.sdkContext, operation); + private getOperationExample( + sdkMethod: SdkServiceMethod + ): Record | undefined { + const httpOperationExamples = sdkMethod.operation.examples; if (httpOperationExamples && httpOperationExamples.length > 0) { const operationExamples: Record = {}; for (const example of httpOperationExamples) { const operationExample = example.rawExample; - operationExample["x-ms-original-file"] = pathToFileURL(example.filePath).toString(); + + // example.filePath is relative path from sdkContext.examplesDir + // this is not a URL format (file:// or https://) + operationExample["x-ms-original-file"] = example.filePath; + operationExamples[ - operationExample.title ?? operationExample.operationId ?? operation.operation.name + operationExample.title ?? operationExample.operationId ?? sdkMethod.name ] = operationExample; } return operationExamples; @@ -739,68 +749,56 @@ export class CodeModelBuilder { } private processOperation( - groupName: string, - operation: Operation, - clientContext: ClientContext + sdkMethod: SdkServiceMethod, + clientContext: ClientContext, + groupName: string ): CodeModelOperation { - const op = getHttpOperationWithCache(this.sdkContext, operation); - + const operationName = sdkMethod.name; + const httpOperation = sdkMethod.operation; + const operationId = groupName ? `${groupName}_${operationName}` : `${operationName}`; const operationGroup = this.codeModel.getOperationGroup(groupName); - const operationName = this.getName(operation); - const opId = groupName ? `${groupName}_${operationName}` : `${operationName}`; - const operationExamples = this.getOperationExample(op); + const operationExamples = this.getOperationExample(sdkMethod); - const codeModelOperation = new CodeModelOperation(operationName, this.getDoc(operation), { - operationId: opId, - summary: this.getSummary(operation), + const codeModelOperation = new CodeModelOperation(operationName, sdkMethod.details ?? "", { + operationId: operationId, + summary: sdkMethod.description, extensions: { "x-ms-examples": operationExamples, }, }); (codeModelOperation as CrossLanguageDefinition).crossLanguageDefinitionId = - getCrossLanguageDefinitionId(this.sdkContext, operation); - codeModelOperation.internalApi = this.isInternal(this.sdkContext, operation); + sdkMethod.crossLanguageDefintionId; + codeModelOperation.internalApi = sdkMethod.access === "internal"; - const convenienceApiName = this.getConvenienceApiName(operation); - let generateConvenienceApi: boolean = Boolean(convenienceApiName); - let generateProtocolApi: boolean = shouldGenerateProtocol(this.sdkContext, operation); + const convenienceApiName = this.getConvenienceApiName(sdkMethod); + let generateConvenienceApi: boolean = sdkMethod.generateConvenient; + let generateProtocolApi: boolean = sdkMethod.generateProtocol; let apiComment: string | undefined = undefined; if (generateConvenienceApi) { // check if the convenience API need to be disabled for some special cases - if (operationIsMultipart(op)) { + if (operationIsMultipart(httpOperation)) { // do not generate protocol method for multipart/form-data, as it be very hard for user to prepare the request body as BinaryData generateProtocolApi = false; - apiComment = `Protocol API requires serialization of parts with content-disposition and data, as operation '${op.operation.name}' is 'multipart/form-data'`; + apiComment = `Protocol API requires serialization of parts with content-disposition and data, as operation '${operationName}' is 'multipart/form-data'`; this.logWarning(apiComment); - } else if (operationIsMultipleContentTypes(op)) { + } else if (operationIsMultipleContentTypes(httpOperation)) { // and multiple content types // issue link: https://github.com/Azure/autorest.java/issues/1958#issuecomment-1562558219 generateConvenienceApi = false; - apiComment = `Convenience API is not generated, as operation '${op.operation.name}' is multiple content-type`; + apiComment = `Convenience API is not generated, as operation '${operationName}' is multiple content-type`; this.logWarning(apiComment); } else if ( - operationIsJsonMergePatch(op) && + operationIsJsonMergePatch(httpOperation) && this.options["stream-style-serialization"] === false ) { // do not generate convenient method for json merge patch operation if stream-style-serialization is not enabled generateConvenienceApi = false; - apiComment = `Convenience API is not generated, as operation '${op.operation.name}' is 'application/merge-patch+json' and stream-style-serialization is not enabled`; + apiComment = `Convenience API is not generated, as operation '${operationName}' is 'application/merge-patch+json' and stream-style-serialization is not enabled`; this.logWarning(apiComment); } - // else { - // const union = operationRefersUnion(this.program, op, this.typeUnionRefCache); - // if (union) { - // // and Union - // generateConvenienceApi = false; - // apiComment = `Convenience API is not generated, as operation '${ - // op.operation.name - // }' refers Union '${getUnionDescription(union, this.typeNameOptions)}'`; - // this.logWarning(apiComment); - // } - // } } if (generateConvenienceApi && convenienceApiName) { codeModelOperation.convenienceApi = new ConvenienceApi(convenienceApiName); @@ -817,8 +815,8 @@ export class CodeModelBuilder { new Request({ protocol: { http: { - path: op.path, - method: op.verb, + path: httpOperation.path, + method: httpOperation.verb, uri: clientContext.baseUri, }, }, @@ -827,77 +825,86 @@ export class CodeModelBuilder { // host clientContext.hostParameters.forEach((it) => codeModelOperation.addParameter(it)); - // parameters - op.parameters.parameters.map((it) => - this.processParameter(codeModelOperation, it, clientContext) - ); - // "accept" header - this.addAcceptHeaderParameter(codeModelOperation, op.responses); - // body - if (op.parameters.body) { - if (op.parameters.body.property) { - if (!isVoidType(op.parameters.body.property.type)) { - this.processParameterBody(codeModelOperation, op, op.parameters.body.property); - } - } else if (op.parameters.body.type) { - let bodyType = op.parameters.body.type; - - if (bodyType.kind === "Model") { - // try use resource type as round-trip model - const resourceType = getResourceOperation(this.program, operation)?.resourceType; - if (resourceType && op.responses && op.responses.length > 0) { - const resp = op.responses[0]; - if (resp.responses && resp.responses.length > 0 && resp.responses[0].body) { - const responseBody = resp.responses[0].body; - const bodyTypeInResponse = this.findResponseBody(responseBody.type); - // response body type is resource type, and request body type (if templated) contains resource type - if ( - bodyTypeInResponse === resourceType && - isModelReferredInTemplate(bodyType, resourceType) - ) { - bodyType = resourceType; - } - } - } - - this.processParameterBody(codeModelOperation, op, bodyType); + // path/query/header parameters + for (const param of httpOperation.parameters) { + // if it's paged operation with request body, skip content-type header added by TCGC, as next link call should not have content type header + if ( + (sdkMethod.kind === "paging" || sdkMethod.kind === "lropaging") && + httpOperation.bodyParam && + param.kind === "header" + ) { + if (param.serializedName.toLocaleLowerCase() === CONTENT_TYPE_KEY) { + continue; } } + // if the request body is optional, skip content-type header added by TCGC + // TODO: add optional content type to code-model, and support optional content-type from codegen, https://github.com/Azure/autorest.java/issues/2930 + if (httpOperation.bodyParam && httpOperation.bodyParam.optional) { + if (param.serializedName.toLocaleLowerCase() === CONTENT_TYPE_KEY) { + continue; + } + } + this.processParameter(codeModelOperation, param, clientContext); + } + + // body + if (httpOperation.bodyParam && httpOperation.__raw && httpOperation.bodyParam.type.__raw) { + this.processParameterBody( + codeModelOperation, + httpOperation.__raw, + httpOperation, + httpOperation.bodyParam + ); } // group ETag header parameters, if exists if (this.options["group-etag-headers"]) { - this.processEtagHeaderParameters(codeModelOperation, op); + this.processEtagHeaderParameters(codeModelOperation, sdkMethod.operation); } // lro metadata - const lroMetadata = this.processLroMetadata(codeModelOperation, op); + let lroMetadata = new LongRunningMetadata(false); + if (sdkMethod.kind === "lro" || sdkMethod.kind === "lropaging") { + lroMetadata = this.processLroMetadata(codeModelOperation, sdkMethod); + } // responses - op.responses.map((it) => this.processResponse(codeModelOperation, it, lroMetadata.longRunning)); + for (const [code, response] of sdkMethod.operation.responses) { + this.processResponse(codeModelOperation, code, response, lroMetadata.longRunning, false); + } + + // exception + for (const [code, response] of sdkMethod.operation.exceptions) { + this.processResponse(codeModelOperation, code, response, lroMetadata.longRunning, true); + } // check for paged - this.processRouteForPaged(codeModelOperation, op.responses); + this.processRouteForPaged(codeModelOperation, sdkMethod.operation.responses, sdkMethod); + // check for long-running operation - this.processRouteForLongRunning(codeModelOperation, operation, op.responses, lroMetadata); + this.processRouteForLongRunning(codeModelOperation, sdkMethod.operation.responses, lroMetadata); operationGroup.addOperation(codeModelOperation); return codeModelOperation; } - private processRouteForPaged(op: CodeModelOperation, responses: HttpOperationResponse[]) { - for (const response of responses) { - if (response.responses && response.responses.length > 0 && response.responses[0].body) { - const responseBody = response.responses[0].body; - const bodyType = this.findResponseBody(responseBody.type); - if (bodyType.kind === "Model") { - const pagedResult = getPagedResult(this.program, bodyType); - if (pagedResult) { + private processRouteForPaged( + op: CodeModelOperation, + responses: Map, + sdkMethod: SdkMethod + ) { + if (sdkMethod.kind === "paging" || sdkMethod.kind === "lropaging") { + for (const [_, response] of responses) { + const bodyType = response.type; + if (bodyType && bodyType.kind === "model") { + const itemName = sdkMethod.response.resultPath; + const nextLinkName = sdkMethod.nextLinkPath; + if (itemName && nextLinkName) { op.extensions = op.extensions ?? {}; op.extensions["x-ms-pageable"] = { - itemName: pagedResult.itemsProperty?.name, - nextLinkName: pagedResult.nextLinkProperty?.name, + itemName: itemName, + nextLinkName: nextLinkName, }; op.responses?.forEach((r) => { @@ -905,7 +912,6 @@ export class CodeModelBuilder { this.trackSchemaUsage(r.schema, { usage: [SchemaContext.Paged] }); } }); - break; } } @@ -915,13 +921,11 @@ export class CodeModelBuilder { private processLroMetadata( op: CodeModelOperation, - httpOperation: HttpOperation + sdkMethod: SdkLroServiceMethod | SdkLroPagingServiceMethod ): LongRunningMetadata { - const operation = httpOperation.operation; - const trackConvenienceApi: boolean = Boolean(op.convenienceApi); - const lroMetadata = getLroMetadata(this.program, operation); + const lroMetadata = sdkMethod.__raw_lro_metadata; // needs lroMetadata.statusMonitorStep, as getLroMetadata would return for @pollingOperation operation if (lroMetadata && lroMetadata.pollingInfo && lroMetadata.statusMonitorStep) { let pollingSchema = undefined; @@ -930,15 +934,15 @@ export class CodeModelBuilder { let pollingStrategy: Metadata | undefined = undefined; let finalResultPropertySerializedName: string | undefined = undefined; - const verb = httpOperation.verb; - const useNewPollStrategy = isLroNewPollingStrategy(httpOperation, lroMetadata); + const verb = sdkMethod.operation.verb; + const useNewPollStrategy = isLroNewPollingStrategy(sdkMethod.operation.__raw, lroMetadata); if (useNewPollStrategy) { // use OperationLocationPollingStrategy pollingStrategy = new Metadata({ language: { java: { name: "OperationLocationPollingStrategy", - namespace: getJavaNamespace(this.namespace) + ".implementation", + namespace: this.getJavaNamespace(this.namespace) + ".implementation", }, }, }); @@ -1014,8 +1018,7 @@ export class CodeModelBuilder { private processRouteForLongRunning( op: CodeModelOperation, - operation: Operation, - responses: HttpOperationResponse[], + responses: Map, lroMetadata: LongRunningMetadata ) { if (lroMetadata.longRunning) { @@ -1023,26 +1026,13 @@ export class CodeModelBuilder { op.extensions["x-ms-long-running-operation"] = true; return; } - - for (const resp of responses) { - if (resp.responses && resp.responses.length > 0 && resp.responses[0].headers) { - for (const [_, header] of Object.entries(resp.responses[0].headers)) { - if (isPollingLocation(this.program, header)) { - op.extensions = op.extensions ?? {}; - op.extensions["x-ms-long-running-operation"] = true; - - break; - } - } - } - } } private _armApiVersionParameter?: Parameter; private processParameter( op: CodeModelOperation, - param: HttpOperationParameter, + param: SdkQueryParameter | SdkPathParameter | SdkHeaderParameter, clientContext: ClientContext ) { if (clientContext.apiVersions && isApiVersion(this.sdkContext, param)) { @@ -1050,11 +1040,11 @@ export class CodeModelBuilder { if (this.isArm()) { // Currently we assume ARM tsp only have one client and one api-version. // TODO: How will service define mixed api-versions(like those in Compute RP)? - const apiVersion = this.apiVersion?.value; + const apiVersion = this.apiVersion; if (!this._armApiVersionParameter) { this._armApiVersionParameter = this.createApiVersionParameter( "api-version", - param.type === "query" ? ParameterLocation.Query : ParameterLocation.Path, + param.kind === "query" ? ParameterLocation.Query : ParameterLocation.Path, apiVersion ); clientContext.addGlobalParameter(this._armApiVersionParameter); @@ -1062,52 +1052,48 @@ export class CodeModelBuilder { op.addParameter(this._armApiVersionParameter); } else { const parameter = - param.type === "query" ? this.apiVersionParameter : this.apiVersionParameterInPath; + param.kind === "query" ? this.apiVersionParameter : this.apiVersionParameterInPath; op.addParameter(parameter); clientContext.addGlobalParameter(parameter); } - } else if (this.isSubscriptionId(param)) { + } else if (param.kind === "path" && param.onClient && this.isSubscriptionId(param)) { const parameter = this.subscriptionIdParameter(param); op.addParameter(parameter); clientContext.addGlobalParameter(parameter); - } else if (SPECIAL_HEADER_NAMES.has(param.name.toLowerCase())) { + } else if ( + param.kind === "header" && + SPECIAL_HEADER_NAMES.has(param.serializedName.toLowerCase()) + ) { // special headers op.specialHeaders = op.specialHeaders ?? []; - if (!stringArrayContainsIgnoreCase(op.specialHeaders, param.name)) { - op.specialHeaders.push(param.name); + if (!stringArrayContainsIgnoreCase(op.specialHeaders, param.serializedName)) { + op.specialHeaders.push(param.serializedName); } } else { // schema - let schema; - const sdkType = getNonNullSdkType(getClientType(this.sdkContext, param.param)); - if ( - param.type === "header" && - param.param.type.kind === "Scalar" && - getEncode(this.program, param.param) === undefined && - getEncode(this.program, param.param.type) === undefined && - (hasScalarAsBase(param.param.type, "utcDateTime") || - hasScalarAsBase(param.param.type, "offsetDateTime")) && - (sdkType.kind === "utcDateTime" || sdkType.kind === "offsetDateTime") - ) { - // utcDateTime in header maps to rfc7231 - schema = this.processDateTimeSchemaFromSdkType(sdkType, param.param.name, true); - } else { - schema = this.processSchemaFromSdkType(sdkType, param.param.name); - } + const sdkType = getNonNullSdkType(param.type); + const schema = this.processSchemaFromSdkType(sdkType, param.name); - // skip-url-encoding let extensions: { [id: string]: any } | undefined = undefined; + if (param.kind === "path") { + if (param.allowReserved) { + extensions = extensions ?? {}; + extensions["x-ms-skip-url-encoding"] = true; + } + } + // TODO: deprecate this logic of string/url for x-ms-skip-url-encoding if ( - (param.type === "query" || param.type === "path") && - param.param.type.kind === "Scalar" && + (param.kind === "query" || param.kind === "path") && + isSdkBuiltInKind(sdkType.kind) && schema instanceof UriSchema ) { - extensions = { "x-ms-skip-url-encoding": true }; + extensions = extensions ?? {}; + extensions["x-ms-skip-url-encoding"] = true; } - if (this.supportsAdvancedVersioning()) { + if (this.supportsAdvancedVersioning() && param.__raw) { // versioning - const addedOn = getAddedOnVersions(this.program, param.param); + const addedOn = getAddedOnVersions(this.program, param.__raw); if (addedOn) { extensions = extensions ?? {}; extensions["x-ms-versioning-added"] = clientContext.getAddedVersions(addedOn); @@ -1117,11 +1103,12 @@ export class CodeModelBuilder { // format if array let style = undefined; let explode = undefined; - if (param.param.type.kind === "Model" && isArrayModelType(this.program, param.param.type)) { - if (param.type === "query") { - const queryParamOptions = getQueryParamOptions(this.program, param.param); - switch (queryParamOptions?.format) { + if (sdkType.kind === "array") { + if (param.kind === "query") { + const format = param.collectionFormat; + switch (format) { case "csv": + case "simple": style = SerializationStyle.Simple; break; @@ -1138,51 +1125,42 @@ export class CodeModelBuilder { break; case "multi": + case "form": style = SerializationStyle.Form; explode = true; break; - - default: - if (queryParamOptions?.format) { - this.logWarning( - `Unrecognized query parameter format: '${queryParamOptions?.format}'.` - ); - } - break; } - } else if (param.type === "header") { - const headerFieldOptions = getHeaderFieldOptions(this.program, param.param); - switch (headerFieldOptions?.format) { + } else if (param.kind === "header") { + const format = param.collectionFormat; + switch (format) { case "csv": style = SerializationStyle.Simple; break; default: - if (headerFieldOptions?.format) { - this.logWarning( - `Unrecognized header parameter format: '${headerFieldOptions?.format}'.` - ); + if (format) { + this.logWarning(`Unrecognized header parameter format: '${format}'.`); } break; } } } - const nullable = isNullableType(param.param.type); - const parameter = new Parameter(this.getName(param.param), this.getDoc(param.param), schema, { - summary: this.getSummary(param.param), + const nullable = param.type.kind === "nullable"; + const parameter = new Parameter(param.name, param.details ?? "", schema, { + summary: param.description, implementation: ImplementationLocation.Method, - required: !param.param.optional, + required: !param.optional, nullable: nullable, protocol: { - http: new HttpParameter(param.type, { + http: new HttpParameter(param.kind, { style: style, explode: explode, }), }, language: { default: { - serializedName: this.getSerializedName(param.param), + serializedName: param.serializedName, // it uses param.name previously, but better to use param.serializedName directly }, }, extensions: extensions, @@ -1199,55 +1177,7 @@ export class CodeModelBuilder { } } - private addAcceptHeaderParameter(op: CodeModelOperation, responses: HttpOperationResponse[]) { - if ( - op.parameters?.some((it) => it.language.default.serializedName?.toLowerCase() === "accept") - ) { - // parameters already include "accept" header - return; - } - - const produces = new Set(); - for (const resp of responses) { - if (resp.responses && resp.responses.length > 0) { - for (const response of resp.responses) { - response.body?.contentTypes.forEach((it) => produces.add(it)); - } - } - } - if (produces.size === 0) { - produces.add("application/json"); - } - const acceptTypes = Array.from(produces.values()).join(", "); - - const acceptSchema = - this.codeModel.schemas.constants?.find( - (it) => it.language.default.name === "accept" && it.value.value === acceptTypes - ) || - this.codeModel.schemas.add( - new ConstantSchema("accept", `Accept: ${acceptTypes}`, { - valueType: this.stringSchema, - value: new ConstantValue(acceptTypes), - }) - ); - op.addParameter( - new Parameter("accept", "Accept header", acceptSchema, { - implementation: ImplementationLocation.Method, - origin: "modelerfour:synthesized/accept", - required: true, - protocol: { - http: new HttpParameter(ParameterLocation.Header), - }, - language: { - default: { - serializedName: "accept", - }, - }, - }) - ); - } - - private processEtagHeaderParameters(op: CodeModelOperation, httpOperation: HttpOperation) { + private processEtagHeaderParameters(op: CodeModelOperation, httpOperation: SdkHttpOperation) { if (op.convenienceApi && op.parameters && op.signatureParameters) { const etagHeadersNames = new Set([ "if-match", @@ -1312,7 +1242,7 @@ export class CodeModelBuilder { } } - const namespace = getNamespace(httpOperation.operation); + const namespace = getNamespace(httpOperation.__raw.operation); // TODO: SdkHttpOperation does not have namespace const schemaName = groupToRequestConditions ? "RequestConditions" : "MatchConditions"; const schemaDescription = groupToRequestConditions ? "Specifies HTTP options for conditional requests based on modification time." @@ -1387,45 +1317,33 @@ export class CodeModelBuilder { private processParameterBody( op: CodeModelOperation, - httpOperation: HttpOperation, - body: ModelProperty | Model + rawHttpOperation: HttpOperation, + sdkHttpOperation: SdkHttpOperation, + sdkBody: SdkBodyParameter ) { // set contentTypes to mediaTypes - op.requests![0].protocol.http!.mediaTypes = httpOperation.parameters.body!.contentTypes; - - const parameters = httpOperation.operation.parameters; + op.requests![0].protocol.http!.mediaTypes = sdkBody.contentTypes; const unknownRequestBody = op.requests![0].protocol.http!.mediaTypes && op.requests![0].protocol.http!.mediaTypes.length > 0 && !isKnownContentType(op.requests![0].protocol.http!.mediaTypes); - const sdkType: SdkType = getClientType(this.sdkContext, body, httpOperation.operation); + const sdkType: SdkType = sdkBody.type; let schema: Schema; - if ( - unknownRequestBody && - body.kind === "ModelProperty" && - body.type.kind === "Scalar" && - body.type.name === "bytes" - ) { - // handle binary request body - schema = this.processBinarySchema(body.type); + if (unknownRequestBody && sdkType.kind === "bytes") { + // if it's unknown request body, handle binary request body + schema = this.processBinarySchemaFromSdkType(sdkType); } else { - schema = this.processSchemaFromSdkType(sdkType, body.name); + schema = this.processSchemaFromSdkType(getNonNullSdkType(sdkType), sdkBody.name); } - // Explicit body parameter @body or @bodyRoot would result to body.kind === "ModelProperty" - // Implicit body parameter would result to body.kind === "Model" - // see https://typespec.io/docs/libraries/http/cheat-sheet#data-types - const bodyParameterFlatten = sdkType.kind === "model" && body.kind === "Model" && !this.isArm(); - - const parameterName = - body.kind === "Model" ? (sdkType.kind === "model" ? sdkType.name : "") : this.getName(body); - const parameter = new Parameter(parameterName, this.getDoc(body), schema, { - summary: this.getSummary(body), + const parameterName = sdkBody.name; + const parameter = new Parameter(parameterName, sdkBody.description ?? "", schema, { + summary: sdkBody.details, implementation: ImplementationLocation.Method, - required: body.kind === "Model" || !body.optional, + required: !sdkBody.optional, protocol: { http: new HttpParameter(ParameterLocation.Body), }, @@ -1441,16 +1359,21 @@ export class CodeModelBuilder { }); } - if (operationIsJsonMergePatch(httpOperation)) { + if (operationIsJsonMergePatch(sdkHttpOperation)) { this.trackSchemaUsage(schema, { usage: [SchemaContext.JsonMergePatch] }); } - if (op.convenienceApi && operationIsMultipart(httpOperation)) { + if (op.convenienceApi && operationIsMultipart(sdkHttpOperation)) { this.trackSchemaUsage(schema, { serializationFormats: [KnownMediaType.Multipart] }); } + // Implicit body parameter would have usage flag: UsageFlags.Spread, for this case we need to do body parameter flatten + const bodyParameterFlatten = + sdkType.kind === "model" && sdkType.usage & UsageFlags.Spread && !this.isArm(); + if (schema instanceof ObjectSchema && bodyParameterFlatten) { // flatten body parameter - + const parameters = sdkHttpOperation.parameters; + const bodyParameter = sdkHttpOperation.bodyParam; // name the schema for documentation schema.language.default.name = pascalCase(op.language.default.name) + "Request"; @@ -1459,7 +1382,7 @@ export class CodeModelBuilder { parameter.language.default.name = "request"; } - if (operationIsJsonMergePatch(httpOperation)) { + if (operationIsJsonMergePatch(sdkHttpOperation)) { // skip model flatten, if "application/merge-patch+json" schema.language.default.name = pascalCase(op.language.default.name) + "PatchRequest"; return; @@ -1475,50 +1398,29 @@ export class CodeModelBuilder { request.parameters = []; op.convenienceApi.requests.push(request); - for (const [_, opParameter] of parameters.properties) { - const serializedName = this.getSerializedName(opParameter); - const existParameter = op.parameters.find( - (it) => it.language.default.serializedName === serializedName + // header/query/path params + for (const opParameter of parameters) { + this.addParameterOrBodyPropertyToCodeModelRequest( + opParameter, + op, + request, + schema, + parameter ); - if (existParameter) { - // parameter - if ( - existParameter.implementation === ImplementationLocation.Method && - (existParameter.origin?.startsWith("modelerfour:synthesized/") ?? true) && - !(existParameter.schema instanceof ConstantSchema) - ) { - request.parameters.push(cloneOperationParameter(existParameter)); - } - } else { - // property from anonymous model - const existBodyProperty = schema.properties?.find( - (it) => it.serializedName === serializedName - ); - if ( - existBodyProperty && - !existBodyProperty.readOnly && - !(existBodyProperty.schema instanceof ConstantSchema) - ) { - request.parameters.push( - new VirtualParameter( - existBodyProperty.language.default.name, - existBodyProperty.language.default.description, - existBodyProperty.schema, - { - originalParameter: parameter, - targetProperty: existBodyProperty, - language: { - default: { - serializedName: existBodyProperty.serializedName, - }, - }, - summary: existBodyProperty.summary, - implementation: ImplementationLocation.Method, - required: existBodyProperty.required, - nullable: existBodyProperty.nullable, - } - ) - ); + } + // body param + if (bodyParameter) { + if (bodyParameter.type.kind === "model") { + for (const bodyProperty of bodyParameter.type.properties) { + if (bodyProperty.kind === "property") { + this.addParameterOrBodyPropertyToCodeModelRequest( + bodyProperty, + op, + request, + schema, + parameter + ); + } } } } @@ -1527,7 +1429,7 @@ export class CodeModelBuilder { if (request.signatureParameters.length > 6) { // create an option bag const name = op.language.default.name + "Options"; - const namespace = getNamespace(httpOperation.operation); + const namespace = getNamespace(rawHttpOperation.operation); // option bag schema const optionBagSchema = this.codeModel.schemas.add( new GroupSchema(name, `Options for ${op.language.default.name} API`, { @@ -1536,7 +1438,7 @@ export class CodeModelBuilder { namespace: namespace, }, java: { - namespace: getJavaNamespace(namespace), + namespace: this.getJavaNamespace(namespace), }, }, }) @@ -1586,6 +1488,72 @@ export class CodeModelBuilder { } } + private addParameterOrBodyPropertyToCodeModelRequest( + opParameter: + | SdkPathParameter + | SdkHeaderParameter + | SdkQueryParameter + | SdkBodyModelPropertyType, + op: CodeModelOperation, + request: Request, + schema: ObjectSchema, + originalParameter: Parameter + ) { + const serializedName = opParameter.serializedName; + let existParameter: Parameter | undefined; + if (opParameter.kind !== "property") { + // not body property + // header/query/path, same location and same serializedName + existParameter = op.parameters?.find( + (it) => + it.protocol.http?.in === opParameter.kind && + it.language.default.serializedName === serializedName + ); + } + request.parameters = request.parameters ?? []; + if (existParameter) { + // parameter + if ( + existParameter.implementation === ImplementationLocation.Method && + (existParameter.origin?.startsWith("modelerfour:synthesized/") ?? true) && + !(existParameter.schema instanceof ConstantSchema) + ) { + request.parameters.push(cloneOperationParameter(existParameter)); + } + } else { + // property from anonymous model + const existBodyProperty = schema.properties?.find( + (it) => it.serializedName === serializedName + ); + if ( + existBodyProperty && + !existBodyProperty.readOnly && + !(existBodyProperty.schema instanceof ConstantSchema) + ) { + request.parameters.push( + new VirtualParameter( + existBodyProperty.language.default.name, + existBodyProperty.language.default.description, + existBodyProperty.schema, + { + originalParameter: originalParameter, + targetProperty: existBodyProperty, + language: { + default: { + serializedName: existBodyProperty.serializedName, + }, + }, + summary: existBodyProperty.summary, + implementation: ImplementationLocation.Method, + required: existBodyProperty.required, + nullable: existBodyProperty.nullable, + } + ) + ); + } + } + } + private findResponseBody(bodyType: Type): Type { // find a type that possibly without http metadata like @statusCode return this.getEffectiveSchemaType(bodyType); @@ -1593,111 +1561,105 @@ export class CodeModelBuilder { private processResponse( op: CodeModelOperation, - resp: HttpOperationResponse, - longRunning: boolean + statusCode: number | HttpStatusCodeRange | "*", + sdkResponse: SdkHttpResponse, + longRunning: boolean, + isErrorResponse: boolean ) { // TODO: what to do if more than 1 response? // It happens when the response type is Union, on one status code. - let response: Response; + // let response: Response; let headers: Array | undefined = undefined; - if (resp.responses && resp.responses.length > 0) { - // headers - headers = []; - for (const response of resp.responses.values()) { - if (response.headers) { - for (const [key, header] of Object.entries(response.headers)) { - const sdkType = getClientType(this.sdkContext, header); - const schema = this.processSchemaFromSdkType(sdkType, key); - headers.push( - new HttpHeader(key, schema, { - language: { - default: { - name: key, - description: this.getDoc(header), - }, - }, - }) - ); - } - } + + // headers + headers = []; + if (sdkResponse.headers) { + for (const header of sdkResponse.headers) { + const schema = this.processSchemaFromSdkType(header.type, header.serializedName); + headers.push( + new HttpHeader(header.serializedName, schema, { + language: { + default: { + name: header.serializedName, + description: header.description ?? header.details, + }, + }, + }) + ); } } - let responseBody: HttpOperationBody | HttpOperationMultipartBody | undefined = undefined; - let bodyType: Type | undefined = undefined; + const bodyType: SdkType | undefined = sdkResponse.type; let trackConvenienceApi: boolean = Boolean(op.convenienceApi); - if (resp.responses && resp.responses.length > 0 && resp.responses[0].body) { - responseBody = resp.responses[0].body; - } - if (responseBody) { - const unknownResponseBody = - responseBody.contentTypes.length > 0 && !isKnownContentType(responseBody.contentTypes); - bodyType = this.findResponseBody(responseBody.type); - if (unknownResponseBody && bodyType.kind === "Scalar" && bodyType.name === "bytes") { - // binary - response = new BinaryResponse({ - protocol: { - http: { - statusCodes: this.getStatusCodes(resp.statusCodes), - headers: headers, - mediaTypes: responseBody.contentTypes, - knownMediaType: KnownMediaType.Binary, - }, + const unknownResponseBody = + sdkResponse.contentTypes && + sdkResponse.contentTypes.length > 0 && + !isKnownContentType(sdkResponse.contentTypes); + + let response: Response; + if (unknownResponseBody && bodyType && bodyType.kind === "bytes") { + // binary + response = new BinaryResponse({ + protocol: { + http: { + statusCodes: this.getStatusCodes(statusCode), + headers: headers, + mediaTypes: sdkResponse.contentTypes, + knownMediaType: KnownMediaType.Binary, }, - language: { - default: { - name: op.language.default.name + "Response", - description: this.getResponseDescription(resp), - }, + }, + language: { + default: { + name: op.language.default.name + "Response", + description: sdkResponse.description, }, - }); - } else { - // schema (usually JSON) - let schema: Schema | undefined = undefined; - if (longRunning) { - // LRO uses the LroMetadata for poll/final result, not the response of activation request - trackConvenienceApi = false; - } - if (!schema) { - const sdkType = getClientType(this.sdkContext, bodyType); - schema = this.processSchemaFromSdkType(sdkType, op.language.default.name + "Response"); - } - response = new SchemaResponse(schema, { - protocol: { - http: { - statusCodes: this.getStatusCodes(resp.statusCodes), - headers: headers, - mediaTypes: responseBody.contentTypes, - }, - }, - language: { - default: { - name: op.language.default.name + "Response", - description: this.getResponseDescription(resp), - }, - }, - }); + }, + }); + } else if (bodyType) { + // schema (usually JSON) + let schema: Schema | undefined = undefined; + if (longRunning) { + // LRO uses the LroMetadata for poll/final result, not the response of activation request + trackConvenienceApi = false; } + if (!schema) { + schema = this.processSchemaFromSdkType(bodyType, op.language.default.name + "Response"); + } + response = new SchemaResponse(schema, { + protocol: { + http: { + statusCodes: this.getStatusCodes(statusCode), + headers: headers, + mediaTypes: sdkResponse.contentTypes, + }, + }, + language: { + default: { + name: op.language.default.name + "Response", + description: sdkResponse.description, + }, + }, + }); } else { // not binary nor schema, usually NoContent response = new Response({ protocol: { http: { - statusCodes: this.getStatusCodes(resp.statusCodes), + statusCodes: this.getStatusCodes(statusCode), headers: headers, }, }, language: { default: { name: op.language.default.name + "Response", - description: this.getResponseDescription(resp), + description: sdkResponse.description, }, }, }); } - if (resp.statusCodes === "*" || (bodyType && isErrorModel(this.program, bodyType))) { - // "*", or the model is @error + + if (isErrorResponse) { op.addException(response); if (response instanceof SchemaResponse) { @@ -1733,16 +1695,6 @@ export class CodeModelBuilder { } } - private getResponseDescription(resp: HttpOperationResponse): string { - return ( - resp.description || - (resp.statusCodes === "*" - ? "An unexpected error response" - : getStatusCodeDescription(resp.statusCodes)) || - "" - ); - } - private processSchemaFromSdkType(type: SdkType, nameHint: string): Schema { return this.schemaCache.process(type, nameHint) || fail("Unable to process schema."); } @@ -1860,11 +1812,13 @@ export class CodeModelBuilder { name: string, precision: number ): NumberSchema { - return this.codeModel.schemas.add( - new NumberSchema(name, type.details ?? "", SchemaType.Integer, precision, { - summary: type.description, - }) - ); + const schema = new NumberSchema(name, type.details ?? "", SchemaType.Integer, precision, { + summary: type.description, + }); + if (type.encode === "string") { + (schema as EncodedSchema).encode = type.encode; + } + return this.codeModel.schemas.add(schema); } private processNumberSchemaFromSdkType(type: SdkBuiltInType, name: string): NumberSchema { @@ -1960,7 +1914,7 @@ export class CodeModelBuilder { namespace: namespace, }, java: { - namespace: getJavaNamespace(namespace), + namespace: this.getJavaNamespace(namespace), }, }, }); @@ -2063,7 +2017,7 @@ export class CodeModelBuilder { namespace: namespace, }, java: { - namespace: getJavaNamespace(namespace), + namespace: this.getJavaNamespace(namespace), }, }, }); @@ -2169,7 +2123,7 @@ export class CodeModelBuilder { nullable = true; nonNullType = nonNullType.type; } - let schema = this.processSchemaFromSdkType(nonNullType, ""); + let schema; let extensions: Record | undefined = undefined; if (this.isSecret(prop)) { @@ -2191,8 +2145,12 @@ export class CodeModelBuilder { if (prop.kind === "property" && prop.multipartOptions) { // TODO: handle MultipartOptions.isMulti if (prop.multipartOptions.isFilePart) { - schema = this.processMultipartFormDataFilePropertySchemaFromSdkType(prop, this.namespace); + schema = this.processMultipartFormDataFilePropertySchemaFromSdkType(prop); + } else { + schema = this.processSchemaFromSdkType(nonNullType, ""); } + } else { + schema = this.processSchemaFromSdkType(nonNullType, ""); } return new Property(prop.name, prop.details ?? "", schema, { @@ -2232,7 +2190,7 @@ export class CodeModelBuilder { namespace: namespace, }, java: { - namespace: getJavaNamespace(namespace), + namespace: this.getJavaNamespace(namespace), }, }, }); @@ -2250,10 +2208,10 @@ export class CodeModelBuilder { return this.codeModel.schemas.add(unionSchema); } - private processBinarySchema(type: Scalar): BinarySchema { + private processBinarySchemaFromSdkType(type: SdkBuiltInType): BinarySchema { return this.codeModel.schemas.add( - new BinarySchema(this.getDoc(type), { - summary: this.getSummary(type), + new BinarySchema(type.description ?? "", { + summary: type.details, }) ); } @@ -2315,13 +2273,17 @@ export class CodeModelBuilder { } private processMultipartFormDataFilePropertySchemaFromSdkType( - property: SdkBodyModelPropertyType, - namespace: string + property: SdkBodyModelPropertyType ): Schema { const processSchemaFunc = (type: SdkType) => this.processSchemaFromSdkType(type, ""); if (property.type.kind === "bytes" || property.type.kind === "model") { + const namespace = + property.type.kind === "model" + ? (getNamespace(property.type.__raw) ?? this.namespace) + : this.namespace; return getFileDetailsSchema( property, + getNamespace(property.type.__raw) ?? this.namespace, namespace, this.codeModel.schemas, this.binarySchema, @@ -2332,12 +2294,17 @@ export class CodeModelBuilder { property.type.kind === "array" && (property.type.valueType.kind === "bytes" || property.type.valueType.kind === "model") ) { + const namespace = + property.type.valueType.kind === "model" + ? (getNamespace(property.type.valueType.__raw) ?? this.namespace) + : this.namespace; return new ArraySchema( property.name, property.details ?? "", getFileDetailsSchema( property, namespace, + this.getJavaNamespace(namespace), this.codeModel.schemas, this.binarySchema, this.stringSchema, @@ -2360,37 +2327,6 @@ export class CodeModelBuilder { return target ? getSummary(this.program, target) : undefined; } - private getName( - target: ModelProperty | Operation, - nameHint: string | undefined = undefined - ): string { - // TODO: once getLibraryName API in typespec-client-generator-core can get projected name from language and client, as well as can handle template case, use getLibraryName API - const emitterClientName = getClientNameOverride(this.sdkContext, target); - if (emitterClientName && typeof emitterClientName === "string") { - return emitterClientName; - } - // TODO: deprecate getProjectedName - const languageProjectedName = getProjectedName(this.program, target, "java"); - if (languageProjectedName) { - return languageProjectedName; - } - - const clientProjectedName = getProjectedName(this.program, target, "client"); - if (clientProjectedName) { - return clientProjectedName; - } - - const friendlyName = getFriendlyName(this.program, target); - if (friendlyName) { - return friendlyName; - } - - if (typeof target.name === "symbol") { - return ""; - } - return target.name || ""; - } - private getSerializedName(target: ModelProperty): string { if (isHeader(this.program, target)) { return getHeaderFieldName(this.program, target); @@ -2404,6 +2340,24 @@ export class CodeModelBuilder { } } + private getParameterLocation(target: ModelProperty): ParameterLocation | "BodyProperty" { + if (isHeader(this.program, target)) { + return ParameterLocation.Header; + } else if (isQueryParam(this.program, target)) { + return ParameterLocation.Query; + } else if (isPathParam(this.program, target)) { + return ParameterLocation.Path; + } else if ( + isBody(this.program, target) || + isBodyRoot(this.program, target) || + isMultipartBodyProperty(this.program, target) + ) { + return ParameterLocation.Body; + } else { + return "BodyProperty"; + } + } + private isReadOnly(target: SdkModelPropertyType): boolean { const segment = target.__raw ? getSegment(this.program, target.__raw) !== undefined : false; if (segment) { @@ -2455,15 +2409,30 @@ export class CodeModelBuilder { } } - private getConvenienceApiName(op: Operation): string | undefined { - // check @convenienceMethod - if (shouldGenerateConvenient(this.sdkContext, op)) { - return this.getName(op); + private getConvenienceApiName(sdkMethod: SdkServiceMethod): string | undefined { + // check @convenienceAPI + if (sdkMethod.generateConvenient) { + return sdkMethod.name; } else { return undefined; } } + private getJavaNamespace(namespace: string | undefined): string | undefined { + const tspNamespace = this.namespace; + const baseJavaNamespace = this.emitterContext.options.namespace; + if (!namespace) { + return undefined; + } else if ( + baseJavaNamespace && + (namespace === tspNamespace || namespace.startsWith(tspNamespace + ".")) + ) { + return baseJavaNamespace + namespace.slice(tspNamespace.length).toLowerCase(); + } else { + return "com." + namespace.toLowerCase(); + } + } + private logWarning(msg: string) { if (this.loggingEnabled) { logWarning(this.program, msg); @@ -2591,19 +2560,13 @@ export class CodeModelBuilder { ); } - private isSubscriptionId(param: HttpOperationParameter): boolean { - return ( - "subscriptionId".toLocaleLowerCase() === param?.name?.toLocaleLowerCase() && - param.param && - isArmCommonType(param.param) && - isPathParam(this.program, param.param) - ); + private isSubscriptionId(param: SdkPathParameter): boolean { + return "subscriptionId".toLocaleLowerCase() === param.serializedName.toLocaleLowerCase(); } - private subscriptionIdParameter(parameter: HttpOperationParameter): Parameter { + private subscriptionIdParameter(parameter: SdkPathParameter): Parameter { if (!this._subscriptionParameter) { - const param = parameter.param; - const description = getDoc(this.program, param); + const description = parameter.description; this._subscriptionParameter = new Parameter( "subscriptionId", description ? description : "The ID of the target subscription.", diff --git a/packages/http-client-java/emitter/src/common/client.ts b/packages/http-client-java/emitter/src/common/client.ts index 5a0537c04..b18286146 100644 --- a/packages/http-client-java/emitter/src/common/client.ts +++ b/packages/http-client-java/emitter/src/common/client.ts @@ -52,3 +52,7 @@ export class ServiceVersion extends Metadata { export interface CrossLanguageDefinition { crossLanguageDefinitionId?: string; } + +export interface EncodedSchema { + encode?: string; +} diff --git a/packages/http-client-java/emitter/src/emitter.ts b/packages/http-client-java/emitter/src/emitter.ts index 606be121c..106c9cc00 100644 --- a/packages/http-client-java/emitter/src/emitter.ts +++ b/packages/http-client-java/emitter/src/emitter.ts @@ -29,7 +29,6 @@ export interface EmitterOptions { "generate-samples"?: boolean; "generate-tests"?: boolean; - "examples-directory"?: string; "enable-sync-stack"?: boolean; "stream-style-serialization"?: boolean; @@ -80,7 +79,6 @@ const EmitterOptionsSchema: JSONSchemaType = { // sample and test "generate-samples": { type: "boolean", nullable: true, default: true }, "generate-tests": { type: "boolean", nullable: true, default: true }, - "examples-directory": { type: "string", nullable: true }, "enable-sync-stack": { type: "boolean", nullable: true, default: true }, "stream-style-serialization": { type: "boolean", nullable: true, default: true }, diff --git a/packages/http-client-java/emitter/src/external-schemas.ts b/packages/http-client-java/emitter/src/external-schemas.ts index 7607b3d7f..5f974927e 100644 --- a/packages/http-client-java/emitter/src/external-schemas.ts +++ b/packages/http-client-java/emitter/src/external-schemas.ts @@ -15,7 +15,7 @@ import { SdkType, } from "@azure-tools/typespec-client-generator-core"; import { CrossLanguageDefinition } from "./common/client.js"; -import { getJavaNamespace, getNamespace, pascalCase } from "./utils.js"; +import { getNamespace, pascalCase } from "./utils.js"; /* * These schema need to reflect @@ -142,7 +142,12 @@ export function createPollOperationDetailsSchema( const fileDetailsMap: Map = new Map(); -function getFileSchemaName(baseName: string) { +function getFileSchemaName(baseName: string, sdkModelType?: SdkModelType): string { + // If the TypeSpec Model exists and is not TypeSpec.Http.File, directly use its name + if (sdkModelType && sdkModelType.crossLanguageDefinitionId !== "TypeSpec.Http.File") { + return baseName; + } + // make sure suffix "FileDetails" if (baseName.toLocaleLowerCase().endsWith("filedetails")) { return pascalCase(baseName); @@ -157,6 +162,7 @@ function createFileDetailsSchema( schemaName: string, propertyName: string, namespace: string, + javaNamespace: string | undefined, schemas: Schemas ) { const fileDetailsSchema = new ObjectSchema( @@ -168,7 +174,7 @@ function createFileDetailsSchema( namespace: namespace, }, java: { - namespace: getJavaNamespace(namespace), + namespace: javaNamespace, }, }, serializationFormats: [KnownMediaType.Multipart], @@ -238,6 +244,7 @@ function addContentTypeProperty( export function getFileDetailsSchema( property: SdkBodyModelPropertyType, namespace: string, + javaNamespace: string | undefined, schemas: Schemas, binarySchema: BinarySchema, stringSchema: StringSchema, @@ -262,7 +269,7 @@ export function getFileDetailsSchema( */ const filePropertyName = property.name; const fileSchemaName = fileSdkType.name; - const schemaName = getFileSchemaName(fileSchemaName); + const schemaName = getFileSchemaName(fileSchemaName, fileSdkType); let fileDetailsSchema = fileDetailsMap.get(schemaName); if (!fileDetailsSchema) { const typeNamespace = getNamespace(property.type.__raw) ?? namespace; @@ -270,6 +277,7 @@ export function getFileDetailsSchema( schemaName, filePropertyName, typeNamespace, + javaNamespace, schemas ); @@ -316,7 +324,13 @@ export function getFileDetailsSchema( const schemaName = getFileSchemaName(filePropertyName); let fileDetailsSchema = fileDetailsMap.get(schemaName); if (!fileDetailsSchema) { - fileDetailsSchema = createFileDetailsSchema(schemaName, filePropertyName, namespace, schemas); + fileDetailsSchema = createFileDetailsSchema( + schemaName, + filePropertyName, + namespace, + javaNamespace, + schemas + ); addContentProperty(fileDetailsSchema, binarySchema); addFilenameProperty(fileDetailsSchema, stringSchema); diff --git a/packages/http-client-java/emitter/src/operation-utils.ts b/packages/http-client-java/emitter/src/operation-utils.ts index bcc612182..a06d565f7 100644 --- a/packages/http-client-java/emitter/src/operation-utils.ts +++ b/packages/http-client-java/emitter/src/operation-utils.ts @@ -1,5 +1,6 @@ import { Parameter } from "@autorest/codemodel"; import { LroMetadata } from "@azure-tools/typespec-azure-core"; +import { SdkHttpOperation } from "@azure-tools/typespec-client-generator-core"; import { ModelProperty, Operation, Program, Type, Union } from "@typespec/compiler"; import { HttpOperation, @@ -23,7 +24,7 @@ export const SPECIAL_HEADER_NAMES = new Set([ export const ORIGIN_API_VERSION = "modelerfour:synthesized/api-version"; -const CONTENT_TYPE_KEY = "content-type"; +export const CONTENT_TYPE_KEY = "content-type"; // azure-core SerializerEncoding.SUPPORTED_MIME_TYPES const SUPPORTED_MIME_TYPES = new Set([ @@ -47,18 +48,18 @@ export function isKnownContentType(contentTypes: string[]): boolean { }); } -export function operationIsJsonMergePatch(op: HttpOperation): boolean { +export function operationIsJsonMergePatch(op: SdkHttpOperation): boolean { return operationIsContentType(op, "application/merge-patch+json"); } -export function operationIsMultipart(op: HttpOperation): boolean { +export function operationIsMultipart(op: SdkHttpOperation): boolean { return operationIsContentType(op, "multipart/form-data"); } -function operationIsContentType(op: HttpOperation, contentType: string): boolean { - for (const param of op.parameters.parameters) { - if (param.type === "header" && param.name.toLowerCase() === CONTENT_TYPE_KEY) { - if (param.param.type.kind === "String" && param.param.type.value === contentType) { +function operationIsContentType(op: SdkHttpOperation, contentType: string): boolean { + for (const param of op.parameters) { + if (param.kind === "header" && param.serializedName.toLowerCase() === CONTENT_TYPE_KEY) { + if (param.type.kind === "constant" && param.type.value === contentType) { return true; } } @@ -66,14 +67,14 @@ function operationIsContentType(op: HttpOperation, contentType: string): boolean return false; } -export function operationIsMultipleContentTypes(op: HttpOperation): boolean { +export function operationIsMultipleContentTypes(op: SdkHttpOperation): boolean { if ( - op.parameters.parameters && - op.parameters.parameters.some( + op.parameters && + op.parameters.some( (parameter) => - parameter?.type === "header" && - parameter?.name?.toLowerCase() === CONTENT_TYPE_KEY && - parameter?.param?.type?.kind === "Union" + parameter.kind === "header" && + parameter.serializedName.toLowerCase() === CONTENT_TYPE_KEY && + parameter.type.kind === "enum" ) ) { return true; diff --git a/packages/http-client-java/emitter/src/prenamer/prenamer.ts b/packages/http-client-java/emitter/src/prenamer/prenamer.ts index f2c046143..d10df9f37 100644 --- a/packages/http-client-java/emitter/src/prenamer/prenamer.ts +++ b/packages/http-client-java/emitter/src/prenamer/prenamer.ts @@ -96,7 +96,7 @@ export class PreNamer { const deduplicateSchemaNames = !!this.options["lenient-model-deduplication"] || - !!this.options["resolve-schema-name-collisions"]; + !!this.options["resolve-schema-name-collisons"]; const scopeNamer = new ScopeNamer({ deduplicateNames: deduplicateSchemaNames, diff --git a/packages/http-client-java/emitter/src/type-utils.ts b/packages/http-client-java/emitter/src/type-utils.ts index 5e8e4c9ff..62daa6349 100644 --- a/packages/http-client-java/emitter/src/type-utils.ts +++ b/packages/http-client-java/emitter/src/type-utils.ts @@ -9,7 +9,6 @@ import { import { DecoratedType, DecoratorApplication, - EncodeData, EnumMember, IntrinsicScalarName, Model, @@ -27,7 +26,6 @@ import { isTemplateInstance, isTypeSpecValueTypeOf, } from "@typespec/compiler"; -import { Version } from "@typespec/versioning"; import { DurationSchema } from "./common/schemas/time.js"; import { getNamespace } from "./utils.js"; @@ -56,8 +54,8 @@ export class ProcessingCache { } } -export function isStable(version: Version): boolean { - return !version.value.toLowerCase().includes("preview"); +export function isStable(version: string): boolean { + return !version.toLowerCase().includes("preview"); } /** adds only if the item is not in the collection already @@ -120,24 +118,6 @@ export function getDefaultValue(value: Value | undefined): any { return undefined; } -export function getDurationFormat(encode: EncodeData): DurationSchema["format"] { - let format: DurationSchema["format"] = "duration-rfc3339"; - // duration encoded as seconds - if (encode.encoding === "seconds") { - const scalarName = encode.type.name; - if (scalarName.startsWith("int") || scalarName.startsWith("uint") || scalarName === "safeint") { - format = "seconds-integer"; - } else if (scalarName.startsWith("float")) { - format = "seconds-number"; - } else { - throw new Error( - `Unrecognized scalar type used by duration encoded as seconds: '${scalarName}'.` - ); - } - } - return format; -} - export function getDurationFormatFromSdkType(type: SdkDurationType): DurationSchema["format"] { let format: DurationSchema["format"] = "duration-rfc3339"; // duration encoded as seconds diff --git a/packages/http-client-java/emitter/src/utils.ts b/packages/http-client-java/emitter/src/utils.ts index 08305502e..6c5b9e6f4 100644 --- a/packages/http-client-java/emitter/src/utils.ts +++ b/packages/http-client-java/emitter/src/utils.ts @@ -42,12 +42,13 @@ export function getNamespace(type: Type | undefined): string | undefined { } } -export function getJavaNamespace(namespace: string | undefined): string | undefined { - return namespace ? "com." + namespace.toLowerCase() : undefined; -} - export function stringArrayContainsIgnoreCase(stringList: string[], str: string): boolean { return stringList && str ? stringList.findIndex((s) => s.toLowerCase() === str.toLowerCase()) !== -1 : false; } + +export function removeClientSuffix(clientName: string): string { + const clientSuffix = "Client"; + return clientName.endsWith(clientSuffix) ? clientName.slice(0, -clientSuffix.length) : clientName; +} diff --git a/packages/http-client-java/eng/scripts/Generate.ps1 b/packages/http-client-java/eng/scripts/Generate.ps1 index f3bc96d1b..38e17f469 100644 --- a/packages/http-client-java/eng/scripts/Generate.ps1 +++ b/packages/http-client-java/eng/scripts/Generate.ps1 @@ -18,4 +18,7 @@ Invoke "npm run build:emitter" $testDir = Join-Path $repoRoot 'test' -Invoke "npx tsp compile $testDir/literal.tsp --trace @typespec/http-client-java --emit @typespec/http-client-java --option @typespec/http-client-java.emitter-output-dir=$testDir/tsp-output --option @typespec/http-client-java.save-inputs=true" +$generatorTestDir = Join-Path $repoRoot 'generator/http-client-generator-test' +Set-Location $generatorTestDir +./Generate.ps1 +Set-Location $PSScriptRoot diff --git a/packages/http-client-java/eng/scripts/Test-Packages.ps1 b/packages/http-client-java/eng/scripts/Test-Packages.ps1 index 39f9fdcb9..5305f1f1b 100644 --- a/packages/http-client-java/eng/scripts/Test-Packages.ps1 +++ b/packages/http-client-java/eng/scripts/Test-Packages.ps1 @@ -6,7 +6,8 @@ param( [string] $Filter = "." ) -$ErrorActionPreference = 'Stop' +$ErrorActionPreference = 'Continue' + Set-StrictMode -Version 3.0 $packageRoot = (Resolve-Path "$PSScriptRoot/../..").Path.Replace('\', '/') . "$packageRoot/../../eng/emitters/scripts/CommandInvocation-Helpers.ps1" @@ -45,14 +46,14 @@ try { & "$packageRoot/eng/scripts/Generate.ps1" Write-Host 'Code generation is completed.' - # try { - # Write-Host 'Checking for differences in generated code...' - # & "$packageRoot/eng/scripts/Check-GitChanges.ps1" - # Write-Host 'Done. No code generation differences detected.' - # } - # catch { - # Write-Error 'Generated code is not up to date. Please run: eng/Generate.ps1' - # } + try { + Write-Host 'Checking for differences in generated code...' + & "$packageRoot/eng/scripts/Check-GitChanges.ps1" + Write-Host 'Done. No code generation differences detected.' + } + catch { + Write-Error 'Generated code is not up to date. Please run: eng/Generate.ps1' + } } } finally { diff --git a/packages/http-client-java/generator/http-client-generator-core/pom.xml b/packages/http-client-java/generator/http-client-generator-core/pom.xml index 483994875..7184d8e27 100644 --- a/packages/http-client-java/generator/http-client-generator-core/pom.xml +++ b/packages/http-client-java/generator/http-client-generator-core/pom.xml @@ -44,7 +44,6 @@ slf4j-api 1.7.36 - com.github.javaparser javaparser-core diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/extension/model/codemodel/NumberSchema.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/extension/model/codemodel/NumberSchema.java index 2fe75ff78..4c3ee3efe 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/extension/model/codemodel/NumberSchema.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/extension/model/codemodel/NumberSchema.java @@ -13,167 +13,189 @@ import java.io.IOException; * Represents a Number value. */ public class NumberSchema extends PrimitiveSchema { - private double precision; - private double multipleOf; - private double maximum; - private boolean exclusiveMaximum; - private double minimum; - private boolean exclusiveMinimum; + private double precision; + private double multipleOf; + private double maximum; + private boolean exclusiveMaximum; + private double minimum; + private boolean exclusiveMinimum; + private String encode; - /** - * Creates a new instance of the NumberSchema class. - */ - public NumberSchema() { - } + /** + * Creates a new instance of the NumberSchema class. + */ + public NumberSchema() { + } - /** - * The precision of the number. (Required) - * - * @return The precision of the number. - */ - public double getPrecision() { - return precision; - } + /** + * The precision of the number. (Required) + * + * @return The precision of the number. + */ + public double getPrecision() { + return precision; + } - /** - * Sets the precision of the number. (Required) - * - * @param precision The precision of the number. - */ - public void setPrecision(double precision) { - this.precision = precision; - } + /** + * Sets the precision of the number. (Required) + * + * @param precision The precision of the number. + */ + public void setPrecision(double precision) { + this.precision = precision; + } - /** - * Gets the multiple of this number must be, if set. - * - * @return The multiple of this number must be, if set. - */ - public double getMultipleOf() { - return multipleOf; - } + /** + * Gets the multiple of this number must be, if set. + * + * @return The multiple of this number must be, if set. + */ + public double getMultipleOf() { + return multipleOf; + } - /** - * Sets the multiple of this number must be, if set. - * - * @param multipleOf The multiple of this number must be, if set. - */ - public void setMultipleOf(double multipleOf) { - this.multipleOf = multipleOf; - } + /** + * Sets the multiple of this number must be, if set. + * + * @param multipleOf The multiple of this number must be, if set. + */ + public void setMultipleOf(double multipleOf) { + this.multipleOf = multipleOf; + } - /** - * Gets the maximum value, if set. - * - * @return The maximum value, if set. - */ - public double getMaximum() { - return maximum; - } + /** + * Gets the maximum value, if set. + * + * @return The maximum value, if set. + */ + public double getMaximum() { + return maximum; + } - /** - * Sets the maximum value, if set. - * - * @param maximum The maximum value, if set. - */ - public void setMaximum(double maximum) { - this.maximum = maximum; - } + /** + * Sets the maximum value, if set. + * + * @param maximum The maximum value, if set. + */ + public void setMaximum(double maximum) { + this.maximum = maximum; + } - /** - * Gets whether the maximum value is exclusive. - * - * @return Whether the maximum value is exclusive. - */ - public boolean isExclusiveMaximum() { - return exclusiveMaximum; - } + /** + * Gets whether the maximum value is exclusive. + * + * @return Whether the maximum value is exclusive. + */ + public boolean isExclusiveMaximum() { + return exclusiveMaximum; + } - /** - * Sets whether the maximum value is exclusive. - * - * @param exclusiveMaximum Whether the maximum value is exclusive. - */ - public void setExclusiveMaximum(boolean exclusiveMaximum) { - this.exclusiveMaximum = exclusiveMaximum; - } + /** + * Sets whether the maximum value is exclusive. + * + * @param exclusiveMaximum Whether the maximum value is exclusive. + */ + public void setExclusiveMaximum(boolean exclusiveMaximum) { + this.exclusiveMaximum = exclusiveMaximum; + } - /** - * Gets the minimum value, if set. - * - * @return The minimum value, if set. - */ - public double getMinimum() { - return minimum; - } + /** + * Gets the minimum value, if set. + * + * @return The minimum value, if set. + */ + public double getMinimum() { + return minimum; + } - /** - * Sets the minimum value, if set. - * - * @param minimum The minimum value, if set. - */ - public void setMinimum(double minimum) { - this.minimum = minimum; - } + /** + * Sets the minimum value, if set. + * + * @param minimum The minimum value, if set. + */ + public void setMinimum(double minimum) { + this.minimum = minimum; + } - /** - * Gets whether the minimum value is exclusive. - * - * @return Whether the minimum value is exclusive. - */ - public boolean isExclusiveMinimum() { - return exclusiveMinimum; - } + /** + * Gets whether the minimum value is exclusive. + * + * @return Whether the minimum value is exclusive. + */ + public boolean isExclusiveMinimum() { + return exclusiveMinimum; + } - /** - * Sets whether the minimum value is exclusive. - * - * @param exclusiveMinimum Whether the minimum value is exclusive. - */ - public void setExclusiveMinimum(boolean exclusiveMinimum) { - this.exclusiveMinimum = exclusiveMinimum; - } + /** + * Sets whether the minimum value is exclusive. + * + * @param exclusiveMinimum Whether the minimum value is exclusive. + */ + public void setExclusiveMinimum(boolean exclusiveMinimum) { + this.exclusiveMinimum = exclusiveMinimum; + } - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - return super.writeParentProperties(jsonWriter.writeStartObject()) - .writeDoubleField("precision", precision) - .writeDoubleField("multipleOf", multipleOf) - .writeDoubleField("maximum", maximum) - .writeBooleanField("exclusiveMaximum", exclusiveMaximum) - .writeDoubleField("minimum", minimum) - .writeBooleanField("exclusiveMinimum", exclusiveMinimum) - .writeEndObject(); - } + /** + * Gets the encode for the number. + * + * @return the encode for the number. + */ + public String getEncode() { + return encode; + } - /** - * Deserializes a NumberSchema instance from the JSON data. - * - * @param jsonReader The JSON reader to deserialize from. - * @return A NumberSchema instance deserialized from the JSON data. - * @throws IOException If an error occurs during deserialization. - */ - public static NumberSchema fromJson(JsonReader jsonReader) throws IOException { - return JsonUtils.readObject(jsonReader, NumberSchema::new, (schema, fieldName, reader) -> { - if (schema.tryConsumeParentProperties(schema, fieldName, reader)) { - return; - } + /** + * Sets the encode for the number. Currently only "string" is supported. + * + * @param encode the encode for the number. + */ + public void setEncode(String encode) { + this.encode = encode; + } - if ("precision".equals(fieldName)) { - schema.precision = reader.getDouble(); - } else if ("multipleOf".equals(fieldName)) { - schema.multipleOf = reader.getDouble(); - } else if ("maximum".equals(fieldName)) { - schema.maximum = reader.getDouble(); - } else if ("exclusiveMaximum".equals(fieldName)) { - schema.exclusiveMaximum = reader.getBoolean(); - } else if ("minimum".equals(fieldName)) { - schema.minimum = reader.getDouble(); - } else if ("exclusiveMinimum".equals(fieldName)) { - schema.exclusiveMinimum = reader.getBoolean(); - } else { - reader.skipChildren(); - } - }); - } + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + return super.writeParentProperties(jsonWriter.writeStartObject()) + .writeDoubleField("precision", precision) + .writeDoubleField("multipleOf", multipleOf) + .writeDoubleField("maximum", maximum) + .writeBooleanField("exclusiveMaximum", exclusiveMaximum) + .writeDoubleField("minimum", minimum) + .writeBooleanField("exclusiveMinimum", exclusiveMinimum) + .writeStringField("encode", encode) + .writeEndObject(); + } + + /** + * Deserializes a NumberSchema instance from the JSON data. + * + * @param jsonReader The JSON reader to deserialize from. + * @return A NumberSchema instance deserialized from the JSON data. + * @throws IOException If an error occurs during deserialization. + */ + public static NumberSchema fromJson(JsonReader jsonReader) throws IOException { + return JsonUtils.readObject(jsonReader, NumberSchema::new, (schema, fieldName, reader) -> { + if (schema.tryConsumeParentProperties(schema, fieldName, reader)) { + return; + } + + if ("precision".equals(fieldName)) { + schema.precision = reader.getDouble(); + } else if ("multipleOf".equals(fieldName)) { + schema.multipleOf = reader.getDouble(); + } else if ("maximum".equals(fieldName)) { + schema.maximum = reader.getDouble(); + } else if ("exclusiveMaximum".equals(fieldName)) { + schema.exclusiveMaximum = reader.getBoolean(); + } else if ("minimum".equals(fieldName)) { + schema.minimum = reader.getDouble(); + } else if ("exclusiveMinimum".equals(fieldName)) { + schema.exclusiveMinimum = reader.getBoolean(); + } else if ("encode".equals(fieldName)) { + schema.encode = reader.getString(); + } else { + reader.skipChildren(); + } + }); + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/implementation/ClientModelPropertiesManager.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/implementation/ClientModelPropertiesManager.java index 0962619cc..bfc193803 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/implementation/ClientModelPropertiesManager.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/implementation/ClientModelPropertiesManager.java @@ -26,6 +26,8 @@ import java.util.Set; import java.util.function.BiConsumer; import java.util.function.Consumer; +import static com.microsoft.typespec.http.client.generator.core.util.ClientModelUtil.getClientModel; + /** * Manages metadata about properties in a {@link ClientModel} and how they correlate with model class generation. *

@@ -36,668 +38,683 @@ import java.util.function.Consumer; * This will also handle getting the discriminator property and the expected value for the field. */ public final class ClientModelPropertiesManager { - private final ClientModel model; - private final String deserializedModelName; - private final boolean hasRequiredProperties; - private final boolean hasConstructorArguments; - private final int requiredPropertiesCount; - private final int setterPropertiesCount; - private final int readOnlyPropertiesCount; - private final LinkedHashMap superConstructorProperties; - private final LinkedHashMap superRequiredProperties; - private final LinkedHashMap superSetterProperties; - private final LinkedHashMap superReadOnlyProperties; - private final ClientModelProperty superAdditionalPropertiesProperty; - private final LinkedHashMap constructorProperties; - private final LinkedHashMap requiredProperties; - private final LinkedHashMap setterProperties; - private final LinkedHashMap readOnlyProperties; - private final ClientModelProperty additionalProperties; - private final ClientModelPropertyWithMetadata discriminatorProperty; - private final String expectedDiscriminator; - private final JsonFlattenedPropertiesTree jsonFlattenedPropertiesTree; - private final String jsonReaderFieldNameVariableName; + private final ClientModel model; - private final String xmlRootElementName; - private final String xmlRootElementNamespace; - private final boolean hasXmlElements; - private final boolean hasXmlTexts; - private final String xmlReaderNameVariableName; - private final List superXmlAttributes; - private final List xmlAttributes; - private final List superXmlTexts; - private final List xmlTexts; - private final List superXmlElements; - private final List xmlElements; - private final Map xmlNamespaceWithPrefix; - private final Map xmlNamespaceToConstantMapping; + private final String deserializedModelName; + private final boolean hasRequiredProperties; + private final boolean hasConstructorArguments; + private final int requiredPropertiesCount; + private final int setterPropertiesCount; + private final int readOnlyPropertiesCount; + private final LinkedHashMap superConstructorProperties; + private final LinkedHashMap superRequiredProperties; + private final LinkedHashMap superSetterProperties; + private final LinkedHashMap superReadOnlyProperties; + private final ClientModelProperty superAdditionalPropertiesProperty; + private final LinkedHashMap constructorProperties; + private final LinkedHashMap requiredProperties; + private final LinkedHashMap setterProperties; + private final LinkedHashMap readOnlyProperties; + private final ClientModelProperty additionalProperties; + private final ClientModelPropertyWithMetadata discriminatorProperty; + private final String expectedDiscriminator; + private final JsonFlattenedPropertiesTree jsonFlattenedPropertiesTree; + private final boolean allFlattenedPropertiesFromParent; + private final String jsonReaderFieldNameVariableName; - /** - * Creates a new instance of {@link ClientModelPropertiesManager}. - * - * @param model The {@link ClientModel}. - */ - public ClientModelPropertiesManager(ClientModel model, JavaSettings settings) { - // The reader name variable needs to be mutable as it may match a property name in the class. - Set possibleReaderFieldNameVariableNames = new LinkedHashSet<>(Arrays.asList( - "fieldName", "jsonFieldName", "deserializationFieldName")); - Set possibleXmlNameVariableNames = new LinkedHashSet<>(Arrays.asList( - "elementName", "xmlElementName", "deserializationElementName")); - this.model = model; - this.deserializedModelName = "deserialized" + model.getName(); - this.expectedDiscriminator = model.getSerializedName(); - ClientModelPropertyWithMetadata discriminatorProperty = null; + private final String xmlRootElementName; + private final String xmlRootElementNamespace; + private final boolean hasXmlElements; + private final boolean hasXmlTexts; + private final String xmlReaderNameVariableName; + private final List superXmlAttributes; + private final List xmlAttributes; + private final List superXmlTexts; + private final List xmlTexts; + private final List superXmlElements; + private final List xmlElements; + private final Map xmlNamespaceWithPrefix; + private final Map xmlNamespaceToConstantMapping; - Map flattenedProperties = new LinkedHashMap<>(); - boolean hasRequiredProperties = false; - boolean hasConstructorArguments = false; - superConstructorProperties = new LinkedHashMap<>(); - superRequiredProperties = new LinkedHashMap<>(); - superSetterProperties = new LinkedHashMap<>(); - superReadOnlyProperties = new LinkedHashMap<>(); - ClientModelProperty superAdditionalProperties = null; - boolean hasXmlElements = false; - boolean hasXmlTexts = false; - xmlNamespaceWithPrefix = new LinkedHashMap<>(); - superXmlAttributes = new ArrayList<>(); - xmlAttributes = new ArrayList<>(); - superXmlTexts = new ArrayList<>(); - xmlTexts = new ArrayList<>(); - superXmlElements = new ArrayList<>(); - xmlElements = new ArrayList<>(); + /** + * Creates a new instance of {@link ClientModelPropertiesManager}. + * + * @param model The {@link ClientModel}. + */ + public ClientModelPropertiesManager(ClientModel model, JavaSettings settings) { + // The reader name variable needs to be mutable as it may match a property name in the class. + Set possibleReaderFieldNameVariableNames = new LinkedHashSet<>(Arrays.asList( + "fieldName", "jsonFieldName", "deserializationFieldName")); + Set possibleXmlNameVariableNames = new LinkedHashSet<>(Arrays.asList( + "elementName", "xmlElementName", "deserializationElementName")); + this.model = model; - if (model.isPolymorphic()) { - ClientModel superTypeModel = model; - ClientModel parentModel = ClientModelUtil.getClientModel(model.getParentModelName()); - while (parentModel != null) { - superTypeModel = parentModel; - parentModel = ClientModelUtil.getClientModel(superTypeModel.getParentModelName()); - } + this.deserializedModelName = "deserialized" + model.getName(); + this.expectedDiscriminator = model.getSerializedName(); + ClientModelPropertyWithMetadata discriminatorProperty = null; - xmlRootElementName = superTypeModel.getXmlName(); - xmlRootElementNamespace = superTypeModel.getXmlNamespace(); + Map flattenedProperties = new LinkedHashMap<>(); + boolean hasRequiredProperties = false; + boolean hasConstructorArguments = false; + superConstructorProperties = new LinkedHashMap<>(); + superRequiredProperties = new LinkedHashMap<>(); + superSetterProperties = new LinkedHashMap<>(); + superReadOnlyProperties = new LinkedHashMap<>(); + ClientModelProperty superAdditionalProperties = null; + boolean hasXmlElements = false; + boolean hasXmlTexts = false; + xmlNamespaceWithPrefix = new LinkedHashMap<>(); + superXmlAttributes = new ArrayList<>(); + xmlAttributes = new ArrayList<>(); + superXmlTexts = new ArrayList<>(); + xmlTexts = new ArrayList<>(); + superXmlElements = new ArrayList<>(); + xmlElements = new ArrayList<>(); + boolean allFlattenedPropertiesFromParent = true; + + if (model.isPolymorphic()) { + ClientModel superTypeModel = model; + ClientModel parentModel = getClientModel(model.getParentModelName()); + while (parentModel != null) { + superTypeModel = parentModel; + parentModel = getClientModel(superTypeModel.getParentModelName()); + } + + xmlRootElementName = superTypeModel.getXmlName(); + xmlRootElementNamespace = superTypeModel.getXmlNamespace(); + } else { + xmlRootElementName = model.getXmlName(); + xmlRootElementNamespace = model.getXmlNamespace(); + } + + for (ClientModelProperty property : ClientModelUtil.getParentProperties(model)) { + // Ignore additional properties from parent types as it will be handled specifically in the subtype. + if (property.isAdditionalProperties()) { + superAdditionalProperties = property; + continue; + } + + if (property.isPolymorphicDiscriminator()) { + discriminatorProperty = new ClientModelPropertyWithMetadata(model, property, true); + } + + if (!property.isPolymorphicDiscriminator()) { + superPropertyConsumer(property, superRequiredProperties, superConstructorProperties, + superReadOnlyProperties, superSetterProperties, settings); + hasRequiredProperties |= property.isRequired(); + hasConstructorArguments |= ClientModelUtil.includePropertyInConstructor(property, settings); + } + + if (property.getNeedsFlatten()) { + flattenedProperties.put(property.getName(), new ClientModelPropertyWithMetadata(model, property, true)); + } + + possibleReaderFieldNameVariableNames.remove(property.getName()); + possibleXmlNameVariableNames.remove(property.getName()); + + if (property.isXmlAttribute()) { + if (!property.isPolymorphicDiscriminator()) { + superXmlAttributes.add(property); + } + } else if (property.isXmlText()) { + hasXmlTexts = true; + superXmlTexts.add(property); + } else { + hasXmlElements = true; + superXmlElements.add(property); + } + + if (!CoreUtils.isNullOrEmpty(property.getXmlPrefix())) { + xmlNamespaceWithPrefix.put(property.getXmlPrefix(), property.getXmlNamespace()); + } + } + + this.superAdditionalPropertiesProperty = superAdditionalProperties; + + constructorProperties = new LinkedHashMap<>(); + requiredProperties = new LinkedHashMap<>(); + setterProperties = new LinkedHashMap<>(); + readOnlyProperties = new LinkedHashMap<>(); + ClientModelProperty additionalProperties = null; + for (ClientModelProperty property : model.getProperties()) { + if (property.isRequired()) { + hasRequiredProperties = true; + requiredProperties.put(property.getSerializedName(), property); + + if (!property.isConstant()) { + if (ClientModelUtil.includePropertyInConstructor(property, settings)) { + constructorProperties.put(property.getSerializedName(), property); + hasConstructorArguments = true; + } else { + readOnlyProperties.put(property.getSerializedName(), property); + } + } + } else if (property.isAdditionalProperties()) { + // Extract the additionalProperties property as this will need to be passed into all deserialization + // logic creation calls. + additionalProperties = property; + } else { + setterProperties.put(property.getSerializedName(), property); + } + + if (property.isPolymorphicDiscriminator()) { + if (discriminatorProperty == null) { + discriminatorProperty = new ClientModelPropertyWithMetadata(model, property, false); + } else if (Objects.equals(discriminatorProperty.getProperty().getSerializedName(), property.getSerializedName())) { + discriminatorProperty = new ClientModelPropertyWithMetadata(model, property, true); } else { - xmlRootElementName = model.getXmlName(); - xmlRootElementNamespace = model.getXmlNamespace(); + discriminatorProperty = new ClientModelPropertyWithMetadata(model, property, false); } + } - for (ClientModelProperty property : ClientModelUtil.getParentProperties(model)) { - // Ignore additional properties from parent types as it will be handled specifically in the subtype. - if (property.isAdditionalProperties()) { - superAdditionalProperties = property; - continue; - } + if (property.getNeedsFlatten()) { + flattenedProperties.put(property.getName(), new ClientModelPropertyWithMetadata(model, property, false)); + allFlattenedPropertiesFromParent = false; + } - if (property.isPolymorphicDiscriminator()) { - discriminatorProperty = new ClientModelPropertyWithMetadata(model, property, true); - } + possibleReaderFieldNameVariableNames.remove(property.getName()); + possibleXmlNameVariableNames.remove(property.getName()); - if (!property.isPolymorphicDiscriminator()) { - superPropertyConsumer(property, superRequiredProperties, superConstructorProperties, - superReadOnlyProperties, superSetterProperties, settings); - hasRequiredProperties |= property.isRequired(); - hasConstructorArguments |= ClientModelUtil.includePropertyInConstructor(property, settings); - } - - if (property.getNeedsFlatten()) { - flattenedProperties.put(property.getName(), new ClientModelPropertyWithMetadata(model, property, true)); - } - - possibleReaderFieldNameVariableNames.remove(property.getName()); - possibleXmlNameVariableNames.remove(property.getName()); - - if (property.isXmlAttribute()) { - if (!property.isPolymorphicDiscriminator()) { - superXmlAttributes.add(property); - } - } else if (property.isXmlText()) { - hasXmlTexts = true; - superXmlTexts.add(property); - } else { - hasXmlElements = true; - superXmlElements.add(property); - } - - if (!CoreUtils.isNullOrEmpty(property.getXmlPrefix())) { - xmlNamespaceWithPrefix.put(property.getXmlPrefix(), property.getXmlNamespace()); - } + if (property.isXmlAttribute()) { + if (!property.isPolymorphicDiscriminator()) { + xmlAttributes.add(property); } + } else if (property.isXmlText()) { + hasXmlTexts = true; + xmlTexts.add(property); + } else { + hasXmlElements = true; + xmlElements.add(property); + } - this.superAdditionalPropertiesProperty = superAdditionalProperties; + if (!CoreUtils.isNullOrEmpty(property.getXmlPrefix())) { + xmlNamespaceWithPrefix.put(property.getXmlPrefix(), property.getXmlNamespace()); + } + } - constructorProperties = new LinkedHashMap<>(); - requiredProperties = new LinkedHashMap<>(); - setterProperties = new LinkedHashMap<>(); - readOnlyProperties = new LinkedHashMap<>(); - ClientModelProperty additionalProperties = null; - for (ClientModelProperty property : model.getProperties()) { - if (property.isRequired()) { - hasRequiredProperties = true; - requiredProperties.put(property.getSerializedName(), property); + this.hasRequiredProperties = hasRequiredProperties; + this.requiredPropertiesCount = requiredProperties.size() + superRequiredProperties.size(); + this.setterPropertiesCount = setterProperties.size() + superSetterProperties.size(); + this.readOnlyPropertiesCount = readOnlyProperties.size() + superReadOnlyProperties.size(); + this.hasConstructorArguments = hasConstructorArguments; + this.hasXmlElements = hasXmlElements; + this.hasXmlTexts = hasXmlTexts; + this.discriminatorProperty = discriminatorProperty; + this.additionalProperties = additionalProperties; + this.jsonFlattenedPropertiesTree = getFlattenedPropertiesHierarchy(model.getPolymorphicDiscriminatorName(), + flattenedProperties); + this.allFlattenedPropertiesFromParent = allFlattenedPropertiesFromParent; + Iterator possibleReaderFieldNameVariableNamesIterator = possibleReaderFieldNameVariableNames.iterator(); + if (possibleReaderFieldNameVariableNamesIterator.hasNext()) { + this.jsonReaderFieldNameVariableName = possibleReaderFieldNameVariableNamesIterator.next(); + } else { + throw new IllegalStateException("Model properties exhausted all possible JsonReader field name variables. " + + "Add additional possible JsonReader field name variables to resolve this issue."); + } - if (!property.isConstant()) { - if (ClientModelUtil.includePropertyInConstructor(property, settings)) { - constructorProperties.put(property.getSerializedName(), property); - hasConstructorArguments = true; - } else { - readOnlyProperties.put(property.getSerializedName(), property); - } - } - } else if (property.isAdditionalProperties()) { - // Extract the additionalProperties property as this will need to be passed into all deserialization - // logic creation calls. - additionalProperties = property; - } else { - setterProperties.put(property.getSerializedName(), property); - } + Iterator possibleXmlNameVariableNamesIterator = possibleXmlNameVariableNames.iterator(); + if (possibleXmlNameVariableNamesIterator.hasNext()) { + this.xmlReaderNameVariableName = possibleXmlNameVariableNamesIterator.next(); + } else { + throw new IllegalStateException("Model properties exhausted all possible XmlReader name variables. " + + "Add additional possible XmlReader name variables to resolve this issue."); + } - if (property.isPolymorphicDiscriminator()) { - if (discriminatorProperty == null) { - discriminatorProperty = new ClientModelPropertyWithMetadata(model, property, false); - } else if (Objects.equals(discriminatorProperty.getProperty().getSerializedName(), property.getSerializedName())) { - discriminatorProperty = new ClientModelPropertyWithMetadata(model, property, true); - } else { - discriminatorProperty = new ClientModelPropertyWithMetadata(model, property, false); - } - } + this.xmlNamespaceToConstantMapping = model.getXmlName() == null + ? Collections.emptyMap() : ClientModelUtil.xmlNamespaceToConstantMapping(model); + } - if (property.getNeedsFlatten()) { - flattenedProperties.put(property.getName(), new ClientModelPropertyWithMetadata(model, property, false)); - } + private static void superPropertyConsumer(ClientModelProperty property, + Map superRequiredProperties, + Map superConstructorProperties, + Map superReadOnlyProperties, + Map superSetterProperties, JavaSettings settings) { + if (property.isRequired()) { + superRequiredProperties.put(property.getSerializedName(), property); - possibleReaderFieldNameVariableNames.remove(property.getName()); - possibleXmlNameVariableNames.remove(property.getName()); - - if (property.isXmlAttribute()) { - if (!property.isPolymorphicDiscriminator()) { - xmlAttributes.add(property); - } - } else if (property.isXmlText()) { - hasXmlTexts = true; - xmlTexts.add(property); - } else { - hasXmlElements = true; - xmlElements.add(property); - } - - if (!CoreUtils.isNullOrEmpty(property.getXmlPrefix())) { - xmlNamespaceWithPrefix.put(property.getXmlPrefix(), property.getXmlNamespace()); - } - } - - this.hasRequiredProperties = hasRequiredProperties; - this.requiredPropertiesCount = requiredProperties.size() + superRequiredProperties.size(); - this.setterPropertiesCount = setterProperties.size() + superSetterProperties.size(); - this.readOnlyPropertiesCount = readOnlyProperties.size() + superReadOnlyProperties.size(); - this.hasConstructorArguments = hasConstructorArguments; - this.hasXmlElements = hasXmlElements; - this.hasXmlTexts = hasXmlTexts; - this.discriminatorProperty = discriminatorProperty; - this.additionalProperties = additionalProperties; - this.jsonFlattenedPropertiesTree = getFlattenedPropertiesHierarchy(model.getPolymorphicDiscriminatorName(), - flattenedProperties); - Iterator possibleReaderFieldNameVariableNamesIterator = possibleReaderFieldNameVariableNames.iterator(); - if (possibleReaderFieldNameVariableNamesIterator.hasNext()) { - this.jsonReaderFieldNameVariableName = possibleReaderFieldNameVariableNamesIterator.next(); + if (!property.isConstant()) { + if (ClientModelUtil.includePropertyInConstructor(property, settings)) { + superConstructorProperties.put(property.getSerializedName(), property); } else { - throw new IllegalStateException("Model properties exhausted all possible JsonReader field name variables. " - + "Add additional possible JsonReader field name variables to resolve this issue."); + superReadOnlyProperties.put(property.getSerializedName(), property); } + } + } else { + superSetterProperties.put(property.getSerializedName(), property); + } + } - Iterator possibleXmlNameVariableNamesIterator = possibleXmlNameVariableNames.iterator(); - if (possibleXmlNameVariableNamesIterator.hasNext()) { - this.xmlReaderNameVariableName = possibleXmlNameVariableNamesIterator.next(); + /** + * Gets the {@link ClientModel} that the properties are based on. + * + * @return The {@link ClientModel} that the properties are based on. + */ + public ClientModel getModel() { + return model; + } + + /** + * Gets the name of the variable used when deserializing an instance of the {@link #getModel() model}. + * + * @return The name of the variable used during deserialization. + */ + public String getDeserializedModelName() { + return deserializedModelName; + } + + /** + * Whether the {@link #getModel() model} contains required properties, either directly or through super classes. + * + * @return Whether the {@link #getModel() model} contains required properties. + */ + public boolean hasRequiredProperties() { + return hasRequiredProperties; + } + + /** + * Gets the number of required properties in the {@link #getModel() model}. + * + * @return The number of required properties in the {@link #getModel() model}. + */ + public int getRequiredPropertiesCount() { + return requiredPropertiesCount; + } + + /** + * Gets the number of setter properties in the {@link #getModel() model}. + * + * @return The number of setter properties in the {@link #getModel() model}. + */ + public int getSetterPropertiesCount() { + return setterPropertiesCount; + } + + /** + * Gets the number of read-only properties in the {@link #getModel() model}. + * + * @return The number of read-only properties in the {@link #getModel() model}. + */ + public int getReadOnlyPropertiesCount() { + return readOnlyPropertiesCount; + } + + /** + * Whether the {@link #getModel() model} has constructor arguments, either directly or required through super + * classes. + * + * @return Whether the {@link #getModel() model} contains constructor arguments. + */ + public boolean hasConstructorArguments() { + return hasConstructorArguments; + } + + /** + * Consumes each constructor {@link ClientModelProperty property} defined by super classes of the + * {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachSuperConstructorProperty(Consumer consumer) { + superConstructorProperties.values().forEach(consumer); + } + + /** + * Consumes each required {@link ClientModelProperty property} defined by super classes of the + * {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachSuperRequiredProperty(Consumer consumer) { + superRequiredProperties.values().forEach(consumer); + } + + /** + * Consumes each non-required {@link ClientModelProperty property} defined by super classes of the + * {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachSuperSetterProperty(Consumer consumer) { + superSetterProperties.values().forEach(consumer); + } + + /** + * Consumes each read-only {@link ClientModelProperty property} defined by super classes of the + * {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachSuperReadOnlyProperty(Consumer consumer) { + superReadOnlyProperties.values().forEach(consumer); + } + + /** + * Consumes each constructor {@link ClientModelProperty property} defined by the {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachConstructorProperty(Consumer consumer) { + constructorProperties.values().forEach(consumer); + } + + /** + * Consumes each required {@link ClientModelProperty property} defined by the {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachRequiredProperty(Consumer consumer) { + requiredProperties.values().forEach(consumer); + } + + /** + * Consumes each non-required {@link ClientModelProperty property} defined by the {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachSetterProperty(Consumer consumer) { + setterProperties.values().forEach(consumer); + } + + /** + * Consumes each read-only {@link ClientModelProperty property} defined by the {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachReadOnlyProperty(Consumer consumer) { + readOnlyProperties.values().forEach(consumer); + } + + /** + * Gets the {@link ClientModelProperty} that defines the additional properties property. + *

+ * If the model doesn't contain additional properties this will return null. + * + * @return The {@link ClientModelProperty} that defines the additional properties property, or null if the model + * doesn't define additional properties. + */ + public ClientModelProperty getAdditionalProperties() { + return additionalProperties; + } + + /** + * Gets the {@link ClientModelProperty} that defines the additional properties property in superclass. + *

+ * If the no superclass contain additional properties, this will return null. + * + * @return The {@link ClientModelProperty} that defines the additional properties property in superclass, or null if + * no superclass defines additional properties. + */ + public ClientModelProperty getSuperAdditionalPropertiesProperty() { + return superAdditionalPropertiesProperty; + } + + /** + * Gets the {@link ClientModelPropertyWithMetadata} that defines the discriminator property for polymorphic types. + *

+ * If the model isn't polymorphic this will return null. + * + * @return The {@link ClientModelPropertyWithMetadata} that defines the discriminator property for polymorphic + * types, or null if the model isn't a polymorphic type. + */ + public ClientModelPropertyWithMetadata getDiscriminatorProperty() { + return discriminatorProperty; + } + + /** + * Gets the expected discriminator value for the polymorphic model. + *

+ * If the model isn't polymorphic this will return null. + * + * @return The expected discriminator value for the polymorphic model, or null if the model isn't a polymorphic + * type. + */ + public String getExpectedDiscriminator() { + return expectedDiscriminator; + } + + /** + * Gets the JSON flattened properties tree for the model. + *

+ * If the model doesn't contain any JSON flattening this will return null. + * + * @return The JSON flattened properties tree for the model, or null if the model doesn't contain any JSON + * flattening. + */ + public JsonFlattenedPropertiesTree getJsonFlattenedPropertiesTree() { + return jsonFlattenedPropertiesTree; + } + + /** + * Whether all the flattened properties are from parent models. + * + * @return Whether all the flattened properties are from parent models. + */ + public boolean isAllFlattenedPropertiesFromParent() { + return allFlattenedPropertiesFromParent; + } + + /** + * Gets the variable name for {@link JsonReader#getFieldName()} in {@link JsonSerializable#fromJson(JsonReader)} + * implementations. + *

+ * This is used instead of a static variable name as deserialization maintains holders for required properties which + * could conflict with the static variable name. The constructor manages determination of the variable name by + * tracking a set of possible names, if all possible names are exhausted the constructor will throw an exception to + * indicate more possible names need to be added to support all code generation expectations. + * + * @return The variable name that tracks the current JSON field name. + */ + public String getJsonReaderFieldNameVariableName() { + return jsonReaderFieldNameVariableName; + } + + /** + * Gets the variable name for {@link XmlReader#getElementName()} in {@link XmlSerializable#fromXml(XmlReader)} + * implementations. + *

+ * This is used instead of a static variable name as deserialization maintains holders for required properties which + * could conflict with the static variable name. The constructor manages determination of the variable name by + * tracking a set of possible names, if all possible names are exhausted the constructor will throw an exception to + * indicate more possible names need to be added to support all code generation expectations. + * + * @return The variable name that tracks the current XML name. + */ + public String getXmlReaderNameVariableName() { + return xmlReaderNameVariableName; + } + + /** + * Gets the default XML root element name for the model. + *

+ * Polymorphism for XML works differently from JSON where the discriminator to determine which type to deserialize + * is determined by an attribute rather than a special property. This results in the super type and all subtypes + * using the same root element name determined by the super type. + * + * @return The default XML root element name. + */ + public String getXmlRootElementName() { + return xmlRootElementName; + } + + /** + * Gets the XML root element namespace for the model. + *

+ * Polymorphism for XML has the super type define the XML namespace. + * + * @return The XML root element namespace. + */ + public String getXmlRootElementNamespace() { + return xmlRootElementNamespace; + } + + /** + * Whether the {@link #getModel() model} defines XML elements, XML properties that aren't + * {@link ClientModelProperty#isXmlAttribute() attributes} or {@link ClientModelProperty#isXmlText() text}. + * + * @return Whether the {@link #getModel() model} defines XML elements + */ + public boolean hasXmlElements() { + return hasXmlElements; + } + + /** + * Whether the {@link #getModel() model} defines XML texts, XML properties that are + * {@link ClientModelProperty#isXmlText() text}. + * + * @return Whether the {@link #getModel() model} defines XML texts + */ + public boolean hasXmlTexts() { + return hasXmlTexts; + } + + /** + * Consumes each XML namespace that has a prefix. + * + * @param consumer XML namespace with prefix consumer. + */ + public void forEachXmlNamespaceWithPrefix(BiConsumer consumer) { + xmlNamespaceWithPrefix.forEach(consumer); + } + + /** + * Consumes each XML attribute {@link ClientModelProperty property} defined by super classes of the + * {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachSuperXmlAttribute(Consumer consumer) { + superXmlAttributes.forEach(consumer); + } + + /** + * Consumes each XML attribute {@link ClientModelProperty property} defined by the {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachXmlAttribute(Consumer consumer) { + xmlAttributes.forEach(consumer); + } + + /** + * Consumes each XML text {@link ClientModelProperty property} defined by super classes of the + * {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachSuperXmlText(Consumer consumer) { + superXmlTexts.forEach(consumer); + } + + /** + * Consumes each XML text {@link ClientModelProperty property} defined by the {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachXmlText(Consumer consumer) { + xmlTexts.forEach(consumer); + } + + /** + * Consumes each XML element {@link ClientModelProperty property} defined by super classes of the + * {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachSuperXmlElement(Consumer consumer) { + superXmlElements.forEach(consumer); + } + + /** + * Consumes each XML element {@link ClientModelProperty property} defined by the {@link #getModel() model}. + * + * @param consumer The {@link ClientModelProperty} consumer. + */ + public void forEachXmlElement(Consumer consumer) { + xmlElements.forEach(consumer); + } + + /** + * Gets the XML namespace constant for the given XML namespace. + * + * @param xmlNamespace The XML namespace. + * @return The XML namespace constant. + */ + public String getXmlNamespaceConstant(String xmlNamespace) { + return xmlNamespaceToConstantMapping.get(xmlNamespace); + } + + /** + * Takes all properties that will be included in a {@code fromJson(JsonReader)} call and for all properties that are + * flattened creates a tree representation of their paths. + *

+ * Flattened properties require additional processing as they must be handled at the same time. For example if a + * model has three flattened properties with JSON paths "im.flattened", "im.deeper.flattened", and + * "im.deeper.flattenedtoo" this will create the following structure: + * + *

+   * im -> flattened
+   *     | deeper -> flattened
+   *               | flattenedtoo
+   * 
+ * + * This structure is then used while generating deserialization logic to ensure that when the "im" JSON sub-object + * is found that it'll look for both "flattened" and the "deeper" JSON sub-object before either reading or skipping + * unknown properties. If this isn't done and deserialization logic is generated on a property-by-property basis, + * this could result in the "im.flattened" check skipping the "deeper" JSON sub-object. + * + * @param discriminatorProperty A potential discriminator property for hierarchical models. + * @param flattenedProperties All flattened properties that are part of a model's deserialization. + * @return The flattened JSON properties structure, or an empty structure if the model doesn't contained flattened + * properties. + */ + private static JsonFlattenedPropertiesTree getFlattenedPropertiesHierarchy(String discriminatorProperty, + Map flattenedProperties) { + JsonFlattenedPropertiesTree structure = JsonFlattenedPropertiesTree.createBaseNode(); + + if (!CoreUtils.isNullOrEmpty(discriminatorProperty)) { + List propertyHierarchy = ClientModelUtil.splitFlattenedSerializedName(discriminatorProperty); + if (!propertyHierarchy.isEmpty()) { + structure = JsonFlattenedPropertiesTree.createBaseNode(); + } + } + + for (ClientModelPropertyWithMetadata property : flattenedProperties.values()) { + if (!property.getProperty().getNeedsFlatten()) { + // Property doesn't need flattening, ignore it. + continue; + } + + // Splits the flattened property into the individual properties in the JSON path. + // For example "im.deeper.flattened" becomes ["im", "deeper", "flattened"]. + List propertyHierarchy = ClientModelUtil.splitFlattenedSerializedName(property.getProperty().getSerializedName()); + + if (propertyHierarchy.size() == 1) { + // Property is marked for flattening but points directly to its JSON path, ignore it. + continue; + } + + // Loop over all the property names in the JSON path, either getting or creating that node in the + // flattened JSON properties structure. + JsonFlattenedPropertiesTree pointer = structure; + for (int i = 0; i < propertyHierarchy.size(); i++) { + String nodeName = propertyHierarchy.get(i); + + // Structure doesn't contain the flattened property. + if (!pointer.hasChildNode(nodeName)) { + // Depending on whether this is the last property in the flattened property either a terminal + // or intermediate node will be inserted. + JsonFlattenedPropertiesTree newPointer = (i == propertyHierarchy.size() - 1) + ? JsonFlattenedPropertiesTree.createTerminalNode(nodeName, property) + : JsonFlattenedPropertiesTree.createIntermediateNode(nodeName); + + pointer.addChildNode(newPointer); + pointer = newPointer; } else { - throw new IllegalStateException("Model properties exhausted all possible XmlReader name variables. " - + "Add additional possible XmlReader name variables to resolve this issue."); + pointer = pointer.getChildNode(nodeName); } - - this.xmlNamespaceToConstantMapping = model.getXmlName() == null - ? Collections.emptyMap() : ClientModelUtil.xmlNamespaceToConstantMapping(model); + } } - private static void superPropertyConsumer(ClientModelProperty property, - Map superRequiredProperties, - Map superConstructorProperties, - Map superReadOnlyProperties, - Map superSetterProperties, JavaSettings settings) { - if (property.isRequired()) { - superRequiredProperties.put(property.getSerializedName(), property); - - if (!property.isConstant()) { - if (ClientModelUtil.includePropertyInConstructor(property, settings)) { - superConstructorProperties.put(property.getSerializedName(), property); - } else { - superReadOnlyProperties.put(property.getSerializedName(), property); - } - } - } else { - superSetterProperties.put(property.getSerializedName(), property); - } - } - - /** - * Gets the {@link ClientModel} that the properties are based on. - * - * @return The {@link ClientModel} that the properties are based on. - */ - public ClientModel getModel() { - return model; - } - - /** - * Gets the name of the variable used when deserializing an instance of the {@link #getModel() model}. - * - * @return The name of the variable used during deserialization. - */ - public String getDeserializedModelName() { - return deserializedModelName; - } - - /** - * Whether the {@link #getModel() model} contains required properties, either directly or through super classes. - * - * @return Whether the {@link #getModel() model} contains required properties. - */ - public boolean hasRequiredProperties() { - return hasRequiredProperties; - } - - /** - * Gets the number of required properties in the {@link #getModel() model}. - * - * @return The number of required properties in the {@link #getModel() model}. - */ - public int getRequiredPropertiesCount() { - return requiredPropertiesCount; - } - - /** - * Gets the number of setter properties in the {@link #getModel() model}. - * - * @return The number of setter properties in the {@link #getModel() model}. - */ - public int getSetterPropertiesCount() { - return setterPropertiesCount; - } - - /** - * Gets the number of read-only properties in the {@link #getModel() model}. - * - * @return The number of read-only properties in the {@link #getModel() model}. - */ - public int getReadOnlyPropertiesCount() { - return readOnlyPropertiesCount; - } - - /** - * Whether the {@link #getModel() model} has constructor arguments, either directly or required through super - * classes. - * - * @return Whether the {@link #getModel() model} contains constructor arguments. - */ - public boolean hasConstructorArguments() { - return hasConstructorArguments; - } - - /** - * Consumes each constructor {@link ClientModelProperty property} defined by super classes of the - * {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachSuperConstructorProperty(Consumer consumer) { - superConstructorProperties.values().forEach(consumer); - } - - /** - * Consumes each required {@link ClientModelProperty property} defined by super classes of the - * {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachSuperRequiredProperty(Consumer consumer) { - superRequiredProperties.values().forEach(consumer); - } - - /** - * Consumes each non-required {@link ClientModelProperty property} defined by super classes of the - * {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachSuperSetterProperty(Consumer consumer) { - superSetterProperties.values().forEach(consumer); - } - - /** - * Consumes each read-only {@link ClientModelProperty property} defined by super classes of the - * {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachSuperReadOnlyProperty(Consumer consumer) { - superReadOnlyProperties.values().forEach(consumer); - } - - /** - * Consumes each constructor {@link ClientModelProperty property} defined by the {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachConstructorProperty(Consumer consumer) { - constructorProperties.values().forEach(consumer); - } - - /** - * Consumes each required {@link ClientModelProperty property} defined by the {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachRequiredProperty(Consumer consumer) { - requiredProperties.values().forEach(consumer); - } - - /** - * Consumes each non-required {@link ClientModelProperty property} defined by the {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachSetterProperty(Consumer consumer) { - setterProperties.values().forEach(consumer); - } - - /** - * Consumes each read-only {@link ClientModelProperty property} defined by the {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachReadOnlyProperty(Consumer consumer) { - readOnlyProperties.values().forEach(consumer); - } - - /** - * Gets the {@link ClientModelProperty} that defines the additional properties property. - *

- * If the model doesn't contain additional properties this will return null. - * - * @return The {@link ClientModelProperty} that defines the additional properties property, or null if the model - * doesn't define additional properties. - */ - public ClientModelProperty getAdditionalProperties() { - return additionalProperties; - } - - /** - * Gets the {@link ClientModelProperty} that defines the additional properties property in superclass. - *

- * If the no superclass contain additional properties, this will return null. - * - * @return The {@link ClientModelProperty} that defines the additional properties property in superclass, or null if - * no superclass defines additional properties. - */ - public ClientModelProperty getSuperAdditionalPropertiesProperty() { - return superAdditionalPropertiesProperty; - } - - /** - * Gets the {@link ClientModelPropertyWithMetadata} that defines the discriminator property for polymorphic types. - *

- * If the model isn't polymorphic this will return null. - * - * @return The {@link ClientModelPropertyWithMetadata} that defines the discriminator property for polymorphic - * types, or null if the model isn't a polymorphic type. - */ - public ClientModelPropertyWithMetadata getDiscriminatorProperty() { - return discriminatorProperty; - } - - /** - * Gets the expected discriminator value for the polymorphic model. - *

- * If the model isn't polymorphic this will return null. - * - * @return The expected discriminator value for the polymorphic model, or null if the model isn't a polymorphic - * type. - */ - public String getExpectedDiscriminator() { - return expectedDiscriminator; - } - - /** - * Gets the JSON flattened properties tree for the model. - *

- * If the model doesn't contain any JSON flattening this will return null. - * - * @return The JSON flattened properties tree for the model, or null if the model doesn't contain any JSON - * flattening. - */ - public JsonFlattenedPropertiesTree getJsonFlattenedPropertiesTree() { - return jsonFlattenedPropertiesTree; - } - - /** - * Gets the variable name for {@link JsonReader#getFieldName()} in {@link JsonSerializable#fromJson(JsonReader)} - * implementations. - *

- * This is used instead of a static variable name as deserialization maintains holders for required properties which - * could conflict with the static variable name. The constructor manages determination of the variable name by - * tracking a set of possible names, if all possible names are exhausted the constructor will throw an exception to - * indicate more possible names need to be added to support all code generation expectations. - * - * @return The variable name that tracks the current JSON field name. - */ - public String getJsonReaderFieldNameVariableName() { - return jsonReaderFieldNameVariableName; - } - - /** - * Gets the variable name for {@link XmlReader#getElementName()} in {@link XmlSerializable#fromXml(XmlReader)} - * implementations. - *

- * This is used instead of a static variable name as deserialization maintains holders for required properties which - * could conflict with the static variable name. The constructor manages determination of the variable name by - * tracking a set of possible names, if all possible names are exhausted the constructor will throw an exception to - * indicate more possible names need to be added to support all code generation expectations. - * - * @return The variable name that tracks the current XML name. - */ - public String getXmlReaderNameVariableName() { - return xmlReaderNameVariableName; - } - - /** - * Gets the default XML root element name for the model. - *

- * Polymorphism for XML works differently from JSON where the discriminator to determine which type to deserialize - * is determined by an attribute rather than a special property. This results in the super type and all subtypes - * using the same root element name determined by the super type. - * - * @return The default XML root element name. - */ - public String getXmlRootElementName() { - return xmlRootElementName; - } - - /** - * Gets the XML root element namespace for the model. - *

- * Polymorphism for XML has the super type define the XML namespace. - * - * @return The XML root element namespace. - */ - public String getXmlRootElementNamespace() { - return xmlRootElementNamespace; - } - - /** - * Whether the {@link #getModel() model} defines XML elements, XML properties that aren't - * {@link ClientModelProperty#isXmlAttribute() attributes} or {@link ClientModelProperty#isXmlText() text}. - * - * @return Whether the {@link #getModel() model} defines XML elements - */ - public boolean hasXmlElements() { - return hasXmlElements; - } - - /** - * Whether the {@link #getModel() model} defines XML texts, XML properties that are - * {@link ClientModelProperty#isXmlText() text}. - * - * @return Whether the {@link #getModel() model} defines XML texts - */ - public boolean hasXmlTexts() { - return hasXmlTexts; - } - - /** - * Consumes each XML namespace that has a prefix. - * - * @param consumer XML namespace with prefix consumer. - */ - public void forEachXmlNamespaceWithPrefix(BiConsumer consumer) { - xmlNamespaceWithPrefix.forEach(consumer); - } - - /** - * Consumes each XML attribute {@link ClientModelProperty property} defined by super classes of the - * {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachSuperXmlAttribute(Consumer consumer) { - superXmlAttributes.forEach(consumer); - } - - /** - * Consumes each XML attribute {@link ClientModelProperty property} defined by the {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachXmlAttribute(Consumer consumer) { - xmlAttributes.forEach(consumer); - } - - /** - * Consumes each XML text {@link ClientModelProperty property} defined by super classes of the - * {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachSuperXmlText(Consumer consumer) { - superXmlTexts.forEach(consumer); - } - - /** - * Consumes each XML text {@link ClientModelProperty property} defined by the {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachXmlText(Consumer consumer) { - xmlTexts.forEach(consumer); - } - - /** - * Consumes each XML element {@link ClientModelProperty property} defined by super classes of the - * {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachSuperXmlElement(Consumer consumer) { - superXmlElements.forEach(consumer); - } - - /** - * Consumes each XML element {@link ClientModelProperty property} defined by the {@link #getModel() model}. - * - * @param consumer The {@link ClientModelProperty} consumer. - */ - public void forEachXmlElement(Consumer consumer) { - xmlElements.forEach(consumer); - } - - /** - * Gets the XML namespace constant for the given XML namespace. - * - * @param xmlNamespace The XML namespace. - * @return The XML namespace constant. - */ - public String getXmlNamespaceConstant(String xmlNamespace) { - return xmlNamespaceToConstantMapping.get(xmlNamespace); - } - - /** - * Takes all properties that will be included in a {@code fromJson(JsonReader)} call and for all properties that are - * flattened creates a tree representation of their paths. - *

- * Flattened properties require additional processing as they must be handled at the same time. For example if a - * model has three flattened properties with JSON paths "im.flattened", "im.deeper.flattened", and - * "im.deeper.flattenedtoo" this will create the following structure: - * - *

-     * im -> flattened
-     *     | deeper -> flattened
-     *               | flattenedtoo
-     * 
- * - * This structure is then used while generating deserialization logic to ensure that when the "im" JSON sub-object - * is found that it'll look for both "flattened" and the "deeper" JSON sub-object before either reading or skipping - * unknown properties. If this isn't done and deserialization logic is generated on a property-by-property basis, - * this could result in the "im.flattened" check skipping the "deeper" JSON sub-object. - * - * @param discriminatorProperty A potential discriminator property for hierarchical models. - * @param flattenedProperties All flattened properties that are part of a model's deserialization. - * @return The flattened JSON properties structure, or an empty structure if the model doesn't contained flattened - * properties. - */ - private static JsonFlattenedPropertiesTree getFlattenedPropertiesHierarchy(String discriminatorProperty, - Map flattenedProperties) { - JsonFlattenedPropertiesTree structure = JsonFlattenedPropertiesTree.createBaseNode(); - - if (!CoreUtils.isNullOrEmpty(discriminatorProperty)) { - List propertyHierarchy = ClientModelUtil.splitFlattenedSerializedName(discriminatorProperty); - if (!propertyHierarchy.isEmpty()) { - structure = JsonFlattenedPropertiesTree.createBaseNode(); - } - } - - for (ClientModelPropertyWithMetadata property : flattenedProperties.values()) { - if (!property.getProperty().getNeedsFlatten()) { - // Property doesn't need flattening, ignore it. - continue; - } - - // Splits the flattened property into the individual properties in the JSON path. - // For example "im.deeper.flattened" becomes ["im", "deeper", "flattened"]. - List propertyHierarchy = ClientModelUtil.splitFlattenedSerializedName(property.getProperty().getSerializedName()); - - if (propertyHierarchy.size() == 1) { - // Property is marked for flattening but points directly to its JSON path, ignore it. - continue; - } - - // Loop over all the property names in the JSON path, either getting or creating that node in the - // flattened JSON properties structure. - JsonFlattenedPropertiesTree pointer = structure; - for (int i = 0; i < propertyHierarchy.size(); i++) { - String nodeName = propertyHierarchy.get(i); - - // Structure doesn't contain the flattened property. - if (!pointer.hasChildNode(nodeName)) { - // Depending on whether this is the last property in the flattened property either a terminal - // or intermediate node will be inserted. - JsonFlattenedPropertiesTree newPointer = (i == propertyHierarchy.size() - 1) - ? JsonFlattenedPropertiesTree.createTerminalNode(nodeName, property) - : JsonFlattenedPropertiesTree.createIntermediateNode(nodeName); - - pointer.addChildNode(newPointer); - pointer = newPointer; - } else { - pointer = pointer.getChildNode(nodeName); - } - } - } - - return structure; - } + return structure; + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/implementation/PolymorphicDiscriminatorHandler.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/implementation/PolymorphicDiscriminatorHandler.java new file mode 100644 index 000000000..d2984edd2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/implementation/PolymorphicDiscriminatorHandler.java @@ -0,0 +1,163 @@ +package com.microsoft.typespec.http.client.generator.core.implementation; + +import com.microsoft.typespec.http.client.generator.core.extension.plugin.JavaSettings; +import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClientModel; +import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClientModelProperty; +import com.microsoft.typespec.http.client.generator.core.model.clientmodel.IType; +import com.microsoft.typespec.http.client.generator.core.model.javamodel.JavaBlock; +import com.microsoft.typespec.http.client.generator.core.model.javamodel.JavaClass; +import com.microsoft.typespec.http.client.generator.core.model.javamodel.JavaFile; +import com.microsoft.typespec.http.client.generator.core.model.javamodel.JavaVisibility; +import com.microsoft.typespec.http.client.generator.core.util.ClientModelUtil; + +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * This class handles generating code for polymorphic discriminators. + *

+ * This class exists to contain all logic for polymorphic discriminators in one location rather that having repetitive + * logic in multiple places. + */ +public final class PolymorphicDiscriminatorHandler { + public static void addAnnotationToField(ClientModel model, JavaFile javaFile, JavaSettings settings) { + if (!model.isPolymorphic() || settings.isStreamStyleSerialization()) { + return; + } + + // After removing the concept of passing discriminator to children models and always doing it, there is no need + // to set the 'include' property of the JsonTypeInfo annotation. We use 'JsonTypeInfo.As.PROPERTY' as the value, + // which is the default value, so it doesn't need to be declared. + // And to support unknown subtypes, we always set a default implementation to the class being generated. + // And the discriminator is passed to child models, so the discriminator property needs to be set to visible. + String jsonTypeInfo = "JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = \"" + + model.getPolymorphicDiscriminatorName() + "\", defaultImpl = " + model.getName() + + ".class, visible = true)"; + + javaFile.annotation(jsonTypeInfo); + javaFile.annotation("JsonTypeName(\"" + model.getSerializedName() + "\")"); + + if (!model.getDerivedModels().isEmpty()) { + javaFile.line("@JsonSubTypes({"); + javaFile.indent(() -> { + Function getDerivedTypeAnnotation = derivedType -> "@JsonSubTypes.Type(name = \"" + + derivedType.getSerializedName() + "\", value = " + derivedType.getName() + ".class)"; + + for (int i = 0; i != model.getDerivedModels().size() - 1; i++) { + ClientModel derivedModel = model.getDerivedModels().get(i); + javaFile.line(getDerivedTypeAnnotation.apply(derivedModel) + ','); + } + javaFile.line(getDerivedTypeAnnotation.apply(model.getDerivedModels() + .get(model.getDerivedModels().size() - 1))); + }); + javaFile.line("})"); + } + } + + public static void declareField(ClientModel model, JavaClass classBlock, Consumer addGeneratedAnnotation, + Consumer addFieldAnnotations, JavaSettings settings) { + if (!model.isPolymorphic()) { + return; + } + + for (ClientModelProperty discriminator : model.getParentPolymorphicDiscriminators()) { + declareFieldInternal(discriminator, model, false, classBlock, addGeneratedAnnotation, addFieldAnnotations, + settings); + } + + declareFieldInternal(model.getPolymorphicDiscriminator(), model, + ClientModelUtil.modelDefinesProperty(model, model.getPolymorphicDiscriminator()), classBlock, + addGeneratedAnnotation, addFieldAnnotations, settings); + } + + private static void declareFieldInternal(ClientModelProperty discriminator, ClientModel model, + boolean discriminatorDefinedByModel, JavaClass classBlock, Consumer addGeneratedAnnotation, + Consumer addFieldAnnotations, JavaSettings settings) { + boolean allPolymorphicModelsInSamePackage = model.isAllPolymorphicModelsInSamePackage(); + boolean discriminatorUsedInConstructor = ClientModelUtil.includePropertyInConstructor(discriminator, settings); + + String propertyName = discriminator.getName(); + IType propertyType = discriminator.getWireType(); + String discriminatorValue = (discriminator.getDefaultValue() == null) + ? discriminator.getClientType().defaultValueExpression(model.getSerializedName()) + : discriminator.getDefaultValue(); + + // Only set the property to a default value if the property isn't included in the constructor. + // There can be cases with polymorphic discriminators where they have both a default value and are + // required, in which case the default value will be set in the constructor. + boolean discriminatorFieldIsInitialized = (!discriminatorUsedInConstructor || discriminator.isConstant()) + && (discriminatorValue != null && !allPolymorphicModelsInSamePackage); + String fieldSignature = discriminatorFieldIsInitialized + ? propertyType + " " + propertyName + " = " + discriminatorValue + : propertyType + " " + propertyName; + + boolean generateCommentAndAnnotations = discriminatorUsedInConstructor + || (allPolymorphicModelsInSamePackage && discriminatorDefinedByModel) + || !allPolymorphicModelsInSamePackage; + + if (generateCommentAndAnnotations) { + classBlock.blockComment(comment -> comment.line(discriminator.getDescription())); + addGeneratedAnnotation.accept(classBlock); + addFieldAnnotations.accept(discriminator); + } + + if (discriminatorUsedInConstructor) { + classBlock.privateFinalMemberVariable(fieldSignature); + } else { + // If the model defines the discriminator and all models in the polymorphic hierarchy are in the same + // package, make it package-private to allow derived models to access it. + if (allPolymorphicModelsInSamePackage && discriminatorDefinedByModel) { + classBlock.memberVariable(JavaVisibility.PackagePrivate, fieldSignature); + } else if (!allPolymorphicModelsInSamePackage) { + classBlock.privateMemberVariable(fieldSignature); + } + } + } + + public static void initializeInConstructor(ClientModel model, JavaBlock constructor, JavaSettings settings) { + if (!model.isPolymorphic()) { + return; + } + + // Polymorphic models are contained in different packages, so the discriminator value was set in the field + // declaration. + if (!model.isAllPolymorphicModelsInSamePackage()) { + return; + } + + for (ClientModelProperty discriminator : model.getParentPolymorphicDiscriminators()) { + initializeInConstructorInternal(discriminator, model, constructor, settings); + } + + initializeInConstructorInternal(model.getPolymorphicDiscriminator(), model, constructor, settings); + } + + private static void initializeInConstructorInternal(ClientModelProperty discriminator, ClientModel model, + JavaBlock constructor, JavaSettings settings) { + // When the polymorphic discriminator is used in the constructor it will be initialized by the constructor. + if (ClientModelUtil.includePropertyInConstructor(discriminator, settings)) { + return; + } + + String discriminatorValue = (discriminator.getDefaultValue() == null) + ? discriminator.getClientType().defaultValueExpression(model.getSerializedName()) + : discriminator.getDefaultValue(); + constructor.line("this." + discriminator.getName() + " = " + discriminatorValue + ";"); + } + + /** + * Determines whether a getter method should be generated for the discriminator property. + * + * @return Whether a getter method should be generated for the discriminator property. + */ + public static boolean generateGetter(ClientModel model, ClientModelProperty discriminator) { + // If all the polymorphic models aren't in the same package the getter for the discriminator value will be + // generated for each model as each model defines properties for all discriminators. + if (!model.isAllPolymorphicModelsInSamePackage()) { + return true; + } + + // If all polymorphic models are in the same package, only the declaring model needs to generate the getter. + return ClientModelUtil.modelDefinesProperty(model, discriminator); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java index 0c1af5027..45e7c858d 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java @@ -18,6 +18,7 @@ import com.microsoft.typespec.http.client.generator.core.extension.plugin.JavaSe import com.microsoft.typespec.http.client.generator.core.extension.plugin.JavaSettings.SyncMethodsGeneration; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClassType; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClientMethod; +import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClientMethod.Builder; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClientMethodParameter; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClientMethodType; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClientModel; @@ -65,1355 +66,1355 @@ import java.util.stream.Stream; * A mapper that maps an {@link Operation} to a lit of {@link ClientMethod ClientMethods}. */ public class ClientMethodMapper implements IMapper> { - private static final ClientMethodMapper INSTANCE = new ClientMethodMapper(); + private static final ClientMethodMapper INSTANCE = new ClientMethodMapper(); - private static final Pattern ANYTHING_THEN_PERIOD = Pattern.compile(".*\\."); + private static final Pattern ANYTHING_THEN_PERIOD = Pattern.compile(".*\\."); - private final Map> parsed = new ConcurrentHashMap<>(); + private final Map> parsed = new ConcurrentHashMap<>(); - private static class CacheKey { - private final Operation operation; - private final boolean isProtocolMethod; + private static class CacheKey { + private final Operation operation; + private final boolean isProtocolMethod; - public CacheKey(Operation operation, boolean isProtocolMethod) { - this.operation = operation; - this.isProtocolMethod = isProtocolMethod; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - CacheKey cacheKey = (CacheKey) o; - return isProtocolMethod == cacheKey.isProtocolMethod && operation.equals(cacheKey.operation); - } - - @Override - public int hashCode() { - return Objects.hash(operation, isProtocolMethod); - } - } - - /** - * Creates a new instance of {@link ClientMethodMapper}. - */ - protected ClientMethodMapper() { - } - - /** - * Gets the global {@link ClientMethodMapper} instance. - * - * @return The global {@link ClientMethodMapper} instance. - */ - public static ClientMethodMapper getInstance() { - return INSTANCE; + public CacheKey(Operation operation, boolean isProtocolMethod) { + this.operation = operation; + this.isProtocolMethod = isProtocolMethod; } @Override - public List map(Operation operation) { - return map(operation, JavaSettings.getInstance().isDataPlaneClient()); + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CacheKey cacheKey = (CacheKey) o; + return isProtocolMethod == cacheKey.isProtocolMethod && operation.equals(cacheKey.operation); } - /** - * Maps an {@link Operation} to a list of {@link ClientMethod ClientMethods}. - * - * @param operation The {@link Operation} being mapped. - * @param isProtocolMethod Whether the operation is a protocol method. - * @return The list of {@link ClientMethod ClientMethods}. - */ - public List map(Operation operation, boolean isProtocolMethod) { - CacheKey cacheKey = new CacheKey(operation, isProtocolMethod); - List clientMethods = parsed.get(cacheKey); - if (clientMethods != null) { - return clientMethods; - } + @Override + public int hashCode() { + return Objects.hash(operation, isProtocolMethod); + } + } - clientMethods = createClientMethods(operation, isProtocolMethod); - parsed.put(cacheKey, clientMethods); + /** + * Creates a new instance of {@link ClientMethodMapper}. + */ + protected ClientMethodMapper() { + } - return clientMethods; + /** + * Gets the global {@link ClientMethodMapper} instance. + * + * @return The global {@link ClientMethodMapper} instance. + */ + public static ClientMethodMapper getInstance() { + return INSTANCE; + } + + @Override + public List map(Operation operation) { + return map(operation, JavaSettings.getInstance().isDataPlaneClient()); + } + + /** + * Maps an {@link Operation} to a list of {@link ClientMethod ClientMethods}. + * + * @param operation The {@link Operation} being mapped. + * @param isProtocolMethod Whether the operation is a protocol method. + * @return The list of {@link ClientMethod ClientMethods}. + */ + public List map(Operation operation, boolean isProtocolMethod) { + CacheKey cacheKey = new CacheKey(operation, isProtocolMethod); + List clientMethods = parsed.get(cacheKey); + if (clientMethods != null) { + return clientMethods; } - /** - * Creates the client methods for the operation. - * - * @param operation the operation. - * @param isProtocolMethod whether the client method to be simplified for resilience to API changes. - * @return the client methods created. - */ - private List createClientMethods(Operation operation, boolean isProtocolMethod) { - JavaSettings settings = JavaSettings.getInstance(); + clientMethods = createClientMethods(operation, isProtocolMethod); + parsed.put(cacheKey, clientMethods); - // With the introduction of "enable-sync-stack" data plane clients now have two distinct ways of creating - // synchronous implementation client methods. - // - // 1. Configure "enable-sync-stack" which will create synchronous proxy methods that will use a fully - // synchronous code path. - // 2. Configure "sync-methods" which will create synchronous implementation client methods that will block - // on the asynchronous proxy method. - // - // If both are support "enable-sync-stack" take precedent. This required substantial changes to the follow code - // as before asynchronous proxy methods would generate synchronous implementation client methods which - // shouldn't eagerly be done anymore as it would have resulted in erroneous synchronous implementation client - // methods. + return clientMethods; + } - Map> proxyMethodsMap = Mappers.getProxyMethodMapper().map(operation); + /** + * Creates the client methods for the operation. + * + * @param operation the operation. + * @param isProtocolMethod whether the client method to be simplified for resilience to API changes. + * @return the client methods created. + */ + private List createClientMethods(Operation operation, boolean isProtocolMethod) { + JavaSettings settings = JavaSettings.getInstance(); - List methods = new ArrayList<>(); + // With the introduction of "enable-sync-stack" data plane clients now have two distinct ways of creating + // synchronous implementation client methods. + // + // 1. Configure "enable-sync-stack" which will create synchronous proxy methods that will use a fully + // synchronous code path. + // 2. Configure "sync-methods" which will create synchronous implementation client methods that will block + // on the asynchronous proxy method. + // + // If both are support "enable-sync-stack" take precedent. This required substantial changes to the follow code + // as before asynchronous proxy methods would generate synchronous implementation client methods which + // shouldn't eagerly be done anymore as it would have resulted in erroneous synchronous implementation client + // methods. - // If this operation is part of a group it'll need to be referenced with a more specific target. - ClientMethod.Builder builder = getClientMethodBuilder() - .clientReference((operation.getOperationGroup() == null || operation.getOperationGroup().getLanguage().getJava().getName().isEmpty()) ? "this" : "this.client") - .setCrossLanguageDefinitionId(operation.getCrossLanguageDefinitionId()); + Map> proxyMethodsMap = Mappers.getProxyMethodMapper().map(operation); - // merge summary and description - String summary = operation.getSummary(); - if (summary == null) { - // summary from m4 is under language - summary = operation.getLanguage().getDefault() == null ? null : operation.getLanguage().getDefault().getSummary(); - } - String description = operation.getLanguage().getJava() == null ? null : operation.getLanguage().getJava().getDescription(); - if (CoreUtils.isNullOrEmpty(summary) && CoreUtils.isNullOrEmpty(description)) { - builder.description(String.format("The %s operation.", operation.getLanguage().getJava().getName())); - } else { - builder.description(SchemaUtil.mergeSummaryWithDescription(summary, description)); - } + List methods = new ArrayList<>(); - // API comment - ImplementationDetails.Builder implDetailsBuilder = null; - if (operation.getLanguage().getJava() != null && !CoreUtils.isNullOrEmpty(operation.getLanguage().getJava().getComment())) { - implDetailsBuilder = new ImplementationDetails.Builder().comment(operation.getLanguage().getJava().getComment()); - builder.implementationDetails(implDetailsBuilder.build()); - } + // If this operation is part of a group it'll need to be referenced with a more specific target. + ClientMethod.Builder builder = getClientMethodBuilder() + .clientReference((operation.getOperationGroup() == null || operation.getOperationGroup().getLanguage().getJava().getName().isEmpty()) ? "this" : "this.client") + .setCrossLanguageDefinitionId(operation.getCrossLanguageDefinitionId()); - // map externalDocs property - if (operation.getExternalDocs() != null) { - ExternalDocumentation externalDocumentation = new ExternalDocumentation.Builder() - .description(operation.getExternalDocs().getDescription()) - .url(operation.getExternalDocs().getUrl()) - .build(); - builder.methodDocumentation(externalDocumentation); - } + // merge summary and description + String summary = operation.getSummary(); + if (summary == null) { + // summary from m4 is under language + summary = operation.getLanguage().getDefault() == null ? null : operation.getLanguage().getDefault().getSummary(); + } + String description = operation.getLanguage().getJava() == null ? null : operation.getLanguage().getJava().getDescription(); + if (CoreUtils.isNullOrEmpty(summary) && CoreUtils.isNullOrEmpty(description)) { + builder.description(String.format("The %s operation.", operation.getLanguage().getJava().getName())); + } else { + builder.description(SchemaUtil.mergeSummaryWithDescription(summary, description)); + } - List requests = getCodeModelRequests(operation, isProtocolMethod, proxyMethodsMap); - for (Request request : requests) { - List proxyMethods = proxyMethodsMap.get(request); - for (ProxyMethod proxyMethod : proxyMethods) { - ReturnTypeHolder returnTypeHolder = getReturnTypes(operation, isProtocolMethod, settings, proxyMethod.isCustomHeaderIgnored()); - builder.proxyMethod(proxyMethod); - List parameters = new ArrayList<>(); - List requiredParameterExpressions = new ArrayList<>(); - Map validateExpressions = new HashMap<>(); - List methodTransformationDetails = new ArrayList<>(); + // API comment + ImplementationDetails.Builder implDetailsBuilder = null; + if (operation.getLanguage().getJava() != null && !CoreUtils.isNullOrEmpty(operation.getLanguage().getJava().getComment())) { + implDetailsBuilder = new ImplementationDetails.Builder().comment(operation.getLanguage().getJava().getComment()); + builder.implementationDetails(implDetailsBuilder.build()); + } - List codeModelParameters = getCodeModelParameters(request, isProtocolMethod); + // map externalDocs property + if (operation.getExternalDocs() != null) { + ExternalDocumentation externalDocumentation = new ExternalDocumentation.Builder() + .description(operation.getExternalDocs().getDescription()) + .url(operation.getExternalDocs().getUrl()) + .build(); + builder.methodDocumentation(externalDocumentation); + } - final boolean isPageable = - operation.getExtensions() != null && operation.getExtensions().getXmsPageable() != null - && shouldGeneratePagingMethods(); - if (isPageable && JavaSettings.getInstance().isPageSizeEnabled()) { - // remove maxpagesize parameter from client method API, it would be in e.g. PagedIterable.iterableByPage(int) - codeModelParameters = codeModelParameters.stream() - .filter(p -> !MethodUtil.isMaxPageSizeParameter(p)) - .collect(Collectors.toList()); - } + List requests = getCodeModelRequests(operation, isProtocolMethod, proxyMethodsMap); + for (Request request : requests) { + List proxyMethods = proxyMethodsMap.get(request); + for (ProxyMethod proxyMethod : proxyMethods) { + ReturnTypeHolder returnTypeHolder = getReturnTypes(operation, isProtocolMethod, settings, proxyMethod.isCustomHeaderIgnored()); + builder.proxyMethod(proxyMethod); + List parameters = new ArrayList<>(); + List requiredParameterExpressions = new ArrayList<>(); + Map validateExpressions = new HashMap<>(); + List methodTransformationDetails = new ArrayList<>(); - final boolean isJsonPatch = MethodUtil.isContentTypeInRequest(request, "application/json-patch+json"); + List codeModelParameters = getCodeModelParameters(request, isProtocolMethod); - final boolean proxyMethodUsesBinaryData = proxyMethod.getParameters().stream() - .anyMatch(proxyMethodParameter -> proxyMethodParameter.getClientType() == ClassType.BINARY_DATA); - final boolean proxyMethodUsesFluxByteBuffer = proxyMethod.getParameters().stream() - .anyMatch(proxyMethodParameter -> proxyMethodParameter.getClientType() == GenericType.FLUX_BYTE_BUFFER); - - Set originalParameters = new HashSet<>(); - for (Parameter parameter : codeModelParameters) { - ClientMethodParameter clientMethodParameter = Mappers.getClientParameterMapper() - .map(parameter, isProtocolMethod); - - if (isJsonPatch) { - clientMethodParameter = CustomClientParameterMapper.getInstance().map(parameter, isProtocolMethod); - } - - // If the codemodel parameter and proxy method parameter types don't match, update the client - // method param to use proxy method parameter type. - if (proxyMethodUsesBinaryData && clientMethodParameter.getClientType() == GenericType.FLUX_BYTE_BUFFER) { - clientMethodParameter = updateClientMethodParameter(clientMethodParameter); - } - - if (request.getSignatureParameters().contains(parameter)) { - parameters.add(clientMethodParameter); - } - - if (!(parameter.getSchema() instanceof ConstantSchema) && parameter.getGroupedBy() == null) { - MethodParameter methodParameter; - String expression; - if (parameter.getImplementation() != Parameter.ImplementationLocation.CLIENT) { - methodParameter = clientMethodParameter; - expression = clientMethodParameter.getName(); - } else { - ProxyMethodParameter proxyParameter = Mappers.getProxyParameterMapper().map(parameter); - methodParameter = proxyParameter; - expression = proxyParameter.getParameterReference(); - } - - // Validations - if (methodParameter.isRequired() && !(methodParameter.getClientType() instanceof PrimitiveType)) { - requiredParameterExpressions.add(expression); - } - String validation = methodParameter.getClientType().validate(expression); - if (validation != null) { - validateExpressions.put(expression, validation); - } - } - - // Transformations - if ((parameter.getOriginalParameter() != null || parameter.getGroupedBy() != null) - && !(parameter.getSchema() instanceof ConstantSchema) && !isProtocolMethod) { - - processParameterTransformations( - methodTransformationDetails, originalParameters, - parameter, clientMethodParameter, isProtocolMethod); - } - } - - // handle the case that the flattened parameter is model with all its properties read-only - // in this case, it is not original parameter from any other parameters - for (Parameter parameter : request.getParameters().stream() - .filter(p -> p.isFlattened() && p.getProtocol() != null && p.getProtocol().getHttp() != null) // flattened proxy parameter - .filter(p -> !originalParameters.contains(p)) // but not original parameter from any other parameters - .collect(Collectors.toList())) { - ClientMethodParameter outParameter = Mappers.getClientParameterMapper().map(parameter); - methodTransformationDetails.add(new MethodTransformationDetail(outParameter, new ArrayList<>())); - } - - final MethodOverloadType defaultOverloadType = hasNonRequiredParameters(parameters) ? MethodOverloadType.OVERLOAD_MAXIMUM : MethodOverloadType.OVERLOAD_MINIMUM_MAXIMUM; - final boolean generateOnlyRequiredParameters = settings.isRequiredParameterClientMethods() && defaultOverloadType == MethodOverloadType.OVERLOAD_MAXIMUM; - - JavaVisibility methodVisibilityInWrapperClient = JavaVisibility.Public; - if (operation.getInternalApi() == Boolean.TRUE - || (isProtocolMethod && operation.getGenerateProtocolApi() == Boolean.FALSE)) { - // Client method is package private in wrapper client, so that the client or developer can still invoke it. - methodVisibilityInWrapperClient = JavaVisibility.PackagePrivate; - } - - builder.parameters(parameters) - .requiredNullableParameterExpressions(requiredParameterExpressions) - .validateExpressions(validateExpressions) - .methodTransformationDetails(methodTransformationDetails) - .methodVisibilityInWrapperClient(methodVisibilityInWrapperClient) - .methodPageDetails(null); - - if (isPageable) { - String pageableItemName = getPageableItemName(operation.getExtensions().getXmsPageable(), proxyMethod.getRawResponseBodyType() != null ? proxyMethod.getRawResponseBodyType() : proxyMethod.getResponseBodyType()); - if (pageableItemName == null) { - // There is no pageable item name for this operation, skip it. - continue; - } - - // If the ProxyMethod is synchronous perform a complete generation of synchronous pageable APIs. - if (proxyMethod.isSync()) { - createSyncPageableClientMethods(operation, isProtocolMethod, settings, methods, builder, - returnTypeHolder, proxyMethod, parameters, pageableItemName, - generateOnlyRequiredParameters, defaultOverloadType); - } else { - // Otherwise, perform a complete generation of asynchronous pageable APIs. - // Then if SyncMethodsGeneration is enabled and Sync Stack is not perform synchronous pageable - // API generation based on SyncMethodsGeneration configuration. - createAsyncPageableClientMethods(operation, isProtocolMethod, settings, methods, builder, - returnTypeHolder, proxyMethod, parameters, pageableItemName, - generateOnlyRequiredParameters, defaultOverloadType); - - if (settings.isGenerateSyncMethods() && !settings.isSyncStackEnabled()) { - createSyncPageableClientMethods(operation, isProtocolMethod, settings, methods, builder, - returnTypeHolder, proxyMethod, parameters, pageableItemName, - generateOnlyRequiredParameters, defaultOverloadType); - } - } - } else if (operation.getExtensions() != null && operation.getExtensions().isXmsLongRunningOperation() - && (settings.isFluent() || settings.getPollingConfig("default") != null) - && !returnTypeHolder.syncReturnType.equals(ClassType.INPUT_STREAM)) { - // temporary skip InputStream, no idea how to do this in PollerFlux - // Skip sync ProxyMethods for polling as sync polling isn't ready yet. - if (proxyMethod.isSync()) { - continue; - } - - JavaVisibility simpleAsyncMethodVisibility = - methodVisibility(ClientMethodType.SimpleAsyncRestResponse, defaultOverloadType, false, isProtocolMethod); - JavaVisibility simpleAsyncMethodVisibilityWithContext = - methodVisibility(ClientMethodType.SimpleAsyncRestResponse, defaultOverloadType, true, isProtocolMethod); - - JavaVisibility simpleSyncMethodVisibility = - methodVisibility(ClientMethodType.SimpleSyncRestResponse, defaultOverloadType, false, - isProtocolMethod); - JavaVisibility simpleSyncMethodVisibilityWithContext = - methodVisibility(ClientMethodType.SimpleSyncRestResponse, defaultOverloadType, true, - isProtocolMethod); - // for vanilla and fluent, the SimpleAsyncRestResponse is VISIBLE, so that they can be used for possible customization on LRO - - // there is ambiguity of RestResponse from simple API and from LRO API - // e.g. SimpleAsyncRestResponse without Context in simple API should be VISIBLE - // hence override here for DPG - if (settings.isDataPlaneClient()) { - simpleAsyncMethodVisibility = NOT_GENERATE; - simpleAsyncMethodVisibilityWithContext = NOT_VISIBLE; - simpleSyncMethodVisibility = NOT_GENERATE; - simpleSyncMethodVisibilityWithContext = NOT_VISIBLE; - } - - // WithResponseAsync, with required and optional parameters - methods.add(builder - .returnValue(createSimpleAsyncRestResponseReturnValue(operation, - returnTypeHolder.asyncRestResponseReturnType, returnTypeHolder.syncReturnType)) - .name(proxyMethod.getSimpleAsyncRestResponseMethodName()) - .onlyRequiredParameters(false) - .type(ClientMethodType.SimpleAsyncRestResponse) - .groupedParameterRequired(false) - .methodVisibility(simpleAsyncMethodVisibility) - .hasWithContextOverload(simpleAsyncMethodVisibilityWithContext != NOT_GENERATE) - .build()); - - builder.methodVisibility(simpleAsyncMethodVisibilityWithContext); - addClientMethodWithContext(methods, builder, parameters, getContextParameter(isProtocolMethod)); - - if (JavaSettings.getInstance().isSyncStackEnabled() && !proxyMethodUsesFluxByteBuffer) { - // WithResponseAsync, with required and optional parameters - methods.add(builder - .returnValue(createSimpleSyncRestResponseReturnValue(operation, - returnTypeHolder.syncReturnWithResponse, returnTypeHolder.syncReturnType)) - .name(proxyMethod.getSimpleRestResponseMethodName()) - .onlyRequiredParameters(false) - .type(ClientMethodType.SimpleSyncRestResponse) - .groupedParameterRequired(false) - .methodVisibility(simpleSyncMethodVisibility) - .proxyMethod(proxyMethod.toSync()) - .build()); - - builder.methodVisibility(simpleSyncMethodVisibilityWithContext); - addClientMethodWithContext(methods, builder, parameters, getContextParameter(isProtocolMethod)); - - // reset builder - builder - .returnValue(createSimpleAsyncRestResponseReturnValue(operation, - returnTypeHolder.asyncRestResponseReturnType, returnTypeHolder.syncReturnType)) - .name(proxyMethod.getSimpleAsyncRestResponseMethodName()) - .onlyRequiredParameters(false) - .type(ClientMethodType.SimpleAsyncRestResponse) - .groupedParameterRequired(false) - .proxyMethod(proxyMethod) - .methodVisibility(simpleAsyncMethodVisibility); - } - - JavaSettings.PollingDetails pollingDetails = settings.getPollingConfig(proxyMethod.getOperationId()); - - MethodPollingDetails methodPollingDetails = null; - MethodPollingDetails dpgMethodPollingDetailsWithModel = null; // for additional LRO methods - - if (pollingDetails != null) { - // try lroMetadata - methodPollingDetails = methodPollingDetailsFromMetadata(operation, pollingDetails); - - // result from methodPollingDetails already handled JavaSettings.PollingDetails (as well as LongRunningMetadata) - if (methodPollingDetails == null) { - methodPollingDetails = new MethodPollingDetails( - pollingDetails.getStrategy(), - pollingDetails.getSyncStrategy(), - getPollingIntermediateType(pollingDetails, returnTypeHolder.syncReturnType), - getPollingFinalType(pollingDetails, returnTypeHolder.syncReturnType, MethodUtil.getHttpMethod(operation)), - pollingDetails.getPollIntervalInSeconds()); - } - } - - if (methodPollingDetails != null && isProtocolMethod - // models of LRO configured - && !(ClassType.BINARY_DATA.equals(methodPollingDetails.getIntermediateType()) - && (ClassType.BINARY_DATA.equals(methodPollingDetails.getFinalType()) || ClassType.VOID.equals(methodPollingDetails.getFinalType().asNullable())))) { - - // a new method to be added as implementation only (not exposed to client) for developer - dpgMethodPollingDetailsWithModel = methodPollingDetails; - - // keep consistency with DPG from Swagger, see getPollingFinalType - IType resultType = ClassType.BINARY_DATA; - // DELETE would not have final response as resource is deleted - if (MethodUtil.getHttpMethod(operation) == HttpMethod.DELETE) { - resultType = PrimitiveType.VOID; - } - - // DPG keep the method with BinaryData - methodPollingDetails = new MethodPollingDetails( - dpgMethodPollingDetailsWithModel.getPollingStrategy(), - dpgMethodPollingDetailsWithModel.getSyncPollingStrategy(), - ClassType.BINARY_DATA, - resultType, - dpgMethodPollingDetailsWithModel.getPollIntervalInSeconds()); - } - - MethodNamer methodNamer = resolveMethodNamer(proxyMethod, operation.getConvenienceApi(), isProtocolMethod); - - createLroMethods(operation, builder, methods, - methodNamer.getLroBeginAsyncMethodName(), - methodNamer.getLroBeginMethodName(), - parameters, returnTypeHolder.syncReturnType, methodPollingDetails, isProtocolMethod, - generateOnlyRequiredParameters, defaultOverloadType, proxyMethod); - - if (dpgMethodPollingDetailsWithModel != null) { - // additional LRO method for data-plane, with intermediate/final type, for convenience of grow-up - // it is public in implementation, but not exposed in wrapper client - - if (implDetailsBuilder == null) { - implDetailsBuilder = new ImplementationDetails.Builder(); - } - implDetailsBuilder.implementationOnly(true); - - builder = builder.implementationDetails(implDetailsBuilder.build()); - - createLroMethods(operation, builder, methods, - methodNamer.getLroModelBeginAsyncMethodName(), - methodNamer.getLroModelBeginMethodName(), - parameters, returnTypeHolder.syncReturnType, dpgMethodPollingDetailsWithModel, isProtocolMethod, - generateOnlyRequiredParameters, defaultOverloadType, proxyMethod); - - builder = builder.implementationDetails(implDetailsBuilder.implementationOnly(false).build()); - } - - this.createAdditionalLroMethods(operation, builder, methods, isProtocolMethod, - returnTypeHolder.asyncReturnType, returnTypeHolder.syncReturnType, proxyMethod, parameters, - generateOnlyRequiredParameters, defaultOverloadType); - } else { - if (proxyMethod.isSync()) { - // If the ProxyMethod is synchronous perform a complete generation of synchronous simple APIs. - - createSimpleSyncClientMethods(operation, isProtocolMethod, settings, methods, builder, - returnTypeHolder, proxyMethod, parameters, generateOnlyRequiredParameters, defaultOverloadType); - } else { - // Otherwise, perform a complete generation of asynchronous simple APIs. - // Then if SyncMethodsGeneration is enabled and Sync Stack is not perform synchronous simple - // API generation based on SyncMethodsGeneration configuration. - - if (settings.getSyncMethods() != SyncMethodsGeneration.SYNC_ONLY) { - // SyncMethodsGeneration.NONE would still generate these - createSimpleAsyncClientMethods(operation, isProtocolMethod, settings, methods, builder, - returnTypeHolder, proxyMethod, parameters, generateOnlyRequiredParameters, defaultOverloadType); - } - - if (settings.isGenerateSyncMethods() && !settings.isSyncStackEnabled()) { - createSimpleSyncClientMethods(operation, isProtocolMethod, settings, methods, builder, - returnTypeHolder, proxyMethod, parameters, generateOnlyRequiredParameters, defaultOverloadType); - } - } - } - } - } - - return methods.stream() - .filter(m -> m.getMethodVisibility() != NOT_GENERATE) - .distinct() + final boolean isPageable = + operation.getExtensions() != null && operation.getExtensions().getXmsPageable() != null + && shouldGeneratePagingMethods(); + if (isPageable && JavaSettings.getInstance().isPageSizeEnabled()) { + // remove maxpagesize parameter from client method API, it would be in e.g. PagedIterable.iterableByPage(int) + codeModelParameters = codeModelParameters.stream() + .filter(p -> !MethodUtil.isMaxPageSizeParameter(p)) .collect(Collectors.toList()); - } - - private void processParameterTransformations( - List methodTransformationDetails, - Set originalParameters, - Parameter parameter, ClientMethodParameter clientMethodParameter, - boolean isProtocolMethod) { - - ClientMethodParameter outParameter; - if (parameter.getOriginalParameter() != null) { - originalParameters.add(parameter.getOriginalParameter()); - outParameter = Mappers.getClientParameterMapper().map(parameter.getOriginalParameter()); - } else { - outParameter = clientMethodParameter; - } - MethodTransformationDetail detail = methodTransformationDetails.stream() - .filter(d -> outParameter.getName().equals(d.getOutParameter().getName())) - .findFirst().orElse(null); - if (detail == null) { - detail = new MethodTransformationDetail(outParameter, new ArrayList<>()); - methodTransformationDetails.add(detail); - } - ParameterMapping mapping = new ParameterMapping(); - if (parameter.getGroupedBy() != null) { - mapping.setInputParameter(Mappers.getClientParameterMapper().map(parameter.getGroupedBy(), isProtocolMethod)); - ClientModel groupModel = Mappers.getModelMapper().map((ObjectSchema) parameter.getGroupedBy().getSchema()); - ClientModelProperty inputProperty = groupModel.getProperties().stream() - .filter(p -> parameter.getLanguage().getJava().getName().equals(p.getName())) - .findFirst().get(); - mapping.setInputParameterProperty(inputProperty); - } else { - mapping.setInputParameter(clientMethodParameter); - } - if (parameter.getOriginalParameter() != null) { - mapping.setOutputParameterProperty(Mappers.getModelPropertyMapper().map(parameter.getTargetProperty())); - mapping.setOutputParameterPropertyName(parameter.getTargetProperty().getLanguage().getJava().getName()); - } - detail.getParameterMappings().add(mapping); - } - - private ReturnTypeHolder getReturnTypes(Operation operation, boolean isProtocolMethod, JavaSettings settings, - boolean isCustomHeaderIgnored) { - ReturnTypeHolder returnTypeHolder = new ReturnTypeHolder(); - - if (operation.getExtensions() != null && operation.getExtensions().getXmsPageable() != null) { - // Mono> - Schema responseBodySchema = SchemaUtil.getLowestCommonParent(operation.getResponses().stream() - .map(Response::getSchema).filter(Objects::nonNull).iterator()); - if (!(responseBodySchema instanceof ObjectSchema)) { - throw new IllegalArgumentException(String.format("[JavaCheck/SchemaError] no common parent found for client models %s", - operation.getResponses().stream().map(Response::getSchema).filter(Objects::nonNull) - .map(SchemaUtil::getJavaName).collect(Collectors.toList()))); - } - ClientModel responseBodyModel = Mappers.getModelMapper().map((ObjectSchema) responseBodySchema); - Stream.concat(responseBodyModel.getProperties().stream(), ClientModelUtil.getParentProperties(responseBodyModel).stream()) - .filter(p -> p.getSerializedName().equals(operation.getExtensions().getXmsPageable().getItemName())) - .findFirst() - .ifPresentOrElse(itemProperty -> { - IType listType = itemProperty.getWireType(); - IType elementType = ((ListType) listType).getElementType(); - if (isProtocolMethod) { - returnTypeHolder.asyncRestResponseReturnType = createProtocolPagedRestResponseReturnType(); - returnTypeHolder.asyncReturnType = createProtocolPagedAsyncReturnType(); - returnTypeHolder.syncReturnType = createProtocolPagedSyncReturnType(); - returnTypeHolder.syncReturnWithResponse = createProtocolPagedRestResponseReturnTypeSync(); - } else { - returnTypeHolder.asyncRestResponseReturnType = createPagedRestResponseReturnType(elementType); - returnTypeHolder.asyncReturnType = createPagedAsyncReturnType(elementType); - returnTypeHolder.syncReturnType = createPagedSyncReturnType(elementType); - returnTypeHolder.syncReturnWithResponse = createPagedRestResponseReturnTypeSync(elementType); - } - }, () -> { - throw new IllegalArgumentException(String.format("[JavaCheck/SchemaError] item name %s not found among properties of client model %s", - operation.getExtensions().getXmsPageable().getItemName(), responseBodyModel.getName())); - }); - - return returnTypeHolder; } - IType responseBodyType = MapperUtils.handleResponseSchema(operation, settings); - if (isProtocolMethod && JavaSettings.getInstance().isBranded()) { - responseBodyType = SchemaUtil.removeModelFromResponse(responseBodyType, operation); - } + final boolean isJsonPatch = MethodUtil.isContentTypeInRequest(request, "application/json-patch+json"); - returnTypeHolder.asyncRestResponseReturnType = Mappers.getProxyMethodMapper() - .getAsyncRestResponseReturnType(operation, responseBodyType, isProtocolMethod, settings, isCustomHeaderIgnored) - .getClientType(); + final boolean proxyMethodUsesBinaryData = proxyMethod.getParameters().stream() + .anyMatch(proxyMethodParameter -> proxyMethodParameter.getClientType() == ClassType.BINARY_DATA); + final boolean proxyMethodUsesFluxByteBuffer = proxyMethod.getParameters().stream() + .anyMatch(proxyMethodParameter -> proxyMethodParameter.getClientType() == GenericType.FLUX_BYTE_BUFFER); - IType restAPIMethodReturnBodyClientType = responseBodyType.getClientType(); - if (responseBodyType.equals(ClassType.INPUT_STREAM)) { - returnTypeHolder.asyncReturnType = createAsyncBinaryReturnType(); - returnTypeHolder.syncReturnType = responseBodyType.getClientType(); - } else { - if (restAPIMethodReturnBodyClientType != PrimitiveType.VOID) { - returnTypeHolder.asyncReturnType = createAsyncBodyReturnType(restAPIMethodReturnBodyClientType); + Set originalParameters = new HashSet<>(); + for (Parameter parameter : codeModelParameters) { + ClientMethodParameter clientMethodParameter = Mappers.getClientParameterMapper() + .map(parameter, isProtocolMethod); + + if (isJsonPatch) { + clientMethodParameter = CustomClientParameterMapper.getInstance().map(parameter, isProtocolMethod); + } + + // If the codemodel parameter and proxy method parameter types don't match, update the client + // method param to use proxy method parameter type. + if (proxyMethodUsesBinaryData && clientMethodParameter.getClientType() == GenericType.FLUX_BYTE_BUFFER) { + clientMethodParameter = updateClientMethodParameter(clientMethodParameter); + } + + if (request.getSignatureParameters().contains(parameter)) { + parameters.add(clientMethodParameter); + } + + if (!(parameter.getSchema() instanceof ConstantSchema) && parameter.getGroupedBy() == null) { + MethodParameter methodParameter; + String expression; + if (parameter.getImplementation() != Parameter.ImplementationLocation.CLIENT) { + methodParameter = clientMethodParameter; + expression = clientMethodParameter.getName(); } else { - returnTypeHolder.asyncReturnType = createAsyncVoidReturnType(); + ProxyMethodParameter proxyParameter = Mappers.getProxyParameterMapper().map(parameter); + methodParameter = proxyParameter; + expression = proxyParameter.getParameterReference(); } - returnTypeHolder.syncReturnType = responseBodyType.getClientType(); - if (responseBodyType == GenericType.FLUX_BYTE_BUFFER && !settings.isFluent()) { - returnTypeHolder.syncReturnType = ClassType.BINARY_DATA; + + // Validations + if (methodParameter.isRequired() && !(methodParameter.getClientType() instanceof PrimitiveType)) { + requiredParameterExpressions.add(expression); } + String validation = methodParameter.getClientType().validate(expression); + if (validation != null) { + validateExpressions.put(expression, validation); + } + } + + // Transformations + if ((parameter.getOriginalParameter() != null || parameter.getGroupedBy() != null) + && !(parameter.getSchema() instanceof ConstantSchema) && !isProtocolMethod) { + + processParameterTransformations( + methodTransformationDetails, originalParameters, + parameter, clientMethodParameter, isProtocolMethod); + } } - returnTypeHolder.syncReturnWithResponse = createSyncReturnWithResponseType(returnTypeHolder.syncReturnType, - operation, isProtocolMethod, settings, isCustomHeaderIgnored); + // handle the case that the flattened parameter is model with all its properties read-only + // in this case, it is not original parameter from any other parameters + for (Parameter parameter : request.getParameters().stream() + .filter(p -> p.isFlattened() && p.getProtocol() != null && p.getProtocol().getHttp() != null) // flattened proxy parameter + .filter(p -> !originalParameters.contains(p)) // but not original parameter from any other parameters + .collect(Collectors.toList())) { + ClientMethodParameter outParameter = Mappers.getClientParameterMapper().map(parameter); + methodTransformationDetails.add(new MethodTransformationDetail(outParameter, new ArrayList<>())); + } - return returnTypeHolder; - } + final MethodOverloadType defaultOverloadType = hasNonRequiredParameters(parameters) ? MethodOverloadType.OVERLOAD_MAXIMUM : MethodOverloadType.OVERLOAD_MINIMUM_MAXIMUM; + final boolean generateOnlyRequiredParameters = settings.isRequiredParameterClientMethods() && defaultOverloadType == MethodOverloadType.OVERLOAD_MAXIMUM; - private static List getCodeModelRequests(Operation operation, boolean isProtocolMethod, - Map> proxyMethodsMap) { - if (!isProtocolMethod && operation.getConvenienceApi() != null && operation.getConvenienceApi().getRequests() != null) { - // convenience API of a protocol API - List requests = operation.getConvenienceApi().getRequests(); - for (Request request : requests) { - // at present, just set the proxy methods - proxyMethodsMap.put(request, proxyMethodsMap.values().iterator().next()); + JavaVisibility methodVisibilityInWrapperClient = JavaVisibility.Public; + if (operation.getInternalApi() == Boolean.TRUE + || (isProtocolMethod && operation.getGenerateProtocolApi() == Boolean.FALSE)) { + // Client method is package private in wrapper client, so that the client or developer can still invoke it. + methodVisibilityInWrapperClient = JavaVisibility.PackagePrivate; + } + + builder.parameters(parameters) + .requiredNullableParameterExpressions(requiredParameterExpressions) + .validateExpressions(validateExpressions) + .methodTransformationDetails(methodTransformationDetails) + .methodVisibilityInWrapperClient(methodVisibilityInWrapperClient) + .methodPageDetails(null); + + if (isPageable) { + String pageableItemName = getPageableItemName(operation.getExtensions().getXmsPageable(), proxyMethod.getRawResponseBodyType() != null ? proxyMethod.getRawResponseBodyType() : proxyMethod.getResponseBodyType()); + if (pageableItemName == null) { + // There is no pageable item name for this operation, skip it. + continue; + } + + // If the ProxyMethod is synchronous perform a complete generation of synchronous pageable APIs. + if (proxyMethod.isSync()) { + createSyncPageableClientMethods(operation, isProtocolMethod, settings, methods, builder, + returnTypeHolder, proxyMethod, parameters, pageableItemName, + generateOnlyRequiredParameters, defaultOverloadType); + } else { + // Otherwise, perform a complete generation of asynchronous pageable APIs. + // Then if SyncMethodsGeneration is enabled and Sync Stack is not perform synchronous pageable + // API generation based on SyncMethodsGeneration configuration. + createAsyncPageableClientMethods(operation, isProtocolMethod, settings, methods, builder, + returnTypeHolder, proxyMethod, parameters, pageableItemName, + generateOnlyRequiredParameters, defaultOverloadType); + + if (settings.isGenerateSyncMethods() && !settings.isSyncStackEnabled()) { + createSyncPageableClientMethods(operation, isProtocolMethod, settings, methods, builder, + returnTypeHolder, proxyMethod, parameters, pageableItemName, + generateOnlyRequiredParameters, defaultOverloadType); } - return requests; + } + } else if (operation.getExtensions() != null && operation.getExtensions().isXmsLongRunningOperation() + && (settings.isFluent() || settings.getPollingConfig("default") != null) + && !returnTypeHolder.syncReturnType.equals(ClassType.INPUT_STREAM)) { + // temporary skip InputStream, no idea how to do this in PollerFlux + // Skip sync ProxyMethods for polling as sync polling isn't ready yet. + if (proxyMethod.isSync()) { + continue; + } + + JavaVisibility simpleAsyncMethodVisibility = + methodVisibility(ClientMethodType.SimpleAsyncRestResponse, defaultOverloadType, false, isProtocolMethod); + JavaVisibility simpleAsyncMethodVisibilityWithContext = + methodVisibility(ClientMethodType.SimpleAsyncRestResponse, defaultOverloadType, true, isProtocolMethod); + + JavaVisibility simpleSyncMethodVisibility = + methodVisibility(ClientMethodType.SimpleSyncRestResponse, defaultOverloadType, false, + isProtocolMethod); + JavaVisibility simpleSyncMethodVisibilityWithContext = + methodVisibility(ClientMethodType.SimpleSyncRestResponse, defaultOverloadType, true, + isProtocolMethod); + // for vanilla and fluent, the SimpleAsyncRestResponse is VISIBLE, so that they can be used for possible customization on LRO + + // there is ambiguity of RestResponse from simple API and from LRO API + // e.g. SimpleAsyncRestResponse without Context in simple API should be VISIBLE + // hence override here for DPG + if (settings.isDataPlaneClient()) { + simpleAsyncMethodVisibility = NOT_GENERATE; + simpleAsyncMethodVisibilityWithContext = NOT_VISIBLE; + simpleSyncMethodVisibility = NOT_GENERATE; + simpleSyncMethodVisibilityWithContext = NOT_VISIBLE; + } + + // WithResponseAsync, with required and optional parameters + methods.add(builder + .returnValue(createSimpleAsyncRestResponseReturnValue(operation, + returnTypeHolder.asyncRestResponseReturnType, returnTypeHolder.syncReturnType)) + .name(proxyMethod.getSimpleAsyncRestResponseMethodName()) + .onlyRequiredParameters(false) + .type(ClientMethodType.SimpleAsyncRestResponse) + .groupedParameterRequired(false) + .methodVisibility(simpleAsyncMethodVisibility) + .hasWithContextOverload(simpleAsyncMethodVisibilityWithContext != NOT_GENERATE) + .build()); + + builder.methodVisibility(simpleAsyncMethodVisibilityWithContext); + addClientMethodWithContext(methods, builder, parameters, getContextParameter(isProtocolMethod)); + + if (JavaSettings.getInstance().isSyncStackEnabled() && !proxyMethodUsesFluxByteBuffer) { + // WithResponseAsync, with required and optional parameters + methods.add(builder + .returnValue(createSimpleSyncRestResponseReturnValue(operation, + returnTypeHolder.syncReturnWithResponse, returnTypeHolder.syncReturnType)) + .name(proxyMethod.getSimpleRestResponseMethodName()) + .onlyRequiredParameters(false) + .type(ClientMethodType.SimpleSyncRestResponse) + .groupedParameterRequired(false) + .methodVisibility(simpleSyncMethodVisibility) + .proxyMethod(proxyMethod.toSync()) + .build()); + + builder.methodVisibility(simpleSyncMethodVisibilityWithContext); + addClientMethodWithContext(methods, builder, parameters, getContextParameter(isProtocolMethod)); + + // reset builder + builder + .returnValue(createSimpleAsyncRestResponseReturnValue(operation, + returnTypeHolder.asyncRestResponseReturnType, returnTypeHolder.syncReturnType)) + .name(proxyMethod.getSimpleAsyncRestResponseMethodName()) + .onlyRequiredParameters(false) + .type(ClientMethodType.SimpleAsyncRestResponse) + .groupedParameterRequired(false) + .proxyMethod(proxyMethod) + .methodVisibility(simpleAsyncMethodVisibility); + } + + JavaSettings.PollingDetails pollingDetails = settings.getPollingConfig(proxyMethod.getOperationId()); + + MethodPollingDetails methodPollingDetails = null; + MethodPollingDetails dpgMethodPollingDetailsWithModel = null; // for additional LRO methods + + if (pollingDetails != null) { + // try lroMetadata + methodPollingDetails = methodPollingDetailsFromMetadata(operation, pollingDetails); + + // result from methodPollingDetails already handled JavaSettings.PollingDetails (as well as LongRunningMetadata) + if (methodPollingDetails == null) { + methodPollingDetails = new MethodPollingDetails( + pollingDetails.getStrategy(), + pollingDetails.getSyncStrategy(), + getPollingIntermediateType(pollingDetails, returnTypeHolder.syncReturnType), + getPollingFinalType(pollingDetails, returnTypeHolder.syncReturnType, MethodUtil.getHttpMethod(operation)), + pollingDetails.getPollIntervalInSeconds()); + } + } + + if (methodPollingDetails != null && isProtocolMethod + // models of LRO configured + && !(ClassType.BINARY_DATA.equals(methodPollingDetails.getIntermediateType()) + && (ClassType.BINARY_DATA.equals(methodPollingDetails.getFinalType()) || ClassType.VOID.equals(methodPollingDetails.getFinalType().asNullable())))) { + + // a new method to be added as implementation only (not exposed to client) for developer + dpgMethodPollingDetailsWithModel = methodPollingDetails; + + // keep consistency with DPG from Swagger, see getPollingFinalType + IType resultType = ClassType.BINARY_DATA; + // DELETE would not have final response as resource is deleted + if (MethodUtil.getHttpMethod(operation) == HttpMethod.DELETE) { + resultType = PrimitiveType.VOID; + } + + // DPG keep the method with BinaryData + methodPollingDetails = new MethodPollingDetails( + dpgMethodPollingDetailsWithModel.getPollingStrategy(), + dpgMethodPollingDetailsWithModel.getSyncPollingStrategy(), + ClassType.BINARY_DATA, + resultType, + dpgMethodPollingDetailsWithModel.getPollIntervalInSeconds()); + } + + MethodNamer methodNamer = resolveMethodNamer(proxyMethod, operation.getConvenienceApi(), isProtocolMethod); + + createLroMethods(operation, builder, methods, + methodNamer.getLroBeginAsyncMethodName(), + methodNamer.getLroBeginMethodName(), + parameters, returnTypeHolder.syncReturnType, methodPollingDetails, isProtocolMethod, + generateOnlyRequiredParameters, defaultOverloadType, proxyMethod); + + if (dpgMethodPollingDetailsWithModel != null) { + // additional LRO method for data-plane, with intermediate/final type, for convenience of grow-up + // it is public in implementation, but not exposed in wrapper client + + if (implDetailsBuilder == null) { + implDetailsBuilder = new ImplementationDetails.Builder(); + } + implDetailsBuilder.implementationOnly(true); + + builder = builder.implementationDetails(implDetailsBuilder.build()); + + createLroMethods(operation, builder, methods, + methodNamer.getLroModelBeginAsyncMethodName(), + methodNamer.getLroModelBeginMethodName(), + parameters, returnTypeHolder.syncReturnType, dpgMethodPollingDetailsWithModel, isProtocolMethod, + generateOnlyRequiredParameters, defaultOverloadType, proxyMethod); + + builder = builder.implementationDetails(implDetailsBuilder.implementationOnly(false).build()); + } + + this.createAdditionalLroMethods(operation, builder, methods, isProtocolMethod, + returnTypeHolder.asyncReturnType, returnTypeHolder.syncReturnType, proxyMethod, parameters, + generateOnlyRequiredParameters, defaultOverloadType); } else { - return operation.getRequests(); + if (proxyMethod.isSync()) { + // If the ProxyMethod is synchronous perform a complete generation of synchronous simple APIs. + + createSimpleSyncClientMethods(operation, isProtocolMethod, settings, methods, builder, + returnTypeHolder, proxyMethod, parameters, generateOnlyRequiredParameters, defaultOverloadType); + } else { + // Otherwise, perform a complete generation of asynchronous simple APIs. + // Then if SyncMethodsGeneration is enabled and Sync Stack is not perform synchronous simple + // API generation based on SyncMethodsGeneration configuration. + + if (settings.getSyncMethods() != SyncMethodsGeneration.SYNC_ONLY) { + // SyncMethodsGeneration.NONE would still generate these + createSimpleAsyncClientMethods(operation, isProtocolMethod, settings, methods, builder, + returnTypeHolder, proxyMethod, parameters, generateOnlyRequiredParameters, defaultOverloadType); + } + + if (settings.isGenerateSyncMethods() && !settings.isSyncStackEnabled()) { + createSimpleSyncClientMethods(operation, isProtocolMethod, settings, methods, builder, + returnTypeHolder, proxyMethod, parameters, generateOnlyRequiredParameters, defaultOverloadType); + } + } } + } } - private static List getCodeModelParameters(Request request, boolean isProtocolMethod) { - if (isProtocolMethod) { - // Required path, body, header and query parameters are allowed - return request.getParameters().stream().filter(p -> { - RequestParameterLocation location = p.getProtocol().getHttp().getIn(); + return methods.stream() + .filter(m -> m.getMethodVisibility() != NOT_GENERATE) + .distinct() + .collect(Collectors.toList()); + } - return p.isRequired() && (location == RequestParameterLocation.PATH - || location == RequestParameterLocation.BODY - || location == RequestParameterLocation.HEADER - || location == RequestParameterLocation.QUERY); - }) - .collect(Collectors.toList()); - } else { - return request.getParameters().stream().filter(p -> !p.isFlattened()).collect(Collectors.toList()); - } + private void processParameterTransformations( + List methodTransformationDetails, + Set originalParameters, + Parameter parameter, ClientMethodParameter clientMethodParameter, + boolean isProtocolMethod) { + + ClientMethodParameter outParameter; + if (parameter.getOriginalParameter() != null) { + originalParameters.add(parameter.getOriginalParameter()); + outParameter = Mappers.getClientParameterMapper().map(parameter.getOriginalParameter()); + } else { + outParameter = clientMethodParameter; + } + MethodTransformationDetail detail = methodTransformationDetails.stream() + .filter(d -> outParameter.getName().equals(d.getOutParameter().getName())) + .findFirst().orElse(null); + if (detail == null) { + detail = new MethodTransformationDetail(outParameter, new ArrayList<>()); + methodTransformationDetails.add(detail); + } + ParameterMapping mapping = new ParameterMapping(); + if (parameter.getGroupedBy() != null) { + mapping.setInputParameter(Mappers.getClientParameterMapper().map(parameter.getGroupedBy(), isProtocolMethod)); + ClientModel groupModel = Mappers.getModelMapper().map((ObjectSchema) parameter.getGroupedBy().getSchema()); + ClientModelProperty inputProperty = groupModel.getProperties().stream() + .filter(p -> parameter.getLanguage().getJava().getName().equals(p.getName())) + .findFirst().get(); + mapping.setInputParameterProperty(inputProperty); + } else { + mapping.setInputParameter(clientMethodParameter); + } + if (parameter.getOriginalParameter() != null) { + mapping.setOutputParameterProperty(Mappers.getModelPropertyMapper().map(parameter.getTargetProperty())); + mapping.setOutputParameterPropertyName(parameter.getTargetProperty().getLanguage().getJava().getName()); + } + detail.getParameterMappings().add(mapping); + } + + private ReturnTypeHolder getReturnTypes(Operation operation, boolean isProtocolMethod, JavaSettings settings, + boolean isCustomHeaderIgnored) { + ReturnTypeHolder returnTypeHolder = new ReturnTypeHolder(); + + if (operation.getExtensions() != null && operation.getExtensions().getXmsPageable() != null) { + // Mono> + Schema responseBodySchema = SchemaUtil.getLowestCommonParent(operation.getResponses().stream() + .map(Response::getSchema).filter(Objects::nonNull).iterator()); + if (!(responseBodySchema instanceof ObjectSchema)) { + throw new IllegalArgumentException(String.format("[JavaCheck/SchemaError] no common parent found for client models %s", + operation.getResponses().stream().map(Response::getSchema).filter(Objects::nonNull) + .map(SchemaUtil::getJavaName).collect(Collectors.toList()))); + } + ClientModel responseBodyModel = Mappers.getModelMapper().map((ObjectSchema) responseBodySchema); + Stream.concat(responseBodyModel.getProperties().stream(), ClientModelUtil.getParentProperties(responseBodyModel).stream()) + .filter(p -> p.getSerializedName().equals(operation.getExtensions().getXmsPageable().getItemName())) + .findFirst() + .ifPresentOrElse(itemProperty -> { + IType listType = itemProperty.getWireType(); + IType elementType = ((ListType) listType).getElementType(); + if (isProtocolMethod) { + returnTypeHolder.asyncRestResponseReturnType = createProtocolPagedRestResponseReturnType(); + returnTypeHolder.asyncReturnType = createProtocolPagedAsyncReturnType(); + returnTypeHolder.syncReturnType = createProtocolPagedSyncReturnType(); + returnTypeHolder.syncReturnWithResponse = createProtocolPagedRestResponseReturnTypeSync(); + } else { + returnTypeHolder.asyncRestResponseReturnType = createPagedRestResponseReturnType(elementType); + returnTypeHolder.asyncReturnType = createPagedAsyncReturnType(elementType); + returnTypeHolder.syncReturnType = createPagedSyncReturnType(elementType); + returnTypeHolder.syncReturnWithResponse = createPagedRestResponseReturnTypeSync(elementType); + } + }, () -> { + throw new IllegalArgumentException(String.format("[JavaCheck/SchemaError] item name %s not found among properties of client model %s", + operation.getExtensions().getXmsPageable().getItemName(), responseBodyModel.getName())); + }); + + return returnTypeHolder; } - private void createAsyncPageableClientMethods(Operation operation, boolean isProtocolMethod, JavaSettings settings, - List methods, ClientMethod.Builder builder, ReturnTypeHolder returnTypeHolder, ProxyMethod proxyMethod, - List parameters, String pageableItemName, + IType responseBodyType = MapperUtils.handleResponseSchema(operation, settings); + if (isProtocolMethod && JavaSettings.getInstance().isBranded()) { + responseBodyType = SchemaUtil.removeModelFromResponse(responseBodyType, operation); + } + + returnTypeHolder.asyncRestResponseReturnType = Mappers.getProxyMethodMapper() + .getAsyncRestResponseReturnType(operation, responseBodyType, isProtocolMethod, settings, isCustomHeaderIgnored) + .getClientType(); + + IType restAPIMethodReturnBodyClientType = responseBodyType.getClientType(); + if (responseBodyType.equals(ClassType.INPUT_STREAM)) { + returnTypeHolder.asyncReturnType = createAsyncBinaryReturnType(); + returnTypeHolder.syncReturnType = responseBodyType.getClientType(); + } else { + if (restAPIMethodReturnBodyClientType != PrimitiveType.VOID) { + returnTypeHolder.asyncReturnType = createAsyncBodyReturnType(restAPIMethodReturnBodyClientType); + } else { + returnTypeHolder.asyncReturnType = createAsyncVoidReturnType(); + } + returnTypeHolder.syncReturnType = responseBodyType.getClientType(); + if (responseBodyType == GenericType.FLUX_BYTE_BUFFER && !settings.isFluent()) { + returnTypeHolder.syncReturnType = ClassType.BINARY_DATA; + } + } + + returnTypeHolder.syncReturnWithResponse = createSyncReturnWithResponseType(returnTypeHolder.syncReturnType, + operation, isProtocolMethod, settings, isCustomHeaderIgnored); + + return returnTypeHolder; + } + + private static List getCodeModelRequests(Operation operation, boolean isProtocolMethod, + Map> proxyMethodsMap) { + if (!isProtocolMethod && operation.getConvenienceApi() != null && operation.getConvenienceApi().getRequests() != null) { + // convenience API of a protocol API + List requests = operation.getConvenienceApi().getRequests(); + for (Request request : requests) { + // at present, just set the proxy methods + proxyMethodsMap.put(request, proxyMethodsMap.values().iterator().next()); + } + return requests; + } else { + return operation.getRequests(); + } + } + + private static List getCodeModelParameters(Request request, boolean isProtocolMethod) { + if (isProtocolMethod) { + // Required path, body, header and query parameters are allowed + return request.getParameters().stream().filter(p -> { + RequestParameterLocation location = p.getProtocol().getHttp().getIn(); + + return p.isRequired() && (location == RequestParameterLocation.PATH + || location == RequestParameterLocation.BODY + || location == RequestParameterLocation.HEADER + || location == RequestParameterLocation.QUERY); + }) + .collect(Collectors.toList()); + } else { + return request.getParameters().stream().filter(p -> !p.isFlattened()).collect(Collectors.toList()); + } + } + + private void createAsyncPageableClientMethods(Operation operation, boolean isProtocolMethod, JavaSettings settings, + List methods, ClientMethod.Builder builder, ReturnTypeHolder returnTypeHolder, ProxyMethod proxyMethod, + List parameters, String pageableItemName, + boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { + + ReturnValue singlePageReturnValue = createPagingAsyncSinglePageReturnValue(operation, + returnTypeHolder.asyncRestResponseReturnType, returnTypeHolder.syncReturnType); + ReturnValue nextPageReturnValue = createPagingAsyncReturnValue(operation, returnTypeHolder.asyncReturnType, + returnTypeHolder.syncReturnType); + MethodVisibilityFunction visibilityFunction = (firstPage, overloadType, includesContext) -> + methodVisibility(firstPage ? ClientMethodType.PagingAsyncSinglePage : ClientMethodType.PagingAsync, + overloadType, includesContext, isProtocolMethod); + + createPageableClientMethods(operation, isProtocolMethod, settings, methods, builder, proxyMethod, parameters, pageableItemName, + false, singlePageReturnValue, nextPageReturnValue, visibilityFunction, getContextParameter(isProtocolMethod), + generateClientMethodWithOnlyRequiredParameters, defaultOverloadType); + } + + private void createSyncPageableClientMethods(Operation operation, boolean isProtocolMethod, JavaSettings settings, + List methods, Builder builder, ReturnTypeHolder returnTypeHolder, ProxyMethod proxyMethod, + List parameters, String pageableItemName, + boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { + + ReturnValue singlePageReturnValue = createPagingSyncSinglePageReturnValue(operation, + returnTypeHolder.syncReturnWithResponse, returnTypeHolder.syncReturnType); + ReturnValue nextPageReturnValue = createPagingSyncReturnValue(operation, returnTypeHolder.syncReturnType); + MethodVisibilityFunction visibilityFunction = (firstPage, overloadType, includesContext) -> + methodVisibility(firstPage ? ClientMethodType.PagingSyncSinglePage : ClientMethodType.PagingSync, + overloadType, includesContext, isProtocolMethod); + + createPageableClientMethods(operation, isProtocolMethod, settings, methods, builder, proxyMethod, parameters, pageableItemName, + true, singlePageReturnValue, nextPageReturnValue, visibilityFunction, getContextParameter(isProtocolMethod), + generateClientMethodWithOnlyRequiredParameters, defaultOverloadType); + } + + private static void createPageableClientMethods(Operation operation, boolean isProtocolMethod, JavaSettings settings, + List methods, Builder builder, ProxyMethod proxyMethod, List parameters, + String pageableItemName, boolean isSync, ReturnValue singlePageReturnValue, ReturnValue nextPageReturnValue, + MethodVisibilityFunction visibilityFunction, ClientMethodParameter contextParameter, boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { - ReturnValue singlePageReturnValue = createPagingAsyncSinglePageReturnValue(operation, - returnTypeHolder.asyncRestResponseReturnType, returnTypeHolder.syncReturnType); - ReturnValue nextPageReturnValue = createPagingAsyncReturnValue(operation, returnTypeHolder.asyncReturnType, - returnTypeHolder.syncReturnType); - MethodVisibilityFunction visibilityFunction = (firstPage, overloadType, includesContext) -> - methodVisibility(firstPage ? ClientMethodType.PagingAsyncSinglePage : ClientMethodType.PagingAsync, - overloadType, includesContext, isProtocolMethod); + MethodNamer methodNamer = resolveMethodNamer(proxyMethod, operation.getConvenienceApi(), isProtocolMethod); - createPageableClientMethods(operation, isProtocolMethod, settings, methods, builder, proxyMethod, parameters, pageableItemName, - false, singlePageReturnValue, nextPageReturnValue, visibilityFunction, getContextParameter(isProtocolMethod), - generateClientMethodWithOnlyRequiredParameters, defaultOverloadType); + Operation nextOperation = operation.getExtensions().getXmsPageable().getNextOperation(); + String nextLinkName = operation.getExtensions().getXmsPageable().getNextLinkName(); + String itemName = operation.getExtensions().getXmsPageable().getItemName(); + ClientMethodType nextMethodType = isSync ? ClientMethodType.PagingSyncSinglePage : ClientMethodType.PagingAsyncSinglePage; + + boolean isNextMethod = (nextOperation == operation); + + IType lroIntermediateType = null; + if (operation.getExtensions().isXmsLongRunningOperation() && !isNextMethod) { + lroIntermediateType = SchemaUtil.getOperationResponseType(operation, settings); } - private void createSyncPageableClientMethods(Operation operation, boolean isProtocolMethod, JavaSettings settings, - List methods, ClientMethod.Builder builder, ReturnTypeHolder returnTypeHolder, ProxyMethod proxyMethod, - List parameters, String pageableItemName, - boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { + List nextMethods = (isNextMethod || nextOperation == null) + ? null : Mappers.getClientMethodMapper().map(nextOperation); - ReturnValue singlePageReturnValue = createPagingSyncSinglePageReturnValue(operation, - returnTypeHolder.syncReturnWithResponse, returnTypeHolder.syncReturnType); - ReturnValue nextPageReturnValue = createPagingSyncReturnValue(operation, returnTypeHolder.syncReturnType); - MethodVisibilityFunction visibilityFunction = (firstPage, overloadType, includesContext) -> - methodVisibility(firstPage ? ClientMethodType.PagingSyncSinglePage : ClientMethodType.PagingSync, - overloadType, includesContext, isProtocolMethod); + ClientMethod nextMethod = (nextMethods == null) ? null + : nextMethods.stream().filter(m -> m.getType() == nextMethodType).findFirst().orElse(null); - createPageableClientMethods(operation, isProtocolMethod, settings, methods, builder, proxyMethod, parameters, pageableItemName, - true, singlePageReturnValue, nextPageReturnValue, visibilityFunction, getContextParameter(isProtocolMethod), - generateClientMethodWithOnlyRequiredParameters, defaultOverloadType); + IType nextLinkType = getPageableNextLinkType(operation.getExtensions().getXmsPageable(), + (proxyMethod.getRawResponseBodyType() != null ? proxyMethod.getRawResponseBodyType() : proxyMethod.getResponseBodyType()).toString()); + + MethodPageDetails details = new MethodPageDetails(CodeNamer.getPropertyName(nextLinkName), nextLinkType, pageableItemName, + nextMethod, lroIntermediateType, nextLinkName, itemName); + builder.methodPageDetails(details); + + String pageMethodName = isSync ? methodNamer.getPagingSinglePageMethodName() : methodNamer.getPagingAsyncSinglePageMethodName(); + ClientMethodType pageMethodType = isSync ? ClientMethodType.PagingSyncSinglePage : ClientMethodType.PagingAsyncSinglePage; + + // Only generate maximum overload of Paging###SinglePage API, and it should not be exposed to user. + + JavaVisibility methodVisibility = visibilityFunction.methodVisibility(true, defaultOverloadType, false); + builder.returnValue(singlePageReturnValue) + .onlyRequiredParameters(false) + .name(pageMethodName) + .type(pageMethodType) + .groupedParameterRequired(false) + .methodVisibility(methodVisibility); + + if (settings.isGenerateAsyncMethods()) { + methods.add(builder.build()); } - private static void createPageableClientMethods(Operation operation, boolean isProtocolMethod, JavaSettings settings, - List methods, ClientMethod.Builder builder, ProxyMethod proxyMethod, List parameters, - String pageableItemName, boolean isSync, ReturnValue singlePageReturnValue, ReturnValue nextPageReturnValue, - MethodVisibilityFunction visibilityFunction, ClientMethodParameter contextParameter, - boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { + // Generate an overload with all parameters, optionally include context. + builder.methodVisibility(visibilityFunction.methodVisibility(true, defaultOverloadType, true)); + addClientMethodWithContext(methods, builder, parameters, pageMethodType, pageMethodName, + singlePageReturnValue, details, contextParameter); - MethodNamer methodNamer = resolveMethodNamer(proxyMethod, operation.getConvenienceApi(), isProtocolMethod); + // If this was the next method there is no further work to be done. + if (isNextMethod) { + return; + } - Operation nextOperation = operation.getExtensions().getXmsPageable().getNextOperation(); - String nextLinkName = operation.getExtensions().getXmsPageable().getNextLinkName(); - String itemName = operation.getExtensions().getXmsPageable().getItemName(); - ClientMethodType nextMethodType = isSync ? ClientMethodType.PagingSyncSinglePage : ClientMethodType.PagingAsyncSinglePage; + // Otherwise repeat what we just did but for next page client methods. + pageMethodName = isSync ? methodNamer.getMethodName() : methodNamer.getSimpleAsyncMethodName(); + pageMethodType = isSync ? ClientMethodType.PagingSync : ClientMethodType.PagingAsync; - boolean isNextMethod = (nextOperation == operation); + builder.returnValue(nextPageReturnValue) + .name(pageMethodName) + .type(pageMethodType) + .groupedParameterRequired(false) + .methodVisibility(visibilityFunction.methodVisibility(false, defaultOverloadType, false)); - IType lroIntermediateType = null; - if (operation.getExtensions().isXmsLongRunningOperation() && !isNextMethod) { - lroIntermediateType = SchemaUtil.getOperationResponseType(operation, settings); + if (settings.isGenerateAsyncMethods()) { + methods.add(builder.build()); + + // overload for versioning + createOverloadForVersioning(isProtocolMethod, methods, builder, parameters); + } + + if (generateClientMethodWithOnlyRequiredParameters) { + methods.add(builder + .onlyRequiredParameters(true) + .methodVisibility(visibilityFunction.methodVisibility(false, MethodOverloadType.OVERLOAD_MINIMUM, false)) + .build()); + } + + MethodPageDetails detailsWithContext = details; + if (nextMethods != null) { + // Match to the nextMethod with Context + IType contextWireType = contextParameter.getWireType(); + nextMethod = nextMethods.stream() + .filter(m -> m.getType() == nextMethodType) + .filter(m -> m.getMethodParameters().stream().anyMatch(p -> contextWireType.equals(p.getClientType()))) + .findFirst() + .orElse(null); + + if (nextMethod != null) { + detailsWithContext = new MethodPageDetails(CodeNamer.getPropertyName(nextLinkName), nextLinkType, + pageableItemName, nextMethod, lroIntermediateType, nextLinkName, itemName); + } + } + + builder.methodVisibility(visibilityFunction.methodVisibility(false, defaultOverloadType, true)); + addClientMethodWithContext(methods, builder, parameters, pageMethodType, pageMethodName, + nextPageReturnValue, detailsWithContext, contextParameter); + } + + private void createSimpleAsyncClientMethods(Operation operation, boolean isProtocolMethod, JavaSettings settings, + List methods, Builder builder, ReturnTypeHolder returnTypeHolder, ProxyMethod proxyMethod, + List parameters, boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { + + ReturnValue responseReturnValue = createSimpleAsyncRestResponseReturnValue(operation, + returnTypeHolder.asyncRestResponseReturnType, returnTypeHolder.syncReturnType); + ReturnValue returnValue = createSimpleAsyncReturnValue(operation, returnTypeHolder.asyncReturnType, + returnTypeHolder.syncReturnType); + MethodVisibilityFunction visibilityFunction = (restResponse, overloadType, includesContext) -> + methodVisibility(restResponse ? ClientMethodType.SimpleAsyncRestResponse : ClientMethodType.SimpleAsync, + overloadType, includesContext, isProtocolMethod); + + createSimpleClientMethods(operation, isProtocolMethod, methods, builder, proxyMethod, parameters, false, responseReturnValue, + returnValue, visibilityFunction, getContextParameter(isProtocolMethod), generateClientMethodWithOnlyRequiredParameters, defaultOverloadType); + } + + private void createSimpleSyncClientMethods(Operation operation, boolean isProtocolMethod, JavaSettings settings, + List methods, Builder builder, ReturnTypeHolder returnTypeHolder, ProxyMethod proxyMethod, + List parameters, boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { + + ReturnValue responseReturnValue = createSimpleSyncRestResponseReturnValue(operation, + returnTypeHolder.syncReturnWithResponse, returnTypeHolder.syncReturnType); + ReturnValue returnValue = createSimpleSyncReturnValue(operation, returnTypeHolder.syncReturnType); + MethodVisibilityFunction visibilityFunction = (restResponse, overloadType, includesContext) -> + methodVisibility(restResponse ? ClientMethodType.SimpleSyncRestResponse : ClientMethodType.SimpleSync, + overloadType, includesContext, isProtocolMethod); + + createSimpleClientMethods(operation, isProtocolMethod, methods, builder, proxyMethod, parameters, true, responseReturnValue, + returnValue, visibilityFunction, getContextParameter(isProtocolMethod), generateClientMethodWithOnlyRequiredParameters, defaultOverloadType); + } + + private static void createSimpleClientMethods(Operation operation, boolean isProtocolMethod, + List methods, Builder builder, + ProxyMethod proxyMethod, List parameters, boolean isSync, + ReturnValue responseReturnValue, ReturnValue returnValue, + MethodVisibilityFunction visibilityFunction, ClientMethodParameter contextParameter, + boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { + + MethodNamer methodNamer = resolveMethodNamer(proxyMethod, operation.getConvenienceApi(), isProtocolMethod); + + String methodName = isSync ? methodNamer.getSimpleRestResponseMethodName() : methodNamer.getSimpleAsyncRestResponseMethodName(); + ClientMethodType methodType = isSync ? ClientMethodType.SimpleSyncRestResponse : ClientMethodType.SimpleAsyncRestResponse; + + JavaVisibility withContextVisibility = visibilityFunction.methodVisibility(true, defaultOverloadType, true); + builder.parameters(parameters) + .returnValue(responseReturnValue) + .onlyRequiredParameters(false) + .name(methodName) + .type(methodType) + .groupedParameterRequired(false) + .hasWithContextOverload(withContextVisibility != NOT_GENERATE) + .methodVisibility(visibilityFunction.methodVisibility(true, defaultOverloadType, false)); + // Always generate an overload of WithResponse with non-required parameters without Context. + // It is only for sync proxy method, and is usually filtered out in methodVisibility function. + methods.add(builder.build()); + + builder.methodVisibility(withContextVisibility); + addClientMethodWithContext(methods, builder, parameters, contextParameter); + + // Repeat the same but for simple returns. + if (proxyMethod.isCustomHeaderIgnored()) { + return; + } + methodName = isSync ? methodNamer.getMethodName() : methodNamer.getSimpleAsyncMethodName(); + methodType = isSync ? ClientMethodType.SimpleSync : ClientMethodType.SimpleAsync; + + builder.parameters(parameters) + .returnValue(returnValue) + .name(methodName) + .type(methodType) + .groupedParameterRequired(false) + .methodVisibility(visibilityFunction.methodVisibility(false, defaultOverloadType, false)); + methods.add(builder.build()); + + // overload for versioning + createOverloadForVersioning(isProtocolMethod, methods, builder, parameters); + + if (generateClientMethodWithOnlyRequiredParameters) { + methods.add(builder + .methodVisibility(visibilityFunction.methodVisibility(false, MethodOverloadType.OVERLOAD_MINIMUM, false)) + .onlyRequiredParameters(true) + .build()); + } + + builder.methodVisibility(visibilityFunction.methodVisibility(false, defaultOverloadType, true)); + addClientMethodWithContext(methods, builder, parameters, contextParameter); + } + + private static void createOverloadForVersioning( + boolean isProtocolMethod, + List methods, ClientMethod.Builder builder, + List parameters) { + + if (!isProtocolMethod && JavaSettings.getInstance().isDataPlaneClient()) { + if (parameters.stream().anyMatch(p -> p.getVersioning() != null && p.getVersioning().getAdded() != null)) { + List> signatures = findOverloadedSignatures(parameters); + for (List overloadedParameters : signatures) { + builder.parameters(overloadedParameters); + methods.add(builder.build()); } + } - List nextMethods = (isNextMethod || nextOperation == null) - ? null : Mappers.getClientMethodMapper().map(nextOperation); - - ClientMethod nextMethod = (nextMethods == null) ? null - : nextMethods.stream().filter(m -> m.getType() == nextMethodType).findFirst().orElse(null); - - IType nextLinkType = getPageableNextLinkType(operation.getExtensions().getXmsPageable(), - (proxyMethod.getRawResponseBodyType() != null ? proxyMethod.getRawResponseBodyType() : proxyMethod.getResponseBodyType()).toString()); - - MethodPageDetails details = new MethodPageDetails(CodeNamer.getPropertyName(nextLinkName), nextLinkType, pageableItemName, - nextMethod, lroIntermediateType, nextLinkName, itemName); - builder.methodPageDetails(details); - - String pageMethodName = isSync ? methodNamer.getPagingSinglePageMethodName() : methodNamer.getPagingAsyncSinglePageMethodName(); - ClientMethodType pageMethodType = isSync ? ClientMethodType.PagingSyncSinglePage : ClientMethodType.PagingAsyncSinglePage; - - // Only generate maximum overload of Paging###SinglePage API, and it should not be exposed to user. - - JavaVisibility methodVisibility = visibilityFunction.methodVisibility(true, defaultOverloadType, false); - builder.returnValue(singlePageReturnValue) - .onlyRequiredParameters(false) - .name(pageMethodName) - .type(pageMethodType) - .groupedParameterRequired(false) - .methodVisibility(methodVisibility); - - if (settings.isGenerateAsyncMethods()) { - methods.add(builder.build()); - } - - // Generate an overload with all parameters, optionally include context. - builder.methodVisibility(visibilityFunction.methodVisibility(true, defaultOverloadType, true)); - addClientMethodWithContext(methods, builder, parameters, pageMethodType, pageMethodName, - singlePageReturnValue, details, contextParameter); - - // If this was the next method there is no further work to be done. - if (isNextMethod) { - return; - } - - // Otherwise repeat what we just did but for next page client methods. - pageMethodName = isSync ? methodNamer.getMethodName() : methodNamer.getSimpleAsyncMethodName(); - pageMethodType = isSync ? ClientMethodType.PagingSync : ClientMethodType.PagingAsync; - - builder.returnValue(nextPageReturnValue) - .name(pageMethodName) - .type(pageMethodType) - .groupedParameterRequired(false) - .methodVisibility(visibilityFunction.methodVisibility(false, defaultOverloadType, false)); - - if (settings.isGenerateAsyncMethods()) { - methods.add(builder.build()); - - // overload for versioning - createOverloadForVersioning(isProtocolMethod, methods, builder, parameters); - } - - if (generateClientMethodWithOnlyRequiredParameters) { - methods.add(builder - .onlyRequiredParameters(true) - .methodVisibility(visibilityFunction.methodVisibility(false, MethodOverloadType.OVERLOAD_MINIMUM, false)) - .build()); - } - - MethodPageDetails detailsWithContext = details; - if (nextMethods != null) { - // Match to the nextMethod with Context - IType contextWireType = contextParameter.getWireType(); - nextMethod = nextMethods.stream() - .filter(m -> m.getType() == nextMethodType) - .filter(m -> m.getMethodParameters().stream().anyMatch(p -> contextWireType.equals(p.getClientType()))) - .findFirst() - .orElse(null); - - if (nextMethod != null) { - detailsWithContext = new MethodPageDetails(CodeNamer.getPropertyName(nextLinkName), nextLinkType, - pageableItemName, nextMethod, lroIntermediateType, nextLinkName, itemName); - } - } - - builder.methodVisibility(visibilityFunction.methodVisibility(false, defaultOverloadType, true)); - addClientMethodWithContext(methods, builder, parameters, pageMethodType, pageMethodName, - nextPageReturnValue, detailsWithContext, contextParameter); + builder.parameters(parameters); } + } - private void createSimpleAsyncClientMethods(Operation operation, boolean isProtocolMethod, JavaSettings settings, - List methods, ClientMethod.Builder builder, ReturnTypeHolder returnTypeHolder, ProxyMethod proxyMethod, - List parameters, boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { + static List> findOverloadedSignatures(List parameters) { + List> signatures = new ArrayList<>(); - ReturnValue responseReturnValue = createSimpleAsyncRestResponseReturnValue(operation, - returnTypeHolder.asyncRestResponseReturnType, returnTypeHolder.syncReturnType); - ReturnValue returnValue = createSimpleAsyncReturnValue(operation, returnTypeHolder.asyncReturnType, - returnTypeHolder.syncReturnType); - MethodVisibilityFunction visibilityFunction = (restResponse, overloadType, includesContext) -> - methodVisibility(restResponse ? ClientMethodType.SimpleAsyncRestResponse : ClientMethodType.SimpleAsync, - overloadType, includesContext, isProtocolMethod); + List allParameters = parameters; + List requiredParameters = parameters.stream() + .filter(MethodParameter::isRequired) + .collect(Collectors.toList()); - createSimpleClientMethods(operation, isProtocolMethod, methods, builder, proxyMethod, parameters, false, responseReturnValue, - returnValue, visibilityFunction, getContextParameter(isProtocolMethod), generateClientMethodWithOnlyRequiredParameters, defaultOverloadType); - } - - private void createSimpleSyncClientMethods(Operation operation, boolean isProtocolMethod, JavaSettings settings, - List methods, ClientMethod.Builder builder, ReturnTypeHolder returnTypeHolder, ProxyMethod proxyMethod, - List parameters, boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { - - ReturnValue responseReturnValue = createSimpleSyncRestResponseReturnValue(operation, - returnTypeHolder.syncReturnWithResponse, returnTypeHolder.syncReturnType); - ReturnValue returnValue = createSimpleSyncReturnValue(operation, returnTypeHolder.syncReturnType); - MethodVisibilityFunction visibilityFunction = (restResponse, overloadType, includesContext) -> - methodVisibility(restResponse ? ClientMethodType.SimpleSyncRestResponse : ClientMethodType.SimpleSync, - overloadType, includesContext, isProtocolMethod); - - createSimpleClientMethods(operation, isProtocolMethod, methods, builder, proxyMethod, parameters, true, responseReturnValue, - returnValue, visibilityFunction, getContextParameter(isProtocolMethod), generateClientMethodWithOnlyRequiredParameters, defaultOverloadType); - } - - private static void createSimpleClientMethods(Operation operation, boolean isProtocolMethod, - List methods, ClientMethod.Builder builder, - ProxyMethod proxyMethod, List parameters, boolean isSync, - ReturnValue responseReturnValue, ReturnValue returnValue, - MethodVisibilityFunction visibilityFunction, ClientMethodParameter contextParameter, - boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { - - MethodNamer methodNamer = resolveMethodNamer(proxyMethod, operation.getConvenienceApi(), isProtocolMethod); - - String methodName = isSync ? methodNamer.getSimpleRestResponseMethodName() : methodNamer.getSimpleAsyncRestResponseMethodName(); - ClientMethodType methodType = isSync ? ClientMethodType.SimpleSyncRestResponse : ClientMethodType.SimpleAsyncRestResponse; - - JavaVisibility withContextVisibility = visibilityFunction.methodVisibility(true, defaultOverloadType, true); - builder.parameters(parameters) - .returnValue(responseReturnValue) - .onlyRequiredParameters(false) - .name(methodName) - .type(methodType) - .groupedParameterRequired(false) - .hasWithContextOverload(withContextVisibility != NOT_GENERATE) - .methodVisibility(visibilityFunction.methodVisibility(true, defaultOverloadType, false)); - // Always generate an overload of WithResponse with non-required parameters without Context. - // It is only for sync proxy method, and is usually filtered out in methodVisibility function. - methods.add(builder.build()); - - builder.methodVisibility(withContextVisibility); - addClientMethodWithContext(methods, builder, parameters, contextParameter); - - // Repeat the same but for simple returns. - if (proxyMethod.isCustomHeaderIgnored()) { - return; - } - methodName = isSync ? methodNamer.getMethodName() : methodNamer.getSimpleAsyncMethodName(); - methodType = isSync ? ClientMethodType.SimpleSync : ClientMethodType.SimpleAsync; - - builder.parameters(parameters) - .returnValue(returnValue) - .name(methodName) - .type(methodType) - .groupedParameterRequired(false) - .methodVisibility(visibilityFunction.methodVisibility(false, defaultOverloadType, false)); - methods.add(builder.build()); - - // overload for versioning - createOverloadForVersioning(isProtocolMethod, methods, builder, parameters); - - if (generateClientMethodWithOnlyRequiredParameters) { - methods.add(builder - .methodVisibility(visibilityFunction.methodVisibility(false, MethodOverloadType.OVERLOAD_MINIMUM, false)) - .onlyRequiredParameters(true) - .build()); - } - - builder.methodVisibility(visibilityFunction.methodVisibility(false, defaultOverloadType, true)); - addClientMethodWithContext(methods, builder, parameters, contextParameter); - } - - private static void createOverloadForVersioning( - boolean isProtocolMethod, - List methods, ClientMethod.Builder builder, - List parameters) { - - if (!isProtocolMethod && JavaSettings.getInstance().isDataPlaneClient()) { - if (parameters.stream().anyMatch(p -> p.getVersioning() != null && p.getVersioning().getAdded() != null)) { - List> signatures = findOverloadedSignatures(parameters); - for (List overloadedParameters : signatures) { - builder.parameters(overloadedParameters); - methods.add(builder.build()); - } - } - - builder.parameters(parameters); - } - } - - static List> findOverloadedSignatures(List parameters) { - List> signatures = new ArrayList<>(); - - List allParameters = parameters; - List requiredParameters = parameters.stream() - .filter(MethodParameter::isRequired) - .collect(Collectors.toList()); - - List versions = allParameters.stream() - .flatMap(p -> { - if (p.getVersioning() != null && p.getVersioning().getAdded() != null) { - return p.getVersioning().getAdded().stream(); - } else { - return Stream.empty(); - } - }).distinct().collect(Collectors.toList()); - versions.add(0, null); // for signature of no version - - for (String version : versions) { - List overloadedParameters = allParameters.stream() - .filter(p -> (p.getVersioning() == null || p.getVersioning().getAdded() == null) - || (p.getVersioning() != null && p.getVersioning().getAdded() != null && p.getVersioning().getAdded().contains(version))) - .collect(Collectors.toList()); - - if (!overloadedParameters.equals(allParameters) - && !overloadedParameters.equals(requiredParameters) - && !signatures.contains(overloadedParameters)) { - // take the signature not same as required-only, not same as full, not same as anything already there - signatures.add(overloadedParameters); - } - } - - return signatures; - } - - private static ClientMethodParameter updateClientMethodParameter(ClientMethodParameter clientMethodParameter) { - return clientMethodParameter.newBuilder() - .rawType(ClassType.BINARY_DATA) - .wireType(ClassType.BINARY_DATA) - .build(); - } - - /** - * Extension point of additional methods for LRO. - */ - protected void createAdditionalLroMethods( - Operation operation, ClientMethod.Builder builder, List methods, - boolean isProtocolMethod, IType asyncReturnType, IType syncReturnType, - ProxyMethod proxyMethod, List parameters, - boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { - - } - - private void createLroMethods( - Operation operation, ClientMethod.Builder builder, List methods, - String asyncMethodName, String syncMethodName, List parameters, IType syncReturnType, - MethodPollingDetails methodPollingDetails, boolean isProtocolMethod, - boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType, - ProxyMethod proxyMethod) { - - boolean proxyMethodUsesFluxByteBuffer = proxyMethod.getParameters().stream() - .anyMatch(proxyMethodParameter -> proxyMethodParameter.getClientType() == GenericType.FLUX_BYTE_BUFFER); - - builder.methodPollingDetails(methodPollingDetails); - if (JavaSettings.getInstance().isGenerateAsyncMethods()) { - // begin method async - methods.add(builder - .returnValue(createLongRunningBeginAsyncReturnValue(operation, syncReturnType, methodPollingDetails)) - .name(asyncMethodName) - .onlyRequiredParameters(false) - .type(ClientMethodType.LongRunningBeginAsync) - .groupedParameterRequired(false) - .methodVisibility(methodVisibility(ClientMethodType.LongRunningBeginAsync, defaultOverloadType, false, isProtocolMethod)) - .build()); - - // overload for versioning - createOverloadForVersioning(isProtocolMethod, methods, builder, parameters); - - if (generateClientMethodWithOnlyRequiredParameters) { - methods.add(builder - .onlyRequiredParameters(true) - .methodVisibility(methodVisibility(ClientMethodType.LongRunningBeginAsync, MethodOverloadType.OVERLOAD_MINIMUM, false, isProtocolMethod)) - .build()); - } - - builder.methodVisibility(methodVisibility(ClientMethodType.LongRunningBeginAsync, defaultOverloadType, true, isProtocolMethod)); - addClientMethodWithContext(methods, builder, parameters, getContextParameter(isProtocolMethod)); - } - - if (!proxyMethodUsesFluxByteBuffer && - (JavaSettings.getInstance().isGenerateSyncMethods() - || JavaSettings.getInstance().isSyncStackEnabled())) { - // begin method sync - methods.add(builder - .returnValue(createLongRunningBeginSyncReturnValue(operation, syncReturnType, methodPollingDetails)) - .name(syncMethodName) - .onlyRequiredParameters(false) - .type(ClientMethodType.LongRunningBeginSync) - .groupedParameterRequired(false) - .methodVisibility(methodVisibility(ClientMethodType.LongRunningBeginSync, defaultOverloadType, false, isProtocolMethod)) - .build()); - - // overload for versioning - createOverloadForVersioning(isProtocolMethod, methods, builder, parameters); - - if (generateClientMethodWithOnlyRequiredParameters) { - methods.add(builder - .onlyRequiredParameters(true) - .methodVisibility(methodVisibility(ClientMethodType.LongRunningBeginSync, MethodOverloadType.OVERLOAD_MINIMUM, false, isProtocolMethod)) - .build()); - } - - builder.methodVisibility(methodVisibility(ClientMethodType.LongRunningBeginSync, defaultOverloadType, true, isProtocolMethod)); - addClientMethodWithContext(methods, builder, parameters, getContextParameter(isProtocolMethod)); - } - } - - private ClientMethodParameter getContextParameter() { - return new ClientMethodParameter.Builder() - .description("The context to associate with this operation.") - .wireType(this.getContextType()) - .name("context") - .requestParameterLocation(RequestParameterLocation.NONE) - .annotations(Collections.emptyList()) - .constant(false) - .defaultValue(null) - .fromClient(false) - .finalParameter(false) - .required(false) - .build(); - } - - /** - * Gets the Context type. - * - * @return The Context type. - */ - protected IType getContextType() { - return ClassType.CONTEXT; - } - - /** - * Creates the synchronous {@code withResponse} type. - * - * @param syncReturnType The return type. - * @param operation The operation. - * @param isProtocolMethod Whether this is a protocol method. - * @param settings Autorest generation settings. - * @return The synchronous {@code withResponse} type. - */ - protected IType createSyncReturnWithResponseType(IType syncReturnType, Operation operation, - boolean isProtocolMethod, JavaSettings settings) { - return this.createSyncReturnWithResponseType(syncReturnType, operation, isProtocolMethod, settings, false); - } - - /** - * Creates the synchronous {@code withResponse} type. - * - * @param syncReturnType The return type. - * @param operation The operation. - * @param isProtocolMethod Whether this is a protocol method. - * @param settings Autorest generation settings. - * @param ignoreCustomHeaders Whether the custom header type is ignored. - * @return The synchronous {@code withResponse} type. - */ - protected IType createSyncReturnWithResponseType(IType syncReturnType, Operation operation, - boolean isProtocolMethod, JavaSettings settings, boolean ignoreCustomHeaders) { - boolean responseContainsHeaders = SchemaUtil.responseContainsHeaderSchemas(operation, settings); - - // If DPG is being generated or the response doesn't contain headers return Response - // If no named response types are being used return ResponseBase - // Else named response types are being used and return that. - if (isProtocolMethod || !responseContainsHeaders) { - return GenericType.Response(syncReturnType); - } else if (settings.isGenericResponseTypes()) { - if (ignoreCustomHeaders || settings.isDisableTypedHeadersMethods()) { - return GenericType.Response(syncReturnType); - } - return GenericType.RestResponse(Mappers.getSchemaMapper().map(ClientMapper.parseHeader(operation, settings)), - syncReturnType); + List versions = allParameters.stream() + .flatMap(p -> { + if (p.getVersioning() != null && p.getVersioning().getAdded() != null) { + return p.getVersioning().getAdded().stream(); } else { - return ClientMapper.getClientResponseClassType(operation, ClientModels.getInstance().getModels(), settings); + return Stream.empty(); } + }).distinct().collect(Collectors.toList()); + versions.add(0, null); // for signature of no version + + for (String version : versions) { + List overloadedParameters = allParameters.stream() + .filter(p -> (p.getVersioning() == null || p.getVersioning().getAdded() == null) + || (p.getVersioning() != null && p.getVersioning().getAdded() != null && p.getVersioning().getAdded().contains(version))) + .collect(Collectors.toList()); + + if (!overloadedParameters.equals(allParameters) + && !overloadedParameters.equals(requiredParameters) + && !signatures.contains(overloadedParameters)) { + // take the signature not same as required-only, not same as full, not same as anything already there + signatures.add(overloadedParameters); + } } - /** - * Creates a simple synchronous REST response {@link ReturnValue}. - * - * @param operation The operation. - * @param syncReturnWithResponse The synchronous {@code withResponse} return. - * @param syncReturnType The synchronous return type. - * @return The simple synchronous REST response {@link ReturnValue}. - */ - protected ReturnValue createSimpleSyncRestResponseReturnValue(Operation operation, IType syncReturnWithResponse, IType syncReturnType) { - return new ReturnValue(returnTypeDescription(operation, syncReturnWithResponse, syncReturnType), - syncReturnWithResponse); + return signatures; + } + + private static ClientMethodParameter updateClientMethodParameter(ClientMethodParameter clientMethodParameter) { + return clientMethodParameter.newBuilder() + .rawType(ClassType.BINARY_DATA) + .wireType(ClassType.BINARY_DATA) + .build(); + } + + /** + * Extension point of additional methods for LRO. + */ + protected void createAdditionalLroMethods( + Operation operation, ClientMethod.Builder builder, List methods, + boolean isProtocolMethod, IType asyncReturnType, IType syncReturnType, + ProxyMethod proxyMethod, List parameters, + boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType) { + + } + + private void createLroMethods( + Operation operation, ClientMethod.Builder builder, List methods, + String asyncMethodName, String syncMethodName, List parameters, IType syncReturnType, + MethodPollingDetails methodPollingDetails, boolean isProtocolMethod, + boolean generateClientMethodWithOnlyRequiredParameters, MethodOverloadType defaultOverloadType, + ProxyMethod proxyMethod) { + + boolean proxyMethodUsesFluxByteBuffer = proxyMethod.getParameters().stream() + .anyMatch(proxyMethodParameter -> proxyMethodParameter.getClientType() == GenericType.FLUX_BYTE_BUFFER); + + builder.methodPollingDetails(methodPollingDetails); + if (JavaSettings.getInstance().isGenerateAsyncMethods()) { + // begin method async + methods.add(builder + .returnValue(createLongRunningBeginAsyncReturnValue(operation, syncReturnType, methodPollingDetails)) + .name(asyncMethodName) + .onlyRequiredParameters(false) + .type(ClientMethodType.LongRunningBeginAsync) + .groupedParameterRequired(false) + .methodVisibility(methodVisibility(ClientMethodType.LongRunningBeginAsync, defaultOverloadType, false, isProtocolMethod)) + .build()); + + // overload for versioning + createOverloadForVersioning(isProtocolMethod, methods, builder, parameters); + + if (generateClientMethodWithOnlyRequiredParameters) { + methods.add(builder + .onlyRequiredParameters(true) + .methodVisibility(methodVisibility(ClientMethodType.LongRunningBeginAsync, MethodOverloadType.OVERLOAD_MINIMUM, false, isProtocolMethod)) + .build()); + } + + builder.methodVisibility(methodVisibility(ClientMethodType.LongRunningBeginAsync, defaultOverloadType, true, isProtocolMethod)); + addClientMethodWithContext(methods, builder, parameters, getContextParameter(isProtocolMethod)); } - /** - * Creates a simple asynchronous REST response {@link ReturnValue}. - * - * @param operation The operation. - * @param asyncRestResponseReturnType The asynchronous {@code withResponse} return. - * @param syncReturnType The synchronous return type. - * @return The simple asynchronous REST response {@link ReturnValue}. - */ - protected ReturnValue createSimpleAsyncRestResponseReturnValue(Operation operation, IType asyncRestResponseReturnType, IType syncReturnType) { - return new ReturnValue(returnTypeDescription(operation, asyncRestResponseReturnType, syncReturnType), - asyncRestResponseReturnType); + if (!proxyMethodUsesFluxByteBuffer && + (JavaSettings.getInstance().isGenerateSyncMethods() + || JavaSettings.getInstance().isSyncStackEnabled())) { + // begin method sync + methods.add(builder + .returnValue(createLongRunningBeginSyncReturnValue(operation, syncReturnType, methodPollingDetails)) + .name(syncMethodName) + .onlyRequiredParameters(false) + .type(ClientMethodType.LongRunningBeginSync) + .groupedParameterRequired(false) + .methodVisibility(methodVisibility(ClientMethodType.LongRunningBeginSync, defaultOverloadType, false, isProtocolMethod)) + .build()); + + // overload for versioning + createOverloadForVersioning(isProtocolMethod, methods, builder, parameters); + + if (generateClientMethodWithOnlyRequiredParameters) { + methods.add(builder + .onlyRequiredParameters(true) + .methodVisibility(methodVisibility(ClientMethodType.LongRunningBeginSync, MethodOverloadType.OVERLOAD_MINIMUM, false, isProtocolMethod)) + .build()); + } + + builder.methodVisibility(methodVisibility(ClientMethodType.LongRunningBeginSync, defaultOverloadType, true, isProtocolMethod)); + addClientMethodWithContext(methods, builder, parameters, getContextParameter(isProtocolMethod)); + } + } + + private ClientMethodParameter getContextParameter() { + return new ClientMethodParameter.Builder() + .description("The context to associate with this operation.") + .wireType(this.getContextType()) + .name("context") + .requestParameterLocation(RequestParameterLocation.NONE) + .annotations(Collections.emptyList()) + .constant(false) + .defaultValue(null) + .fromClient(false) + .finalParameter(false) + .required(false) + .build(); + } + + /** + * Gets the Context type. + * + * @return The Context type. + */ + protected IType getContextType() { + return ClassType.CONTEXT; + } + + /** + * Creates the synchronous {@code withResponse} type. + * + * @param syncReturnType The return type. + * @param operation The operation. + * @param isProtocolMethod Whether this is a protocol method. + * @param settings Autorest generation settings. + * @return The synchronous {@code withResponse} type. + */ + protected IType createSyncReturnWithResponseType(IType syncReturnType, Operation operation, + boolean isProtocolMethod, JavaSettings settings) { + return this.createSyncReturnWithResponseType(syncReturnType, operation, isProtocolMethod, settings, false); + } + + /** + * Creates the synchronous {@code withResponse} type. + * + * @param syncReturnType The return type. + * @param operation The operation. + * @param isProtocolMethod Whether this is a protocol method. + * @param settings Autorest generation settings. + * @param ignoreCustomHeaders Whether the custom header type is ignored. + * @return The synchronous {@code withResponse} type. + */ + protected IType createSyncReturnWithResponseType(IType syncReturnType, Operation operation, + boolean isProtocolMethod, JavaSettings settings, boolean ignoreCustomHeaders) { + boolean responseContainsHeaders = SchemaUtil.responseContainsHeaderSchemas(operation, settings); + + // If DPG is being generated or the response doesn't contain headers return Response + // If no named response types are being used return ResponseBase + // Else named response types are being used and return that. + if (isProtocolMethod || !responseContainsHeaders) { + return GenericType.Response(syncReturnType); + } else if (settings.isGenericResponseTypes()) { + if (ignoreCustomHeaders || settings.isDisableTypedHeadersMethods()) { + return GenericType.Response(syncReturnType); + } + return GenericType.RestResponse(Mappers.getSchemaMapper().map(ClientMapper.parseHeader(operation, settings)), + syncReturnType); + } else { + return ClientMapper.getClientResponseClassType(operation, ClientModels.getInstance().getModels(), settings); + } + } + + /** + * Creates a simple synchronous REST response {@link ReturnValue}. + * + * @param operation The operation. + * @param syncReturnWithResponse The synchronous {@code withResponse} return. + * @param syncReturnType The synchronous return type. + * @return The simple synchronous REST response {@link ReturnValue}. + */ + protected ReturnValue createSimpleSyncRestResponseReturnValue(Operation operation, IType syncReturnWithResponse, IType syncReturnType) { + return new ReturnValue(returnTypeDescription(operation, syncReturnWithResponse, syncReturnType), + syncReturnWithResponse); + } + + /** + * Creates a simple asynchronous REST response {@link ReturnValue}. + * + * @param operation The operation. + * @param asyncRestResponseReturnType The asynchronous {@code withResponse} return. + * @param syncReturnType The synchronous return type. + * @return The simple asynchronous REST response {@link ReturnValue}. + */ + protected ReturnValue createSimpleAsyncRestResponseReturnValue(Operation operation, IType asyncRestResponseReturnType, IType syncReturnType) { + return new ReturnValue(returnTypeDescription(operation, asyncRestResponseReturnType, syncReturnType), + asyncRestResponseReturnType); + } + + /** + * Creates a simple synchronous return value. + * + * @param operation The operation. + * @param syncReturnType The synchronous return value. + * @return The simple synchronous return value. + */ + protected ReturnValue createSimpleSyncReturnValue(Operation operation, IType syncReturnType) { + return new ReturnValue(returnTypeDescription(operation, syncReturnType, syncReturnType), + syncReturnType); + } + + /** + * Creates a simple asynchronous return value. + * + * @param operation The operation. + * @param asyncReturnType The asynchronous return type. + * @param syncReturnType The synchronous return type. + * @return The simple asynchronous return value. + */ + protected ReturnValue createSimpleAsyncReturnValue(Operation operation, IType asyncReturnType, IType syncReturnType) { + return new ReturnValue(returnTypeDescription(operation, asyncReturnType, syncReturnType), + asyncReturnType); + } + + /** + * Creates a synchronous long-running return value. + * + * @param operation The operation. + * @param syncReturnType The synchronous return type. + * @return The synchronous long-running return value. + */ + protected ReturnValue createLongRunningSyncReturnValue(Operation operation, IType syncReturnType) { + return new ReturnValue(returnTypeDescription(operation, syncReturnType, syncReturnType), + syncReturnType); + } + + /** + * Creates an asynchronous long-running return value. + * + * @param operation The operation. + * @param asyncReturnType The asynchronous return type. + * @param syncReturnType The synchronous return type. + * @return The asynchronous long-running return value. + */ + protected ReturnValue createLongRunningAsyncReturnValue(Operation operation, IType asyncReturnType, IType syncReturnType) { + return new ReturnValue(returnTypeDescription(operation, asyncReturnType, syncReturnType), + asyncReturnType); + } + + private ReturnValue createLongRunningBeginSyncReturnValue(Operation operation, IType syncReturnType, MethodPollingDetails pollingDetails) { + if (JavaSettings.getInstance().isFluent()) { + IType returnType = GenericType.SyncPoller(GenericType.PollResult(syncReturnType.asNullable()), syncReturnType.asNullable()); + return new ReturnValue(returnTypeDescription(operation, returnType, syncReturnType), returnType); + } else { + IType returnType = GenericType.SyncPoller(pollingDetails.getIntermediateType(), pollingDetails.getFinalType()); + return new ReturnValue(returnTypeDescription(operation, returnType, pollingDetails.getFinalType()), returnType); + } + } + + /** + * Creates an asynchronous long-running begin return value. + * + * @param operation The operation. + * @param syncReturnType The synchronous return type. + * @param pollingDetails The polling details. + * @return The asynchronous long-running begin return value. + */ + protected ReturnValue createLongRunningBeginAsyncReturnValue(Operation operation, IType syncReturnType, MethodPollingDetails pollingDetails) { + if (JavaSettings.getInstance().isFluent()) { + IType returnType = GenericType.PollerFlux(GenericType.PollResult(syncReturnType.asNullable()), syncReturnType.asNullable()); + return new ReturnValue(returnTypeDescription(operation, returnType, syncReturnType), returnType); + } else { + IType returnType = GenericType.PollerFlux(pollingDetails.getIntermediateType(), pollingDetails.getFinalType()); + return new ReturnValue(returnTypeDescription(operation, returnType, pollingDetails.getFinalType()), returnType); + } + } + + /** + * Creates a synchronous paging return value. + * + * @param operation The operation. + * @param syncReturnType The synchronous return type. + * @return The synchronous paging return value. + */ + protected ReturnValue createPagingSyncReturnValue(Operation operation, IType syncReturnType) { + return new ReturnValue(returnTypeDescription(operation, syncReturnType, syncReturnType), + syncReturnType); + } + + /** + * Creates an asynchronous paging return value. + * + * @param operation The operation. + * @param asyncReturnType The asynchronous return type. + * @param syncReturnType The synchronous return type. + * @return The asynchronous paging return value. + */ + protected ReturnValue createPagingAsyncReturnValue(Operation operation, IType asyncReturnType, IType syncReturnType) { + return new ReturnValue(returnTypeDescription(operation, asyncReturnType, syncReturnType), + asyncReturnType); + } + + /** + * Creates an asynchronous single page paging return value. + * + * @param operation The operation. + * @param asyncRestResponseReturnType The asynchronous REST response return type. + * @param syncReturnType The synchronous return type. + * @return The asynchronous single page paging return value. + */ + protected ReturnValue createPagingAsyncSinglePageReturnValue(Operation operation, IType asyncRestResponseReturnType, IType syncReturnType) { + return new ReturnValue(returnTypeDescription(operation, asyncRestResponseReturnType, syncReturnType), + asyncRestResponseReturnType); + } + + /** + * Creates a synchronous single page paging return value. + * + * @param operation The operation. + * @param syncRestResponseReturnType The synchronous REST response return type. + * @param syncReturnType The synchronous return type. + * @return The synchronous single page paging return value. + */ + protected ReturnValue createPagingSyncSinglePageReturnValue(Operation operation, + IType syncRestResponseReturnType, IType syncReturnType) { + return new ReturnValue(returnTypeDescription(operation, syncRestResponseReturnType, syncReturnType), + syncRestResponseReturnType); + } + + /** + * Whether paging methods should be generated. + * + * @return Whether paging methods should be generated. + */ + protected boolean shouldGeneratePagingMethods() { + return true; + } + + /** + * Creates an asynchronous void return type. + * + * @return The asynchronous void return type. + */ + protected IType createAsyncVoidReturnType() { + return GenericType.Mono(ClassType.VOID); + } + + /** + * Creates an asynchronous body return type. + * + * @param restAPIMethodReturnBodyClientType The type of the body. + * @return The asynchronous body return type. + */ + protected IType createAsyncBodyReturnType(IType restAPIMethodReturnBodyClientType) { + return GenericType.Mono(restAPIMethodReturnBodyClientType); + } + + /** + * Creates an asynchronous binary return type. + * + * @return The asynchronous binary return type. + */ + protected IType createAsyncBinaryReturnType() { + return GenericType.Flux(ClassType.BYTE_BUFFER); + } + + /** + * Creates a synchronous paged return type. + * + * @param elementType The element type of the page. + * @return The synchronous paged return type. + */ + protected IType createPagedSyncReturnType(IType elementType) { + return GenericType.PagedIterable(elementType); + } + + /** + * Creates an asynchronous paged return type. + * + * @param elementType The element type of the page. + * @return The asynchronous paged return type. + */ + protected IType createPagedAsyncReturnType(IType elementType) { + return GenericType.PagedFlux(elementType); + } + + /** + * Creates an asynchronous paged REST response return type. + * + * @param elementType The element type of the page. + * @return The asynchronous paged REST response return type. + */ + protected IType createPagedRestResponseReturnType(IType elementType) { + return GenericType.Mono(GenericType.PagedResponse(elementType)); + } + + /** + * Creates a synchronous paged REST response return type. + * + * @param elementType The element type of the page. + * @return The synchronous paged REST response return type. + */ + protected IType createPagedRestResponseReturnTypeSync(IType elementType) { + return GenericType.PagedResponse(elementType); + } + + /** + * Creates a synchronous paged protocol return type. + * + * @return The synchronous paged protocol return type. + */ + protected IType createProtocolPagedSyncReturnType() { + return GenericType.PagedIterable(ClassType.BINARY_DATA); + } + + /** + * Creates an asynchronous paged protocol return type. + * + * @return The asynchronous paged protocol return type. + */ + protected IType createProtocolPagedAsyncReturnType() { + return GenericType.PagedFlux(ClassType.BINARY_DATA); + } + + /** + * Creates an asynchronous paged protocol REST response return type. + * + * @return The asynchronous paged protocol REST response return type. + */ + protected IType createProtocolPagedRestResponseReturnType() { + return GenericType.Mono(GenericType.PagedResponse(ClassType.BINARY_DATA)); + } + + /** + * Creates a synchronous paged protocol REST response return type. + * + * @return The synchronous paged protocol REST response return type. + */ + protected IType createProtocolPagedRestResponseReturnTypeSync() { + return GenericType.PagedResponse(ClassType.BINARY_DATA); + } + + /** + * Gets a {@link ClientMethod.Builder}. + * + * @return A {@link ClientMethod.Builder}. + */ + protected ClientMethod.Builder getClientMethodBuilder() { + return new ClientMethod.Builder(); + } + + /** + * A {@link JavaVisibility} where the method isn't visible in public API. + */ + protected static final JavaVisibility NOT_VISIBLE = JavaVisibility.Private; + + /** + * A {@link JavaVisibility} where the method is visible in public API. + */ + protected static final JavaVisibility VISIBLE = JavaVisibility.Public; + + /** + * A {@link JavaVisibility} where the method shouldn't be generated. + */ + protected static final JavaVisibility NOT_GENERATE = null; + + /** + * Enum describing the type of method overload. + */ + protected enum MethodOverloadType { + // minimum overload, only required parameters + OVERLOAD_MINIMUM(0x01), + // maximum overload, required parameters and optional parameters + OVERLOAD_MAXIMUM(0x10), + // both a minimum overload and maximum overload, usually because of no optional parameters in API + OVERLOAD_MINIMUM_MAXIMUM(0x11); + + private final int value; + + MethodOverloadType(int value) { + this.value = value; } - /** - * Creates a simple synchronous return value. - * - * @param operation The operation. - * @param syncReturnType The synchronous return value. - * @return The simple synchronous return value. - */ - protected ReturnValue createSimpleSyncReturnValue(Operation operation, IType syncReturnType) { - return new ReturnValue(returnTypeDescription(operation, syncReturnType, syncReturnType), - syncReturnType); + public int value() { + return value; } + } - /** - * Creates a simple asynchronous return value. - * - * @param operation The operation. - * @param asyncReturnType The asynchronous return type. - * @param syncReturnType The synchronous return type. - * @return The simple asynchronous return value. - */ - protected ReturnValue createSimpleAsyncReturnValue(Operation operation, IType asyncReturnType, IType syncReturnType) { - return new ReturnValue(returnTypeDescription(operation, asyncReturnType, syncReturnType), - asyncReturnType); - } + /** + * Extension for configuration on method visibility. + *

+ * ClientMethodTemplate.writeMethod (and whether it is called) would also decide the visibility in generated code. + * + * @param methodType the type of the client method. + * @param methodOverloadType type of method overload. + * @param hasContextParameter whether the method has Context parameter. + * @param isProtocolMethod whether the client method to be simplified for resilience to API changes. + * @return method visibility, null if do not generate. + */ + protected JavaVisibility methodVisibility(ClientMethodType methodType, MethodOverloadType methodOverloadType, + boolean hasContextParameter, boolean isProtocolMethod) { - /** - * Creates a synchronous long-running return value. - * - * @param operation The operation. - * @param syncReturnType The synchronous return type. - * @return The synchronous long-running return value. - */ - protected ReturnValue createLongRunningSyncReturnValue(Operation operation, IType syncReturnType) { - return new ReturnValue(returnTypeDescription(operation, syncReturnType, syncReturnType), - syncReturnType); - } - - /** - * Creates an asynchronous long-running return value. - * - * @param operation The operation. - * @param asyncReturnType The asynchronous return type. - * @param syncReturnType The synchronous return type. - * @return The asynchronous long-running return value. - */ - protected ReturnValue createLongRunningAsyncReturnValue(Operation operation, IType asyncReturnType, IType syncReturnType) { - return new ReturnValue(returnTypeDescription(operation, asyncReturnType, syncReturnType), - asyncReturnType); - } - - private ReturnValue createLongRunningBeginSyncReturnValue(Operation operation, IType syncReturnType, MethodPollingDetails pollingDetails) { - if (JavaSettings.getInstance().isFluent()) { - IType returnType = GenericType.SyncPoller(GenericType.PollResult(syncReturnType.asNullable()), syncReturnType.asNullable()); - return new ReturnValue(returnTypeDescription(operation, returnType, syncReturnType), returnType); - } else { - IType returnType = GenericType.SyncPoller(pollingDetails.getIntermediateType(), pollingDetails.getFinalType()); - return new ReturnValue(returnTypeDescription(operation, returnType, pollingDetails.getFinalType()), returnType); - } - } - - /** - * Creates an asynchronous long-running begin return value. - * - * @param operation The operation. - * @param syncReturnType The synchronous return type. - * @param pollingDetails The polling details. - * @return The asynchronous long-running begin return value. - */ - protected ReturnValue createLongRunningBeginAsyncReturnValue(Operation operation, IType syncReturnType, MethodPollingDetails pollingDetails) { - if (JavaSettings.getInstance().isFluent()) { - IType returnType = GenericType.PollerFlux(GenericType.PollResult(syncReturnType.asNullable()), syncReturnType.asNullable()); - return new ReturnValue(returnTypeDescription(operation, returnType, syncReturnType), returnType); - } else { - IType returnType = GenericType.PollerFlux(pollingDetails.getIntermediateType(), pollingDetails.getFinalType()); - return new ReturnValue(returnTypeDescription(operation, returnType, pollingDetails.getFinalType()), returnType); - } - } - - /** - * Creates a synchronous paging return value. - * - * @param operation The operation. - * @param syncReturnType The synchronous return type. - * @return The synchronous paging return value. - */ - protected ReturnValue createPagingSyncReturnValue(Operation operation, IType syncReturnType) { - return new ReturnValue(returnTypeDescription(operation, syncReturnType, syncReturnType), - syncReturnType); - } - - /** - * Creates an asynchronous paging return value. - * - * @param operation The operation. - * @param asyncReturnType The asynchronous return type. - * @param syncReturnType The synchronous return type. - * @return The asynchronous paging return value. - */ - protected ReturnValue createPagingAsyncReturnValue(Operation operation, IType asyncReturnType, IType syncReturnType) { - return new ReturnValue(returnTypeDescription(operation, asyncReturnType, syncReturnType), - asyncReturnType); - } - - /** - * Creates an asynchronous single page paging return value. - * - * @param operation The operation. - * @param asyncRestResponseReturnType The asynchronous REST response return type. - * @param syncReturnType The synchronous return type. - * @return The asynchronous single page paging return value. - */ - protected ReturnValue createPagingAsyncSinglePageReturnValue(Operation operation, IType asyncRestResponseReturnType, IType syncReturnType) { - return new ReturnValue(returnTypeDescription(operation, asyncRestResponseReturnType, syncReturnType), - asyncRestResponseReturnType); - } - - /** - * Creates a synchronous single page paging return value. - * - * @param operation The operation. - * @param syncRestResponseReturnType The synchronous REST response return type. - * @param syncReturnType The synchronous return type. - * @return The synchronous single page paging return value. - */ - protected ReturnValue createPagingSyncSinglePageReturnValue(Operation operation, - IType syncRestResponseReturnType, IType syncReturnType) { - return new ReturnValue(returnTypeDescription(operation, syncRestResponseReturnType, syncReturnType), - syncRestResponseReturnType); - } - - /** - * Whether paging methods should be generated. - * - * @return Whether paging methods should be generated. - */ - protected boolean shouldGeneratePagingMethods() { - return true; - } - - /** - * Creates an asynchronous void return type. - * - * @return The asynchronous void return type. - */ - protected IType createAsyncVoidReturnType() { - return GenericType.Mono(ClassType.VOID); - } - - /** - * Creates an asynchronous body return type. - * - * @param restAPIMethodReturnBodyClientType The type of the body. - * @return The asynchronous body return type. - */ - protected IType createAsyncBodyReturnType(IType restAPIMethodReturnBodyClientType) { - return GenericType.Mono(restAPIMethodReturnBodyClientType); - } - - /** - * Creates an asynchronous binary return type. - * - * @return The asynchronous binary return type. - */ - protected IType createAsyncBinaryReturnType() { - return GenericType.Flux(ClassType.BYTE_BUFFER); - } - - /** - * Creates a synchronous paged return type. - * - * @param elementType The element type of the page. - * @return The synchronous paged return type. - */ - protected IType createPagedSyncReturnType(IType elementType) { - return GenericType.PagedIterable(elementType); - } - - /** - * Creates an asynchronous paged return type. - * - * @param elementType The element type of the page. - * @return The asynchronous paged return type. - */ - protected IType createPagedAsyncReturnType(IType elementType) { - return GenericType.PagedFlux(elementType); - } - - /** - * Creates an asynchronous paged REST response return type. - * - * @param elementType The element type of the page. - * @return The asynchronous paged REST response return type. - */ - protected IType createPagedRestResponseReturnType(IType elementType) { - return GenericType.Mono(GenericType.PagedResponse(elementType)); - } - - /** - * Creates a synchronous paged REST response return type. - * - * @param elementType The element type of the page. - * @return The synchronous paged REST response return type. - */ - protected IType createPagedRestResponseReturnTypeSync(IType elementType) { - return GenericType.PagedResponse(elementType); - } - - /** - * Creates a synchronous paged protocol return type. - * - * @return The synchronous paged protocol return type. - */ - protected IType createProtocolPagedSyncReturnType() { - return GenericType.PagedIterable(ClassType.BINARY_DATA); - } - - /** - * Creates an asynchronous paged protocol return type. - * - * @return The asynchronous paged protocol return type. - */ - protected IType createProtocolPagedAsyncReturnType() { - return GenericType.PagedFlux(ClassType.BINARY_DATA); - } - - /** - * Creates an asynchronous paged protocol REST response return type. - * - * @return The asynchronous paged protocol REST response return type. - */ - protected IType createProtocolPagedRestResponseReturnType() { - return GenericType.Mono(GenericType.PagedResponse(ClassType.BINARY_DATA)); - } - - /** - * Creates a synchronous paged protocol REST response return type. - * - * @return The synchronous paged protocol REST response return type. - */ - protected IType createProtocolPagedRestResponseReturnTypeSync() { - return GenericType.PagedResponse(ClassType.BINARY_DATA); - } - - /** - * Gets a {@link ClientMethod.Builder}. - * - * @return A {@link ClientMethod.Builder}. - */ - protected ClientMethod.Builder getClientMethodBuilder() { - return new ClientMethod.Builder(); - } - - /** - * A {@link JavaVisibility} where the method isn't visible in public API. - */ - protected static final JavaVisibility NOT_VISIBLE = JavaVisibility.Private; - - /** - * A {@link JavaVisibility} where the method is visible in public API. - */ - protected static final JavaVisibility VISIBLE = JavaVisibility.Public; - - /** - * A {@link JavaVisibility} where the method shouldn't be generated. - */ - protected static final JavaVisibility NOT_GENERATE = null; - - /** - * Enum describing the type of method overload. - */ - protected enum MethodOverloadType { - // minimum overload, only required parameters - OVERLOAD_MINIMUM(0x01), - // maximum overload, required parameters and optional parameters - OVERLOAD_MAXIMUM(0x10), - // both a minimum overload and maximum overload, usually because of no optional parameters in API - OVERLOAD_MINIMUM_MAXIMUM(0x11); - - private final int value; - - MethodOverloadType(int value) { - this.value = value; - } - - public int value() { - return value; - } - } - - /** - * Extension for configuration on method visibility. - *

- * ClientMethodTemplate.writeMethod (and whether it is called) would also decide the visibility in generated code. - * - * @param methodType the type of the client method. - * @param methodOverloadType type of method overload. - * @param hasContextParameter whether the method has Context parameter. - * @param isProtocolMethod whether the client method to be simplified for resilience to API changes. - * @return method visibility, null if do not generate. - */ - protected JavaVisibility methodVisibility(ClientMethodType methodType, MethodOverloadType methodOverloadType, - boolean hasContextParameter, boolean isProtocolMethod) { - - JavaSettings settings = JavaSettings.getInstance(); - if (settings.isDataPlaneClient()) { - if (isProtocolMethod) { + JavaSettings settings = JavaSettings.getInstance(); + if (settings.isDataPlaneClient()) { + if (isProtocolMethod) { /* Rule for DPG protocol method @@ -1421,319 +1422,319 @@ public class ClientMethodMapper implements IMapper 2. For sync method, Context is included in "RequestOptions", hence do not generate method with Context parameter. 3. For async method, Context is not included in method (this rule is valid for all clients). */ - if (methodType == ClientMethodType.SimpleAsync - || methodType == ClientMethodType.SimpleSync - || !hasContextParameter - || (methodType == ClientMethodType.PagingSyncSinglePage && !settings.isSyncStackEnabled())) { - return NOT_GENERATE; - } - - if (methodType == ClientMethodType.PagingAsyncSinglePage - || (methodType == ClientMethodType.PagingSyncSinglePage && settings.isSyncStackEnabled())) { - return NOT_VISIBLE; - } - return VISIBLE; - } else { - // at present, only generate convenience method for simple API and pageable API (no LRO) - return ((methodType == ClientMethodType.SimpleAsync && !hasContextParameter) - || (methodType == ClientMethodType.SimpleSync && !hasContextParameter) - || (methodType == ClientMethodType.PagingAsync && !hasContextParameter) - || (methodType == ClientMethodType.PagingSync && !hasContextParameter) - || (methodType == ClientMethodType.LongRunningBeginAsync && !hasContextParameter) - || (methodType == ClientMethodType.LongRunningBeginSync && !hasContextParameter)) - // || (methodType == ClientMethodType.SimpleSyncRestResponse && hasContextParameter)) - ? VISIBLE - : NOT_GENERATE; - } - } else { - if (methodType == ClientMethodType.SimpleSyncRestResponse && !hasContextParameter) { - return NOT_GENERATE; - } else if (methodType == ClientMethodType.SimpleSync && hasContextParameter) { - return NOT_GENERATE; - } - return VISIBLE; + if (methodType == ClientMethodType.SimpleAsync + || methodType == ClientMethodType.SimpleSync + || !hasContextParameter + || (methodType == ClientMethodType.PagingSyncSinglePage && !settings.isSyncStackEnabled())) { + return NOT_GENERATE; } + + if (methodType == ClientMethodType.PagingAsyncSinglePage + || (methodType == ClientMethodType.PagingSyncSinglePage && settings.isSyncStackEnabled())) { + return NOT_VISIBLE; + } + return VISIBLE; + } else { + // at present, only generate convenience method for simple API and pageable API (no LRO) + return ((methodType == ClientMethodType.SimpleAsync && !hasContextParameter) + || (methodType == ClientMethodType.SimpleSync && !hasContextParameter) + || (methodType == ClientMethodType.PagingAsync && !hasContextParameter) + || (methodType == ClientMethodType.PagingSync && !hasContextParameter) + || (methodType == ClientMethodType.LongRunningBeginAsync && !hasContextParameter) + || (methodType == ClientMethodType.LongRunningBeginSync && !hasContextParameter)) + // || (methodType == ClientMethodType.SimpleSyncRestResponse && hasContextParameter)) + ? VISIBLE + : NOT_GENERATE; + } + } else { + if (methodType == ClientMethodType.SimpleSyncRestResponse && !hasContextParameter) { + return NOT_GENERATE; + } else if (methodType == ClientMethodType.SimpleSync && hasContextParameter) { + return NOT_GENERATE; + } + return VISIBLE; + } + } + + @FunctionalInterface + private interface MethodVisibilityFunction { + JavaVisibility methodVisibility(boolean isRestResponseOrIsFirstPage, MethodOverloadType methodOverloadType, boolean hasContextParameter); + } + + private static void addClientMethodWithContext(List methods, Builder builder, + List parameters, ClientMethodType clientMethodType, String proxyMethodName, + ReturnValue returnValue, MethodPageDetails details, ClientMethodParameter contextParameter) { + + List updatedParams = new ArrayList<>(parameters); + if (JavaSettings.getInstance().isBranded() || contextParameter.getClientType().equals(ClassType.REQUEST_OPTIONS)) { + updatedParams.add(contextParameter); } - @FunctionalInterface - private interface MethodVisibilityFunction { - JavaVisibility methodVisibility(boolean isRestResponseOrIsFirstPage, MethodOverloadType methodOverloadType, boolean hasContextParameter); + methods.add(builder + .parameters(updatedParams) // update builder parameters to include context + .returnValue(returnValue) + .name(proxyMethodName) + .onlyRequiredParameters(false) + .type(clientMethodType) + .groupedParameterRequired(false) + .methodPageDetails(details) + .build()); + // reset the parameters to original params + builder.parameters(parameters); + } + + /** + * Gets the Context parameter. + * + * @param isProtocolMethod Whether the method is a protocol method. + * @return The Context parameter. + */ + protected ClientMethodParameter getContextParameter(boolean isProtocolMethod) { + return isProtocolMethod + ? ClientMethodParameter.REQUEST_OPTIONS_PARAMETER + : getContextParameter(); + } + + /** + * Adds a {@link ClientMethod} that has a Context parameter included. + * + * @param methods The list of {@link ClientMethod ClientMethods} already created. + * @param builder The builder for the {@link ClientMethod}. + * @param parameters Parameters of the method. + * @param contextParameter The Context parameter. + */ + protected static void addClientMethodWithContext(List methods, Builder builder, + List parameters, ClientMethodParameter contextParameter) { + List updatedParams = new ArrayList<>(parameters); + if (JavaSettings.getInstance().isBranded() || contextParameter.getClientType().equals(ClassType.REQUEST_OPTIONS)) { + updatedParams.add(contextParameter); } - private static void addClientMethodWithContext(List methods, ClientMethod.Builder builder, - List parameters, ClientMethodType clientMethodType, String proxyMethodName, - ReturnValue returnValue, MethodPageDetails details, ClientMethodParameter contextParameter) { + methods.add(builder + .parameters(updatedParams) // update builder parameters to include context + .onlyRequiredParameters(false) + .hasWithContextOverload(false) // WithContext overload doesn't have a withContext overload + .build()); + // reset the parameters to original params + builder.parameters(parameters); + } - List updatedParams = new ArrayList<>(parameters); - if (JavaSettings.getInstance().isBranded() || contextParameter.getClientType().equals(ClassType.REQUEST_OPTIONS)) { - updatedParams.add(contextParameter); - } + private static String getPageableItemName(XmsPageable xmsPageable, IType responseBodyType) { + ClientModel responseBodyModel = ClientModelUtil.getClientModel(responseBodyType.toString()); + return Stream.concat(responseBodyModel.getProperties().stream(), ClientModelUtil.getParentProperties(responseBodyModel).stream()) + .filter(p -> p.getSerializedName().equals(xmsPageable.getItemName())) + .map(ClientModelProperty::getName).findAny().orElse(null); + } - methods.add(builder - .parameters(updatedParams) // update builder parameters to include context - .returnValue(returnValue) - .name(proxyMethodName) - .onlyRequiredParameters(false) - .type(clientMethodType) - .groupedParameterRequired(false) - .methodPageDetails(details) - .build()); - // reset the parameters to original params - builder.parameters(parameters); + private static IType getPageableNextLinkType(XmsPageable xmsPageable, String clientModelName) { + ClientModel responseBodyModel = ClientModelUtil.getClientModel(clientModelName); + IType nextLinkType = responseBodyModel.getProperties().stream() + .filter(p -> p.getSerializedName().equals(xmsPageable.getNextLinkName())) + .map(ClientModelProperty::getClientType).findAny().orElse(null); + if (nextLinkType == null && !CoreUtils.isNullOrEmpty(responseBodyModel.getParentModelName())) { + // try find nextLink property in parent model + nextLinkType = getPageableNextLinkType(xmsPageable, responseBodyModel.getParentModelName()); + } + return nextLinkType; + } + + private IType getPollingIntermediateType(JavaSettings.PollingDetails details, IType syncReturnType) { + IType pollResponseType = syncReturnType.asNullable(); + if (JavaSettings.getInstance().isFluent()) { + return pollResponseType; + } + if (details != null && details.getIntermediateType() != null) { + pollResponseType = createTypeFromModelName(details.getIntermediateType(), JavaSettings.getInstance()); + } + // azure-core wants poll response to be non-null + if (pollResponseType.asNullable() == ClassType.VOID) { + pollResponseType = ClassType.BINARY_DATA; } - /** - * Gets the Context parameter. - * - * @param isProtocolMethod Whether the method is a protocol method. - * @return The Context parameter. - */ - protected ClientMethodParameter getContextParameter(boolean isProtocolMethod) { - return isProtocolMethod - ? ClientMethodParameter.REQUEST_OPTIONS_PARAMETER - : getContextParameter(); + return pollResponseType; + } + + private IType getPollingFinalType(JavaSettings.PollingDetails details, IType syncReturnType, HttpMethod httpMethod) { + IType resultType = syncReturnType.asNullable(); + if (JavaSettings.getInstance().isFluent()) { + return resultType; + } + if (details != null && details.getFinalType() != null) { + resultType = createTypeFromModelName(details.getFinalType(), JavaSettings.getInstance()); + } + // azure-core wants poll response to be non-null + if (resultType.asNullable() == ClassType.VOID) { + resultType = ClassType.BINARY_DATA; + } + // DELETE would not have final response as resource is deleted + if (httpMethod == HttpMethod.DELETE) { + resultType = PrimitiveType.VOID; } - /** - * Adds a {@link ClientMethod} that has a Context parameter included. - * - * @param methods The list of {@link ClientMethod ClientMethods} already created. - * @param builder The builder for the {@link ClientMethod}. - * @param parameters Parameters of the method. - * @param contextParameter The Context parameter. - */ - protected static void addClientMethodWithContext(List methods, ClientMethod.Builder builder, - List parameters, ClientMethodParameter contextParameter) { - List updatedParams = new ArrayList<>(parameters); - if (JavaSettings.getInstance().isBranded() || contextParameter.getClientType().equals(ClassType.REQUEST_OPTIONS)) { - updatedParams.add(contextParameter); - } + return resultType; + } - methods.add(builder - .parameters(updatedParams) // update builder parameters to include context - .onlyRequiredParameters(false) - .hasWithContextOverload(false) // WithContext overload doesn't have a withContext overload - .build()); - // reset the parameters to original params - builder.parameters(parameters); + private static boolean hasNonRequiredParameters(List parameters) { + return parameters.stream().anyMatch(p -> !p.isRequired() && !p.isConstant()); + } + + /** + * Creates the return type Javadoc description. + * + * @param operation The operation. + * @param returnType The return type. + * @param baseType The base type. + * @return The return type Javadoc description. + */ + protected static String returnTypeDescription(Operation operation, IType returnType, IType baseType) { + if (returnType == PrimitiveType.VOID) { + // void methods don't have a return value, therefore no return Javadoc. + return null; + } + String description = null; + // try the description of the operation + if (operation.getLanguage() != null && operation.getLanguage().getDefault() != null) { + String operationDescription = SchemaUtil.mergeSummaryWithDescription(operation.getSummary(), operation.getLanguage().getDefault().getDescription()); + if (!CoreUtils.isNullOrEmpty(operationDescription)) { + if (operationDescription.toLowerCase().startsWith("get ") || operationDescription.toLowerCase().startsWith("gets ")) { + int startIndex = operationDescription.indexOf(" ") + 1; + description = formatReturnTypeDescription(operationDescription.substring(startIndex)); + } + } } - private static String getPageableItemName(XmsPageable xmsPageable, IType responseBodyType) { - ClientModel responseBodyModel = ClientModelUtil.getClientModel(responseBodyType.toString()); - return Stream.concat(responseBodyModel.getProperties().stream(), ClientModelUtil.getParentProperties(responseBodyModel).stream()) - .filter(p -> p.getSerializedName().equals(xmsPageable.getItemName())) - .map(ClientModelProperty::getName).findAny().orElse(null); + // try the description on the schema of return type + if (description == null && operation.getResponses() != null && !operation.getResponses().isEmpty()) { + Schema responseSchema = operation.getResponses().get(0).getSchema(); + if (responseSchema != null && !CoreUtils.isNullOrEmpty(responseSchema.getSummary())) { + description = formatReturnTypeDescription(responseSchema.getSummary()); + } else if (responseSchema != null && responseSchema.getLanguage() != null && responseSchema.getLanguage().getDefault() != null) { + String responseSchemaDescription = responseSchema.getLanguage().getDefault().getDescription(); + if (!CoreUtils.isNullOrEmpty(responseSchemaDescription)) { + description = formatReturnTypeDescription(responseSchemaDescription); + } + } } - private static IType getPageableNextLinkType(XmsPageable xmsPageable, String clientModelName) { - ClientModel responseBodyModel = ClientModelUtil.getClientModel(clientModelName); - IType nextLinkType = responseBodyModel.getProperties().stream() - .filter(p -> p.getSerializedName().equals(xmsPageable.getNextLinkName())) - .map(ClientModelProperty::getClientType).findAny().orElse(null); - if (nextLinkType == null && !CoreUtils.isNullOrEmpty(responseBodyModel.getParentModelName())) { - // try find nextLink property in parent model - nextLinkType = getPageableNextLinkType(xmsPageable, responseBodyModel.getParentModelName()); - } - return nextLinkType; + // Mono of HEAD method + if (description == null + && baseType == PrimitiveType.BOOLEAN + && HttpMethod.HEAD == MethodUtil.getHttpMethod(operation)) { + description = "whether resource exists"; } - private IType getPollingIntermediateType(JavaSettings.PollingDetails details, IType syncReturnType) { - IType pollResponseType = syncReturnType.asNullable(); - if (JavaSettings.getInstance().isFluent()) { - return pollResponseType; - } - if (details != null && details.getIntermediateType() != null) { - pollResponseType = createTypeFromModelName(details.getIntermediateType(), JavaSettings.getInstance()); - } - // azure-core wants poll response to be non-null - if (pollResponseType.asNullable() == ClassType.VOID) { - pollResponseType = ClassType.BINARY_DATA; - } + description = ReturnTypeDescriptionAssembler.assemble(description, returnType, baseType); - return pollResponseType; + return description == null ? "the response" : description; + } + + private static String formatReturnTypeDescription(String description) { + description = description.trim(); + int endIndex = description.indexOf(". "); // Get 1st sentence. + if (endIndex == -1 && description.length() > 0 && description.charAt(description.length() - 1) == '.') { + // Remove last period. + endIndex = description.length() - 1; + } + if (endIndex != -1) { + description = description.substring(0, endIndex); + } + if (description.length() > 0 && Character.isUpperCase(description.charAt(0))) { + description = description.substring(0, 1).toLowerCase() + description.substring(1); + } + return description; + } + + private static MethodPollingDetails methodPollingDetailsFromMetadata( + Operation operation, + JavaSettings.PollingDetails pollingDetails) { + + if (pollingDetails == null || operation.getConvenienceApi() == null) { + return null; } - private IType getPollingFinalType(JavaSettings.PollingDetails details, IType syncReturnType, HttpMethod httpMethod) { - IType resultType = syncReturnType.asNullable(); - if (JavaSettings.getInstance().isFluent()) { - return resultType; - } - if (details != null && details.getFinalType() != null) { - resultType = createTypeFromModelName(details.getFinalType(), JavaSettings.getInstance()); - } - // azure-core wants poll response to be non-null - if (resultType.asNullable() == ClassType.VOID) { - resultType = ClassType.BINARY_DATA; - } - // DELETE would not have final response as resource is deleted - if (httpMethod == HttpMethod.DELETE) { - resultType = PrimitiveType.VOID; - } + MethodPollingDetails methodPollingDetails = null; + if (operation.getLroMetadata() != null) { + // only TypeSpec would have LongRunningMetadata + LongRunningMetadata metadata = operation.getLroMetadata(); + ObjectMapper objectMapper = Mappers.getObjectMapper(); + IType intermediateType = objectMapper.map(metadata.getPollResultType()); + IType finalType = metadata.getFinalResultType() == null + ? PrimitiveType.VOID + : objectMapper.map(metadata.getFinalResultType()); - return resultType; + // PollingDetails would override LongRunningMetadata + if (pollingDetails.getIntermediateType() != null) { + intermediateType = createTypeFromModelName(pollingDetails.getIntermediateType(), JavaSettings.getInstance()); + } + if (pollingDetails.getFinalType() != null) { + finalType = createTypeFromModelName(pollingDetails.getFinalType(), JavaSettings.getInstance()); + } + + // PollingStrategy + JavaSettings settings = JavaSettings.getInstance(); + final String packageName = settings.getPackage(settings.getImplementationSubpackage()); + String pollingStrategy = metadata.getPollingStrategy() == null + ? pollingDetails.getStrategy() + : String.format(JavaSettings.PollingDetails.DEFAULT_POLLING_STRATEGY_FORMAT, packageName + "." + metadata.getPollingStrategy().getLanguage().getJava().getName()); + String syncPollingStrategy = metadata.getPollingStrategy() == null + ? pollingDetails.getSyncStrategy() + : String.format(JavaSettings.PollingDetails.DEFAULT_POLLING_STRATEGY_FORMAT, packageName + ".Sync" + metadata.getPollingStrategy().getLanguage().getJava().getName()); + if (metadata.getPollingStrategy() != null && metadata.getFinalResultPropertySerializedName() != null) { + // add "" argument to polling strategy constructor + Function addPropertyNameToArguments = (strategy) -> { + strategy = strategy.substring(0, strategy.length() - 1) + ", "; + strategy += ClassType.STRING.defaultValueExpression(metadata.getFinalResultPropertySerializedName()); + strategy += ")"; + return strategy; + }; + pollingStrategy = addPropertyNameToArguments.apply(pollingStrategy); + syncPollingStrategy = addPropertyNameToArguments.apply(syncPollingStrategy); + } + + methodPollingDetails = new MethodPollingDetails( + pollingStrategy, + syncPollingStrategy, + intermediateType, + finalType, + pollingDetails.getPollIntervalInSeconds()); } + return methodPollingDetails; + } - private static boolean hasNonRequiredParameters(List parameters) { - return parameters.stream().anyMatch(p -> !p.isRequired() && !p.isConstant()); + /** + * Create IType from model name (full name or simple name). + * + * @param modelName the model name. If it is simple name, package name from JavaSetting will be used. + * @return IType of the model + */ + private static IType createTypeFromModelName(String modelName, JavaSettings settings) { + String finalTypeName; + String finalTypePackage; + if (modelName.contains(".")) { + finalTypeName = ANYTHING_THEN_PERIOD.matcher(modelName).replaceAll(""); + finalTypePackage = modelName.replace("." + finalTypeName, ""); + } else { + finalTypeName = modelName; + finalTypePackage = JavaSettings.getInstance().getPackage(); } + return new ClassType.Builder().packageName(finalTypePackage).name(finalTypeName).build(); + } - /** - * Creates the return type Javadoc description. - * - * @param operation The operation. - * @param returnType The return type. - * @param baseType The base type. - * @return The return type Javadoc description. - */ - protected static String returnTypeDescription(Operation operation, IType returnType, IType baseType) { - if (returnType == PrimitiveType.VOID) { - // void methods don't have a return value, therefore no return Javadoc. - return null; - } - String description = null; - // try the description of the operation - if (operation.getLanguage() != null && operation.getLanguage().getDefault() != null) { - String operationDescription = operation.getLanguage().getDefault().getDescription(); - if (!CoreUtils.isNullOrEmpty(operationDescription)) { - if (operationDescription.toLowerCase().startsWith("get ") || operationDescription.toLowerCase().startsWith("gets ")) { - int startIndex = operationDescription.indexOf(" ") + 1; - description = formatReturnTypeDescription(operationDescription.substring(startIndex)); - } - } - } - - // try the description on the schema of return type - if (description == null && operation.getResponses() != null && !operation.getResponses().isEmpty()) { - Schema responseSchema = operation.getResponses().get(0).getSchema(); - if (responseSchema != null && !CoreUtils.isNullOrEmpty(responseSchema.getSummary())) { - description = formatReturnTypeDescription(responseSchema.getSummary()); - } else if (responseSchema != null && responseSchema.getLanguage() != null && responseSchema.getLanguage().getDefault() != null) { - String responseSchemaDescription = responseSchema.getLanguage().getDefault().getDescription(); - if (!CoreUtils.isNullOrEmpty(responseSchemaDescription)) { - description = formatReturnTypeDescription(responseSchemaDescription); - } - } - } - - // Mono of HEAD method - if (description == null - && baseType == PrimitiveType.BOOLEAN - && HttpMethod.HEAD == MethodUtil.getHttpMethod(operation)) { - description = "whether resource exists"; - } - - description = ReturnTypeDescriptionAssembler.assemble(description, returnType, baseType); - - return description == null ? "the response" : description; + private static MethodNamer resolveMethodNamer(ProxyMethod proxyMethod, ConvenienceApi convenienceApi, boolean isProtocolMethod) { + if (!isProtocolMethod && convenienceApi != null) { + return new MethodNamer(SchemaUtil.getJavaName(convenienceApi)); + } else { + if (proxyMethod.isSync()) { + return new MethodNamer(proxyMethod.getBaseName()); + } + return new MethodNamer(proxyMethod.getName()); } + } - private static String formatReturnTypeDescription(String description) { - description = description.trim(); - int endIndex = description.indexOf(". "); // Get 1st sentence. - if (endIndex == -1 && description.length() > 0 && description.charAt(description.length() - 1) == '.') { - // Remove last period. - endIndex = description.length() - 1; - } - if (endIndex != -1) { - description = description.substring(0, endIndex); - } - if (description.length() > 0 && Character.isUpperCase(description.charAt(0))) { - description = description.substring(0, 1).toLowerCase() + description.substring(1); - } - return description; - } - - private static MethodPollingDetails methodPollingDetailsFromMetadata( - Operation operation, - JavaSettings.PollingDetails pollingDetails) { - - if (pollingDetails == null || operation.getConvenienceApi() == null) { - return null; - } - - MethodPollingDetails methodPollingDetails = null; - if (operation.getLroMetadata() != null) { - // only TypeSpec would have LongRunningMetadata - LongRunningMetadata metadata = operation.getLroMetadata(); - ObjectMapper objectMapper = Mappers.getObjectMapper(); - IType intermediateType = objectMapper.map(metadata.getPollResultType()); - IType finalType = metadata.getFinalResultType() == null - ? PrimitiveType.VOID - : objectMapper.map(metadata.getFinalResultType()); - - // PollingDetails would override LongRunningMetadata - if (pollingDetails.getIntermediateType() != null) { - intermediateType = createTypeFromModelName(pollingDetails.getIntermediateType(), JavaSettings.getInstance()); - } - if (pollingDetails.getFinalType() != null) { - finalType = createTypeFromModelName(pollingDetails.getFinalType(), JavaSettings.getInstance()); - } - - // PollingStrategy - JavaSettings settings = JavaSettings.getInstance(); - final String packageName = settings.getPackage(settings.getImplementationSubpackage()); - String pollingStrategy = metadata.getPollingStrategy() == null - ? pollingDetails.getStrategy() - : String.format(JavaSettings.PollingDetails.DEFAULT_POLLING_STRATEGY_FORMAT, packageName + "." + metadata.getPollingStrategy().getLanguage().getJava().getName()); - String syncPollingStrategy = metadata.getPollingStrategy() == null - ? pollingDetails.getSyncStrategy() - : String.format(JavaSettings.PollingDetails.DEFAULT_POLLING_STRATEGY_FORMAT, packageName + ".Sync" + metadata.getPollingStrategy().getLanguage().getJava().getName()); - if (metadata.getPollingStrategy() != null && metadata.getFinalResultPropertySerializedName() != null) { - // add "" argument to polling strategy constructor - Function addPropertyNameToArguments = (strategy) -> { - strategy = strategy.substring(0, strategy.length() - 1) + ", "; - strategy += ClassType.STRING.defaultValueExpression(metadata.getFinalResultPropertySerializedName()); - strategy += ")"; - return strategy; - }; - pollingStrategy = addPropertyNameToArguments.apply(pollingStrategy); - syncPollingStrategy = addPropertyNameToArguments.apply(syncPollingStrategy); - } - - methodPollingDetails = new MethodPollingDetails( - pollingStrategy, - syncPollingStrategy, - intermediateType, - finalType, - pollingDetails.getPollIntervalInSeconds()); - } - return methodPollingDetails; - } - - /** - * Create IType from model name (full name or simple name). - * - * @param modelName the model name. If it is simple name, package name from JavaSetting will be used. - * @return IType of the model - */ - private static IType createTypeFromModelName(String modelName, JavaSettings settings) { - String finalTypeName; - String finalTypePackage; - if (modelName.contains(".")) { - finalTypeName = ANYTHING_THEN_PERIOD.matcher(modelName).replaceAll(""); - finalTypePackage = modelName.replace("." + finalTypeName, ""); - } else { - finalTypeName = modelName; - finalTypePackage = JavaSettings.getInstance().getPackage(); - } - return new ClassType.Builder().packageName(finalTypePackage).name(finalTypeName).build(); - } - - private static MethodNamer resolveMethodNamer(ProxyMethod proxyMethod, ConvenienceApi convenienceApi, boolean isProtocolMethod) { - if (!isProtocolMethod && convenienceApi != null) { - return new MethodNamer(SchemaUtil.getJavaName(convenienceApi)); - } else { - if (proxyMethod.isSync()) { - return new MethodNamer(proxyMethod.getBaseName()); - } - return new MethodNamer(proxyMethod.getName()); - } - } - - private static final class ReturnTypeHolder { - IType asyncRestResponseReturnType; - IType asyncReturnType; - IType syncReturnType; - IType syncReturnWithResponse; - } + private static final class ReturnTypeHolder { + IType asyncRestResponseReturnType; + IType asyncReturnType; + IType syncReturnType; + IType syncReturnWithResponse; + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/PrimitiveMapper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/PrimitiveMapper.java index 06362527b..6588549c0 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/PrimitiveMapper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/PrimitiveMapper.java @@ -18,101 +18,101 @@ import java.util.HashMap; import java.util.Map; public class PrimitiveMapper implements IMapper { - private static final PrimitiveMapper INSTANCE = new PrimitiveMapper(); - protected Map parsed = new HashMap<>(); + private static final PrimitiveMapper INSTANCE = new PrimitiveMapper(); + protected Map parsed = new HashMap<>(); - protected PrimitiveMapper() { + protected PrimitiveMapper() { + } + + public static PrimitiveMapper getInstance() { + return INSTANCE; + } + + @Override + public IType map(PrimitiveSchema primaryType) { + if (primaryType == null) { + return null; } - public static PrimitiveMapper getInstance() { - return INSTANCE; - } + return parsed.computeIfAbsent(primaryType, this::createPrimitiveType); + } - @Override - public IType map(PrimitiveSchema primaryType) { - if (primaryType == null) { - return null; - } + /** + * Extension. + * + * @param primaryType the primitive schema. + * @return the client model type. + */ + protected IType createPrimitiveType(PrimitiveSchema primaryType) { + boolean isLowLevelClient = JavaSettings.getInstance().isDataPlaneClient(); + boolean urlAsString = JavaSettings.getInstance().urlAsString(); + boolean uuidAsString = JavaSettings.getInstance().uuidAsString(); - return parsed.computeIfAbsent(primaryType, this::createPrimitiveType); - } - - /** - * Extension. - * - * @param primaryType the primitive schema. - * @return the client model type. - */ - protected IType createPrimitiveType(PrimitiveSchema primaryType) { - boolean isLowLevelClient = JavaSettings.getInstance().isDataPlaneClient(); - boolean urlAsString = JavaSettings.getInstance().urlAsString(); - boolean uuidAsString = JavaSettings.getInstance().uuidAsString(); - - switch (primaryType.getType()) { + switch (primaryType.getType()) { // case null: // iType = PrimitiveType.Void; // break; - case BOOLEAN: return PrimitiveType.BOOLEAN; - case BYTE_ARRAY: - ByteArraySchema byteArraySchema = (ByteArraySchema) primaryType; - return (byteArraySchema.getFormat() == ByteArraySchema.Format.BASE_64_URL) - ? ClassType.BASE_64_URL - : ArrayType.BYTE_ARRAY; - case CHAR: return PrimitiveType.CHAR; - case DATE: return isLowLevelClient ? ClassType.STRING : ClassType.LOCAL_DATE; - case DATE_TIME: - DateTimeSchema dateTimeSchema = (DateTimeSchema) primaryType; - return (dateTimeSchema.getFormat() == DateTimeSchema.Format.DATE_TIME_RFC_1123) - ? ClassType.DATE_TIME_RFC_1123 - : ClassType.DATE_TIME; - case TIME: + case BOOLEAN: return PrimitiveType.BOOLEAN; + case BYTE_ARRAY: + ByteArraySchema byteArraySchema = (ByteArraySchema) primaryType; + return (byteArraySchema.getFormat() == ByteArraySchema.Format.BASE_64_URL) + ? ClassType.BASE_64_URL + : ArrayType.BYTE_ARRAY; + case CHAR: return PrimitiveType.CHAR; + case DATE: return isLowLevelClient ? ClassType.STRING : ClassType.LOCAL_DATE; + case DATE_TIME: + DateTimeSchema dateTimeSchema = (DateTimeSchema) primaryType; + return (dateTimeSchema.getFormat() == DateTimeSchema.Format.DATE_TIME_RFC_1123) + ? ClassType.DATE_TIME_RFC_1123 + : ClassType.DATE_TIME; + case TIME: // TimeSchema timeSchema = (TimeSchema) primaryType; - return ClassType.STRING; + return ClassType.STRING; // case KnownPrimaryType.DateTimeRfc1123: // iType = ClassType.DateTimeRfc1123; // break; - case NUMBER: - NumberSchema numberSchema = (NumberSchema) primaryType; - if (numberSchema.getPrecision() == 64) { - return PrimitiveType.DOUBLE; - } else if (numberSchema.getPrecision() == 32) { - return PrimitiveType.FLOAT; - } else { - return ClassType.BIG_DECIMAL; - } - case INTEGER: - NumberSchema intSchema = (NumberSchema) primaryType; - return (intSchema.getPrecision() == 64) - ? PrimitiveType.LONG - : PrimitiveType.INT; -// case KnownPrimaryType.Long: -// iType = PrimitiveType.Long; -// break; -// case KnownPrimaryType.Stream: -// iType = GenericType.FluxByteBuffer; -// break; - case STRING: return ClassType.STRING; - case ARM_ID: return ClassType.STRING; - case URI: return isLowLevelClient || urlAsString ? ClassType.STRING : ClassType.URL; - case DURATION: - DurationSchema durationSchema = (DurationSchema) primaryType; - IType durationType = ClassType.DURATION; - if (durationSchema.getFormat() != null) { - switch (durationSchema.getFormat()) { - case SECONDS_INTEGER: - return PrimitiveType.DURATION_LONG; - case SECONDS_NUMBER: - return PrimitiveType.DURATION_DOUBLE; - } - } - return durationType; - case UNIXTIME: return isLowLevelClient ? PrimitiveType.LONG : PrimitiveType.UNIX_TIME_LONG; - case UUID: return isLowLevelClient || uuidAsString ? ClassType.STRING : ClassType.UUID; - case OBJECT: return ClassType.OBJECT; - case CREDENTIAL: return ClassType.TOKEN_CREDENTIAL; - default: - throw new UnsupportedOperationException(String.format("Unrecognized AutoRest Primitive Type: %s", - primaryType.getType())); + case NUMBER: + NumberSchema numberSchema = (NumberSchema) primaryType; + if (numberSchema.getPrecision() == 64) { + return PrimitiveType.DOUBLE; + } else if (numberSchema.getPrecision() == 32) { + return PrimitiveType.FLOAT; + } else { + return ClassType.BIG_DECIMAL; } + case INTEGER: + NumberSchema intSchema = (NumberSchema) primaryType; + if ("string".equals(intSchema.getEncode())) { + return (intSchema.getPrecision() == 64) + ? PrimitiveType.LONG_AS_STRING + : PrimitiveType.INT_AS_STRING; + } else { + return (intSchema.getPrecision() == 64) + ? PrimitiveType.LONG + : PrimitiveType.INT; + } + case STRING: return ClassType.STRING; + case ARM_ID: return ClassType.STRING; + case URI: return isLowLevelClient || urlAsString ? ClassType.STRING : ClassType.URL; + case DURATION: + DurationSchema durationSchema = (DurationSchema) primaryType; + IType durationType = ClassType.DURATION; + if (durationSchema.getFormat() != null) { + switch (durationSchema.getFormat()) { + case SECONDS_INTEGER: + return PrimitiveType.DURATION_LONG; + case SECONDS_NUMBER: + return PrimitiveType.DURATION_DOUBLE; + } + } + return durationType; + case UNIXTIME: return isLowLevelClient ? PrimitiveType.LONG : PrimitiveType.UNIX_TIME_LONG; + case UUID: return isLowLevelClient || uuidAsString ? ClassType.STRING : ClassType.UUID; + case OBJECT: return ClassType.OBJECT; + case CREDENTIAL: return ClassType.TOKEN_CREDENTIAL; + default: + throw new UnsupportedOperationException(String.format("Unrecognized AutoRest Primitive Type: %s", + primaryType.getType())); } + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClassType.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClassType.java index 144c3515e..4723530ff 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClassType.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClassType.java @@ -82,854 +82,876 @@ import java.util.function.Function; public class ClassType implements IType { - private static class ClassDetails { + private static class ClassDetails { - private final Class azureClass; - private final String genericClass; - - public ClassDetails(Class azureClass, String genericClass) { - this.azureClass = azureClass; - this.genericClass = genericClass; - } - - public String getAzureClass() { - return azureClass.getName(); - } - - public String getGenericClass() { - return genericClass; - } + private final Class azureClass; + private final String genericClass; + public ClassDetails(Class azureClass, String genericClass) { + this.azureClass = azureClass; + this.genericClass = genericClass; } - private static final Map, ClassDetails> CLASS_TYPE_MAPPING = new HashMap, ClassDetails>() {{ - put(RestProxy.class, new ClassDetails(RestProxy.class, "io.clientcore.core.http.RestProxy")); - put(HttpPipeline.class, new ClassDetails(HttpPipeline.class, "io.clientcore.core.http.pipeline.HttpPipeline")); - put(HttpPipelineBuilder.class, new ClassDetails(HttpPipelineBuilder.class, "io.clientcore.core.http.pipeline.HttpPipelineBuilder")); - put(Context.class, new ClassDetails(Context.class, "io.clientcore.core.util.Context")); - put(HttpClient.class, new ClassDetails(HttpClient.class, "io.clientcore.core.http.client.HttpClient")); - put(HttpLogOptions.class, new ClassDetails(HttpLogOptions.class, "io.clientcore.core.http.models.HttpLogOptions")); - put(HttpPipelinePolicy.class, new ClassDetails(HttpPipelinePolicy.class, "io.clientcore.core.http.pipeline.HttpPipelinePolicy")); - put(KeyCredentialPolicy.class, new ClassDetails(KeyCredentialPolicy.class, "io.clientcore.core.http.pipeline.KeyCredentialPolicy")); - put(RetryPolicy.class, new ClassDetails(RetryPolicy.class, "io.clientcore.core.http.pipeline.HttpRetryPolicy")); - put(RedirectPolicy.class, new ClassDetails(RedirectPolicy.class, "io.clientcore.core.http.pipeline.HttpRedirectPolicy")); - put(Configuration.class, new ClassDetails(Configuration.class, "io.clientcore.core.util.configuration.Configuration")); - put(HttpHeaders.class, new ClassDetails(HttpHeaders.class, "io.clientcore.core.models.Headers")); - put(HttpHeaderName.class, new ClassDetails(HttpHeaderName.class, "io.clientcore.core.http.models.HttpHeaderName")); - put(HttpRequest.class, new ClassDetails(HttpRequest.class, "io.clientcore.core.http.models.HttpRequest")); - put(RequestOptions.class, new ClassDetails(RequestOptions.class, "io.clientcore.core.http.models.RequestOptions")); - put(BinaryData.class, new ClassDetails(BinaryData.class, "io.clientcore.core.util.binarydata.BinaryData")); - put(RetryOptions.class, new ClassDetails(RetryOptions.class, "io.clientcore.core.http.models.HttpRetryOptions")); - put(ProxyOptions.class, new ClassDetails(ProxyOptions.class, "io.clientcore.core.http.models.ProxyOptions")); - put(Response.class, new ClassDetails(Response.class, "io.clientcore.core.http.models.Response")); - put(SimpleResponse.class, new ClassDetails(SimpleResponse.class, "io.clientcore.core.http.SimpleResponse")); - put(ExpandableStringEnum.class, new ClassDetails(ExpandableStringEnum.class, "io.clientcore.core.util.ExpandableEnum")); - put(HttpResponseException.class, new ClassDetails(HttpResponseException.class, "io.clientcore.core.http.exception.HttpResponseException")); - put(HttpTrait.class, new ClassDetails(HttpTrait.class, "io.clientcore.core.models.traits.HttpTrait")); - put(ConfigurationTrait.class, new ClassDetails(ConfigurationTrait.class, "io.clientcore.core.models.traits.ConfigurationTrait")); - put(EndpointTrait.class, new ClassDetails(EndpointTrait.class, "io.clientcore.core.models.traits.EndpointTrait")); - put(KeyCredentialTrait.class, new ClassDetails(KeyCredentialTrait.class, "io.clientcore.core.models.traits.KeyCredentialTrait")); - put(TypeReference.class, new ClassDetails(TypeReference.class, "io.clientcore.core.models.TypeReference")); - put(ClientLogger.class, new ClassDetails(ClientLogger.class, "io.clientcore.core.util.ClientLogger")); - put(LogLevel.class, new ClassDetails(LogLevel.class, "io.clientcore.core.util.ClientLogger.LogLevel")); - }}; - - private static ClassType.Builder getClassTypeBuilder(Class classKey) { - if (!JavaSettings.getInstance().isBranded()) { - if (CLASS_TYPE_MAPPING.containsKey(classKey)) { - return new ClassType.Builder(false).knownClass(CLASS_TYPE_MAPPING.get(classKey).getGenericClass()); - } else { - return new Builder(false).packageName(classKey.getPackage().getName() - .replace(ExternalPackage.AZURE_CORE_PACKAGE_NAME, ExternalPackage.CLIENTCORE_PACKAGE_NAME) - .replace(ExternalPackage.AZURE_JSON_PACKAGE_NAME, ExternalPackage.CLIENTCORE_JSON_PACKAGE_NAME)) - .name(classKey.getSimpleName()); - } - } else { - if (CLASS_TYPE_MAPPING.containsKey(classKey)) { - return new ClassType.Builder(false).knownClass(CLASS_TYPE_MAPPING.get(classKey).getAzureClass()); - } else { - return new Builder(false).packageName(classKey.getPackage().getName()).name(classKey.getSimpleName()); - } - } + public String getAzureClass() { + return azureClass.getName(); } - public static final ClassType REQUEST_CONDITIONS = new Builder().knownClass(RequestConditions.class).build(); - public static final ClassType MATCH_CONDITIONS = new Builder().knownClass(MatchConditions.class).build(); - public static final ClassType CORE_UTILS = getClassTypeBuilder(CoreUtils.class).build(); - public static final ClassType RESPONSE = getClassTypeBuilder(Response.class).build(); - public static final ClassType SIMPLE_RESPONSE = getClassTypeBuilder(SimpleResponse.class).build(); - public static final ClassType EXPANDABLE_STRING_ENUM = getClassTypeBuilder(ExpandableStringEnum.class).build(); - public static final ClassType HTTP_PIPELINE_BUILDER = getClassTypeBuilder(HttpPipelineBuilder.class).build(); - public static final ClassType KEY_CREDENTIAL_POLICY = getClassTypeBuilder(KeyCredentialPolicy.class).build(); - public static final ClassType KEY_CREDENTIAL_TRAIT = getClassTypeBuilder(KeyCredentialTrait.class).build(); - public static final ClassType ENDPOINT_TRAIT = getClassTypeBuilder(EndpointTrait.class).build(); - public static final ClassType HTTP_TRAIT = getClassTypeBuilder(HttpTrait.class).build(); - public static final ClassType CONFIGURATION_TRAIT = getClassTypeBuilder(ConfigurationTrait.class).build(); - public static final ClassType PROXY_TRAIT = new ClassType.Builder(false) - .packageName("io.clientcore.core.models.traits").name("ProxyTrait") - .build(); - public static final ClassType POLL_OPERATION_DETAILS = getClassTypeBuilder(PollOperationDetails.class).build(); - public static final ClassType JSON_SERIALIZABLE = getClassTypeBuilder(JsonSerializable.class).build(); - public static final ClassType JSON_WRITER = getClassTypeBuilder(JsonWriter.class).build(); - public static final ClassType JSON_READER = getClassTypeBuilder(JsonReader.class).build(); - public static final ClassType JSON_TOKEN = getClassTypeBuilder(JsonToken.class).build(); + public String getGenericClass() { + return genericClass; + } - public static final ClassType VOID = new ClassType.Builder(false).knownClass(Void.class).build(); + } - public static final ClassType BOOLEAN = new Builder(false).knownClass(Boolean.class) - .defaultValueExpressionConverter(String::toLowerCase) - .jsonToken("JsonToken.BOOLEAN") - .jsonDeserializationMethod("getNullable(JsonReader::getBoolean)") - .serializationMethodBase("writeBoolean") - .xmlElementDeserializationMethod("getNullableElement(Boolean::parseBoolean)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Boolean::parseBoolean)") - .build(); + private static final Map, ClassDetails> CLASS_TYPE_MAPPING = new HashMap, ClassDetails>() {{ + put(RestProxy.class, new ClassDetails(RestProxy.class, "io.clientcore.core.http.RestProxy")); + put(HttpPipeline.class, new ClassDetails(HttpPipeline.class, "io.clientcore.core.http.pipeline.HttpPipeline")); + put(HttpPipelineBuilder.class, new ClassDetails(HttpPipelineBuilder.class, "io.clientcore.core.http.pipeline.HttpPipelineBuilder")); + put(Context.class, new ClassDetails(Context.class, "io.clientcore.core.util.Context")); + put(HttpClient.class, new ClassDetails(HttpClient.class, "io.clientcore.core.http.client.HttpClient")); + put(HttpLogOptions.class, new ClassDetails(HttpLogOptions.class, "io.clientcore.core.http.models.HttpLogOptions")); + put(HttpPipelinePolicy.class, new ClassDetails(HttpPipelinePolicy.class, "io.clientcore.core.http.pipeline.HttpPipelinePolicy")); + put(KeyCredentialPolicy.class, new ClassDetails(KeyCredentialPolicy.class, "io.clientcore.core.http.pipeline.KeyCredentialPolicy")); + put(RetryPolicy.class, new ClassDetails(RetryPolicy.class, "io.clientcore.core.http.pipeline.HttpRetryPolicy")); + put(RedirectPolicy.class, new ClassDetails(RedirectPolicy.class, "io.clientcore.core.http.pipeline.HttpRedirectPolicy")); + put(Configuration.class, new ClassDetails(Configuration.class, "io.clientcore.core.util.configuration.Configuration")); + put(HttpHeaders.class, new ClassDetails(HttpHeaders.class, "io.clientcore.core.models.Headers")); + put(HttpHeaderName.class, new ClassDetails(HttpHeaderName.class, "io.clientcore.core.http.models.HttpHeaderName")); + put(HttpRequest.class, new ClassDetails(HttpRequest.class, "io.clientcore.core.http.models.HttpRequest")); + put(RequestOptions.class, new ClassDetails(RequestOptions.class, "io.clientcore.core.http.models.RequestOptions")); + put(BinaryData.class, new ClassDetails(BinaryData.class, "io.clientcore.core.util.binarydata.BinaryData")); + put(RetryOptions.class, new ClassDetails(RetryOptions.class, "io.clientcore.core.http.models.HttpRetryOptions")); + put(ProxyOptions.class, new ClassDetails(ProxyOptions.class, "io.clientcore.core.http.models.ProxyOptions")); + put(Response.class, new ClassDetails(Response.class, "io.clientcore.core.http.models.Response")); + put(SimpleResponse.class, new ClassDetails(SimpleResponse.class, "io.clientcore.core.http.SimpleResponse")); + put(ExpandableStringEnum.class, new ClassDetails(ExpandableStringEnum.class, "io.clientcore.core.util.ExpandableEnum")); + put(HttpResponseException.class, new ClassDetails(HttpResponseException.class, "io.clientcore.core.http.exception.HttpResponseException")); + put(HttpTrait.class, new ClassDetails(HttpTrait.class, "io.clientcore.core.models.traits.HttpTrait")); + put(ConfigurationTrait.class, new ClassDetails(ConfigurationTrait.class, "io.clientcore.core.models.traits.ConfigurationTrait")); + put(EndpointTrait.class, new ClassDetails(EndpointTrait.class, "io.clientcore.core.models.traits.EndpointTrait")); + put(KeyCredentialTrait.class, new ClassDetails(KeyCredentialTrait.class, "io.clientcore.core.models.traits.KeyCredentialTrait")); + put(TypeReference.class, new ClassDetails(TypeReference.class, "io.clientcore.core.models.TypeReference")); + put(ClientLogger.class, new ClassDetails(ClientLogger.class, "io.clientcore.core.util.ClientLogger")); + put(LogLevel.class, new ClassDetails(LogLevel.class, "io.clientcore.core.util.ClientLogger.LogLevel")); + }}; - public static final ClassType BYTE = new Builder(false).knownClass(Byte.class) - .jsonDeserializationMethod("getNullable(JsonReader::getInt)") - .jsonToken("JsonToken.NUMBER") - .serializationMethodBase("writeNumber") - .xmlElementDeserializationMethod("getNullableElement(Byte::parseByte)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Byte::parseByte)") - .build(); + private static ClassType.Builder getClassTypeBuilder(Class classKey) { + if (!JavaSettings.getInstance().isBranded()) { + if (CLASS_TYPE_MAPPING.containsKey(classKey)) { + return new ClassType.Builder(false).knownClass(CLASS_TYPE_MAPPING.get(classKey).getGenericClass()); + } else { + return new Builder(false).packageName(classKey.getPackage().getName() + .replace(ExternalPackage.AZURE_CORE_PACKAGE_NAME, ExternalPackage.CLIENTCORE_PACKAGE_NAME) + .replace(ExternalPackage.AZURE_JSON_PACKAGE_NAME, ExternalPackage.CLIENTCORE_JSON_PACKAGE_NAME)) + .name(classKey.getSimpleName()); + } + } else { + if (CLASS_TYPE_MAPPING.containsKey(classKey)) { + return new ClassType.Builder(false).knownClass(CLASS_TYPE_MAPPING.get(classKey).getAzureClass()); + } else { + return new Builder(false).packageName(classKey.getPackage().getName()).name(classKey.getSimpleName()); + } + } + } - public static final ClassType INTEGER = new Builder(false).knownClass(Integer.class) - .defaultValueExpressionConverter(Function.identity()) - .jsonToken("JsonToken.NUMBER") - .jsonDeserializationMethod("getNullable(JsonReader::getInt)") - .serializationMethodBase("writeNumber") - .xmlElementDeserializationMethod("getNullableElement(Integer::parseInt)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Integer::parseInt)") - .build(); + public static final ClassType REQUEST_CONDITIONS = new Builder().knownClass(RequestConditions.class).build(); + public static final ClassType MATCH_CONDITIONS = new Builder().knownClass(MatchConditions.class).build(); + public static final ClassType CORE_UTILS = getClassTypeBuilder(CoreUtils.class).build(); + public static final ClassType RESPONSE = getClassTypeBuilder(Response.class).build(); + public static final ClassType SIMPLE_RESPONSE = getClassTypeBuilder(SimpleResponse.class).build(); + public static final ClassType EXPANDABLE_STRING_ENUM = getClassTypeBuilder(ExpandableStringEnum.class).build(); + public static final ClassType HTTP_PIPELINE_BUILDER = getClassTypeBuilder(HttpPipelineBuilder.class).build(); + public static final ClassType KEY_CREDENTIAL_POLICY = getClassTypeBuilder(KeyCredentialPolicy.class).build(); + public static final ClassType KEY_CREDENTIAL_TRAIT = getClassTypeBuilder(KeyCredentialTrait.class).build(); + public static final ClassType ENDPOINT_TRAIT = getClassTypeBuilder(EndpointTrait.class).build(); + public static final ClassType HTTP_TRAIT = getClassTypeBuilder(HttpTrait.class).build(); + public static final ClassType CONFIGURATION_TRAIT = getClassTypeBuilder(ConfigurationTrait.class).build(); + public static final ClassType PROXY_TRAIT = new ClassType.Builder(false) + .packageName("io.clientcore.core.models.traits").name("ProxyTrait") + .build(); + public static final ClassType POLL_OPERATION_DETAILS = getClassTypeBuilder(PollOperationDetails.class).build(); + public static final ClassType JSON_SERIALIZABLE = getClassTypeBuilder(JsonSerializable.class).build(); + public static final ClassType JSON_WRITER = getClassTypeBuilder(JsonWriter.class).build(); + public static final ClassType JSON_READER = getClassTypeBuilder(JsonReader.class).build(); + public static final ClassType JSON_TOKEN = getClassTypeBuilder(JsonToken.class).build(); - public static final ClassType LONG = new Builder(false) - .prototypeAsLong() - .build(); + public static final ClassType VOID = new ClassType.Builder(false).knownClass(Void.class).build(); - public static final ClassType FLOAT = new Builder(false).knownClass(Float.class) - .defaultValueExpressionConverter(defaultValueExpression -> Float.parseFloat(defaultValueExpression) + "F") - .jsonToken("JsonToken.NUMBER") - .jsonDeserializationMethod("getNullable(JsonReader::getFloat)") - .serializationMethodBase("writeNumber") - .xmlElementDeserializationMethod("getNullableElement(Float::parseFloat)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Float::parseFloat)") - .build(); + public static final ClassType BOOLEAN = new Builder(false).knownClass(Boolean.class) + .defaultValueExpressionConverter(String::toLowerCase) + .jsonToken("JsonToken.BOOLEAN") + .jsonDeserializationMethod("getNullable(JsonReader::getBoolean)") + .serializationMethodBase("writeBoolean") + .xmlElementDeserializationMethod("getNullableElement(Boolean::parseBoolean)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Boolean::parseBoolean)") + .build(); - public static final ClassType DOUBLE = new Builder(false).knownClass(Double.class) - .prototypeAsDouble() - .build(); + public static final ClassType BYTE = new Builder(false).knownClass(Byte.class) + .jsonDeserializationMethod("getNullable(JsonReader::getInt)") + .jsonToken("JsonToken.NUMBER") + .serializationMethodBase("writeNumber") + .xmlElementDeserializationMethod("getNullableElement(Byte::parseByte)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Byte::parseByte)") + .build(); - public static final ClassType CHARACTER = new Builder(false).knownClass(Character.class) - .defaultValueExpressionConverter(defaultValueExpression -> String.valueOf((defaultValueExpression.charAt(0)))) - .jsonToken("JsonToken.STRING") - .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") - .jsonDeserializationMethod("getNullable(nonNullReader -> nonNullReader.getString().charAt(0))") - .serializationMethodBase("writeString") - .xmlElementDeserializationMethod("getNullableElement(nonNullString -> nonNullString.charAt(0))") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, nonNullString -> nonNullString.charAt(0))") - .build(); + public static final ClassType INTEGER = new Builder(false).knownClass(Integer.class) + .defaultValueExpressionConverter(Function.identity()) + .jsonToken("JsonToken.NUMBER") + .jsonDeserializationMethod("getNullable(JsonReader::getInt)") + .serializationMethodBase("writeNumber") + .xmlElementDeserializationMethod("getNullableElement(Integer::parseInt)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Integer::parseInt)") + .build(); - public static final ClassType STRING = new Builder(false).knownClass(String.class) - .defaultValueExpressionConverter(defaultValueExpression -> "\"" + TemplateUtil.escapeString(defaultValueExpression) + "\"") - .jsonToken("JsonToken.STRING") - .jsonDeserializationMethod("getString()") - .serializationMethodBase("writeString") - .xmlElementDeserializationMethod("getStringElement()") - .xmlAttributeDeserializationTemplate("%s.getStringAttribute(%s, %s)") - .build(); + public static final ClassType INTEGER_AS_STRING = new Builder(false) + .knownClass(Integer.class) + .defaultValueExpressionConverter(defaultValueExpression -> "Integer.parseInt(\"" + defaultValueExpression + "\")") + .jsonToken("JsonToken.NUMBER") + .jsonDeserializationMethod("getNullable(nonNullReader -> Integer.parseInt(nonNullReader.getString()))") + .serializationMethodBase("writeString") + .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") + .xmlElementDeserializationMethod("getNullableElement(Integer::valueOf)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Integer::valueOf)") + .build(); - public static final ClassType BASE_64_URL = getClassTypeBuilder(Base64Url.class) - .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") - .jsonToken("JsonToken.STRING") - .jsonDeserializationMethod("getNullable(nonNullReader -> new Base64Url(nonNullReader.getString()))") - .serializationMethodBase("writeString") - .xmlElementDeserializationMethod("getNullableElement(Base64Url::new)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Base64Url::new)") - .build(); + public static final ClassType LONG = new Builder(false) + .prototypeAsLong() + .build(); - public static final ClassType ANDROID_BASE_64_URL = new ClassType.Builder(false) - .packageName("com.azure.android.core.util").name("Base64Url") - .build(); + public static final ClassType LONG_AS_STRING = new Builder(false) + .prototypeAsLong() + .defaultValueExpressionConverter(defaultValueExpression -> "Long.parseLong(\"" + defaultValueExpression + "\")") + .jsonToken("JsonToken.STRING") + .jsonDeserializationMethod("getNullable(nonNullReader -> Long.parseLong(nonNullReader.getString()))") + .serializationMethodBase("writeString") + .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") + .xmlElementDeserializationMethod("getNullableElement(Long::valueOf)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Long::valueOf)") + .build(); - public static final ClassType LOCAL_DATE = new Builder(false).knownClass(java.time.LocalDate.class) - .defaultValueExpressionConverter(defaultValueExpression -> "LocalDate.parse(\"" + defaultValueExpression + "\")") - .jsonToken("JsonToken.STRING") - .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") - .jsonDeserializationMethod("getNullable(nonNullReader -> LocalDate.parse(nonNullReader.getString()))") - .serializationMethodBase("writeString") - .xmlElementDeserializationMethod("getNullableElement(LocalDate::parse)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, LocalDate::parse)") - .build(); + public static final ClassType FLOAT = new Builder(false).knownClass(Float.class) + .defaultValueExpressionConverter(defaultValueExpression -> Float.parseFloat(defaultValueExpression) + "F") + .jsonToken("JsonToken.NUMBER") + .jsonDeserializationMethod("getNullable(JsonReader::getFloat)") + .serializationMethodBase("writeNumber") + .xmlElementDeserializationMethod("getNullableElement(Float::parseFloat)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Float::parseFloat)") + .build(); - public static final ClassType ANDROID_LOCAL_DATE = new ClassType.Builder(false) - .packageName("org.threeten.bp").name("LocalDate") - .build(); + public static final ClassType DOUBLE = new Builder(false).knownClass(Double.class) + .prototypeAsDouble() + .build(); - public static final ClassType DATE_TIME = new Builder(false).knownClass(OffsetDateTime.class) - .defaultValueExpressionConverter(defaultValueExpression -> "OffsetDateTime.parse(\"" + defaultValueExpression + "\")") - .jsonToken("JsonToken.STRING") - .serializationValueGetterModifier(valueGetter -> valueGetter + " == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(" + valueGetter + ")") - .jsonDeserializationMethod("getNullable(nonNullReader -> " + CORE_UTILS.getName() + ".parseBestOffsetDateTime(nonNullReader.getString()))") - .serializationMethodBase("writeString") - .xmlElementDeserializationMethod("getNullableElement(dateString -> " + CORE_UTILS.getName() + ".parseBestOffsetDateTime(dateString))") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, dateString -> " + CORE_UTILS.getName() + ".parseBestOffsetDateTime(dateString))") - .build(); + public static final ClassType CHARACTER = new Builder(false).knownClass(Character.class) + .defaultValueExpressionConverter(defaultValueExpression -> String.valueOf((defaultValueExpression.charAt(0)))) + .jsonToken("JsonToken.STRING") + .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") + .jsonDeserializationMethod("getNullable(nonNullReader -> nonNullReader.getString().charAt(0))") + .serializationMethodBase("writeString") + .xmlElementDeserializationMethod("getNullableElement(nonNullString -> nonNullString.charAt(0))") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, nonNullString -> nonNullString.charAt(0))") + .build(); - public static final ClassType DURATION = new Builder(false).knownClass(Duration.class) - .defaultValueExpressionConverter(defaultValueExpression -> "Duration.parse(\"" + defaultValueExpression + "\")") - .jsonToken("JsonToken.STRING") - .serializationValueGetterModifier(valueGetter -> CORE_UTILS.getName() + ".durationToStringWithDays(" + valueGetter + ")") - .jsonDeserializationMethod("getNullable(nonNullReader -> Duration.parse(nonNullReader.getString()))") - .serializationMethodBase("writeString") - .xmlElementDeserializationMethod("getNullableElement(Duration::parse)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Duration::parse)") - .build(); + public static final ClassType STRING = new Builder(false).knownClass(String.class) + .defaultValueExpressionConverter(defaultValueExpression -> "\"" + TemplateUtil.escapeString(defaultValueExpression) + "\"") + .jsonToken("JsonToken.STRING") + .jsonDeserializationMethod("getString()") + .serializationMethodBase("writeString") + .xmlElementDeserializationMethod("getStringElement()") + .xmlAttributeDeserializationTemplate("%s.getStringAttribute(%s, %s)") + .build(); - public static final ClassType ANDROID_DURATION = new ClassType.Builder(false) - .packageName("org.threeten.bp").name("Duration") - .build(); + public static final ClassType BASE_64_URL = getClassTypeBuilder(Base64Url.class) + .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") + .jsonToken("JsonToken.STRING") + .jsonDeserializationMethod("getNullable(nonNullReader -> new Base64Url(nonNullReader.getString()))") + .serializationMethodBase("writeString") + .xmlElementDeserializationMethod("getNullableElement(Base64Url::new)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Base64Url::new)") + .build(); - public static final ClassType DATE_TIME_RFC_1123 = getClassTypeBuilder(DateTimeRfc1123.class) - .defaultValueExpressionConverter(defaultValueExpression -> "new DateTimeRfc1123(\"" + defaultValueExpression + "\")") - .jsonToken("JsonToken.STRING") - .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") - .jsonDeserializationMethod("getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString()))") - .serializationMethodBase("writeString") - .xmlElementDeserializationMethod("getNullableElement(DateTimeRfc1123::new)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, DateTimeRfc1123::new)") - .build(); + public static final ClassType ANDROID_BASE_64_URL = new ClassType.Builder(false) + .packageName("com.azure.android.core.util").name("Base64Url") + .build(); - public static final ClassType ANDROID_DATE_TIME_RFC_1123 = new ClassType.Builder(false) - .packageName("com.azure.android.core.util").name("DateTimeRfc1123") - .build(); + public static final ClassType LOCAL_DATE = new Builder(false).knownClass(java.time.LocalDate.class) + .defaultValueExpressionConverter(defaultValueExpression -> "LocalDate.parse(\"" + defaultValueExpression + "\")") + .jsonToken("JsonToken.STRING") + .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") + .jsonDeserializationMethod("getNullable(nonNullReader -> LocalDate.parse(nonNullReader.getString()))") + .serializationMethodBase("writeString") + .xmlElementDeserializationMethod("getNullableElement(LocalDate::parse)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, LocalDate::parse)") + .build(); - public static final ClassType BIG_DECIMAL = new Builder(false).knownClass(BigDecimal.class) - .defaultValueExpressionConverter(defaultValueExpression -> "new BigDecimal(\"" + defaultValueExpression + "\")") - .jsonToken("JsonToken.NUMBER") - .serializationMethodBase("writeNumber") - .jsonDeserializationMethod("getNullable(nonNullReader -> new BigDecimal(nonNullReader.getString()))") - .xmlElementDeserializationMethod("getNullableElement(BigDecimal::new)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, BigDecimal::new)") - .build(); + public static final ClassType ANDROID_LOCAL_DATE = new ClassType.Builder(false) + .packageName("org.threeten.bp").name("LocalDate") + .build(); - public static final ClassType UUID = new Builder(false).knownClass(java.util.UUID.class) - .defaultValueExpressionConverter(defaultValueExpression -> "UUID.fromString(\"" + defaultValueExpression + "\")") - .jsonToken("JsonToken.STRING") - .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") - .jsonDeserializationMethod("getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString()))") - .serializationMethodBase("writeString") - .xmlElementDeserializationMethod("getNullableElement(UUID::fromString)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, UUID::fromString)") - .build(); + public static final ClassType DATE_TIME = new Builder(false).knownClass(OffsetDateTime.class) + .defaultValueExpressionConverter(defaultValueExpression -> "OffsetDateTime.parse(\"" + defaultValueExpression + "\")") + .jsonToken("JsonToken.STRING") + .serializationValueGetterModifier(valueGetter -> valueGetter + " == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(" + valueGetter + ")") + .jsonDeserializationMethod("getNullable(nonNullReader -> " + CORE_UTILS.getName() + ".parseBestOffsetDateTime(nonNullReader.getString()))") + .serializationMethodBase("writeString") + .xmlElementDeserializationMethod("getNullableElement(dateString -> " + CORE_UTILS.getName() + ".parseBestOffsetDateTime(dateString))") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, dateString -> " + CORE_UTILS.getName() + ".parseBestOffsetDateTime(dateString))") + .build(); - public static final ClassType OBJECT = new ClassType.Builder(false) - .knownClass(Object.class) - .build(); + public static final ClassType DURATION = new Builder(false).knownClass(Duration.class) + .defaultValueExpressionConverter(defaultValueExpression -> "Duration.parse(\"" + defaultValueExpression + "\")") + .jsonToken("JsonToken.STRING") + .serializationValueGetterModifier(valueGetter -> CORE_UTILS.getName() + ".durationToStringWithDays(" + valueGetter + ")") + .jsonDeserializationMethod("getNullable(nonNullReader -> Duration.parse(nonNullReader.getString()))") + .serializationMethodBase("writeString") + .xmlElementDeserializationMethod("getNullableElement(Duration::parse)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Duration::parse)") + .build(); - public static final ClassType TOKEN_CREDENTIAL = new ClassType.Builder(false).knownClass(TokenCredential.class) - .build(); + public static final ClassType ANDROID_DURATION = new ClassType.Builder(false) + .packageName("org.threeten.bp").name("Duration") + .build(); - public static final ClassType ANDROID_HTTP_RESPONSE_EXCEPTION = new ClassType.Builder(false) - .packageName("com.azure.android.core.http.exception").name("HttpResponseException") - .build(); + public static final ClassType DATE_TIME_RFC_1123 = getClassTypeBuilder(DateTimeRfc1123.class) + .defaultValueExpressionConverter(defaultValueExpression -> "new DateTimeRfc1123(\"" + defaultValueExpression + "\")") + .jsonToken("JsonToken.STRING") + .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") + .jsonDeserializationMethod("getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString()))") + .serializationMethodBase("writeString") + .xmlElementDeserializationMethod("getNullableElement(DateTimeRfc1123::new)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, DateTimeRfc1123::new)") + .build(); - public static final ClassType UNIX_TIME_DATE_TIME = new ClassType.Builder(false) - .defaultValueExpressionConverter(defaultValueExpression -> "OffsetDateTime.parse(\"" + defaultValueExpression + "\")") - .jsonToken("JsonToken.STRING") - .knownClass(OffsetDateTime.class) - .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") - .jsonDeserializationMethod("getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))") - .serializationMethodBase("writeString") - .xmlElementDeserializationMethod("getNullableElement(OffsetDateTime::parse)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, OffsetDateTime::parse)") - .build(); + public static final ClassType ANDROID_DATE_TIME_RFC_1123 = new ClassType.Builder(false) + .packageName("com.azure.android.core.util").name("DateTimeRfc1123") + .build(); - public static final ClassType ANDROID_DATE_TIME = new ClassType.Builder(false) - .packageName("org.threeten.bp").name("OffsetDateTime") - .build(); + public static final ClassType BIG_DECIMAL = new Builder(false).knownClass(BigDecimal.class) + .defaultValueExpressionConverter(defaultValueExpression -> "new BigDecimal(\"" + defaultValueExpression + "\")") + .jsonToken("JsonToken.NUMBER") + .serializationMethodBase("writeNumber") + .jsonDeserializationMethod("getNullable(nonNullReader -> new BigDecimal(nonNullReader.getString()))") + .xmlElementDeserializationMethod("getNullableElement(BigDecimal::new)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, BigDecimal::new)") + .build(); - public static final ClassType UNIX_TIME_LONG = new ClassType.Builder(false) - .prototypeAsLong() - .build(); + public static final ClassType UUID = new Builder(false).knownClass(java.util.UUID.class) + .defaultValueExpressionConverter(defaultValueExpression -> "UUID.fromString(\"" + defaultValueExpression + "\")") + .jsonToken("JsonToken.STRING") + .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") + .jsonDeserializationMethod("getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString()))") + .serializationMethodBase("writeString") + .xmlElementDeserializationMethod("getNullableElement(UUID::fromString)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, UUID::fromString)") + .build(); - public static final ClassType DURATION_LONG = new ClassType.Builder(false) - .prototypeAsLong() - .build(); + public static final ClassType OBJECT = new ClassType.Builder(false) + .knownClass(Object.class) + .build(); - public static final ClassType DURATION_DOUBLE = new ClassType.Builder(false) - .prototypeAsDouble() - .build(); + public static final ClassType TOKEN_CREDENTIAL = new ClassType.Builder(false).knownClass(TokenCredential.class) + .build(); - public static final ClassType HTTP_PIPELINE = getClassTypeBuilder(HttpPipeline.class).build(); + public static final ClassType ANDROID_HTTP_RESPONSE_EXCEPTION = new ClassType.Builder(false) + .packageName("com.azure.android.core.http.exception").name("HttpResponseException") + .build(); - public static final ClassType ANDROID_HTTP_PIPELINE = new ClassType.Builder(false) - .packageName("com.azure.android.core.http").name("HttpPipeline") - .build(); + public static final ClassType UNIX_TIME_DATE_TIME = new ClassType.Builder(false) + .defaultValueExpressionConverter(defaultValueExpression -> "OffsetDateTime.parse(\"" + defaultValueExpression + "\")") + .jsonToken("JsonToken.STRING") + .knownClass(OffsetDateTime.class) + .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") + .jsonDeserializationMethod("getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))") + .serializationMethodBase("writeString") + .xmlElementDeserializationMethod("getNullableElement(OffsetDateTime::parse)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, OffsetDateTime::parse)") + .build(); - public static final ClassType REST_PROXY = getClassTypeBuilder(RestProxy.class).build(); + public static final ClassType ANDROID_DATE_TIME = new ClassType.Builder(false) + .packageName("org.threeten.bp").name("OffsetDateTime") + .build(); - public static final ClassType ANDROID_REST_PROXY = new ClassType.Builder(false) - .packageName("com.azure.android.core.rest").name("RestProxy") - .build(); + public static final ClassType UNIX_TIME_LONG = new ClassType.Builder(false) + .prototypeAsLong() + .build(); - public static final ClassType SERIALIZER_ADAPTER = new ClassType.Builder(false).knownClass(SerializerAdapter.class) - .build(); - public static final ClassType JSON_SERIALIZER = getClassTypeBuilder(JsonSerializer.class) - .build(); + public static final ClassType DURATION_LONG = new ClassType.Builder(false) + .prototypeAsLong() + .build(); - public static final ClassType ANDROID_JACKSON_SERDER = new ClassType.Builder(false) - .packageName("com.azure.android.core.serde.jackson").name("JacksonSerder") - .build(); + public static final ClassType DURATION_DOUBLE = new ClassType.Builder(false) + .prototypeAsDouble() + .build(); - public static final ClassType FUNCTION = new ClassType.Builder(false).knownClass(Function.class).build(); + public static final ClassType HTTP_PIPELINE = getClassTypeBuilder(HttpPipeline.class).build(); - public static final ClassType BYTE_BUFFER = new ClassType.Builder(false).knownClass(ByteBuffer.class).build(); + public static final ClassType ANDROID_HTTP_PIPELINE = new ClassType.Builder(false) + .packageName("com.azure.android.core.http").name("HttpPipeline") + .build(); - public static final ClassType URL = new Builder(false) - .defaultValueExpressionConverter(defaultValueExpression -> "new URL(\"" + defaultValueExpression + "\")") - .knownClass(java.net.URL.class) - .jsonToken("JsonToken.STRING") - .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") - .jsonDeserializationMethod("getNullable(nonNullReader -> new URL(nonNullReader.getString()))") - .serializationMethodBase("writeString") - .xmlElementDeserializationMethod("getNullableElement(urlString -> { try { return new URL(urlString); } catch (MalformedURLException e) { throw new XMLStreamException(e); } })") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, URL::new)") - .build(); + public static final ClassType REST_PROXY = getClassTypeBuilder(RestProxy.class).build(); - public static final ClassType STREAM_RESPONSE = new ClassType.Builder(false).knownClass(StreamResponse.class) - .build(); + public static final ClassType ANDROID_REST_PROXY = new ClassType.Builder(false) + .packageName("com.azure.android.core.rest").name("RestProxy") + .build(); - public static final ClassType INPUT_STREAM = new ClassType.Builder(false).knownClass(InputStream.class) - .build(); + public static final ClassType SERIALIZER_ADAPTER = new ClassType.Builder(false).knownClass(SerializerAdapter.class) + .build(); + public static final ClassType JSON_SERIALIZER = getClassTypeBuilder(JsonSerializer.class) + .build(); - public static final ClassType CONTEXT = ClassType.getClassTypeBuilder(Context.class) - .defaultValueExpressionConverter(epr -> "com.azure.core.util.Context.NONE") - .build(); + public static final ClassType ANDROID_JACKSON_SERDER = new ClassType.Builder(false) + .packageName("com.azure.android.core.serde.jackson").name("JacksonSerder") + .build(); - public static final ClassType ANDROID_CONTEXT = new ClassType.Builder(false) - .packageName("com.azure.android.core.util").name("Context") - .build(); + public static final ClassType FUNCTION = new ClassType.Builder(false).knownClass(Function.class).build(); - public static final ClassType CLIENT_LOGGER = ClassType.getClassTypeBuilder(ClientLogger.class).build(); - public static final ClassType LOG_LEVEL = ClassType.getClassTypeBuilder(LogLevel.class).build(); + public static final ClassType BYTE_BUFFER = new ClassType.Builder(false).knownClass(ByteBuffer.class).build(); - public static final ClassType AZURE_ENVIRONMENT = new ClassType.Builder(false) - .packageName("com.azure.core.management").name("AzureEnvironment") - .build(); + public static final ClassType URL = new Builder(false) + .defaultValueExpressionConverter(defaultValueExpression -> "new URL(\"" + defaultValueExpression + "\")") + .knownClass(java.net.URL.class) + .jsonToken("JsonToken.STRING") + .serializationValueGetterModifier(valueGetter -> "Objects.toString(" + valueGetter + ", null)") + .jsonDeserializationMethod("getNullable(nonNullReader -> new URL(nonNullReader.getString()))") + .serializationMethodBase("writeString") + .xmlElementDeserializationMethod("getNullableElement(urlString -> { try { return new URL(urlString); } catch (MalformedURLException e) { throw new XMLStreamException(e); } })") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, URL::new)") + .build(); - public static final ClassType HTTP_CLIENT = getClassTypeBuilder(HttpClient.class).build(); + public static final ClassType STREAM_RESPONSE = new ClassType.Builder(false).knownClass(StreamResponse.class) + .build(); - public static final ClassType ANDROID_HTTP_CLIENT = new ClassType.Builder(false) - .packageName("com.azure.android.core.http").name("HttpClient") - .build(); + public static final ClassType INPUT_STREAM = new ClassType.Builder(false).knownClass(InputStream.class) + .build(); - public static final ClassType HTTP_PIPELINE_POLICY = getClassTypeBuilder(HttpPipelinePolicy.class).build(); + public static final ClassType CONTEXT = ClassType.getClassTypeBuilder(Context.class) + .defaultValueExpressionConverter(epr -> "com.azure.core.util.Context.NONE") + .build(); - public static final ClassType ANDROID_HTTP_PIPELINE_POLICY = new ClassType.Builder(false) - .packageName("com.azure.android.core.http").name("HttpPipelinePolicy") - .build(); + public static final ClassType ANDROID_CONTEXT = new ClassType.Builder(false) + .packageName("com.azure.android.core.util").name("Context") + .build(); - public static final ClassType HTTP_LOG_OPTIONS = getClassTypeBuilder(HttpLogOptions.class).build(); + public static final ClassType CLIENT_LOGGER = ClassType.getClassTypeBuilder(ClientLogger.class).build(); + public static final ClassType LOG_LEVEL = ClassType.getClassTypeBuilder(LogLevel.class).build(); - public static final ClassType ANDROID_HTTP_LOG_OPTIONS = new ClassType.Builder(false) - .packageName("com.azure.android.core.http.policy").name("HttpLogOptions") - .build(); + public static final ClassType AZURE_ENVIRONMENT = new ClassType.Builder(false) + .packageName("com.azure.core.management").name("AzureEnvironment") + .build(); - public static final ClassType CONFIGURATION = getClassTypeBuilder(Configuration.class).build(); + public static final ClassType HTTP_CLIENT = getClassTypeBuilder(HttpClient.class).build(); - public static final ClassType SERVICE_VERSION = new ClassType.Builder(false).knownClass(ServiceVersion.class) - .build(); + public static final ClassType ANDROID_HTTP_CLIENT = new ClassType.Builder(false) + .packageName("com.azure.android.core.http").name("HttpClient") + .build(); - public static final ClassType AZURE_KEY_CREDENTIAL = new ClassType.Builder(false) - .knownClass(AzureKeyCredential.class) - .build(); + public static final ClassType HTTP_PIPELINE_POLICY = getClassTypeBuilder(HttpPipelinePolicy.class).build(); - public static final ClassType KEY_CREDENTIAL = getClassTypeBuilder(KeyCredential.class).build(); + public static final ClassType ANDROID_HTTP_PIPELINE_POLICY = new ClassType.Builder(false) + .packageName("com.azure.android.core.http").name("HttpPipelinePolicy") + .build(); - public static final ClassType RETRY_POLICY = getClassTypeBuilder(RetryPolicy.class).build(); - public static final ClassType REDIRECT_POLICY = getClassTypeBuilder(RedirectPolicy.class).build(); + public static final ClassType HTTP_LOG_OPTIONS = getClassTypeBuilder(HttpLogOptions.class).build(); - public static final ClassType RETRY_OPTIONS = getClassTypeBuilder(RetryOptions.class).build(); + public static final ClassType ANDROID_HTTP_LOG_OPTIONS = new ClassType.Builder(false) + .packageName("com.azure.android.core.http.policy").name("HttpLogOptions") + .build(); - public static final ClassType REDIRECT_OPTIONS = new ClassType.Builder(false) - .packageName("io.clientcore.core.http.models").name("HttpRedirectOptions") - .build(); + public static final ClassType CONFIGURATION = getClassTypeBuilder(Configuration.class).build(); - public static final ClassType ANDROID_RETRY_POLICY = new ClassType.Builder(false) - .packageName("com.azure.android.core.http.policy").name("RetryPolicy") - .build(); + public static final ClassType SERVICE_VERSION = new ClassType.Builder(false).knownClass(ServiceVersion.class) + .build(); - public static final ClassType JSON_PATCH_DOCUMENT = new ClassType.Builder(false).knownClass(JsonPatchDocument.class) - .jsonToken("JsonToken.START_OBJECT") - .build(); + public static final ClassType AZURE_KEY_CREDENTIAL = new ClassType.Builder(false) + .knownClass(AzureKeyCredential.class) + .build(); - public static final ClassType BINARY_DATA = getClassTypeBuilder(BinaryData.class) - .defaultValueExpressionConverter(defaultValueExpression -> "BinaryData.fromObject(\"" + defaultValueExpression + "\")") - // When used as model property, serialization code will not use the "writeUntyped(nullableVar)", - // because some backend would fail the request on "null" value. - .serializationMethodBase("writeUntyped") - .serializationValueGetterModifier(valueGetter -> valueGetter + " == null ? null : " + valueGetter + ".toObject(Object.class)") - .jsonDeserializationMethod("getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))") - .xmlElementDeserializationMethod("getNullableElement(BinaryData::fromObject)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, BinaryData::fromObject)") - .build(); + public static final ClassType KEY_CREDENTIAL = getClassTypeBuilder(KeyCredential.class).build(); - public static final ClassType REQUEST_OPTIONS = getClassTypeBuilder(RequestOptions.class).build(); - public static final ClassType PROXY_OPTIONS = getClassTypeBuilder(ProxyOptions.class).build(); - public static final ClassType CLIENT_OPTIONS = getClassTypeBuilder(ClientOptions.class).build(); - public static final ClassType HTTP_REQUEST = getClassTypeBuilder(HttpRequest.class).build(); - public static final ClassType HTTP_HEADERS = getClassTypeBuilder(HttpHeaders.class).build(); - public static final ClassType HTTP_HEADER_NAME = getClassTypeBuilder(HttpHeaderName.class).build(); + public static final ClassType RETRY_POLICY = getClassTypeBuilder(RetryPolicy.class).build(); + public static final ClassType REDIRECT_POLICY = getClassTypeBuilder(RedirectPolicy.class).build(); - // Java exception types - public static final ClassType HTTP_RESPONSE_EXCEPTION = getClassTypeBuilder(HttpResponseException.class).build(); - public static final ClassType CLIENT_AUTHENTICATION_EXCEPTION = getClassTypeBuilder(ClientAuthenticationException.class) - .build(); - public static final ClassType RESOURCE_EXISTS_EXCEPTION = getClassTypeBuilder(ResourceExistsException.class) - .build(); - public static final ClassType RESOURCE_MODIFIED_EXCEPTION = getClassTypeBuilder(ResourceModifiedException.class) - .build(); - public static final ClassType RESOURCE_NOT_FOUND_EXCEPTION = getClassTypeBuilder(ResourceNotFoundException.class) - .build(); - public static final ClassType TOO_MANY_REDIRECTS_EXCEPTION = getClassTypeBuilder(TooManyRedirectsException.class) - .build(); - public static final ClassType RESPONSE_ERROR = new Builder() - .knownClass(ResponseError.class) - .jsonToken("JsonToken.START_OBJECT") - .build(); - public static final ClassType RESPONSE_INNER_ERROR = new Builder() - .packageName("com.azure.core.models").name("ResponseInnerError") - .jsonToken("JsonToken.START_OBJECT") - .build(); + public static final ClassType RETRY_OPTIONS = getClassTypeBuilder(RetryOptions.class).build(); - private final String fullName; - private final String packageName; - private final String name; - private final List implementationImports; - private final XmsExtensions extensions; - private final Function defaultValueExpressionConverter; + public static final ClassType REDIRECT_OPTIONS = new ClassType.Builder(false) + .packageName("io.clientcore.core.http.models").name("HttpRedirectOptions") + .build(); + + public static final ClassType ANDROID_RETRY_POLICY = new ClassType.Builder(false) + .packageName("com.azure.android.core.http.policy").name("RetryPolicy") + .build(); + + public static final ClassType JSON_PATCH_DOCUMENT = new ClassType.Builder(false).knownClass(JsonPatchDocument.class) + .jsonToken("JsonToken.START_OBJECT") + .build(); + + public static final ClassType BINARY_DATA = getClassTypeBuilder(BinaryData.class) + .defaultValueExpressionConverter(defaultValueExpression -> "BinaryData.fromObject(\"" + defaultValueExpression + "\")") + // When used as model property, serialization code will not use the "writeUntyped(nullableVar)", + // because some backend would fail the request on "null" value. + .serializationMethodBase("writeUntyped") + .serializationValueGetterModifier(valueGetter -> valueGetter + " == null ? null : " + valueGetter + ".toObject(Object.class)") + .jsonDeserializationMethod("getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))") + .xmlElementDeserializationMethod("getNullableElement(BinaryData::fromObject)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, BinaryData::fromObject)") + .build(); + + public static final ClassType REQUEST_OPTIONS = getClassTypeBuilder(RequestOptions.class).build(); + public static final ClassType PROXY_OPTIONS = getClassTypeBuilder(ProxyOptions.class).build(); + public static final ClassType CLIENT_OPTIONS = getClassTypeBuilder(ClientOptions.class).build(); + public static final ClassType HTTP_REQUEST = getClassTypeBuilder(HttpRequest.class).build(); + public static final ClassType HTTP_HEADERS = getClassTypeBuilder(HttpHeaders.class).build(); + public static final ClassType HTTP_HEADER_NAME = getClassTypeBuilder(HttpHeaderName.class).build(); + + // Java exception types + public static final ClassType HTTP_RESPONSE_EXCEPTION = getClassTypeBuilder(HttpResponseException.class).build(); + public static final ClassType CLIENT_AUTHENTICATION_EXCEPTION = getClassTypeBuilder(ClientAuthenticationException.class) + .build(); + public static final ClassType RESOURCE_EXISTS_EXCEPTION = getClassTypeBuilder(ResourceExistsException.class) + .build(); + public static final ClassType RESOURCE_MODIFIED_EXCEPTION = getClassTypeBuilder(ResourceModifiedException.class) + .build(); + public static final ClassType RESOURCE_NOT_FOUND_EXCEPTION = getClassTypeBuilder(ResourceNotFoundException.class) + .build(); + public static final ClassType TOO_MANY_REDIRECTS_EXCEPTION = getClassTypeBuilder(TooManyRedirectsException.class) + .build(); + public static final ClassType RESPONSE_ERROR = new Builder() + .knownClass(ResponseError.class) + .jsonToken("JsonToken.START_OBJECT") + .build(); + public static final ClassType RESPONSE_INNER_ERROR = new Builder() + .packageName("com.azure.core.models").name("ResponseInnerError") + .jsonToken("JsonToken.START_OBJECT") + .build(); + + private final String fullName; + private final String packageName; + private final String name; + private final List implementationImports; + private final XmsExtensions extensions; + private final Function defaultValueExpressionConverter; + private final boolean isSwaggerType; + private final Function serializationValueGetterModifier; + private final String jsonToken; + private final String serializationMethodBase; + private final String jsonDeserializationMethod; + private final String xmlAttributeDeserializationTemplate; + private final String xmlElementDeserializationMethod; + private final boolean usedInXml; + + private ClassType(String packageKeyword, String name, List implementationImports, XmsExtensions extensions, + Function defaultValueExpressionConverter, boolean isSwaggerType, String jsonToken, + String serializationMethodBase, Function serializationValueGetterModifier, + String jsonDeserializationMethod, String xmlAttributeDeserializationTemplate, + String xmlElementDeserializationMethod, boolean usedInXml) { + this.fullName = packageKeyword + "." + name; + this.packageName = packageKeyword; + this.name = name; + this.implementationImports = implementationImports; + this.extensions = extensions; + this.defaultValueExpressionConverter = defaultValueExpressionConverter; + this.isSwaggerType = isSwaggerType; + this.jsonToken = jsonToken; + this.serializationMethodBase = serializationMethodBase; + this.serializationValueGetterModifier = serializationValueGetterModifier; + this.jsonDeserializationMethod = jsonDeserializationMethod; + this.xmlAttributeDeserializationTemplate = xmlAttributeDeserializationTemplate; + this.xmlElementDeserializationMethod = xmlElementDeserializationMethod; + this.usedInXml = usedInXml; + } + + public final String getPackage() { + return packageName; + } + + public final String getName() { + return name; + } + + private List getImplementationImports() { + return implementationImports; + } + + public XmsExtensions getExtensions() { + return extensions; + } + + private Function getDefaultValueExpressionConverter() { + return defaultValueExpressionConverter; + } + + public final boolean isBoxedType() { + // TODO (alzimmer): This should be a property on the ClassType + return this.equals(ClassType.VOID) + || this.equals(ClassType.BOOLEAN) + || this.equals(ClassType.BYTE) + || this.equals(ClassType.INTEGER) + || this.equals(ClassType.LONG) + || this.equals(ClassType.FLOAT) + || this.equals(ClassType.DOUBLE); + } + + @Override + public String toString() { + return name; + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof ClassType)) { + return false; + } + ClassType that = (ClassType) other; + return Objects.equals(this.name, that.name) && Objects.equals(this.packageName, that.packageName); + } + + @Override + public int hashCode() { + return Objects.hash(packageName, name); + } + + public final IType asNullable() { + return this; + } + + public final boolean contains(IType type) { + return this.equals(type); + } + + public final String getFullName() { + return fullName; + } + + public final void addImportsTo(Set imports, boolean includeImplementationImports) { + if (!getPackage().equals("java.lang")) { + imports.add(fullName); + } + + if (this == ClassType.UNIX_TIME_LONG) { + imports.add(Instant.class.getName()); + imports.add(ZoneOffset.class.getName()); + } + + if (this == ClassType.DATE_TIME) { + imports.add(DateTimeFormatter.class.getName()); + } + + if (this == ClassType.URL) { + imports.add(java.net.URL.class.getName()); + imports.add(java.net.MalformedURLException.class.getName()); + } + + if (includeImplementationImports && getImplementationImports() != null) { + imports.addAll(getImplementationImports()); + } + } + + public final String defaultValueExpression(String sourceExpression) { + String result = sourceExpression; + if (result != null) { + if (getDefaultValueExpressionConverter() != null) { + result = defaultValueExpressionConverter.apply(sourceExpression); + } else { + result = "new " + this + "()"; + } + } + return result; + } + + @Override + public String defaultValueExpression() { + return "null"; + } + + public final IType getClientType() { + IType clientType = this; + if (this == ClassType.DATE_TIME_RFC_1123) { + clientType = ClassType.DATE_TIME; + } else if (this == ClassType.UNIX_TIME_LONG) { + clientType = ClassType.DATE_TIME; + } else if (this == ClassType.BASE_64_URL) { + clientType = ArrayType.BYTE_ARRAY; + } else if (this == ClassType.DURATION_LONG) { + clientType = ClassType.DURATION; + } else if (this == ClassType.DURATION_DOUBLE) { + clientType = ClassType.DURATION; + } + return clientType; + } + + public String convertToClientType(String expression) { + if (this == ClassType.DATE_TIME_RFC_1123 || this == ClassType.ANDROID_DATE_TIME_RFC_1123) { + expression = expression + ".getDateTime()"; + } else if (this == ClassType.UNIX_TIME_LONG) { + expression = "OffsetDateTime.ofInstant(Instant.ofEpochSecond(" + expression + "), ZoneOffset.UTC)"; + } else if (this == ClassType.BASE_64_URL) { + expression = expression + ".decodedBytes()"; + } else if (this == ClassType.URL) { + expression = "new URL(" + expression + ")"; + } else if (this == ClassType.DURATION_LONG) { + expression = "Duration.ofSeconds(" + expression + ")"; + } else if (this == ClassType.DURATION_DOUBLE) { + expression = "Duration.ofNanos((long) (" + expression + " * 1000_000_000L))"; + } + + return expression; + } + + public String convertFromClientType(String expression) { + if (this == ClassType.DATE_TIME_RFC_1123 || this == ClassType.ANDROID_DATE_TIME_RFC_1123) { + expression = "new DateTimeRfc1123(" + expression + ")"; + } else if (this == ClassType.UNIX_TIME_LONG) { + expression = expression + ".toEpochSecond()"; + } else if (this == ClassType.BASE_64_URL) { + expression = "Base64Url.encode(" + expression + ")"; + } else if (this == ClassType.URL) { + expression = expression + ".toString()"; + } else if (this == ClassType.DURATION_LONG) { + expression = expression + ".getSeconds()"; + } else if (this == ClassType.DURATION_DOUBLE) { + expression = "(double) " + expression + ".toNanos() / 1000_000_000L"; + } + + return expression; + } + + public String validate(String expression) { + if (packageName.startsWith(JavaSettings.getInstance().getPackage())) { + return expression + ".validate()"; + } else { + return null; + } + } + + public boolean isSwaggerType() { + return isSwaggerType; + } + + @Override + public String jsonToken() { + return jsonToken; + } + + @Override + public String jsonDeserializationMethod(String jsonReaderName) { + if (jsonDeserializationMethod == null) { + return null; + } + + return jsonReaderName + "." + jsonDeserializationMethod; + } + + @Override + public String jsonSerializationMethodCall(String jsonWriterName, String fieldName, String valueGetter, + boolean jsonMergePatch) { + if (!isSwaggerType && CoreUtils.isNullOrEmpty(serializationMethodBase)) { + return null; + } + + String methodBase = isSwaggerType ? "writeJson" : serializationMethodBase; + String value = serializationValueGetterModifier != null + ? serializationValueGetterModifier.apply(valueGetter) : valueGetter; + + return fieldName == null + ? jsonWriterName + "." + methodBase + "(" + value + ")" + : jsonWriterName + "." + methodBase + "Field(\"" + fieldName + "\", " + value + ")"; + } + + @Override + public String xmlDeserializationMethod(String xmlReaderName, String attributeName, String attributeNamespace, + boolean namespaceIsConstant) { + if (attributeName == null) { + return xmlReaderName + "." + xmlElementDeserializationMethod; + } else if (attributeNamespace == null) { + return String.format(xmlAttributeDeserializationTemplate, xmlReaderName, "null", + "\"" + attributeName + "\""); + } else { + String namespace = namespaceIsConstant ? attributeNamespace : "\"" + attributeNamespace + "\""; + return String.format(xmlAttributeDeserializationTemplate, xmlReaderName, namespace, + "\"" + attributeName + "\""); + } + } + + @Override + public String xmlSerializationMethodCall(String xmlWriterName, String attributeOrElementName, String namespaceUri, + String valueGetter, boolean isAttribute, boolean nameIsVariable, boolean namespaceIsConstant) { + if (isSwaggerType) { + if (isAttribute) { + throw new RuntimeException("Swagger types cannot be written as attributes."); + } + + return xmlWriterName + ".writeXml(" + valueGetter + ", \"" + attributeOrElementName + "\")"; + } + + String value = serializationValueGetterModifier != null + ? serializationValueGetterModifier.apply(valueGetter) : valueGetter; + return xmlSerializationCallHelper(xmlWriterName, serializationMethodBase, attributeOrElementName, namespaceUri, + value, isAttribute, nameIsVariable, namespaceIsConstant); + } + + @Override + public boolean isUsedInXml() { + return usedInXml; + } + + public static class Builder { + /* + * Used to indicate if the class type is generated based on a Swagger definition and isn't a pre-defined, + * handwritten type. + */ private final boolean isSwaggerType; - private final Function serializationValueGetterModifier; - private final String jsonToken; - private final String serializationMethodBase; - private final String jsonDeserializationMethod; - private final String xmlAttributeDeserializationTemplate; - private final String xmlElementDeserializationMethod; - private final boolean usedInXml; - private ClassType(String packageKeyword, String name, List implementationImports, XmsExtensions extensions, - Function defaultValueExpressionConverter, boolean isSwaggerType, String jsonToken, - String serializationMethodBase, Function serializationValueGetterModifier, - String jsonDeserializationMethod, String xmlAttributeDeserializationTemplate, - String xmlElementDeserializationMethod, boolean usedInXml) { - this.fullName = packageKeyword + "." + name; - this.packageName = packageKeyword; - this.name = name; - this.implementationImports = implementationImports; - this.extensions = extensions; - this.defaultValueExpressionConverter = defaultValueExpressionConverter; - this.isSwaggerType = isSwaggerType; - this.jsonToken = jsonToken; - this.serializationMethodBase = serializationMethodBase; - this.serializationValueGetterModifier = serializationValueGetterModifier; - this.jsonDeserializationMethod = jsonDeserializationMethod; - this.xmlAttributeDeserializationTemplate = xmlAttributeDeserializationTemplate; - this.xmlElementDeserializationMethod = xmlElementDeserializationMethod; - this.usedInXml = usedInXml; + private String packageName; + private String name; + private List implementationImports; + private XmsExtensions extensions; + private Function defaultValueExpressionConverter; + private Function serializationValueGetterModifier; + private String jsonToken; + private String jsonDeserializationMethod; + private String serializationMethodBase; + private String xmlAttributeDeserializationTemplate; + private String xmlElementDeserializationMethod; + private boolean usedInXml; + + public Builder() { + this(true); } - public final String getPackage() { - return packageName; + private Builder(boolean isSwaggerType) { + this.isSwaggerType = isSwaggerType; } - public final String getName() { - return name; + public Builder packageName(String packageName) { + this.packageName = packageName; + return this; } - private List getImplementationImports() { - return implementationImports; + public Builder name(String name) { + this.name = name; + return this; } - public XmsExtensions getExtensions() { - return extensions; + public Builder prototypeAsLong() { + return this.knownClass(Long.class) + .defaultValueExpressionConverter(defaultValueExpression -> defaultValueExpression + 'L') + .jsonToken("JsonToken.NUMBER") + .serializationMethodBase("writeNumber") + .jsonDeserializationMethod("getNullable(JsonReader::getLong)") + .xmlElementDeserializationMethod("getNullableElement(Long::parseLong)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Long::parseLong)"); } - private Function getDefaultValueExpressionConverter() { - return defaultValueExpressionConverter; + public Builder prototypeAsDouble() { + return this.knownClass(Double.class) + .defaultValueExpressionConverter(defaultValueExpression -> java.lang.String.valueOf(java.lang.Double.parseDouble(defaultValueExpression)) + 'D') + .jsonToken("JsonToken.NUMBER") + .serializationMethodBase("writeNumber") + .jsonDeserializationMethod("getNullable(JsonReader::getDouble)") + .xmlElementDeserializationMethod("getNullableElement(Double::parseDouble)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Double::parseDouble)"); } - public final boolean isBoxedType() { - // TODO (alzimmer): This should be a property on the ClassType - return this.equals(ClassType.VOID) - || this.equals(ClassType.BOOLEAN) - || this.equals(ClassType.BYTE) - || this.equals(ClassType.INTEGER) - || this.equals(ClassType.LONG) - || this.equals(ClassType.FLOAT) - || this.equals(ClassType.DOUBLE); + public Builder knownClass(Class clazz) { + return packageName(clazz.getPackage().getName()) + .name(clazz.getSimpleName()); } - @Override - public String toString() { - return name; + private Builder knownClass(String fullName) { + int index = fullName.lastIndexOf("."); + return packageName(fullName.substring(0, index)) + .name(fullName.substring(index + 1)); } - @Override - public boolean equals(final Object other) { - if (this == other) { - return true; - } - if (!(other instanceof ClassType)) { - return false; - } - ClassType that = (ClassType) other; - return Objects.equals(this.name, that.name) && Objects.equals(this.packageName, that.packageName); + public Builder implementationImports(String... implementationImports) { + this.implementationImports = Arrays.asList(implementationImports); + return this; } - @Override - public int hashCode() { - return Objects.hash(packageName, name); + public Builder extensions(XmsExtensions extensions) { + this.extensions = extensions; + return this; } - public final IType asNullable() { - return this; + public Builder defaultValueExpressionConverter(Function defaultValueExpressionConverter) { + this.defaultValueExpressionConverter = defaultValueExpressionConverter; + return this; } - public final boolean contains(IType type) { - return this.equals(type); + public Builder jsonToken(String jsonToken) { + this.jsonToken = jsonToken; + return this; } - public final String getFullName() { - return fullName; + public Builder serializationValueGetterModifier(Function serializationValueGetterModifier) { + this.serializationValueGetterModifier = serializationValueGetterModifier; + return this; } - public final void addImportsTo(Set imports, boolean includeImplementationImports) { - if (!getPackage().equals("java.lang")) { - imports.add(fullName); - } - - if (this == ClassType.UNIX_TIME_LONG) { - imports.add(Instant.class.getName()); - imports.add(ZoneOffset.class.getName()); - } - - if (this == ClassType.DATE_TIME) { - imports.add(DateTimeFormatter.class.getName()); - } - - if (this == ClassType.URL) { - imports.add(java.net.URL.class.getName()); - imports.add(java.net.MalformedURLException.class.getName()); - } - - if (includeImplementationImports && getImplementationImports() != null) { - imports.addAll(getImplementationImports()); - } + public Builder jsonDeserializationMethod(String jsonDeserializationMethod) { + this.jsonDeserializationMethod = jsonDeserializationMethod; + return this; } - public final String defaultValueExpression(String sourceExpression) { - String result = sourceExpression; - if (result != null) { - if (getDefaultValueExpressionConverter() != null) { - result = defaultValueExpressionConverter.apply(sourceExpression); - } else { - result = "new " + this + "()"; - } - } - return result; + public Builder serializationMethodBase(String serializationMethodBase) { + this.serializationMethodBase = serializationMethodBase; + return this; } - @Override - public String defaultValueExpression() { - return "null"; + public Builder xmlAttributeDeserializationTemplate(String xmlAttributeDeserializationTemplate) { + this.xmlAttributeDeserializationTemplate = xmlAttributeDeserializationTemplate; + return this; } - public final IType getClientType() { - IType clientType = this; - if (this == ClassType.DATE_TIME_RFC_1123) { - clientType = ClassType.DATE_TIME; - } else if (this == ClassType.UNIX_TIME_LONG) { - clientType = ClassType.DATE_TIME; - } else if (this == ClassType.BASE_64_URL) { - clientType = ArrayType.BYTE_ARRAY; - } else if (this == ClassType.DURATION_LONG) { - clientType = ClassType.DURATION; - } else if (this == ClassType.DURATION_DOUBLE) { - clientType = ClassType.DURATION; - } - return clientType; + public Builder xmlElementDeserializationMethod(String xmlElementDeserializationMethod) { + this.xmlElementDeserializationMethod = xmlElementDeserializationMethod; + return this; } - public String convertToClientType(String expression) { - if (this == ClassType.DATE_TIME_RFC_1123 || this == ClassType.ANDROID_DATE_TIME_RFC_1123) { - expression = expression + ".getDateTime()"; - } else if (this == ClassType.UNIX_TIME_LONG) { - expression = "OffsetDateTime.ofInstant(Instant.ofEpochSecond(" + expression + "), ZoneOffset.UTC)"; - } else if (this == ClassType.BASE_64_URL) { - expression = expression + ".decodedBytes()"; - } else if (this == ClassType.URL) { - expression = "new URL(" + expression + ")"; - } else if (this == ClassType.DURATION_LONG) { - expression = "Duration.ofSeconds(" + expression + ")"; - } else if (this == ClassType.DURATION_DOUBLE) { - expression = "Duration.ofNanos((long) (" + expression + " * 1000_000_000L))"; - } - - return expression; + public Builder usedInXml(boolean usedInXml) { + this.usedInXml = usedInXml; + return this; } - public String convertFromClientType(String expression) { - if (this == ClassType.DATE_TIME_RFC_1123 || this == ClassType.ANDROID_DATE_TIME_RFC_1123) { - expression = "new DateTimeRfc1123(" + expression + ")"; - } else if (this == ClassType.UNIX_TIME_LONG) { - expression = expression + ".toEpochSecond()"; - } else if (this == ClassType.BASE_64_URL) { - expression = "Base64Url.encode(" + expression + ")"; - } else if (this == ClassType.URL) { - expression = expression + ".toString()"; - } else if (this == ClassType.DURATION_LONG) { - expression = expression + ".getSeconds()"; - } else if (this == ClassType.DURATION_DOUBLE) { - expression = "(double) " + expression + ".toNanos() / 1000_000_000L"; - } + public ClassType build() { + // Deserialization of Swagger types needs to be handled differently as the named reader needs + // to be passed to the deserialization method and the reader name cannot be determined here. + String jsonDeserializationMethod = isSwaggerType ? null : this.jsonDeserializationMethod; + String xmlAttributeDeserializationTemplate = isSwaggerType + ? null : this.xmlAttributeDeserializationTemplate; + String xmlElementDeserializationMethod = isSwaggerType ? null : this.xmlElementDeserializationMethod; - return expression; + return new ClassType(packageName, name, implementationImports, extensions, defaultValueExpressionConverter, + isSwaggerType, jsonToken, serializationMethodBase, serializationValueGetterModifier, + jsonDeserializationMethod, xmlAttributeDeserializationTemplate, xmlElementDeserializationMethod, + usedInXml); + } + } + + static String xmlSerializationCallHelper(String writer, String method, String xmlName, String namespace, + String value, boolean isAttribute, boolean nameIsVariable, boolean namespaceIsConstant) { + String name = (xmlName == null) ? null + : nameIsVariable ? xmlName : "\"" + xmlName + "\""; + namespace = (namespace == null) ? null + : namespaceIsConstant ? namespace : "\"" + namespace + "\""; + + if (isAttribute) { + method = method + "Attribute"; + return (namespace == null) + ? writer + "." + method + "(" + name + ", " + value + ")" + : writer + "." + method + "(" + namespace + ", " + name + ", " + value + ")"; } - public String validate(String expression) { - if (packageName.startsWith(JavaSettings.getInstance().getPackage())) { - return expression + ".validate()"; - } else { - return null; - } - } - - public boolean isSwaggerType() { - return isSwaggerType; - } - - @Override - public String jsonToken() { - return jsonToken; - } - - @Override - public String jsonDeserializationMethod(String jsonReaderName) { - if (jsonDeserializationMethod == null) { - return null; - } - - return jsonReaderName + "." + jsonDeserializationMethod; - } - - @Override - public String jsonSerializationMethodCall(String jsonWriterName, String fieldName, String valueGetter, - boolean jsonMergePatch) { - if (!isSwaggerType && CoreUtils.isNullOrEmpty(serializationMethodBase)) { - return null; - } - - String methodBase = isSwaggerType ? "writeJson" : serializationMethodBase; - String value = serializationValueGetterModifier != null - ? serializationValueGetterModifier.apply(valueGetter) : valueGetter; - - return fieldName == null - ? jsonWriterName + "." + methodBase + "(" + value + ")" - : jsonWriterName + "." + methodBase + "Field(\"" + fieldName + "\", " + value + ")"; - } - - @Override - public String xmlDeserializationMethod(String xmlReaderName, String attributeName, String attributeNamespace, - boolean namespaceIsConstant) { - if (attributeName == null) { - return xmlReaderName + "." + xmlElementDeserializationMethod; - } else if (attributeNamespace == null) { - return String.format(xmlAttributeDeserializationTemplate, xmlReaderName, "null", - "\"" + attributeName + "\""); - } else { - String namespace = namespaceIsConstant ? attributeNamespace : "\"" + attributeNamespace + "\""; - return String.format(xmlAttributeDeserializationTemplate, xmlReaderName, namespace, - "\"" + attributeName + "\""); - } - } - - @Override - public String xmlSerializationMethodCall(String xmlWriterName, String attributeOrElementName, String namespaceUri, - String valueGetter, boolean isAttribute, boolean nameIsVariable, boolean namespaceIsConstant) { - if (isSwaggerType) { - if (isAttribute) { - throw new RuntimeException("Swagger types cannot be written as attributes."); - } - - return xmlWriterName + ".writeXml(" + valueGetter + ", \"" + attributeOrElementName + "\")"; - } - - String value = serializationValueGetterModifier != null - ? serializationValueGetterModifier.apply(valueGetter) : valueGetter; - return xmlSerializationCallHelper(xmlWriterName, serializationMethodBase, attributeOrElementName, namespaceUri, - value, isAttribute, nameIsVariable, namespaceIsConstant); - } - - @Override - public boolean isUsedInXml() { - return usedInXml; - } - - public static class Builder { - /* - * Used to indicate if the class type is generated based on a Swagger definition and isn't a pre-defined, - * handwritten type. - */ - private final boolean isSwaggerType; - - private String packageName; - private String name; - private List implementationImports; - private XmsExtensions extensions; - private Function defaultValueExpressionConverter; - private Function serializationValueGetterModifier; - private String jsonToken; - private String jsonDeserializationMethod; - private String serializationMethodBase; - private String xmlAttributeDeserializationTemplate; - private String xmlElementDeserializationMethod; - private boolean usedInXml; - - public Builder() { - this(true); - } - - private Builder(boolean isSwaggerType) { - this.isSwaggerType = isSwaggerType; - } - - public Builder packageName(String packageName) { - this.packageName = packageName; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder prototypeAsLong() { - return this.knownClass(Long.class) - .defaultValueExpressionConverter(defaultValueExpression -> defaultValueExpression + 'L') - .jsonToken("JsonToken.NUMBER") - .serializationMethodBase("writeNumber") - .jsonDeserializationMethod("getNullable(JsonReader::getLong)") - .xmlElementDeserializationMethod("getNullableElement(Long::parseLong)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Long::parseLong)"); - } - - public Builder prototypeAsDouble() { - return this.knownClass(Double.class) - .defaultValueExpressionConverter(defaultValueExpression -> java.lang.String.valueOf(java.lang.Double.parseDouble(defaultValueExpression)) + 'D') - .jsonToken("JsonToken.NUMBER") - .serializationMethodBase("writeNumber") - .jsonDeserializationMethod("getNullable(JsonReader::getDouble)") - .xmlElementDeserializationMethod("getNullableElement(Double::parseDouble)") - .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Double::parseDouble)"); - } - - public Builder knownClass(Class clazz) { - return packageName(clazz.getPackage().getName()) - .name(clazz.getSimpleName()); - } - - private Builder knownClass(String fullName) { - int index = fullName.lastIndexOf("."); - return packageName(fullName.substring(0, index)) - .name(fullName.substring(index + 1)); - } - - public Builder implementationImports(String... implementationImports) { - this.implementationImports = Arrays.asList(implementationImports); - return this; - } - - public Builder extensions(XmsExtensions extensions) { - this.extensions = extensions; - return this; - } - - public Builder defaultValueExpressionConverter(Function defaultValueExpressionConverter) { - this.defaultValueExpressionConverter = defaultValueExpressionConverter; - return this; - } - - public Builder jsonToken(String jsonToken) { - this.jsonToken = jsonToken; - return this; - } - - public Builder serializationValueGetterModifier(Function serializationValueGetterModifier) { - this.serializationValueGetterModifier = serializationValueGetterModifier; - return this; - } - - public Builder jsonDeserializationMethod(String jsonDeserializationMethod) { - this.jsonDeserializationMethod = jsonDeserializationMethod; - return this; - } - - public Builder serializationMethodBase(String serializationMethodBase) { - this.serializationMethodBase = serializationMethodBase; - return this; - } - - public Builder xmlAttributeDeserializationTemplate(String xmlAttributeDeserializationTemplate) { - this.xmlAttributeDeserializationTemplate = xmlAttributeDeserializationTemplate; - return this; - } - - public Builder xmlElementDeserializationMethod(String xmlElementDeserializationMethod) { - this.xmlElementDeserializationMethod = xmlElementDeserializationMethod; - return this; - } - - public Builder usedInXml(boolean usedInXml) { - this.usedInXml = usedInXml; - return this; - } - - public ClassType build() { - // Deserialization of Swagger types needs to be handled differently as the named reader needs - // to be passed to the deserialization method and the reader name cannot be determined here. - String jsonDeserializationMethod = isSwaggerType ? null : this.jsonDeserializationMethod; - String xmlAttributeDeserializationTemplate = isSwaggerType - ? null : this.xmlAttributeDeserializationTemplate; - String xmlElementDeserializationMethod = isSwaggerType ? null : this.xmlElementDeserializationMethod; - - return new ClassType(packageName, name, implementationImports, extensions, defaultValueExpressionConverter, - isSwaggerType, jsonToken, serializationMethodBase, serializationValueGetterModifier, - jsonDeserializationMethod, xmlAttributeDeserializationTemplate, xmlElementDeserializationMethod, - usedInXml); - } - } - - static String xmlSerializationCallHelper(String writer, String method, String xmlName, String namespace, - String value, boolean isAttribute, boolean nameIsVariable, boolean namespaceIsConstant) { - String name = (xmlName == null) ? null - : nameIsVariable ? xmlName : "\"" + xmlName + "\""; - namespace = (namespace == null) ? null - : namespaceIsConstant ? namespace : "\"" + namespace + "\""; - - if (isAttribute) { - method = method + "Attribute"; - return (namespace == null) - ? writer + "." + method + "(" + name + ", " + value + ")" - : writer + "." + method + "(" + namespace + ", " + name + ", " + value + ")"; - } - - if (name == null) { - return writer + "." + method + "(" + value + ")"; - } else { - method = method + "Element"; - return (namespace == null) - ? writer + "." + method + "(" + name + ", " + value + ")" - : writer + "." + method + "(" + namespace + ", " + name + ", " + value + ")"; - } + if (name == null) { + return writer + "." + method + "(" + value + ")"; + } else { + method = method + "Element"; + return (namespace == null) + ? writer + "." + method + "(" + name + ", " + value + ")" + : writer + "." + method + "(" + namespace + ", " + name + ", " + value + ")"; } + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientModel.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientModel.java index 0a0a5f1f1..2b19bfb26 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientModel.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientModel.java @@ -5,6 +5,7 @@ package com.microsoft.typespec.http.client.generator.core.model.clientmodel; import com.microsoft.typespec.http.client.generator.core.extension.plugin.JavaSettings; import com.azure.core.util.CoreUtils; +import com.microsoft.typespec.http.client.generator.core.util.ClientModelUtil; import java.util.ArrayList; import java.util.Collections; @@ -15,763 +16,856 @@ import java.util.Set; * A model that is defined by the client. */ public class ClientModel { - /** - * The package that this model class belongs to. - */ - private final String packageName; + /** + * The package that this model class belongs to. + */ + private final String packageName; + + /** + * Get the name of this model. + */ + private final String name; + + private final String fullName; + + /** + * Get the imports for this model. + */ + private final List imports; + + /** + * Get the description of this model. + */ + private final String description; + + /** + * Get whether this model is part of a polymorphic hierarchy. + */ + private final boolean isPolymorphic; + + /** + * Get whether this model is a parent in a polymorphic hierarchy. + */ + private final boolean isPolymorphicParent; + + /** + * Get the properties used by parent models as polymorphic discriminators. + */ + private final List parentPolymorphicDiscriminators; + /** + * Get the property that determines which polymorphic model type to create. + */ + private final ClientModelProperty polymorphicDiscriminator; + + /** + * Get the name of the property that determines which polymorphic model type to create. + */ + private final String polymorphicDiscriminatorName; + + /** + * Get the name that is used for this model when it is serialized. + */ + private final String serializedName; + + /** + * Get whether this model needs serialization flattening. + */ + private final boolean needsFlatten; + + /** + * Get the parent model of this model. + */ + private final String parentModelName; + + /** + * Get the models that derive from this model. + */ + private final List derivedModels; + + /** + * Get the name that will be used for this model's XML element representation. + */ + private final String xmlName; + + /** + * The xml namespace for a model. + */ + private final String xmlNamespace; + + /** + * Get the properties for this model. + */ + private final List properties; + + /** + * Get the property references for this model. They are used to call property method from i.e. a parent model. + */ + private final List propertyReferences; + + /** + * The type of the model. + */ + private final IType modelType; + + /** + * Whether this model is a strongly-typed HTTP headers class. + */ + private final boolean stronglyTypedHeader; + + /** + * The implementation details for the model. + */ + private final ImplementationDetails implementationDetails; + + /** + * Whether the model is used in XML serialization. + */ + private final boolean usedInXml; + + private final Set serializationFormats; + + /** + * The cross language definition id for the model. + */ + private final String crossLanguageDefinitionId; + + // Set of non-final properties that are set on access. + // This pattern is used as when the ClientModel is initialized the ModelMapper may not have mapped all models + // related to the one being initialized. When that happens some properties may not be set correctly. For example, + // checks into the polymorphic hierarchy may not be correct. This pattern allows for the properties to be set + // correctly when they are accessed. + + /** + * Whether all models in the polymorphic hierarchy containing this model are in the same package. + *

+ * If this model isn't polymorphic, this will always be false. + */ + private Boolean allPolymorphicModelsInSamePackage; + + /** + * Whether the polymorphic discriminator for this model was defined by the model. + *

+ * If this model isn't polymorphic, this will always be false. + */ + private Boolean polymorphicDiscriminatorDefinedByModel; + + /** + * Create a new ServiceModel with the provided properties. + * + * @param packageKeyword The package that this model class belongs to. + * @param name The name of this model. + * @param imports The imports for this model. + * @param description The description of this model. + * @param isPolymorphic Whether this model has model types that derive from it. + * @param polymorphicDiscriminator The property that determines which polymorphic model type to create. + * @param polymorphicDiscriminatorName The name of the property that determines which polymorphic model type to + * create. + * @param serializedName The name that is used for this model when it is serialized. + * @param needsFlatten Whether this model needs serialization flattening. + * @param parentModelName The parent model of this model. + * @param derivedModels The models that derive from this model. + * @param xmlName The name that will be used for this model's XML element representation. + * @param xmlNamespace The XML namespace that will be used for this model's XML element representation. + * @param properties The properties for this model. + * @param propertyReferences The property references for this model. + * @param modelType the type of the model. + * @param stronglyTypedHeader Whether this model is a strongly-typed HTTP headers class. + * @param implementationDetails The implementation details for the model. + * @param usedInXml Whether the model is used in XML serialization. + * @param crossLanguageDefinitionId The cross language definition id for the model. + */ + protected ClientModel(String packageKeyword, String name, List imports, String description, + boolean isPolymorphic, ClientModelProperty polymorphicDiscriminator, String polymorphicDiscriminatorName, + String serializedName, boolean needsFlatten, String parentModelName, List derivedModels, + String xmlName, String xmlNamespace, List properties, + List propertyReferences, IType modelType, boolean stronglyTypedHeader, + ImplementationDetails implementationDetails, boolean usedInXml, Set serializationFormats, + String crossLanguageDefinitionId) { + this.packageName = packageKeyword; + this.name = name; + this.fullName = packageName + "." + name; + this.imports = imports; + this.description = description; + this.isPolymorphic = isPolymorphic; + this.isPolymorphicParent = isPolymorphic && !CoreUtils.isNullOrEmpty(derivedModels); + this.parentPolymorphicDiscriminators = new ArrayList<>(); + this.polymorphicDiscriminator = polymorphicDiscriminator; + this.polymorphicDiscriminatorName = polymorphicDiscriminatorName; + this.serializedName = serializedName; + this.needsFlatten = needsFlatten; + this.parentModelName = parentModelName; + this.derivedModels = derivedModels; + this.xmlName = xmlName; + this.xmlNamespace = xmlNamespace; + this.properties = properties; + this.propertyReferences = propertyReferences; + this.modelType = modelType; + this.stronglyTypedHeader = stronglyTypedHeader; + this.implementationDetails = implementationDetails; + this.usedInXml = usedInXml; + this.crossLanguageDefinitionId = crossLanguageDefinitionId; + this.serializationFormats = serializationFormats; + } + + /** + * Get the cross language definition id for the model. + * + * @return the cross language definition id for the model. + */ + public String getCrossLanguageDefinitionId() { + return crossLanguageDefinitionId; + } + + /** + * Gets the package that this model class belongs to. + * + * @return The package that this model class belongs to. + */ + public final String getPackage() { + return packageName; + } + + /** + * Gets the name of this model. + * + * @return The name of this model. + */ + public final String getName() { + return name; + } + + /** + * Gets the fully qualified name of this model. + * + * @return The fully qualified name of this model. + */ + public final String getFullName() { + return fullName; + } + + /** + * Gets the imports for this model. + * + * @return The imports for this model. + */ + public final List getImports() { + return imports; + } + + /** + * Gets the description of this model. + * + * @return The description of this model. + */ + public final String getDescription() { + return description; + } + + /** + * Gets whether this model is part of a polymorphic hierarchy. + * + * @return Whether this model is part of a polymorphic hierarchy. + */ + public final boolean isPolymorphic() { + return isPolymorphic; + } + + /** + * Gets whether this model is a parent in a polymorphic hierarchy. + * + * @return Whether this model is a parent in a polymorphic hierarchy. + */ + public final boolean isPolymorphicParent() { + return isPolymorphicParent; + } + + /** + * Gets the properties used by parent models as polymorphic discriminators. + *

+ * The only time this will return a non-empty list is when this model is used in a multi-level polymorphic + * hierarchy. Or, as an example, if the root model uses a polymorphic discriminator of {@code kind} and this model + * uses a polymorphic discriminator of {@code type} this will have a single property where the serialized name is + * {@code kind} and the default value for it will be what to root model uses to determine that this is the model + * that should be deserialized. Continuing this example, the third level models, or those that are determined by the + * {@code type} value, will also have a single property where the serialized name is {@code kind} and the default + * value will be what the second level model uses to determine that this is the model that should be deserialized. + * This is because the {@code kind} property will always need to be present for these models. If there are even + * deeper levels of polymorphism, the same pattern will continue. So, if in the third level there is a model that + * introduces another polymorphic discriminator of {@code format} that model would have two properties in this list, + * one with {@code kind} with a default that determined the second level model and one with {@code type} with a + * default that determined the third level model. The fourth level model would then have both as well. + * + * @return The properties used by parent models as polymorphic discriminators. + */ + public final List getParentPolymorphicDiscriminators() { + return parentPolymorphicDiscriminators; + } + + /** + * Gets the property that determines which polymorphic model type to create. + * + * @return The property that determines which polymorphic model type to create. + */ + public final ClientModelProperty getPolymorphicDiscriminator() { + return polymorphicDiscriminator; + } + + /** + * Gets the name of the property that determines which polymorphic model type to create. + * + * @return The name of the property that determines which polymorphic model type to create. + */ + public final String getPolymorphicDiscriminatorName() { + return polymorphicDiscriminatorName; + } + + /** + * Gets the name that is used for this model when it is serialized. + * + * @return The name that is used for this model when it is serialized. + */ + public final String getSerializedName() { + return serializedName; + } + + /** + * Gets whether this model needs serialization flattening. + * + * @return Whether this model needs serialization flattening. + */ + public final boolean getNeedsFlatten() { + return needsFlatten; + } + + /** + * Gets the parent model of this model. + * + * @return The parent model of this model. + */ + public final String getParentModelName() { + return parentModelName; + } + + /** + * Gets the models that derive from this model. + * + * @return The models that derive from this model. + */ + public final List getDerivedModels() { + return derivedModels; + } + + /** + * Gets the name that will be used for this model's XML element representation. + * + * @return The name that will be used for this model's XML element representation. + */ + public final String getXmlName() { + return xmlName; + } + + /** + * Gets the XML namespace that will be used for this model's XML element representation. + * + * @return The XML namespace that will be used for this model's XML element representation. + */ + public String getXmlNamespace() { + return xmlNamespace; + } + + /** + * Gets the properties for this model. + * + * @return The properties for this model. + */ + public final List getProperties() { + return properties; + } + + /** + * Gets the type of the model. + * + * @return The type of the model. + */ + public IType getType() { + return modelType; + } + + /** + * Gets the property references for this model. They are used to call property method from i.e. a parent model. + * + * @return The property references for this model. + */ + public List getPropertyReferences() { + return propertyReferences == null ? Collections.emptyList() : propertyReferences; + } + + /** + * Whether this model is a strongly-typed HTTP headers class. + * + * @return Whether this model is a strongly-typed HTTP headers class. + */ + public boolean isStronglyTypedHeader() { + return stronglyTypedHeader; + } + + /** + * Gets the implementation details for the model. + * + * @return The implementation details for the model. + */ + public ImplementationDetails getImplementationDetails() { + return implementationDetails; + } + + /** + * List the properties that have access (getter or setter) methods. + *

+ * It does not include properties from superclass (even though they can be accessed via inheritance). It does not + * include properties that only have private access (e.g. property of a flattened model). It includes properties + * that can be accessed from the model but not declared in this model (e.g. properties from a flattened model). + * + * @return The properties that have access (getter or setter) methods. + */ + public List getAccessibleProperties() { + List propertyAccesses = new ArrayList<>(); + if (properties != null) { + for (ClientModelProperty property : properties) { + if (!property.getClientFlatten()) { + propertyAccesses.add(property); + } + } + } + + for (ClientModelPropertyReference clientModelPropertyReference : getPropertyReferences()) { + if (clientModelPropertyReference.isFromFlattenedProperty()) { + propertyAccesses.add(clientModelPropertyReference); + } + } + + return propertyAccesses; + } + + /** + * Add this ServiceModel's imports to the provided set of imports. + * + * @param imports The set of imports to add to. + * @param settings The settings for this Java generator session. + */ + public void addImportsTo(Set imports, JavaSettings settings) { + // whether annotated as Immutable or Fluent is also determined by its superclass + imports.add(this.getFullName()); + addFluentAnnotationImport(imports); + addImmutableAnnotationImport(imports); + + if (settings.getClientFlattenAnnotationTarget() == JavaSettings.ClientFlattenAnnotationTarget.TYPE + && needsFlatten) { + addJsonFlattenAnnotationImport(imports); + } + + imports.addAll(getImports()); + + if (isPolymorphic()) { + imports.add("com.fasterxml.jackson.annotation.JsonTypeInfo"); + imports.add("com.fasterxml.jackson.annotation.JsonTypeName"); + + if (getDerivedModels() != null && getDerivedModels().size() > 0) { + imports.add("com.fasterxml.jackson.annotation.JsonSubTypes"); + getDerivedModels().forEach(m -> imports.add(m.getFullName())); + } + } + + for (ClientModelProperty property : getProperties()) { + property.addImportsTo(imports, usedInXml); + } + } + + /** + * Add the Fluent annotation import to the provided set of imports. + * + * @param imports The set of imports to add to. + */ + protected void addJsonFlattenAnnotationImport(Set imports) { + imports.add("com.azure.core.annotation.JsonFlatten"); + } + + /** + * Add the Immutable annotation import to the provided set of imports. + * + * @param imports The set of imports to add to. + */ + protected void addImmutableAnnotationImport(Set imports) { + Annotation.IMMUTABLE.addImportsTo(imports); + if (!JavaSettings.getInstance().isBranded()) { + Annotation.TYPE_CONDITIONS.addImportsTo(imports); + Annotation.METADATA.addImportsTo(imports); + } + } + + /** + * Add the Fluent annotation import to the provided set of imports. + * + * @param imports The set of imports to add to. + */ + protected void addFluentAnnotationImport(Set imports) { + Annotation.FLUENT.addImportsTo(imports); + if (!JavaSettings.getInstance().isBranded()) { + Annotation.METADATA.addImportsTo(imports); + } + } + + /** + * Whether the model is used in XML serialization. + * + * @return Whether the model is used in XML serialization. + */ + public final boolean isUsedInXml() { + return usedInXml; + } + + /** + * Gets the Set of serialization format of the model. + * + * @return the Set of serialization format of the model. + */ + public Set getSerializationFormats() { + return serializationFormats; + } + + /** + * Whether the polymorphic structure containing the model and all subtypes are in the same package. + *

+ * If this model isn't polymorphic, this will always be false. + * + * @return Whether the polymorphic structure containing the model and all subtypes are in the same package. + */ + public final boolean isAllPolymorphicModelsInSamePackage() { + if (!isPolymorphic) { + return false; + } + + if (allPolymorphicModelsInSamePackage == null) { + allPolymorphicModelsInSamePackage = allPolymorphicModelsInSamePackageInternal(this); + } + + return allPolymorphicModelsInSamePackage; + } + + /** + * Whether the model defines the polymorphic discriminator property. + *

+ * If this model isn't polymorphic, this will always be false. + * + * @return Whether the model defines the polymorphic discriminator property. + */ + public final boolean isPolymorphicDiscriminatorDefinedByModel() { + if (!isPolymorphic) { + return false; + } + + if (polymorphicDiscriminatorDefinedByModel == null) { + polymorphicDiscriminatorDefinedByModel = ClientModelUtil.modelDefinesProperty(this, polymorphicDiscriminator); + } + + return polymorphicDiscriminatorDefinedByModel; + } + + private static boolean allPolymorphicModelsInSamePackageInternal(ClientModel model) { + if (!model.isPolymorphic()) { + return false; + } + + String packageName = model.getPackage(); + ClientModel parent = ClientModelUtil.getClientModel(model.getParentModelName()); + ClientModel lastParent = model; + while (parent != null) { + lastParent = parent; + if (!packageName.equals(parent.getPackage())) { + return false; + } + + parent = ClientModelUtil.getClientModel(parent.getParentModelName()); + } + + return checkChildrenModelsPackage(lastParent, packageName); + } + + private static boolean checkChildrenModelsPackage(ClientModel model, String packageName) { + List children = model.getDerivedModels(); + if (children == null || children.isEmpty()) { + return true; + } + + for (ClientModel child : children) { + if (!packageName.equals(child.getPackage()) || !checkChildrenModelsPackage(child, packageName)) { + return false; + } + } + + return true; + } + + /** + * A builder for building a new ClientModel. + */ + public static class Builder { + protected String packageName; + protected String name; + protected List imports = Collections.emptyList(); + protected String description; + protected boolean isPolymorphic; + protected ClientModelProperty polymorphicDiscriminator; + protected String polymorphicDiscriminatorName; + protected String serializedName; + protected boolean needsFlatten = false; + protected String parentModelName; + protected List derivedModels = Collections.emptyList(); + protected String xmlName; + protected List properties; + protected String xmlNamespace; + protected List propertyReferences; + protected IType modelType; + protected boolean stronglyTypedHeader; + protected ImplementationDetails implementationDetails; + protected boolean usedInXml; + protected String crossLanguageDefinitionId; + protected Set serializationFormats = Collections.emptySet(); /** - * Get the name of this model. - */ - private final String name; - - private final String fullName; - - /** - * Get the imports for this model. - */ - private final List imports; - - /** - * Get the description of this model. - */ - private final String description; - - /** - * Get whether this model is part of a polymorphic hierarchy. - */ - private final boolean isPolymorphic; - - /** - * Get whether this model is a parent in a polymorphic hierarchy. - */ - private final boolean isPolymorphicParent; - - /** - * Get the properties used by parent models as polymorphic discriminators. - */ - private final List parentPolymorphicDiscriminators; - /** - * Get the property that determines which polymorphic model type to create. - */ - private final ClientModelProperty polymorphicDiscriminator; - - /** - * Get the name of the property that determines which polymorphic model type to create. - */ - private final String polymorphicDiscriminatorName; - - /** - * Get the name that is used for this model when it is serialized. - */ - private final String serializedName; - - /** - * Get whether this model needs serialization flattening. - */ - private final boolean needsFlatten; - - /** - * Get the parent model of this model. - */ - private final String parentModelName; - - /** - * Get the models that derive from this model. - */ - private final List derivedModels; - - /** - * Get the name that will be used for this model's XML element representation. - */ - private final String xmlName; - - /** - * The xml namespace for a model. - */ - private final String xmlNamespace; - - /** - * Get the properties for this model. - */ - private final List properties; - - /** - * Get the property references for this model. They are used to call property method from i.e. a parent model. - */ - private final List propertyReferences; - - /** - * The type of the model. - */ - private final IType modelType; - - /** - * Whether this model is a strongly-typed HTTP headers class. - */ - private final boolean stronglyTypedHeader; - - /** - * The implementation details for the model. - */ - private final ImplementationDetails implementationDetails; - - /** - * Whether the model is used in XML serialization. - */ - private final boolean usedInXml; - - private final Set serializationFormats; - - /** - * The cross language definition id for the model. - */ - private final String crossLanguageDefinitionId; - - /** - * Create a new ServiceModel with the provided properties. + * Sets the package that this model class belongs to. + * + * @param packageName the package that this model class belongs to + * @return the Builder itself + */ + public Builder packageName(String packageName) { + this.packageName = packageName; + return this; + } + + /** + * Sets the name of this model. + * + * @param name the name of this model + * @return the Builder itself + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Sets the imports for this model. + * + * @param imports the imports for this model + * @return the Builder itself + */ + public Builder imports(List imports) { + this.imports = imports; + return this; + } + + /** + * Sets the description of this model. + * + * @param description the description of this model + * @return the Builder itself + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Sets whether this model has model types that derive from it. + * + * @param isPolymorphic whether this model has model types that derive from it + * @return the Builder itself + */ + public Builder polymorphic(boolean isPolymorphic) { + this.isPolymorphic = isPolymorphic; + return this; + } + + /** + * Sets the property that determines which polymorphic model type to create. + * + * @param polymorphicDiscriminator the property that determines which polymorphic model type to create + * @return the Builder itself + */ + public Builder polymorphicDiscriminator(ClientModelProperty polymorphicDiscriminator) { + this.polymorphicDiscriminator = polymorphicDiscriminator; + return this; + } + + public Builder polymorphicDiscriminatorName(String polymorphicDiscriminatorName) { + this.polymorphicDiscriminatorName = polymorphicDiscriminatorName; + return this; + } + + /** + * Sets the name that is used for this model when it is serialized. + * + * @param serializedName the name that is used for this model when it is serialized + * @return the Builder itself + */ + public Builder serializedName(String serializedName) { + this.serializedName = serializedName; + return this; + } + + /** + * Sets whether this model needs serialization flattening. + * + * @param needsFlatten whether this model needs serialization flattening + * @return the Builder itself + */ + public Builder needsFlatten(boolean needsFlatten) { + this.needsFlatten = needsFlatten; + return this; + } + + /** + * Sets the parent model of this model. + * + * @param parentModelName the parent model of this model + * @return the Builder itself + */ + public Builder parentModelName(String parentModelName) { + this.parentModelName = parentModelName; + return this; + } + + /** + * Sets the models that derive from this model. + * + * @param derivedModels the models that derive from this model + * @return the Builder itself + */ + public Builder derivedModels(List derivedModels) { + this.derivedModels = derivedModels; + return this; + } + + /** + * Sets the name that will be used for this model's XML element representation. + * + * @param xmlName the name that will be used for this model's XML element representation + * @return the Builder itself + */ + public Builder xmlName(String xmlName) { + this.xmlName = xmlName; + return this; + } + + /** + * Sets the XML namespace that will be used for this model's XML element representation. + * + * @param xmlNamespace the XML namespace that will be used for this model's XML element representation + * @return the Builder itself + */ + public Builder xmlNamespace(String xmlNamespace) { + this.xmlNamespace = xmlNamespace; + return this; + } + + /** + * Sets the properties for this model. + * + * @param properties the properties for this model + * @return the Builder itself + */ + public Builder properties(List properties) { + this.properties = properties; + return this; + } + + /** + * Sets the property references for this model. They are used to call property method from i.e. a parent model. + * + * @param propertyReferences the property references. + * @return the Builder itself + */ + public Builder propertyReferences(List propertyReferences) { + this.propertyReferences = propertyReferences; + return this; + } + + /** + * Sets the model type. + * + * @param modelType the model type. + * @return the Builder itself + */ + public Builder type(IType modelType) { + this.modelType = modelType; + return this; + } + + /** + * Sets whether the model is a strongly-typed HTTP headers class. + * + * @param stronglyTypedHeader Whether the model is a strongly-typed HTTP headers class. + * @return the Builder itself + */ + public Builder stronglyTypedHeader(boolean stronglyTypedHeader) { + this.stronglyTypedHeader = stronglyTypedHeader; + return this; + } + + /** + * Sets the implementation details for the model. + * + * @param implementationDetails the implementation details. + * @return the Builder itself + */ + public Builder implementationDetails(ImplementationDetails implementationDetails) { + this.implementationDetails = implementationDetails; + return this; + } + + /** + * Sets whether the model is used in XML serialization. * - * @param packageKeyword The package that this model class belongs to. - * @param name The name of this model. - * @param imports The imports for this model. - * @param description The description of this model. - * @param isPolymorphic Whether this model has model types that derive from it. - * @param polymorphicDiscriminator The property that determines which polymorphic model type to create. - * @param polymorphicDiscriminatorName The name of the property that determines which polymorphic model type to - * create. - * @param serializedName The name that is used for this model when it is serialized. - * @param needsFlatten Whether this model needs serialization flattening. - * @param parentModelName The parent model of this model. - * @param derivedModels The models that derive from this model. - * @param xmlName The name that will be used for this model's XML element representation. - * @param xmlNamespace The XML namespace that will be used for this model's XML element representation. - * @param properties The properties for this model. - * @param propertyReferences The property references for this model. - * @param modelType the type of the model. - * @param stronglyTypedHeader Whether this model is a strongly-typed HTTP headers class. - * @param implementationDetails The implementation details for the model. * @param usedInXml Whether the model is used in XML serialization. - * @param crossLanguageDefinitionId The cross language definition id for the model. + * @return the Builder itself */ - protected ClientModel(String packageKeyword, String name, List imports, String description, - boolean isPolymorphic, ClientModelProperty polymorphicDiscriminator, String polymorphicDiscriminatorName, - String serializedName, boolean needsFlatten, String parentModelName, List derivedModels, - String xmlName, String xmlNamespace, List properties, - List propertyReferences, IType modelType, boolean stronglyTypedHeader, - ImplementationDetails implementationDetails, boolean usedInXml, Set serializationFormats, - String crossLanguageDefinitionId) { - this.packageName = packageKeyword; - this.name = name; - this.fullName = packageName + "." + name; - this.imports = imports; - this.description = description; - this.isPolymorphic = isPolymorphic; - this.isPolymorphicParent = isPolymorphic && !CoreUtils.isNullOrEmpty(derivedModels); - this.parentPolymorphicDiscriminators = new ArrayList<>(); - this.polymorphicDiscriminator = polymorphicDiscriminator; - this.polymorphicDiscriminatorName = polymorphicDiscriminatorName; - this.serializedName = serializedName; - this.needsFlatten = needsFlatten; - this.parentModelName = parentModelName; - this.derivedModels = derivedModels; - this.xmlName = xmlName; - this.xmlNamespace = xmlNamespace; - this.properties = properties; - this.propertyReferences = propertyReferences; - this.modelType = modelType; - this.stronglyTypedHeader = stronglyTypedHeader; - this.implementationDetails = implementationDetails; - this.usedInXml = usedInXml; - this.crossLanguageDefinitionId = crossLanguageDefinitionId; - this.serializationFormats = serializationFormats; + public Builder usedInXml(boolean usedInXml) { + this.usedInXml = usedInXml; + return this; } /** - * Get the cross language definition id for the model. + * Sets the cross language definition id for the model. * - * @return the cross language definition id for the model. + * @param crossLanguageDefinitionId the cross language definition id for the model. + * @return the Builder itself */ - public String getCrossLanguageDefinitionId() { - return crossLanguageDefinitionId; + public Builder crossLanguageDefinitionId(String crossLanguageDefinitionId) { + this.crossLanguageDefinitionId = crossLanguageDefinitionId; + return this; } /** - * Gets the package that this model class belongs to. + * Sets the Set of serialization format of this model. * - * @return The package that this model class belongs to. + * @param serializationFormats the Set of serialization format of this model. + * @return the Builder itself */ - public final String getPackage() { - return packageName; + public Builder serializationFormats(Set serializationFormats) { + this.serializationFormats = serializationFormats == null ? Collections.emptySet() : serializationFormats; + return this; } /** - * Gets the name of this model. + * Build a new ClientModel instance with the provided properties. * - * @return The name of this model. + * @return a new ClientModel instance with the provided properties */ - public final String getName() { - return name; - } - - /** - * Gets the fully qualified name of this model. - * - * @return The fully qualified name of this model. - */ - public final String getFullName() { - return fullName; - } - - /** - * Gets the imports for this model. - * - * @return The imports for this model. - */ - public final List getImports() { - return imports; - } - - /** - * Gets the description of this model. - * - * @return The description of this model. - */ - public final String getDescription() { - return description; - } - - /** - * Gets whether this model is part of a polymorphic hierarchy. - * - * @return Whether this model is part of a polymorphic hierarchy. - */ - public final boolean isPolymorphic() { - return isPolymorphic; - } - - /** - * Gets whether this model is a parent in a polymorphic hierarchy. - * - * @return Whether this model is a parent in a polymorphic hierarchy. - */ - public final boolean isPolymorphicParent() { - return isPolymorphicParent; - } - - /** - * Gets the properties used by parent models as polymorphic discriminators. - *

- * The only time this will return a non-empty list is when this model is used in a multi-level polymorphic - * hierarchy. Or, as an example, if the root model uses a polymorphic discriminator of {@code kind} and this model - * uses a polymorphic discriminator of {@code type} this will have a single property where the serialized name is - * {@code kind} and the default value for it will be what to root model uses to determine that this is the model - * that should be deserialized. Continuing this example, the third level models, or those that are determined by the - * {@code type} value, will also have a single property where the serialized name is {@code kind} and the default - * value will be what the second level model uses to determine that this is the model that should be deserialized. - * This is because the {@code kind} property will always need to be present for these models. If there are even - * deeper levels of polymorphism, the same pattern will continue. So, if in the third level there is a model that - * introduces another polymorphic discriminator of {@code format} that model would have two properties in this list, - * one with {@code kind} with a default that determined the second level model and one with {@code type} with a - * default that determined the third level model. The fourth level model would then have both as well. - * - * @return The properties used by parent models as polymorphic discriminators. - */ - public final List getParentPolymorphicDiscriminators() { - return parentPolymorphicDiscriminators; - } - - /** - * Gets the property that determines which polymorphic model type to create. - * - * @return The property that determines which polymorphic model type to create. - */ - public final ClientModelProperty getPolymorphicDiscriminator() { - return polymorphicDiscriminator; - } - - /** - * Gets the name of the property that determines which polymorphic model type to create. - * - * @return The name of the property that determines which polymorphic model type to create. - */ - public final String getPolymorphicDiscriminatorName() { - return polymorphicDiscriminatorName; - } - - /** - * Gets the name that is used for this model when it is serialized. - * - * @return The name that is used for this model when it is serialized. - */ - public final String getSerializedName() { - return serializedName; - } - - /** - * Gets whether this model needs serialization flattening. - * - * @return Whether this model needs serialization flattening. - */ - public final boolean getNeedsFlatten() { - return needsFlatten; - } - - /** - * Gets the parent model of this model. - * - * @return The parent model of this model. - */ - public final String getParentModelName() { - return parentModelName; - } - - /** - * Gets the models that derive from this model. - * - * @return The models that derive from this model. - */ - public final List getDerivedModels() { - return derivedModels; - } - - /** - * Gets the name that will be used for this model's XML element representation. - * - * @return The name that will be used for this model's XML element representation. - */ - public final String getXmlName() { - return xmlName; - } - - /** - * Gets the XML namespace that will be used for this model's XML element representation. - * - * @return The XML namespace that will be used for this model's XML element representation. - */ - public String getXmlNamespace() { - return xmlNamespace; - } - - /** - * Gets the properties for this model. - * - * @return The properties for this model. - */ - public final List getProperties() { - return properties; - } - - /** - * Gets the type of the model. - * - * @return The type of the model. - */ - public IType getType() { - return modelType; - } - - /** - * Gets the property references for this model. They are used to call property method from i.e. a parent model. - * - * @return The property references for this model. - */ - public List getPropertyReferences() { - return propertyReferences == null ? Collections.emptyList() : propertyReferences; - } - - /** - * Whether this model is a strongly-typed HTTP headers class. - * - * @return Whether this model is a strongly-typed HTTP headers class. - */ - public boolean isStronglyTypedHeader() { - return stronglyTypedHeader; - } - - /** - * Gets the implementation details for the model. - * - * @return The implementation details for the model. - */ - public ImplementationDetails getImplementationDetails() { - return implementationDetails; - } - - /** - * List the properties that have access (getter or setter) methods. - *

- * It does not include properties from superclass (even though they can be accessed via inheritance). It does not - * include properties that only have private access (e.g. property of a flattened model). It includes properties - * that can be accessed from the model but not declared in this model (e.g. properties from a flattened model). - * - * @return The properties that have access (getter or setter) methods. - */ - public List getAccessibleProperties() { - List propertyAccesses = new ArrayList<>(); - if (properties != null) { - for (ClientModelProperty property : properties) { - if (!property.getClientFlatten()) { - propertyAccesses.add(property); - } - } - } - - for (ClientModelPropertyReference clientModelPropertyReference : getPropertyReferences()) { - if (clientModelPropertyReference.isFromFlattenedProperty()) { - propertyAccesses.add(clientModelPropertyReference); - } - } - - return propertyAccesses; - } - - /** - * Add this ServiceModel's imports to the provided set of imports. - * - * @param imports The set of imports to add to. - * @param settings The settings for this Java generator session. - */ - public void addImportsTo(Set imports, JavaSettings settings) { - // whether annotated as Immutable or Fluent is also determined by its superclass - imports.add(this.getFullName()); - addFluentAnnotationImport(imports); - addImmutableAnnotationImport(imports); - - if (settings.getClientFlattenAnnotationTarget() == JavaSettings.ClientFlattenAnnotationTarget.TYPE - && needsFlatten) { - addJsonFlattenAnnotationImport(imports); - } - - imports.addAll(getImports()); - - if (isPolymorphic()) { - imports.add("com.fasterxml.jackson.annotation.JsonTypeInfo"); - imports.add("com.fasterxml.jackson.annotation.JsonTypeName"); - - if (getDerivedModels() != null && getDerivedModels().size() > 0) { - imports.add("com.fasterxml.jackson.annotation.JsonSubTypes"); - getDerivedModels().forEach(m -> imports.add(m.getFullName())); - } - } - - for (ClientModelProperty property : getProperties()) { - property.addImportsTo(imports, usedInXml); - } - } - - /** - * Add the Fluent annotation import to the provided set of imports. - * - * @param imports The set of imports to add to. - */ - protected void addJsonFlattenAnnotationImport(Set imports) { - imports.add("com.azure.core.annotation.JsonFlatten"); - } - - /** - * Add the Immutable annotation import to the provided set of imports. - * - * @param imports The set of imports to add to. - */ - protected void addImmutableAnnotationImport(Set imports) { - Annotation.IMMUTABLE.addImportsTo(imports); - if (!JavaSettings.getInstance().isBranded()) { - Annotation.TYPE_CONDITIONS.addImportsTo(imports); - Annotation.METADATA.addImportsTo(imports); - } - } - - /** - * Add the Fluent annotation import to the provided set of imports. - * - * @param imports The set of imports to add to. - */ - protected void addFluentAnnotationImport(Set imports) { - Annotation.FLUENT.addImportsTo(imports); - if (!JavaSettings.getInstance().isBranded()) { - Annotation.METADATA.addImportsTo(imports); - } - } - - /** - * Whether the model is used in XML serialization. - * - * @return Whether the model is used in XML serialization. - */ - public final boolean isUsedInXml() { - return usedInXml; - } - - /** - * Gets the Set of serialization format of the model. - * - * @return the Set of serialization format of the model. - */ - public Set getSerializationFormats() { - return serializationFormats; - } - - /** - * A builder for building a new ClientModel. - */ - public static class Builder { - protected String packageName; - protected String name; - protected List imports = Collections.emptyList(); - protected String description; - protected boolean isPolymorphic; - protected ClientModelProperty polymorphicDiscriminator; - protected String polymorphicDiscriminatorName; - protected String serializedName; - protected boolean needsFlatten = false; - protected String parentModelName; - protected List derivedModels = Collections.emptyList(); - protected String xmlName; - protected List properties; - protected String xmlNamespace; - protected List propertyReferences; - protected IType modelType; - protected boolean stronglyTypedHeader; - protected ImplementationDetails implementationDetails; - protected boolean usedInXml; - protected String crossLanguageDefinitionId; - protected Set serializationFormats = Collections.emptySet(); - - /** - * Sets the package that this model class belongs to. - * - * @param packageName the package that this model class belongs to - * @return the Builder itself - */ - public Builder packageName(String packageName) { - this.packageName = packageName; - return this; - } - - /** - * Sets the name of this model. - * - * @param name the name of this model - * @return the Builder itself - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Sets the imports for this model. - * - * @param imports the imports for this model - * @return the Builder itself - */ - public Builder imports(List imports) { - this.imports = imports; - return this; - } - - /** - * Sets the description of this model. - * - * @param description the description of this model - * @return the Builder itself - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Sets whether this model has model types that derive from it. - * - * @param isPolymorphic whether this model has model types that derive from it - * @return the Builder itself - */ - public Builder polymorphic(boolean isPolymorphic) { - this.isPolymorphic = isPolymorphic; - return this; - } - - /** - * Sets the property that determines which polymorphic model type to create. - * - * @param polymorphicDiscriminator the property that determines which polymorphic model type to create - * @return the Builder itself - */ - public Builder polymorphicDiscriminator(ClientModelProperty polymorphicDiscriminator) { - this.polymorphicDiscriminator = polymorphicDiscriminator; - return this; - } - - public Builder polymorphicDiscriminatorName(String polymorphicDiscriminatorName) { - this.polymorphicDiscriminatorName = polymorphicDiscriminatorName; - return this; - } - - /** - * Sets the name that is used for this model when it is serialized. - * - * @param serializedName the name that is used for this model when it is serialized - * @return the Builder itself - */ - public Builder serializedName(String serializedName) { - this.serializedName = serializedName; - return this; - } - - /** - * Sets whether this model needs serialization flattening. - * - * @param needsFlatten whether this model needs serialization flattening - * @return the Builder itself - */ - public Builder needsFlatten(boolean needsFlatten) { - this.needsFlatten = needsFlatten; - return this; - } - - /** - * Sets the parent model of this model. - * - * @param parentModelName the parent model of this model - * @return the Builder itself - */ - public Builder parentModelName(String parentModelName) { - this.parentModelName = parentModelName; - return this; - } - - /** - * Sets the models that derive from this model. - * - * @param derivedModels the models that derive from this model - * @return the Builder itself - */ - public Builder derivedModels(List derivedModels) { - this.derivedModels = derivedModels; - return this; - } - - /** - * Sets the name that will be used for this model's XML element representation. - * - * @param xmlName the name that will be used for this model's XML element representation - * @return the Builder itself - */ - public Builder xmlName(String xmlName) { - this.xmlName = xmlName; - return this; - } - - /** - * Sets the XML namespace that will be used for this model's XML element representation. - * - * @param xmlNamespace the XML namespace that will be used for this model's XML element representation - * @return the Builder itself - */ - public Builder xmlNamespace(String xmlNamespace) { - this.xmlNamespace = xmlNamespace; - return this; - } - - /** - * Sets the properties for this model. - * - * @param properties the properties for this model - * @return the Builder itself - */ - public Builder properties(List properties) { - this.properties = properties; - return this; - } - - /** - * Sets the property references for this model. They are used to call property method from i.e. a parent model. - * - * @param propertyReferences the property references. - * @return the Builder itself - */ - public Builder propertyReferences(List propertyReferences) { - this.propertyReferences = propertyReferences; - return this; - } - - /** - * Sets the model type. - * - * @param modelType the model type. - * @return the Builder itself - */ - public Builder type(IType modelType) { - this.modelType = modelType; - return this; - } - - /** - * Sets whether the model is a strongly-typed HTTP headers class. - * - * @param stronglyTypedHeader Whether the model is a strongly-typed HTTP headers class. - * @return the Builder itself - */ - public Builder stronglyTypedHeader(boolean stronglyTypedHeader) { - this.stronglyTypedHeader = stronglyTypedHeader; - return this; - } - - /** - * Sets the implementation details for the model. - * - * @param implementationDetails the implementation details. - * @return the Builder itself - */ - public Builder implementationDetails(ImplementationDetails implementationDetails) { - this.implementationDetails = implementationDetails; - return this; - } - - /** - * Sets whether the model is used in XML serialization. - * - * @param usedInXml Whether the model is used in XML serialization. - * @return the Builder itself - */ - public Builder usedInXml(boolean usedInXml) { - this.usedInXml = usedInXml; - return this; - } - - /** - * Sets the cross language definition id for the model. - * - * @param crossLanguageDefinitionId the cross language definition id for the model. - * @return the Builder itself - */ - public Builder crossLanguageDefinitionId(String crossLanguageDefinitionId) { - this.crossLanguageDefinitionId = crossLanguageDefinitionId; - return this; - } - - /** - * Sets the Set of serialization format of this model. - * - * @param serializationFormats the Set of serialization format of this model. - * @return the Builder itself - */ - public Builder serializationFormats(Set serializationFormats) { - this.serializationFormats = serializationFormats == null ? Collections.emptySet() : serializationFormats; - return this; - } - - /** - * Build a new ClientModel instance with the provided properties. - * - * @return a new ClientModel instance with the provided properties - */ - public ClientModel build() { - return new ClientModel(packageName, name, imports, description, isPolymorphic, polymorphicDiscriminator, - polymorphicDiscriminatorName, serializedName, needsFlatten, parentModelName, derivedModels, xmlName, - xmlNamespace, properties, propertyReferences, modelType, stronglyTypedHeader, implementationDetails, - usedInXml, serializationFormats, crossLanguageDefinitionId); - } + public ClientModel build() { + return new ClientModel(packageName, name, imports, description, isPolymorphic, polymorphicDiscriminator, + polymorphicDiscriminatorName, serializedName, needsFlatten, parentModelName, derivedModels, xmlName, + xmlNamespace, properties, propertyReferences, modelType, stronglyTypedHeader, implementationDetails, + usedInXml, serializationFormats, crossLanguageDefinitionId); } + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/PrimitiveType.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/PrimitiveType.java index e29be8009..a19b73906 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/PrimitiveType.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/PrimitiveType.java @@ -12,127 +12,152 @@ import java.util.function.Function; * A basic type used by a client. */ public class PrimitiveType implements IType { - public static final PrimitiveType VOID = new Builder() - .name("void") - .nullableType(ClassType.VOID) - .build(); + public static final PrimitiveType VOID = new Builder() + .name("void") + .nullableType(ClassType.VOID) + .build(); - public static final PrimitiveType BOOLEAN = new Builder() - .name("boolean") - .nullableType(ClassType.BOOLEAN) - .defaultValueExpressionConverter(String::toLowerCase) - .defaultValue("false") - .jsonToken("JsonToken.BOOLEAN") - .serializationMethodBase("writeBoolean") - .jsonDeserializationMethod("getBoolean()") - .xmlAttributeDeserializationTemplate("%s.getBooleanAttribute(%s, %s)") - .xmlElementDeserializationMethod("getBooleanElement()") - .build(); + public static final PrimitiveType BOOLEAN = new Builder() + .name("boolean") + .nullableType(ClassType.BOOLEAN) + .defaultValueExpressionConverter(String::toLowerCase) + .defaultValue("false") + .jsonToken("JsonToken.BOOLEAN") + .serializationMethodBase("writeBoolean") + .jsonDeserializationMethod("getBoolean()") + .xmlAttributeDeserializationTemplate("%s.getBooleanAttribute(%s, %s)") + .xmlElementDeserializationMethod("getBooleanElement()") + .build(); - public static final PrimitiveType BYTE = new Builder() - .name("byte") - .nullableType(ClassType.BYTE) - .defaultValueExpressionConverter(Function.identity()) - .defaultValue("0") - .jsonToken("JsonToken.NUMBER") - .serializationMethodBase("writeInt") - .jsonDeserializationMethod("getInt()") - .xmlAttributeDeserializationTemplate("%s.getIntAttribute(%s, %s)") - .xmlElementDeserializationMethod("getIntElement()") - .build(); + public static final PrimitiveType BYTE = new Builder() + .name("byte") + .nullableType(ClassType.BYTE) + .defaultValueExpressionConverter(Function.identity()) + .defaultValue("0") + .jsonToken("JsonToken.NUMBER") + .serializationMethodBase("writeInt") + .jsonDeserializationMethod("getInt()") + .xmlAttributeDeserializationTemplate("%s.getIntAttribute(%s, %s)") + .xmlElementDeserializationMethod("getIntElement()") + .build(); - public static final PrimitiveType INT = new Builder() - .name("int") - .nullableType(ClassType.INTEGER) - .defaultValueExpressionConverter(Function.identity()) - .defaultValue("0") - .jsonToken("JsonToken.NUMBER") - .serializationMethodBase("writeInt") - .jsonDeserializationMethod("getInt()") - .xmlAttributeDeserializationTemplate("%s.getIntAttribute(%s, %s)") - .xmlElementDeserializationMethod("getIntElement()") - .build(); + public static final PrimitiveType INT = new Builder() + .name("int") + .nullableType(ClassType.INTEGER) + .defaultValueExpressionConverter(Function.identity()) + .defaultValue("0") + .jsonToken("JsonToken.NUMBER") + .serializationMethodBase("writeInt") + .jsonDeserializationMethod("getInt()") + .xmlAttributeDeserializationTemplate("%s.getIntAttribute(%s, %s)") + .xmlElementDeserializationMethod("getIntElement()") + .build(); - public static final PrimitiveType LONG = new Builder() - .prototypeAsLong() - .build(); + public static final PrimitiveType LONG = new Builder() + .prototypeAsLong() + .build(); - public static final PrimitiveType FLOAT = new Builder() - .name("float") - .nullableType(ClassType.FLOAT) - .defaultValueExpressionConverter(defaultValueExpression -> defaultValueExpression + "f") - .defaultValue("0.0") - .jsonToken("JsonToken.NUMBER") - .serializationMethodBase("writeFloat") - .jsonDeserializationMethod("getFloat()") - .xmlAttributeDeserializationTemplate("%s.getFloatAttribute(%s, %s)") - .xmlElementDeserializationMethod("getFloatElement()") - .build(); + public static final PrimitiveType INT_AS_STRING = new Builder() + .name("int") + .nullableType(ClassType.INTEGER_AS_STRING) + .defaultValueExpressionConverter(defaultValueExpression -> "Integer.parseInt(\"" + defaultValueExpression + "\")") + .jsonToken("JsonToken.STRING") + .defaultValue("0") + .serializationMethodBase("writeString") + .wrapSerializationWithObjectsToString(true) + .jsonDeserializationMethod("getNullable(nonNullReader -> Integer.parseInt(nonNullReader.getString()))") + .xmlElementDeserializationMethod("getNullableElement(Integer::valueOf)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Integer::valueOf)") + .build(); - public static final PrimitiveType DOUBLE = new Builder() - .prototypeAsDouble() - .build(); + public static final PrimitiveType LONG_AS_STRING = new Builder() + .prototypeAsLong() + .nullableType(ClassType.LONG_AS_STRING) + .defaultValueExpressionConverter(defaultValueExpression -> "Long.parseLong(\"" + defaultValueExpression + "\")") + .jsonToken("JsonToken.STRING") + .serializationMethodBase("writeString") + .wrapSerializationWithObjectsToString(true) + .jsonDeserializationMethod("getNullable(nonNullReader -> Long.parseLong(nonNullReader.getString()))") + .xmlElementDeserializationMethod("getNullableElement(Long::valueOf)") + .xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, Long::valueOf)") + .build(); - public static final PrimitiveType CHAR = new Builder() - .name("char") - .nullableType(ClassType.CHARACTER) - .defaultValueExpressionConverter(defaultValueExpression -> Integer.toString(defaultValueExpression.charAt(0))) - .defaultValue("\u0000") - .jsonToken("JsonToken.STRING") - .serializationMethodBase("writeString") - .wrapSerializationWithObjectsToString(true) - .jsonDeserializationMethod("getString().charAt(0)") - .xmlAttributeDeserializationTemplate("%s.getStringAttribute(%s, %s).charAt(0)") - .xmlElementDeserializationMethod("getStringElement().charAt(0)") - .build(); + public static final PrimitiveType FLOAT = new Builder() + .name("float") + .nullableType(ClassType.FLOAT) + .defaultValueExpressionConverter(defaultValueExpression -> defaultValueExpression + "f") + .defaultValue("0.0") + .jsonToken("JsonToken.NUMBER") + .serializationMethodBase("writeFloat") + .jsonDeserializationMethod("getFloat()") + .xmlAttributeDeserializationTemplate("%s.getFloatAttribute(%s, %s)") + .xmlElementDeserializationMethod("getFloatElement()") + .build(); - public static final PrimitiveType UNIX_TIME_LONG = new Builder() - .prototypeAsLong() - .nullableType(ClassType.UNIX_TIME_LONG) - .build(); + public static final PrimitiveType DOUBLE = new Builder() + .prototypeAsDouble() + .build(); - public static final PrimitiveType DURATION_LONG = new Builder() - .prototypeAsLong() - .nullableType(ClassType.DURATION_LONG) - .build(); + public static final PrimitiveType CHAR = new Builder() + .name("char") + .nullableType(ClassType.CHARACTER) + .defaultValueExpressionConverter(defaultValueExpression -> Integer.toString(defaultValueExpression.charAt(0))) + .defaultValue("\u0000") + .jsonToken("JsonToken.STRING") + .serializationMethodBase("writeString") + .wrapSerializationWithObjectsToString(true) + .jsonDeserializationMethod("getString().charAt(0)") + .xmlAttributeDeserializationTemplate("%s.getStringAttribute(%s, %s).charAt(0)") + .xmlElementDeserializationMethod("getStringElement().charAt(0)") + .build(); - public static final PrimitiveType DURATION_DOUBLE = new Builder() - .prototypeAsDouble() - .nullableType(ClassType.DURATION_DOUBLE) - .build(); + public static final PrimitiveType UNIX_TIME_LONG = new Builder() + .prototypeAsLong() + .nullableType(ClassType.UNIX_TIME_LONG) + .build(); - /** - * The name of this type. - */ - private final String name; - /** - * The nullable version of this primitive type. - */ - private final ClassType nullableType; - private final Function defaultValueExpressionConverter; - private final String defaultValue; - private final String jsonToken; - private final String serializationMethodBase; - private final boolean wrapSerializationWithObjectsToString; - private final String jsonDeserializationMethod; - private final String xmlAttributeDeserializationTemplate; - private final String xmlElementDeserializationMethod; + public static final PrimitiveType DURATION_LONG = new Builder() + .prototypeAsLong() + .nullableType(ClassType.DURATION_LONG) + .build(); - private PrimitiveType(String name, ClassType nullableType, Function defaultValueExpressionConverter, - String defaultValue, String jsonToken, String serializationMethodBase, - boolean wrapSerializationWithObjectsToString, String jsonDeserializationMethod, - String xmlAttributeDeserializationTemplate, String xmlElementDeserializationMethod) { - this.name = name; - this.nullableType = nullableType; - this.defaultValueExpressionConverter = defaultValueExpressionConverter; - this.defaultValue = defaultValue; - this.jsonToken = jsonToken; - this.serializationMethodBase = serializationMethodBase; - this.wrapSerializationWithObjectsToString = wrapSerializationWithObjectsToString; - this.jsonDeserializationMethod = jsonDeserializationMethod; - this.xmlAttributeDeserializationTemplate = xmlAttributeDeserializationTemplate; - this.xmlElementDeserializationMethod = xmlElementDeserializationMethod; - } + public static final PrimitiveType DURATION_DOUBLE = new Builder() + .prototypeAsDouble() + .nullableType(ClassType.DURATION_DOUBLE) + .build(); + + /** + * The name of this type. + */ + private final String name; + /** + * The nullable version of this primitive type. + */ + private final ClassType nullableType; + private final Function defaultValueExpressionConverter; + private final String defaultValue; + private final String jsonToken; + private final String serializationMethodBase; + private final boolean wrapSerializationWithObjectsToString; + private final String jsonDeserializationMethod; + private final String xmlAttributeDeserializationTemplate; + private final String xmlElementDeserializationMethod; + + private PrimitiveType(String name, ClassType nullableType, Function defaultValueExpressionConverter, + String defaultValue, String jsonToken, String serializationMethodBase, + boolean wrapSerializationWithObjectsToString, String jsonDeserializationMethod, + String xmlAttributeDeserializationTemplate, String xmlElementDeserializationMethod) { + this.name = name; + this.nullableType = nullableType; + this.defaultValueExpressionConverter = defaultValueExpressionConverter; + this.defaultValue = defaultValue; + this.jsonToken = jsonToken; + this.serializationMethodBase = serializationMethodBase; + this.wrapSerializationWithObjectsToString = wrapSerializationWithObjectsToString; + this.jsonDeserializationMethod = jsonDeserializationMethod; + this.xmlAttributeDeserializationTemplate = xmlAttributeDeserializationTemplate; + this.xmlElementDeserializationMethod = xmlElementDeserializationMethod; + } // public static PrimitiveType fromNullableType(ClassType nullableType) { // if (nullableType == ClassType.Void) { @@ -154,262 +179,262 @@ public class PrimitiveType implements IType { // } // } - public final String getName() { - return name; + public final String getName() { + return name; + } + + private ClassType getNullableType() { + return nullableType; + } + + @Override + public final void addImportsTo(Set imports, boolean includeImplementationImports) { + if (this == PrimitiveType.UNIX_TIME_LONG) { + imports.add(Instant.class.getName()); + imports.add(ZoneOffset.class.getName()); + } + } + + @Override + public final boolean isNullable() { + return false; + } + + @Override + public final IType asNullable() { + return getNullableType(); + } + + @Override + public final boolean contains(IType type) { + return this == type; + } + + private Function getDefaultValueExpressionConverter() { + return defaultValueExpressionConverter; + } + + @Override + public final String defaultValueExpression(String sourceExpression) { + String result = sourceExpression; + if (result != null && getDefaultValueExpressionConverter() != null) { + result = defaultValueExpressionConverter.apply(sourceExpression); + } + return result; + } + + @Override + public final String defaultValueExpression() { + return defaultValueExpression(defaultValue); + } + + @Override + public final IType getClientType() { + IType clientType = this; + if (this == PrimitiveType.UNIX_TIME_LONG) { + clientType = ClassType.UNIX_TIME_DATE_TIME; + } else if (this == PrimitiveType.DURATION_LONG) { + clientType = ClassType.DURATION; + } else if (this == PrimitiveType.DURATION_DOUBLE) { + clientType = ClassType.DURATION; + } + return clientType; + } + + @Override + public final String convertToClientType(String expression) { + if (getClientType() == this) { + return expression; } - private ClassType getNullableType() { - return nullableType; + if (this == PrimitiveType.UNIX_TIME_LONG) { + expression = String.format("OffsetDateTime.ofInstant(Instant.ofEpochSecond(%1$s), ZoneOffset.UTC)", expression); + } else if (this == PrimitiveType.DURATION_LONG) { + expression = String.format("Duration.ofSeconds(%s)", expression); + } else if (this == PrimitiveType.DURATION_DOUBLE) { + expression = String.format("Duration.ofNanos((long) (%s * 1000_000_000L))", expression); + } + return expression; + } + + @Override + public final String convertFromClientType(String expression) { + if (getClientType() == this) { + return expression; } - @Override - public final void addImportsTo(Set imports, boolean includeImplementationImports) { - if (this == PrimitiveType.UNIX_TIME_LONG) { - imports.add(Instant.class.getName()); - imports.add(ZoneOffset.class.getName()); - } + if (this == PrimitiveType.UNIX_TIME_LONG) { + expression = String.format("%1$s.toEpochSecond()", expression); + } else if (this == PrimitiveType.DURATION_LONG) { + expression = String.format("%s.getSeconds()", expression); + } else if (this == PrimitiveType.DURATION_DOUBLE) { + expression = String.format("(double) %s.toNanos() / 1000_000_000L", expression); + } + return expression; + } + + @Override + public final String validate(String expression) { + return null; + } + + @Override + public String jsonToken() { + return jsonToken; + } + + @Override + public String jsonDeserializationMethod(String jsonReaderName) { + if (jsonDeserializationMethod == null) { + return null; } - @Override - public final boolean isNullable() { - return false; + return jsonReaderName + "." + jsonDeserializationMethod; + } + + @Override + public String jsonSerializationMethodCall(String jsonWriterName, String fieldName, String valueGetter, + boolean jsonMergePatch) { + if (wrapSerializationWithObjectsToString) { + return fieldName == null + ? String.format("%s.%s(Objects.toString(%s, null))", jsonWriterName, serializationMethodBase, valueGetter) + : String.format("%s.%sField(\"%s\", Objects.toString(%s, null))", jsonWriterName, + serializationMethodBase, fieldName, valueGetter); } - @Override - public final IType asNullable() { - return getNullableType(); + return fieldName == null + ? String.format("%s.%s(%s)", jsonWriterName, serializationMethodBase, valueGetter) + : String.format("%s.%sField(\"%s\", %s)", jsonWriterName, serializationMethodBase, fieldName, valueGetter); + } + + @Override + public String xmlDeserializationMethod(String xmlReaderName, String attributeName, String attributeNamespace, + boolean namespaceIsConstant) { + if (attributeName == null) { + return xmlReaderName + "." + xmlElementDeserializationMethod; + } else if (attributeNamespace == null) { + return String.format(xmlAttributeDeserializationTemplate, xmlReaderName, "null", + "\"" + attributeName + "\""); + } else { + String namespace = namespaceIsConstant ? attributeNamespace : "\"" + attributeNamespace + "\""; + return String.format(xmlAttributeDeserializationTemplate, xmlReaderName, namespace, + "\"" + attributeName + "\""); + } + } + + @Override + public String xmlSerializationMethodCall(String xmlWriterName, String attributeOrElementName, String namespaceUri, + String valueGetter, boolean isAttribute, boolean nameIsVariable, boolean namespaceIsConstant) { + String value = wrapSerializationWithObjectsToString + ? "Objects.toString(" + valueGetter + ", null)" : valueGetter; + + return ClassType.xmlSerializationCallHelper(xmlWriterName, serializationMethodBase, attributeOrElementName, + namespaceUri, value, isAttribute, nameIsVariable, namespaceIsConstant); + } + + @Override + public boolean isUsedInXml() { + return false; + } + + @Override + public String toString() { + return getName(); + } + + private static class Builder { + + private String name; + private ClassType nullableType; + private Function defaultValueExpressionConverter; + private String defaultValue; + private String jsonToken; + private String serializationMethodBase; + private boolean wrapSerializationWithObjectsToString = false; + private String jsonDeserializationMethod; + private String xmlAttributeDeserializationTemplate; + private String xmlElementDeserializationMethod; + + public Builder name(String name) { + this.name = name; + return this; } - @Override - public final boolean contains(IType type) { - return this == type; + public Builder prototypeAsLong() { + return this.name("long") + .nullableType(ClassType.LONG) + .defaultValueExpressionConverter(defaultValueExpression -> defaultValueExpression + 'L') + .defaultValue("0") + .jsonToken("JsonToken.NUMBER") + .serializationMethodBase("writeLong") + .wrapSerializationWithObjectsToString(false) + .jsonDeserializationMethod("getLong()") + .xmlAttributeDeserializationTemplate("%s.getLongAttribute(%s, %s)") + .xmlElementDeserializationMethod("getLongElement()"); } - private Function getDefaultValueExpressionConverter() { - return defaultValueExpressionConverter; + public Builder prototypeAsDouble() { + return this.name("double") + .nullableType(ClassType.DOUBLE) + .defaultValueExpressionConverter(defaultValueExpression -> java.lang.Double.toString(java.lang.Double.parseDouble(defaultValueExpression))) + .defaultValue("0.0") + .jsonToken("JsonToken.NUMBER") + .serializationMethodBase("writeDouble") + .wrapSerializationWithObjectsToString(false) + .jsonDeserializationMethod("getDouble()") + .xmlAttributeDeserializationTemplate("%s.getDoubleAttribute(%s, %s)") + .xmlElementDeserializationMethod("getDoubleElement()"); } - @Override - public final String defaultValueExpression(String sourceExpression) { - String result = sourceExpression; - if (result != null && getDefaultValueExpressionConverter() != null) { - result = defaultValueExpressionConverter.apply(sourceExpression); - } - return result; + public Builder nullableType(ClassType nullableType) { + this.nullableType = nullableType; + return this; } - @Override - public final String defaultValueExpression() { - return defaultValueExpression(defaultValue); + public Builder defaultValue(String defaultValue) { + this.defaultValue = defaultValue; + return this; } - @Override - public final IType getClientType() { - IType clientType = this; - if (this == PrimitiveType.UNIX_TIME_LONG) { - clientType = ClassType.UNIX_TIME_DATE_TIME; - } else if (this == PrimitiveType.DURATION_LONG) { - clientType = ClassType.DURATION; - } else if (this == PrimitiveType.DURATION_DOUBLE) { - clientType = ClassType.DURATION; - } - return clientType; + public Builder defaultValueExpressionConverter(java.util.function.Function defaultValueExpressionConverter) { + this.defaultValueExpressionConverter = defaultValueExpressionConverter; + return this; } - @Override - public final String convertToClientType(String expression) { - if (getClientType() == this) { - return expression; - } - - if (this == PrimitiveType.UNIX_TIME_LONG) { - expression = String.format("OffsetDateTime.ofInstant(Instant.ofEpochSecond(%1$s), ZoneOffset.UTC)", expression); - } else if (this == PrimitiveType.DURATION_LONG) { - expression = String.format("Duration.ofSeconds(%s)", expression); - } else if (this == PrimitiveType.DURATION_DOUBLE) { - expression = String.format("Duration.ofNanos((long) (%s * 1000_000_000L))", expression); - } - return expression; + public Builder wrapSerializationWithObjectsToString(boolean wrapSerializationWithObjectsToString) { + this.wrapSerializationWithObjectsToString = wrapSerializationWithObjectsToString; + return this; } - @Override - public final String convertFromClientType(String expression) { - if (getClientType() == this) { - return expression; - } - - if (this == PrimitiveType.UNIX_TIME_LONG) { - expression = String.format("%1$s.toEpochSecond()", expression); - } else if (this == PrimitiveType.DURATION_LONG) { - expression = String.format("%s.getSeconds()", expression); - } else if (this == PrimitiveType.DURATION_DOUBLE) { - expression = String.format("(double) %s.toNanos() / 1000_000_000L", expression); - } - return expression; + public Builder jsonToken(String jsonToken) { + this.jsonToken = jsonToken; + return this; } - @Override - public final String validate(String expression) { - return null; + public Builder jsonDeserializationMethod(String jsonDeserializationMethod) { + this.jsonDeserializationMethod = jsonDeserializationMethod; + return this; } - @Override - public String jsonToken() { - return jsonToken; + public Builder serializationMethodBase(String serializationMethodBase) { + this.serializationMethodBase = serializationMethodBase; + return this; } - @Override - public String jsonDeserializationMethod(String jsonReaderName) { - if (jsonDeserializationMethod == null) { - return null; - } - - return jsonReaderName + "." + jsonDeserializationMethod; + public Builder xmlAttributeDeserializationTemplate(String xmlAttributeDeserializationTemplate) { + this.xmlAttributeDeserializationTemplate = xmlAttributeDeserializationTemplate; + return this; } - @Override - public String jsonSerializationMethodCall(String jsonWriterName, String fieldName, String valueGetter, - boolean jsonMergePatch) { - if (wrapSerializationWithObjectsToString) { - return fieldName == null - ? String.format("%s.%s(Objects.toString(%s, null))", jsonWriterName, serializationMethodBase, valueGetter) - : String.format("%s.%sField(\"%s\", Objects.toString(%s, null))", jsonWriterName, - serializationMethodBase, fieldName, valueGetter); - } - - return fieldName == null - ? String.format("%s.%s(%s)", jsonWriterName, serializationMethodBase, valueGetter) - : String.format("%s.%sField(\"%s\", %s)", jsonWriterName, serializationMethodBase, fieldName, valueGetter); + public Builder xmlElementDeserializationMethod(String xmlElementDeserializationMethod) { + this.xmlElementDeserializationMethod = xmlElementDeserializationMethod; + return this; } - @Override - public String xmlDeserializationMethod(String xmlReaderName, String attributeName, String attributeNamespace, - boolean namespaceIsConstant) { - if (attributeName == null) { - return xmlReaderName + "." + xmlElementDeserializationMethod; - } else if (attributeNamespace == null) { - return String.format(xmlAttributeDeserializationTemplate, xmlReaderName, "null", - "\"" + attributeName + "\""); - } else { - String namespace = namespaceIsConstant ? attributeNamespace : "\"" + attributeNamespace + "\""; - return String.format(xmlAttributeDeserializationTemplate, xmlReaderName, namespace, - "\"" + attributeName + "\""); - } - } - - @Override - public String xmlSerializationMethodCall(String xmlWriterName, String attributeOrElementName, String namespaceUri, - String valueGetter, boolean isAttribute, boolean nameIsVariable, boolean namespaceIsConstant) { - String value = wrapSerializationWithObjectsToString - ? "Objects.toString(" + valueGetter + ", null)" : valueGetter; - - return ClassType.xmlSerializationCallHelper(xmlWriterName, serializationMethodBase, attributeOrElementName, - namespaceUri, value, isAttribute, nameIsVariable, namespaceIsConstant); - } - - @Override - public boolean isUsedInXml() { - return false; - } - - @Override - public String toString() { - return getName(); - } - - private static class Builder { - - private String name; - private ClassType nullableType; - private Function defaultValueExpressionConverter; - private String defaultValue; - private String jsonToken; - private String serializationMethodBase; - private boolean wrapSerializationWithObjectsToString = false; - private String jsonDeserializationMethod; - private String xmlAttributeDeserializationTemplate; - private String xmlElementDeserializationMethod; - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder prototypeAsLong() { - return this.name("long") - .nullableType(ClassType.LONG) - .defaultValueExpressionConverter(defaultValueExpression -> defaultValueExpression + 'L') - .defaultValue("0") - .jsonToken("JsonToken.NUMBER") - .serializationMethodBase("writeLong") - .wrapSerializationWithObjectsToString(false) - .jsonDeserializationMethod("getLong()") - .xmlAttributeDeserializationTemplate("%s.getLongAttribute(%s, %s)") - .xmlElementDeserializationMethod("getLongElement()"); - } - - public Builder prototypeAsDouble() { - return this.name("double") - .nullableType(ClassType.DOUBLE) - .defaultValueExpressionConverter(defaultValueExpression -> java.lang.Double.toString(java.lang.Double.parseDouble(defaultValueExpression))) - .defaultValue("0.0") - .jsonToken("JsonToken.NUMBER") - .serializationMethodBase("writeDouble") - .wrapSerializationWithObjectsToString(false) - .jsonDeserializationMethod("getDouble()") - .xmlAttributeDeserializationTemplate("%s.getDoubleAttribute(%s, %s)") - .xmlElementDeserializationMethod("getDoubleElement()"); - } - - public Builder nullableType(ClassType nullableType) { - this.nullableType = nullableType; - return this; - } - - public Builder defaultValue(String defaultValue) { - this.defaultValue = defaultValue; - return this; - } - - public Builder defaultValueExpressionConverter(java.util.function.Function defaultValueExpressionConverter) { - this.defaultValueExpressionConverter = defaultValueExpressionConverter; - return this; - } - - public Builder wrapSerializationWithObjectsToString(boolean wrapSerializationWithObjectsToString) { - this.wrapSerializationWithObjectsToString = wrapSerializationWithObjectsToString; - return this; - } - - public Builder jsonToken(String jsonToken) { - this.jsonToken = jsonToken; - return this; - } - - public Builder jsonDeserializationMethod(String jsonDeserializationMethod) { - this.jsonDeserializationMethod = jsonDeserializationMethod; - return this; - } - - public Builder serializationMethodBase(String serializationMethodBase) { - this.serializationMethodBase = serializationMethodBase; - return this; - } - - public Builder xmlAttributeDeserializationTemplate(String xmlAttributeDeserializationTemplate) { - this.xmlAttributeDeserializationTemplate = xmlAttributeDeserializationTemplate; - return this; - } - - public Builder xmlElementDeserializationMethod(String xmlElementDeserializationMethod) { - this.xmlElementDeserializationMethod = xmlElementDeserializationMethod; - return this; - } - - public PrimitiveType build() { - return new PrimitiveType(name, nullableType, defaultValueExpressionConverter, defaultValue, jsonToken, - serializationMethodBase, wrapSerializationWithObjectsToString, jsonDeserializationMethod, - xmlAttributeDeserializationTemplate, xmlElementDeserializationMethod); - } + public PrimitiveType build() { + return new PrimitiveType(name, nullableType, defaultValueExpressionConverter, defaultValue, jsonToken, + serializationMethodBase, wrapSerializationWithObjectsToString, jsonDeserializationMethod, + xmlAttributeDeserializationTemplate, xmlElementDeserializationMethod); } + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ProxyMethodExample.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ProxyMethodExample.java index 63cb56b2b..05ce29441 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ProxyMethodExample.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ProxyMethodExample.java @@ -29,351 +29,316 @@ import java.util.stream.Stream; public class ProxyMethodExample { - private final Logger logger = new PluginLogger(Javagen.getPluginInstance(), ProxyMethodExample.class); - private static final String SLASH = "/"; + private final Logger logger = new PluginLogger(Javagen.getPluginInstance(), ProxyMethodExample.class); + private static final String SLASH = "/"; - private static String tspDirectory = null; + // https://azure.github.io/autorest/extensions/#x-ms-examples + // https://github.com/Azure/azure-rest-api-specs/blob/main/documentation/x-ms-examples.md - public static void setTspDirectory(String tspDirectory) { - ProxyMethodExample.tspDirectory = tspDirectory; + public static class ParameterValue { + private final Object objectValue; + + public ParameterValue(Object objectValue) { + this.objectValue = objectValue; } - // https://azure.github.io/autorest/extensions/#x-ms-examples - // https://github.com/Azure/azure-rest-api-specs/blob/main/documentation/x-ms-examples.md - - public static class ParameterValue { - private final Object objectValue; - - public ParameterValue(Object objectValue) { - this.objectValue = objectValue; - } - - /** - * @return the object value of the parameter - */ - public Object getObjectValue() { - return objectValue; - } - - /** - * Gets the un-escaped query value. - *

- * This is done by heuristic, and not guaranteed to be correct. - * - * @return the un-escaped query value - */ - public Object getUnescapedQueryValue() { - Object unescapedValue = objectValue; - if (objectValue instanceof String) { - unescapedValue = URLDecoder.decode((String) objectValue, StandardCharsets.UTF_8); - } - return unescapedValue; - } - - @Override - public String toString() { - return "ParameterValue{objectValue=" + getJsonString() + '}'; - } - - public String getJsonString() { - try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - JsonWriter jsonWriter = JsonProviders.createWriter(outputStream)) { - jsonWriter.writeUntyped(objectValue).flush(); - return outputStream.toString(StandardCharsets.UTF_8); - } catch (IOException e) { - return objectValue.toString(); - } - } - } - - public static class Response { - - private final int statusCode; - private final HttpHeaders httpHeaders; - private final Object body; - - @SuppressWarnings("unchecked") - public Response(int statusCode, Object response) { - this.statusCode = statusCode; - this.httpHeaders = new HttpHeaders(); - if (response instanceof Map) { - Map responseMap = (Map) response; - if (responseMap.containsKey("headers") && responseMap.get("headers") instanceof Map) { - Map headersMap = (Map) responseMap.get("headers"); - headersMap.forEach( - (header, value) -> httpHeaders.add(HttpHeaderName.fromString(header), String.valueOf(value))); - } - this.body = responseMap.getOrDefault("body", null); - } else { - this.body = null; - } - } - - /** @return the status code */ - public int getStatusCode() { - return statusCode; - } - - /** @return the http headers */ - public HttpHeaders getHttpHeaders() { - return httpHeaders; - } - - /** @return the response body */ - public Object getBody() { - return body; - } - - /** @return the response body as JSON string */ - public String getJsonBody() { - return getJson(body); - } - - /** - * @param obj the object for JSON string - * @return the object as JSON string - */ - public String getJson(Object obj) { - if (obj != null) { - try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - JsonWriter jsonWriter = JsonProviders.createWriter(outputStream)) { - jsonWriter.writeUntyped(obj).flush(); - return outputStream.toString(StandardCharsets.UTF_8); - } catch (IOException e) { - return obj.toString(); - } - } else { - return ""; - } - } - - @Override - public String toString() { - return "Response{statusCode=" + statusCode + ", httpHeaders=" + httpHeaders + ", body=" + getJsonBody() - + '}'; - } - } - - private final Map parameters = new LinkedHashMap<>(); - private final Map responses = new LinkedHashMap<>(); - private final String originalFile; - private String relativeOriginalFileName; - private String codeSnippetIdentifier; - private String name; - /** - * @return the map of parameter name to parameter object values + * @return the object value of the parameter */ - public Map getParameters() { - return parameters; + public Object getObjectValue() { + return objectValue; } /** - * @return the map of status code to response - */ - public Map getResponses() { - return responses; - } - - /** - * @return the primary response - */ - public Response getPrimaryResponse() { - if (responses.isEmpty()) { - return null; - } - - Response firstResponse = null; - for (Response response : responses.values()) { - if (firstResponse == null) { - firstResponse = response; - } - - if (response.statusCode / 100 == 2) { - return response; - } - } - - return firstResponse; - } - - /** - * @return value of "x-ms-original-file" extension - */ - public String getOriginalFile() { - return originalFile; - } - - /** - * Heuristically find relative path of the original file to the repository. + * Gets the un-escaped query value. *

- * For instance, - * "specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json" + * This is done by heuristic, and not guaranteed to be correct. * - * @return the relative path of the original file + * @return the un-escaped query value */ - public String getRelativeOriginalFileName() { - if (relativeOriginalFileName == null && !CoreUtils.isNullOrEmpty(this.getOriginalFile())) { - String originalFileName = this.getOriginalFile(); - try { - URL url = new URI(originalFileName).toURL(); - switch (url.getProtocol()) { - case "http": - case "https": { - String[] segments = url.getPath().split(SLASH); - if (segments.length > 3) { - // first 3 should be owner, name, branch - originalFileName = Arrays.stream(segments) - .filter(s -> !s.isEmpty()) - .skip(3) - .collect(Collectors.joining(SLASH)); - } - break; - } - - case "file": { - String relativeFileName = tspDirectory != null - ? getRelativeOriginalFileNameForTsp(url) - : getRelativeOriginalFileNameForSwagger(url); - if (relativeFileName != null) { - originalFileName = relativeFileName; - } - break; - } - - default: { - logger.error("Unknown protocol in x-ms-original-file: '{}'", originalFileName); - break; - } - } - } catch (MalformedURLException | URISyntaxException | IllegalArgumentException e) { - logger.error("Failed to parse x-ms-original-file: '{}'", originalFileName); - } - relativeOriginalFileName = originalFileName; - } - return relativeOriginalFileName; - } - - /** - * identifier of the codesnippet label from codesnippet-maven-plugin - * - * @return the identifier of the codesnippet label that wraps around the example code - * @see codesnippet-maven-plugin - */ - public String getCodeSnippetIdentifier() { - return codeSnippetIdentifier; - } - - /** @return example name */ - public String getName() { - return name; - } - - private ProxyMethodExample(String originalFile) { - this.originalFile = originalFile; - } - - static String getRelativeOriginalFileNameForTsp(URL url) { - // TypeSpec - /* - * Example: - * directory "specification/standbypool/StandbyPool.Management" - * originalFileName "file:///C:/github/azure-sdk-for-java/sdk/standbypool/azure-resourcemanager-standbypool/TempTypeSpecFiles/StandbyPool.Management/examples/2023-12-01-preview/StandbyVirtualMachinePools_Update.json" - * - * There is an overlap of "StandbyPool.Management", so that we can combine the 2 to Result: - * "specification/standbypool/StandbyPool.Management/examples/2023-12-01-preview/StandbyVirtualMachinePools_Update.json" - */ - String originalFileName = null; - String[] directorySegments = tspDirectory.split(SLASH); - String directoryLastSegment = directorySegments[directorySegments.length - 1]; - int sharedDirectorySegment = -1; - String[] segments = url.getPath().split(SLASH); - for (int i = segments.length - 1; i >= 0; --i) { - if (Objects.equals(directoryLastSegment, segments[i])) { - sharedDirectorySegment = i; - break; - } - } - if (sharedDirectorySegment >= 0) { - originalFileName = Stream.concat(Arrays.stream(directorySegments), - Arrays.stream(segments).skip(sharedDirectorySegment + 1)).collect(Collectors.joining(SLASH)); - } - return originalFileName; - } - - static String getRelativeOriginalFileNameForSwagger(URL url) { - // Swagger - /* - * The examples should be under "specification//resource-manager" - * or "specification//data-plane" - */ - String originalFileName = null; - String[] segments = url.getPath().split(SLASH); - int resourceManagerOrDataPlaneSegmentIndex = -1; - for (int i = 0; i < segments.length; ++i) { - if ("resource-manager".equals(segments[i]) || "data-plane".equals(segments[i])) { - resourceManagerOrDataPlaneSegmentIndex = i; - break; - } - } - if (resourceManagerOrDataPlaneSegmentIndex > 2) { - originalFileName = Arrays.stream(segments) - .skip(resourceManagerOrDataPlaneSegmentIndex - 2) - .collect(Collectors.joining(SLASH)); - } - return originalFileName; + public Object getUnescapedQueryValue() { + Object unescapedValue = objectValue; + if (objectValue instanceof String) { + unescapedValue = URLDecoder.decode((String) objectValue, StandardCharsets.UTF_8); + } + return unescapedValue; } @Override public String toString() { - return "ProxyMethodExample{" + "parameters=" + parameters + ", responses=" + responses + '}'; + return "ParameterValue{objectValue=" + getJsonString() + '}'; } - public static final class Builder { - private final Map parameters = new LinkedHashMap<>(); - private final Map responses = new LinkedHashMap<>(); - private String originalFile; - private String codeSnippetIdentifier; - private String name; + public String getJsonString() { + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + JsonWriter jsonWriter = JsonProviders.createWriter(outputStream)) { + jsonWriter.writeUntyped(objectValue).flush(); + return outputStream.toString(StandardCharsets.UTF_8); + } catch (IOException e) { + return objectValue.toString(); + } + } + } - public Builder() { + public static class Response { + + private final int statusCode; + private final HttpHeaders httpHeaders; + private final Object body; + + @SuppressWarnings("unchecked") + public Response(int statusCode, Object response) { + this.statusCode = statusCode; + this.httpHeaders = new HttpHeaders(); + if (response instanceof Map) { + Map responseMap = (Map) response; + if (responseMap.containsKey("headers") && responseMap.get("headers") instanceof Map) { + Map headersMap = (Map) responseMap.get("headers"); + headersMap.forEach( + (header, value) -> httpHeaders.add(HttpHeaderName.fromString(header), String.valueOf(value))); } + this.body = responseMap.getOrDefault("body", null); + } else { + this.body = null; + } + } - public Builder parameter(String parameterName, Object parameterValue) { - if (parameterValue != null) { - this.parameters.put(parameterName, new ParameterValue(parameterValue)); + /** @return the status code */ + public int getStatusCode() { + return statusCode; + } + + /** @return the http headers */ + public HttpHeaders getHttpHeaders() { + return httpHeaders; + } + + /** @return the response body */ + public Object getBody() { + return body; + } + + /** @return the response body as JSON string */ + public String getJsonBody() { + return getJson(body); + } + + /** + * @param obj the object for JSON string + * @return the object as JSON string + */ + public String getJson(Object obj) { + if (obj != null) { + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + JsonWriter jsonWriter = JsonProviders.createWriter(outputStream)) { + jsonWriter.writeUntyped(obj).flush(); + return outputStream.toString(StandardCharsets.UTF_8); + } catch (IOException e) { + return obj.toString(); + } + } else { + return ""; + } + } + + @Override + public String toString() { + return "Response{statusCode=" + statusCode + ", httpHeaders=" + httpHeaders + ", body=" + getJsonBody() + + '}'; + } + } + + private final Map parameters = new LinkedHashMap<>(); + private final Map responses = new LinkedHashMap<>(); + private final String originalFile; + private String relativeOriginalFileName; + private String codeSnippetIdentifier; + private String name; + + /** + * @return the map of parameter name to parameter object values + */ + public Map getParameters() { + return parameters; + } + + /** + * @return the map of status code to response + */ + public Map getResponses() { + return responses; + } + + /** + * @return the primary response + */ + public Response getPrimaryResponse() { + if (responses.isEmpty()) { + return null; + } + + Response firstResponse = null; + for (Response response : responses.values()) { + if (firstResponse == null) { + firstResponse = response; + } + + if (response.statusCode / 100 == 2) { + return response; + } + } + + return firstResponse; + } + + /** + * @return value of "x-ms-original-file" extension + */ + public String getOriginalFile() { + return originalFile; + } + + /** + * Heuristically find relative path of the original file to the repository. + *

+ * For instance, + * "specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json" + * + * @return the relative path of the original file + */ + public String getRelativeOriginalFileName() { + if (relativeOriginalFileName == null && !CoreUtils.isNullOrEmpty(this.getOriginalFile())) { + String originalFileName = this.getOriginalFile(); + try { + URL url = new URI(originalFileName).toURL(); + switch (url.getProtocol()) { + case "http": + case "https": { + String[] segments = url.getPath().split(SLASH); + if (segments.length > 3) { + // first 3 should be owner, name, branch + originalFileName = Arrays.stream(segments) + .filter(s -> !s.isEmpty()) + .skip(3) + .collect(Collectors.joining(SLASH)); } - return this; - } + break; + } - public Builder response(Integer statusCode, Object response) { - this.responses.put(statusCode, new Response(statusCode, response)); - return this; - } + case "file": { + String relativeFileName = getRelativeOriginalFileNameForSwagger(url); + if (relativeFileName != null) { + originalFileName = relativeFileName; + } + break; + } - public Builder originalFile(String originalFile) { - this.originalFile = originalFile; - return this; - } - - public Builder codeSnippetIdentifier(String identifier) { - this.codeSnippetIdentifier = identifier; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public ProxyMethodExample build() { - ProxyMethodExample proxyMethodExample = new ProxyMethodExample(originalFile); - proxyMethodExample.parameters.putAll(this.parameters); - proxyMethodExample.responses.putAll(this.responses); - proxyMethodExample.codeSnippetIdentifier = this.codeSnippetIdentifier; - proxyMethodExample.name = this.name; - return proxyMethodExample; + default: { + logger.error("Unknown protocol in x-ms-original-file: '{}'", originalFileName); + break; + } } + } catch (MalformedURLException | URISyntaxException | IllegalArgumentException e) { + // relative file path from TypeSpec, it is not URL + // go with default flow of "relativeOriginalFileName = originalFileName;" + } + relativeOriginalFileName = originalFileName; } + return relativeOriginalFileName; + } + + /** + * identifier of the codesnippet label from codesnippet-maven-plugin + * + * @return the identifier of the codesnippet label that wraps around the example code + * @see codesnippet-maven-plugin + */ + public String getCodeSnippetIdentifier() { + return codeSnippetIdentifier; + } + + /** @return example name */ + public String getName() { + return name; + } + + private ProxyMethodExample(String originalFile) { + this.originalFile = originalFile; + } + + static String getRelativeOriginalFileNameForSwagger(URL url) { + // Swagger + /* + * The examples should be under "specification//resource-manager" + * or "specification//data-plane" + */ + String originalFileName = null; + String[] segments = url.getPath().split(SLASH); + int resourceManagerOrDataPlaneSegmentIndex = -1; + for (int i = 0; i < segments.length; ++i) { + if ("resource-manager".equals(segments[i]) || "data-plane".equals(segments[i])) { + resourceManagerOrDataPlaneSegmentIndex = i; + break; + } + } + if (resourceManagerOrDataPlaneSegmentIndex > 2) { + originalFileName = Arrays.stream(segments) + .skip(resourceManagerOrDataPlaneSegmentIndex - 2) + .collect(Collectors.joining(SLASH)); + } + return originalFileName; + } + + @Override + public String toString() { + return "ProxyMethodExample{" + "parameters=" + parameters + ", responses=" + responses + '}'; + } + + public static final class Builder { + private final Map parameters = new LinkedHashMap<>(); + private final Map responses = new LinkedHashMap<>(); + private String originalFile; + private String codeSnippetIdentifier; + private String name; + + public Builder() { + } + + public Builder parameter(String parameterName, Object parameterValue) { + if (parameterValue != null) { + this.parameters.put(parameterName, new ParameterValue(parameterValue)); + } + return this; + } + + public Builder response(Integer statusCode, Object response) { + this.responses.put(statusCode, new Response(statusCode, response)); + return this; + } + + public Builder originalFile(String originalFile) { + this.originalFile = originalFile; + return this; + } + + public Builder codeSnippetIdentifier(String identifier) { + this.codeSnippetIdentifier = identifier; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public ProxyMethodExample build() { + ProxyMethodExample proxyMethodExample = new ProxyMethodExample(originalFile); + proxyMethodExample.parameters.putAll(this.parameters); + proxyMethodExample.responses.putAll(this.responses); + proxyMethodExample.codeSnippetIdentifier = this.codeSnippetIdentifier; + proxyMethodExample.name = this.name; + return proxyMethodExample; + } + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/javamodel/JavaClass.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/javamodel/JavaClass.java index de0505169..c929c0c22 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/javamodel/JavaClass.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/javamodel/JavaClass.java @@ -13,205 +13,219 @@ import java.util.function.Consumer; import java.util.stream.Collectors; public class JavaClass implements JavaType { - private final JavaFileContents contents; - private boolean addNewLine; + private final JavaFileContents contents; + private boolean addNewLine; - public JavaClass(JavaFileContents contents) { - this.contents = contents; - } + public JavaClass(JavaFileContents contents) { + this.contents = contents; + } - private void addExpectedNewLine() { - if (addNewLine) { - contents.line(); - addNewLine = false; - } + private void addExpectedNewLine() { + if (addNewLine) { + contents.line(); + addNewLine = false; } + } - public final void privateMemberVariable(String variableType, String variableName) { - privateMemberVariable(variableType + " " + variableName); - } + public final void privateMemberVariable(String variableType, String variableName) { + memberVariable(JavaVisibility.Private, variableType + " " + variableName); + } - public final void privateMemberVariable(String variableDeclaration) { - addExpectedNewLine(); - contents.line("private " + variableDeclaration + ";"); - addNewLine = true; - } + public final void privateMemberVariable(String variableDeclaration) { + memberVariable(JavaVisibility.Private, variableDeclaration); + } - public final void privateFinalMemberVariable(String variableDeclaration) { - addExpectedNewLine(); - contents.line("private final " + variableDeclaration + ";"); - addNewLine = true; - } + /** + * Adds a variable declaration. + *

+ * If the visibility is null or {@link JavaVisibility#PackagePrivate}, the variable will be package-private. + * + * @param visibility The visibility of the variable. + * @param variableDeclaration The variable declaration. + */ + public final void memberVariable(JavaVisibility visibility, String variableDeclaration) { + addExpectedNewLine(); + String line = (visibility == null || visibility == JavaVisibility.PackagePrivate) + ? variableDeclaration + ";" : visibility + " " + variableDeclaration + ";"; + contents.line(line); + addNewLine = true; + } - public final void privateFinalMemberVariable(String variableType, String variableName) { - addExpectedNewLine(); - contents.line("private final " + variableType + " " + variableName + ";"); - addNewLine = true; - } + public final void privateFinalMemberVariable(String variableDeclaration) { + addExpectedNewLine(); + contents.line("private final " + variableDeclaration + ";"); + addNewLine = true; + } - public final void privateFinalMemberVariable(String variableType, String variableName, String finalValue) { - addExpectedNewLine(); - contents.line("private final " + variableType + " " + variableName + " = " + finalValue + ";"); - addNewLine = true; - } + public final void privateFinalMemberVariable(String variableType, String variableName) { + addExpectedNewLine(); + contents.line("private final " + variableType + " " + variableName + ";"); + addNewLine = true; + } - public final void publicStaticFinalVariable(String variableDeclaration) { - addExpectedNewLine(); - contents.line("public static final " + variableDeclaration + ";"); - addNewLine = true; - } + public final void privateFinalMemberVariable(String variableType, String variableName, String finalValue) { + addExpectedNewLine(); + contents.line("private final " + variableType + " " + variableName + " = " + finalValue + ";"); + addNewLine = true; + } - public final void privateStaticFinalVariable(String variableDeclaration) { - addExpectedNewLine(); - contents.line("private static final " + variableDeclaration + ";"); - addNewLine = true; - } + public final void publicStaticFinalVariable(String variableDeclaration) { + addExpectedNewLine(); + contents.line("public static final " + variableDeclaration + ";"); + addNewLine = true; + } - public final void protectedMemberVariable(String variableType, String variableName) { - addExpectedNewLine(); - contents.line("protected " + variableType + " " + variableName + ";"); - addNewLine = true; - } + public final void privateStaticFinalVariable(String variableDeclaration) { + addExpectedNewLine(); + contents.line("private static final " + variableDeclaration + ";"); + addNewLine = true; + } - /** - * Adds a variable with the given declaration and visibility. - *

- * This doesn't support modifiers. If you need to add modifiers, use - * {@link #variable(String, JavaVisibility, JavaModifier...)}. This will just be a non-final, non-static variable - * with the given visibility. - * - * @param variableDeclaration The variable declaration. - * @param visibility The visibility of the variable. - */ - public final void variable(String variableDeclaration, JavaVisibility visibility) { - addExpectedNewLine(); - contents.line(visibility + " " + variableDeclaration + ";"); - addNewLine = true; - } + public final void protectedMemberVariable(String variableType, String variableName) { + addExpectedNewLine(); + contents.line("protected " + variableType + " " + variableName + ";"); + addNewLine = true; + } - /** - * Adds a variable with the given declaration, visibility, and modifiers. - *

- * Adding a private constant variable would be: - * {@code variable(declaration, JavaVisibility.Private, JavaModifier.Static, JavaModifier.Final)} - * - * @param variableDeclaration The variable declaration. - * @param visibility The visibility of the variable. - * @param modifiers The modifiers of the variable. - */ - public final void variable(String variableDeclaration, JavaVisibility visibility, JavaModifier... modifiers) { - addExpectedNewLine(); - String modifier = CoreUtils.isNullOrEmpty(modifiers) ? "" - : Arrays.stream(modifiers).map(JavaModifier::toString).collect(Collectors.joining(" ")); - contents.line(visibility + " " + modifier + " " + variableDeclaration + ";"); - addNewLine = true; - } + /** + * Adds a variable with the given declaration and visibility. + *

+ * This doesn't support modifiers. If you need to add modifiers, use + * {@link #variable(String, JavaVisibility, JavaModifier...)}. This will just be a non-final, non-static variable + * with the given visibility. + * + * @param variableDeclaration The variable declaration. + * @param visibility The visibility of the variable. + */ + public final void variable(String variableDeclaration, JavaVisibility visibility) { + addExpectedNewLine(); + contents.line(visibility + " " + variableDeclaration + ";"); + addNewLine = true; + } - public final void constructor(JavaVisibility visibility, String constructorSignature, Consumer constructor) { - addExpectedNewLine(); - contents.constructor(visibility, constructorSignature, constructor); - addNewLine = true; - } + /** + * Adds a variable with the given declaration, visibility, and modifiers. + *

+ * Adding a private constant variable would be: + * {@code variable(declaration, JavaVisibility.Private, JavaModifier.Static, JavaModifier.Final)} + * + * @param variableDeclaration The variable declaration. + * @param visibility The visibility of the variable. + * @param modifiers The modifiers of the variable. + */ + public final void variable(String variableDeclaration, JavaVisibility visibility, JavaModifier... modifiers) { + addExpectedNewLine(); + String modifier = CoreUtils.isNullOrEmpty(modifiers) ? "" + : Arrays.stream(modifiers).map(JavaModifier::toString).collect(Collectors.joining(" ")); + contents.line(visibility + " " + modifier + " " + variableDeclaration + ";"); + addNewLine = true; + } - public final void privateConstructor(String constructorSignature, Consumer constructor) { - constructor(JavaVisibility.Private, constructorSignature, constructor); - } + public final void constructor(JavaVisibility visibility, String constructorSignature, Consumer constructor) { + addExpectedNewLine(); + contents.constructor(visibility, constructorSignature, constructor); + addNewLine = true; + } - public final void publicConstructor(String constructorSignature, Consumer constructor) { - constructor(JavaVisibility.Public, constructorSignature, constructor); - } + public final void privateConstructor(String constructorSignature, Consumer constructor) { + constructor(JavaVisibility.Private, constructorSignature, constructor); + } - public final void packagePrivateConstructor(String constructorSignature, Consumer constructor) { - constructor(JavaVisibility.PackagePrivate, constructorSignature, constructor); - } + public final void publicConstructor(String constructorSignature, Consumer constructor) { + constructor(JavaVisibility.Public, constructorSignature, constructor); + } - public final void method(JavaVisibility visibility, List modifiers, String methodSignature, Consumer method) { - addExpectedNewLine(); - contents.method(visibility, modifiers, methodSignature, method); - addNewLine = true; - } + public final void packagePrivateConstructor(String constructorSignature, Consumer constructor) { + constructor(JavaVisibility.PackagePrivate, constructorSignature, constructor); + } - public final void publicMethod(String methodSignature, Consumer method) { - method(JavaVisibility.Public, null, methodSignature, method); - } + public final void method(JavaVisibility visibility, List modifiers, String methodSignature, Consumer method) { + addExpectedNewLine(); + contents.method(visibility, modifiers, methodSignature, method); + addNewLine = true; + } - public final void packagePrivateMethod(String methodSignature, Consumer method) { - method(JavaVisibility.PackagePrivate, null, methodSignature, method); - } + public final void publicMethod(String methodSignature, Consumer method) { + method(JavaVisibility.Public, null, methodSignature, method); + } - public final void privateMethod(String methodSignature, Consumer method) { - method(JavaVisibility.Private, null, methodSignature, method); - } + public final void packagePrivateMethod(String methodSignature, Consumer method) { + method(JavaVisibility.PackagePrivate, null, methodSignature, method); + } - public final void publicStaticMethod(String methodSignature, Consumer method) { - staticMethod(JavaVisibility.Public, methodSignature, method); - } + public final void privateMethod(String methodSignature, Consumer method) { + method(JavaVisibility.Private, null, methodSignature, method); + } - /** - * Adds a static method with a declared visibility to the class. - * - * @param visibility The visibility of the method. - * @param methodSignature The method signature. - * @param method The logic to generate the method. - */ - public final void staticMethod(JavaVisibility visibility, String methodSignature, Consumer method) { - Objects.requireNonNull(visibility, "'visibility' cannot be null."); - method(visibility, Collections.singletonList(JavaModifier.Static), methodSignature, method); - } + public final void publicStaticMethod(String methodSignature, Consumer method) { + staticMethod(JavaVisibility.Public, methodSignature, method); + } - public final void interfaceBlock(JavaVisibility visibility, String interfaceSignature, Consumer interfaceBlock) { - addExpectedNewLine(); - contents.interfaceBlock(visibility, interfaceSignature, interfaceBlock); - addNewLine = true; - } + /** + * Adds a static method with a declared visibility to the class. + * + * @param visibility The visibility of the method. + * @param methodSignature The method signature. + * @param method The logic to generate the method. + */ + public final void staticMethod(JavaVisibility visibility, String methodSignature, Consumer method) { + Objects.requireNonNull(visibility, "'visibility' cannot be null."); + method(visibility, Collections.singletonList(JavaModifier.Static), methodSignature, method); + } - public final void publicInterface(String interfaceSignature, Consumer interfaceBlock) { - interfaceBlock(JavaVisibility.Public, interfaceSignature, interfaceBlock); - } + public final void interfaceBlock(JavaVisibility visibility, String interfaceSignature, Consumer interfaceBlock) { + addExpectedNewLine(); + contents.interfaceBlock(visibility, interfaceSignature, interfaceBlock); + addNewLine = true; + } - public final void privateStaticFinalClass(String classSignature, Consumer classBlock) { - staticFinalClass(JavaVisibility.Private, classSignature, classBlock); - } + public final void publicInterface(String interfaceSignature, Consumer interfaceBlock) { + interfaceBlock(JavaVisibility.Public, interfaceSignature, interfaceBlock); + } - public final void staticFinalClass(JavaVisibility visibility, String classSignature, Consumer classBlock) { - addExpectedNewLine(); - contents.classBlock(visibility, Arrays.asList(JavaModifier.Static, JavaModifier.Final), classSignature, - classBlock); - addNewLine = true; - } + public final void privateStaticFinalClass(String classSignature, Consumer classBlock) { + staticFinalClass(JavaVisibility.Private, classSignature, classBlock); + } - public final void blockComment(String description) { - addExpectedNewLine(); - contents.blockComment(description); - } + public final void staticFinalClass(JavaVisibility visibility, String classSignature, Consumer classBlock) { + addExpectedNewLine(); + contents.classBlock(visibility, Arrays.asList(JavaModifier.Static, JavaModifier.Final), classSignature, + classBlock); + addNewLine = true; + } - public final void lineComment(String description) { - addExpectedNewLine(); - contents.lineComment(description); - } + public final void blockComment(String description) { + addExpectedNewLine(); + contents.blockComment(description); + } - public final void blockComment(Consumer commentAction) { - addExpectedNewLine(); - contents.blockComment(commentAction); - } + public final void lineComment(String description) { + addExpectedNewLine(); + contents.lineComment(description); + } - public final void javadocComment(String description) { - addExpectedNewLine(); - contents.javadocComment(description); - } + public final void blockComment(Consumer commentAction) { + addExpectedNewLine(); + contents.blockComment(commentAction); + } - public final void javadocComment(Consumer commentAction) { - addExpectedNewLine(); - contents.javadocComment(commentAction); - } + public final void javadocComment(String description) { + addExpectedNewLine(); + contents.javadocComment(description); + } - public final void annotation(String... annotations) { - addExpectedNewLine(); - contents.annotation(annotations); - } + public final void javadocComment(Consumer commentAction) { + addExpectedNewLine(); + contents.javadocComment(commentAction); + } - public final void staticBlock(Consumer codeBlock) { - addExpectedNewLine(); - contents.block("static", codeBlock); - } + public final void annotation(String... annotations) { + addExpectedNewLine(); + contents.annotation(annotations); + } + + public final void staticBlock(Consumer codeBlock) { + addExpectedNewLine(); + contents.block("static", codeBlock); + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ConvenienceMethodTemplateBase.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ConvenienceMethodTemplateBase.java index 790933983..676635356 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ConvenienceMethodTemplateBase.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ConvenienceMethodTemplateBase.java @@ -59,795 +59,803 @@ import java.util.stream.Collectors; abstract class ConvenienceMethodTemplateBase { - protected ConvenienceMethodTemplateBase() { + protected ConvenienceMethodTemplateBase() { + } + + public void write(ConvenienceMethod convenienceMethodObj, JavaClass classBlock, Set typeReferenceStaticClasses) { + if (!isMethodIncluded(convenienceMethodObj)) { + return; } - public void write(ConvenienceMethod convenienceMethodObj, JavaClass classBlock, Set typeReferenceStaticClasses) { - if (!isMethodIncluded(convenienceMethodObj)) { - return; - } + ClientMethod protocolMethod = convenienceMethodObj.getProtocolMethod(); + convenienceMethodObj.getConvenienceMethods().stream() + .filter(this::isMethodIncluded) + .forEach(convenienceMethod -> { + // javadoc + classBlock.javadocComment(comment -> ClientMethodTemplate.generateJavadoc(convenienceMethod, comment, + convenienceMethod.getProxyMethod(), false)); - ClientMethod protocolMethod = convenienceMethodObj.getProtocolMethod(); - convenienceMethodObj.getConvenienceMethods().stream() - .filter(this::isMethodIncluded) - .forEach(convenienceMethod -> { - // javadoc - classBlock.javadocComment(comment -> ClientMethodTemplate.generateJavadoc(convenienceMethod, comment, - convenienceMethod.getProxyMethod(), false)); + addGeneratedAnnotation(classBlock); + TemplateUtil.writeClientMethodServiceMethodAnnotation(convenienceMethod, classBlock); - addGeneratedAnnotation(classBlock); - TemplateUtil.writeClientMethodServiceMethodAnnotation(convenienceMethod, classBlock); + JavaVisibility methodVisibility = convenienceMethod.getMethodVisibilityInWrapperClient(); - JavaVisibility methodVisibility = convenienceMethod.getMethodVisibilityInWrapperClient(); + // convenience method + String methodDeclaration = String.format("%1$s %2$s(%3$s)", + convenienceMethod.getReturnValue().getType(), getMethodName(convenienceMethod), + convenienceMethod.getParametersDeclaration()); + classBlock.method(methodVisibility, null, methodDeclaration, methodBlock -> { + methodBlock.line("// Generated convenience method for " + getMethodName(protocolMethod)); - // convenience method - String methodDeclaration = String.format("%1$s %2$s(%3$s)", - convenienceMethod.getReturnValue().getType(), getMethodName(convenienceMethod), - convenienceMethod.getParametersDeclaration()); - classBlock.method(methodVisibility, null, methodDeclaration, methodBlock -> { - methodBlock.line("// Generated convenience method for " + getMethodName(protocolMethod)); + writeMethodImplementation(protocolMethod, convenienceMethod, methodBlock, typeReferenceStaticClasses); + }); + }); + } - writeMethodImplementation(protocolMethod, convenienceMethod, methodBlock, typeReferenceStaticClasses); - }); - }); + /** + * Write the implementation of the convenience method. + * + * @param protocolMethod the protocol method. + * @param convenienceMethod the convenience method. + * @param methodBlock the code block. + */ + protected void writeMethodImplementation( + ClientMethod protocolMethod, + ClientMethod convenienceMethod, + JavaBlock methodBlock, + Set typeReferenceStaticClasses) { + + // matched parameters from convenience method to protocol method + Map parametersMap = + findParametersForConvenienceMethod(convenienceMethod, protocolMethod); + + // RequestOptions + methodBlock.line("RequestOptions requestOptions = new RequestOptions();"); + + // parameter transformation + if (!CoreUtils.isNullOrEmpty(convenienceMethod.getMethodTransformationDetails())) { + convenienceMethod.getMethodTransformationDetails() + .forEach(d -> writeParameterTransformation(d, convenienceMethod, protocolMethod, methodBlock, parametersMap)); } - /** - * Write the implementation of the convenience method. - * - * @param protocolMethod the protocol method. - * @param convenienceMethod the convenience method. - * @param methodBlock the code block. - */ - protected void writeMethodImplementation( - ClientMethod protocolMethod, - ClientMethod convenienceMethod, - JavaBlock methodBlock, - Set typeReferenceStaticClasses) { + writeValidationForVersioning(convenienceMethod, parametersMap.keySet(), methodBlock); - // matched parameters from convenience method to protocol method - Map parametersMap = - findParametersForConvenienceMethod(convenienceMethod, protocolMethod); + boolean isJsonMergePatchOperation = protocolMethod != null && protocolMethod.getProxyMethod() != null + && "application/merge-patch+json".equalsIgnoreCase(protocolMethod.getProxyMethod().getRequestContentType()); + Map parameterExpressionsMap = new HashMap<>(); + for (Map.Entry entry : parametersMap.entrySet()) { + MethodParameter parameter = entry.getKey(); + MethodParameter protocolParameter = entry.getValue(); - // RequestOptions - methodBlock.line("RequestOptions requestOptions = new RequestOptions();"); + if (parameter.getProxyMethodParameter() != null && parameter.getProxyMethodParameter().getOrigin() == ParameterSynthesizedOrigin.CONTEXT) { + // Context + methodBlock.line(String.format("requestOptions.setContext(%s);", parameter.getName())); + } else if (protocolParameter != null) { + // protocol method parameter exists + String expression = expressionConvertToType(parameter.getName(), parameter, protocolMethod.getProxyMethod().getRequestContentType()); + parameterExpressionsMap.put(protocolParameter.getName(), expression); + } else if (parameter.getProxyMethodParameter() != null) { + // protocol method parameter not exist, set the parameter via RequestOptions + switch (parameter.getProxyMethodParameter().getRequestParameterLocation()) { + case HEADER: + writeHeader(parameter, methodBlock); + break; - // parameter transformation - if (!CoreUtils.isNullOrEmpty(convenienceMethod.getMethodTransformationDetails())) { - convenienceMethod.getMethodTransformationDetails() - .forEach(d -> writeParameterTransformation(d, convenienceMethod, protocolMethod, methodBlock, parametersMap)); - } + case QUERY: + writeQueryParam(parameter, methodBlock); + break; - writeValidationForVersioning(convenienceMethod, parametersMap.keySet(), methodBlock); + case BODY: + Consumer writeLine = javaBlock -> { + IType parameterType = parameter.getClientMethodParameter().getClientType(); + String expression = expressionConvertToBinaryData(parameter.getName(), + parameter.getClientMethodParameter().getWireType(), + protocolMethod.getProxyMethod().getRequestContentType()); - boolean isJsonMergePatchOperation = protocolMethod != null && protocolMethod.getProxyMethod() != null - && "application/merge-patch+json".equalsIgnoreCase(protocolMethod.getProxyMethod().getRequestContentType()); - Map parameterExpressionsMap = new HashMap<>(); - for (Map.Entry entry : parametersMap.entrySet()) { - MethodParameter parameter = entry.getKey(); - MethodParameter protocolParameter = entry.getValue(); - - if (parameter.getProxyMethodParameter() != null && parameter.getProxyMethodParameter().getOrigin() == ParameterSynthesizedOrigin.CONTEXT) { - // Context - methodBlock.line(String.format("requestOptions.setContext(%s);", parameter.getName())); - } else if (protocolParameter != null) { - // protocol method parameter exists - String expression = expressionConvertToType(parameter.getName(), parameter, protocolMethod.getProxyMethod().getRequestContentType()); - parameterExpressionsMap.put(protocolParameter.getName(), expression); - } else if (parameter.getProxyMethodParameter() != null) { - // protocol method parameter not exist, set the parameter via RequestOptions - switch (parameter.getProxyMethodParameter().getRequestParameterLocation()) { - case HEADER: - writeHeader(parameter, methodBlock); - break; - - case QUERY: - writeQueryParam(parameter, methodBlock); - break; - - case BODY: - Consumer writeLine = javaBlock -> { - IType parameterType = parameter.getClientMethodParameter().getClientType(); - String expression = expressionConvertToBinaryData(parameter.getName(), - parameter.getClientMethodParameter().getWireType(), - protocolMethod.getProxyMethod().getRequestContentType()); - - if (isJsonMergePatchOperation - && ClientModelUtil.isClientModel(parameterType) - && ClientModelUtil.isJsonMergePatchModel(ClientModelUtil.getClientModel(((ClassType) parameterType).getName()), JavaSettings.getInstance())) { - String variableName = writeParameterConversionExpressionWithJsonMergePatchEnabled(javaBlock, parameterType.toString(), parameter.getName(), expression); - javaBlock.line("requestOptions.setBody(" + variableName + ");"); - } else { - javaBlock.line("requestOptions.setBody(" + expression + ");"); - } - }; - if (!parameter.getClientMethodParameter().isRequired()) { - methodBlock.ifBlock(parameter.getName() + " != null", writeLine); - } else { - writeLine.accept(methodBlock); - } - break; - } - } - } - - // invocation with protocol method parameters and RequestOptions - String invocationExpression = protocolMethod.getMethodInputParameters().stream() - .map(p -> { - String parameterName = p.getName(); - String expression = parameterExpressionsMap.get(parameterName); - IType parameterRawType = p.getRawType(); - if (isJsonMergePatchOperation && ClientModelUtil.isClientModel(parameterRawType) - && RequestParameterLocation.BODY.equals(p.getRequestParameterLocation()) - && ClientModelUtil.isJsonMergePatchModel(ClientModelUtil.getClientModel(((ClassType) parameterRawType).getName()), JavaSettings.getInstance())) { - return writeParameterConversionExpressionWithJsonMergePatchEnabled(methodBlock, parameterRawType.toString(), parameterName, expression); - } else { - return expression == null ? parameterName : expression; - } - }) - .collect(Collectors.joining(", ")); - - // write the invocation of protocol method, and related type conversion - writeInvocationAndConversion(convenienceMethod, protocolMethod, invocationExpression, methodBlock, typeReferenceStaticClasses); - } - - - /** - * Write the validation for parameters against current api-version. - * - * @param parameters the parameters - * @param methodBlock the method block - */ - protected void writeValidationForVersioning(ClientMethod convenienceMethod, Set parameters, JavaBlock methodBlock) { - // validate parameter for versioning - for (MethodParameter parameter : parameters) { - if (parameter.getClientMethodParameter().getVersioning() != null && parameter.getClientMethodParameter().getVersioning().getAdded() != null) { - String condition = String.format( - "!Arrays.asList(%s).contains(serviceClient.getServiceVersion().getVersion())", - parameter.getClientMethodParameter().getVersioning().getAdded().stream().map(ClassType.STRING::defaultValueExpression).collect(Collectors.joining(", "))); - methodBlock.ifBlock(condition, ifBlock -> { - String exceptionExpression = String.format( - "new IllegalArgumentException(\"Parameter %1$s is only available in api-version %2$s.\")", - parameter.getName(), - String.join(", ", parameter.getClientMethodParameter().getVersioning().getAdded())); - writeThrowException(convenienceMethod.getType(), exceptionExpression, ifBlock); - }); - } - } - } - - abstract void writeThrowException(ClientMethodType methodType, String exceptionExpression, JavaBlock methodBlock); - - private static boolean isGroupByTransformation(MethodTransformationDetail detail) { - return !CoreUtils.isNullOrEmpty(detail.getParameterMappings()) - && detail.getParameterMappings().iterator().next().getOutputParameterPropertyName() == null; - } - - private static void writeParameterTransformation( - MethodTransformationDetail detail, - ClientMethod convenienceMethod, ClientMethod protocolMethod, - JavaBlock methodBlock, - Map parametersMap) { - - if (isGroupByTransformation(detail)) { - // grouping - - ParameterMapping mapping = detail.getParameterMappings().iterator().next(); - ClientMethodParameter sourceParameter = mapping.getInputParameter(); - - boolean sourceParameterInMethod = false; - for (MethodParameter parameter: parametersMap.keySet()) { - if (parameter.clientMethodParameter != null && parameter.clientMethodParameter.getName() != null - && Objects.equals(parameter.clientMethodParameter.getName(), sourceParameter.getName())) { - sourceParameterInMethod = true; - break; - } - } - - if (sourceParameterInMethod) { - // null check on input parameter - String assignmentExpression = "%1$s %2$s = %3$s.%4$s();"; - if (!sourceParameter.isRequired()) { - assignmentExpression = "%1$s %2$s = %3$s == null ? null : %3$s.%4$s();"; - } - - methodBlock.line(String.format(assignmentExpression, - detail.getOutParameter().getClientType(), - detail.getOutParameter().getName(), - sourceParameter.getName(), - CodeNamer.getModelNamer().modelPropertyGetterName(mapping.getInputParameterProperty()))); - - if (detail.getOutParameter().getRequestParameterLocation() != null) { - ClientMethodParameter clientMethodParameter = detail.getOutParameter(); - ProxyMethodParameter proxyMethodParameter = convenienceMethod.getProxyMethod().getAllParameters().stream() - .filter(p -> clientMethodParameter.getName().equals(CodeNamer.getEscapedReservedClientMethodParameterName(p.getName()))) - .findFirst().orElse(null); - if (proxyMethodParameter != null) { - MethodParameter methodParameter = new MethodParameter(proxyMethodParameter, clientMethodParameter); - parametersMap.put(methodParameter, findProtocolMethodParameterForConvenienceMethod(methodParameter, protocolMethod)); - } - } - } - } else { - // flatten (possible with grouping) - ClientMethodParameter targetParameter = detail.getOutParameter(); - if (targetParameter.getWireType() == ClassType.BINARY_DATA) { - IType targetType = targetParameter.getRawType(); - - StringBuilder ctorExpression = new StringBuilder(); - StringBuilder setterExpression = new StringBuilder(); - String targetParameterName = targetParameter.getName(); - String targetParameterObjectName = targetParameterName + "Obj"; - for (ParameterMapping mapping : detail.getParameterMappings()) { - String parameterName = mapping.getInputParameter().getName(); - - String inputPath = parameterName; - boolean propertyRequired = mapping.getInputParameter().isRequired(); - if (mapping.getInputParameterProperty() != null) { - inputPath = String.format("%s.%s()", mapping.getInputParameter().getName(), - CodeNamer.getModelNamer().modelPropertyGetterName(mapping.getInputParameterProperty())); - propertyRequired = mapping.getInputParameterProperty().isRequired(); - } - if (propertyRequired) { - // required - if (JavaSettings.getInstance().isRequiredFieldsAsConstructorArgs()) { - if (ctorExpression.length() > 0) { - ctorExpression.append(", "); - } - ctorExpression.append(inputPath); - } else { - setterExpression.append(".").append(mapping.getOutputParameterProperty().getSetterName()).append("(").append(inputPath).append(")"); - } - } else if (!convenienceMethod.getOnlyRequiredParameters()) { - // optional - setterExpression.append(".").append(mapping.getOutputParameterProperty().getSetterName()).append("(").append(inputPath).append(")"); - } - } - methodBlock.line(String.format("%1$s %2$s = new %1$s(%3$s)%4$s;", targetType, targetParameterObjectName, ctorExpression, setterExpression)); - - String expression = null; - if (targetParameter.getRawType() instanceof ClassType) { - ClientModel model = ClientModelUtil.getClientModel(targetParameter.getRawType().toString()); - // serialize model for multipart/form-data - if (model != null && ClientModelUtil.isMultipartModel(model)) { - expression = expressionMultipartFormDataToBinaryData(targetParameterObjectName, model); - } - } - if (expression == null) { - expression = expressionConvertToBinaryData(targetParameterObjectName, targetParameter.getRawType(), protocolMethod.getProxyMethod().getRequestContentType()); - } - methodBlock.line(String.format("BinaryData %1$s = %2$s;", targetParameterName, expression)); - } - } - } - - protected void addImports(Set imports, List convenienceMethods) { - // methods - JavaSettings settings = JavaSettings.getInstance(); - convenienceMethods.stream().flatMap(m -> m.getConvenienceMethods().stream()) - .forEach(m -> { - m.addImportsTo(imports, false, settings); - // hack, add wire type of parameters, as they are not added in ClientMethod, even when includeImplementationImports=true - for (ClientMethodParameter p : m.getParameters()) { - p.getWireType().addImportsTo(imports, false); - - // add imports from models, as some convenience API need to process model properties - if (p.getWireType() instanceof ClassType) { - ClientModel model = ClientModelUtil.getClientModel(p.getWireType().toString()); - if (model != null) { - model.addImportsTo(imports, settings); - } - } - } - }); - - ClassType.HTTP_HEADER_NAME.addImportsTo(imports, false); - ClassType.BINARY_DATA.addImportsTo(imports, false); - ClassType.REQUEST_OPTIONS.addImportsTo(imports, false); - imports.add(Collectors.class.getName()); - imports.add(Objects.class.getName()); - imports.add(FluxUtil.class.getName()); - - // collection format - imports.add(JacksonAdapter.class.getName()); - imports.add(CollectionFormat.class.getName()); - imports.add(TypeReference.class.getName()); - if (!JavaSettings.getInstance().isBranded()) { - imports.add(Type.class.getName()); - imports.add(ParameterizedType.class.getName()); - } - - // byte[] - ClassType.BASE_64_URL.addImportsTo(imports, false); - - // flatten payload - imports.add(Map.class.getName()); - imports.add(HashMap.class.getName()); - - // MultipartFormDataHelper class - imports.add(settings.getPackage(settings.getImplementationSubpackage()) + "." + ClientModelUtil.MULTI_PART_FORM_DATA_HELPER_CLASS_NAME); - - // versioning - imports.add(Arrays.class.getName()); - - // JsonMergePatchHelper class - imports.add(settings.getPackage(settings.getImplementationSubpackage()) + "." + ClientModelUtil.JSON_MERGE_PATCH_HELPER_CLASS_NAME); - } - - protected void addGeneratedAnnotation(JavaType typeBlock) { - if (JavaSettings.getInstance().isBranded()) { - typeBlock.annotation(Annotation.GENERATED.getName()); - } else { - typeBlock.annotation(Annotation.METADATA.getName() + "(generated = true)"); - } - } - - /** - * Whether the convenience method should be included. - * - * @param method the convenience method. - * @return Whether include the convenience method. - */ - protected abstract boolean isMethodIncluded(ClientMethod method); - - /** - * Whether the convenience/protocol method should be included. - * - * @param method the convenience/protocol method. - * @return Whether include the convenience/protocol method. - */ - protected abstract boolean isMethodIncluded(ConvenienceMethod method); - - protected boolean isMethodAsync(ClientMethod method) { - return method.getType().name().contains("Async"); - } - - protected boolean isMethodVisible(ClientMethod method) { - return method.getMethodVisibility() == JavaVisibility.Public; - } - - protected String getMethodName(ClientMethod method) { - if (isMethodAsync(method)) { - return method.getName().endsWith("Async") - ? method.getName().substring(0, method.getName().length() - "Async".length()) - : method.getName(); - } else { - return method.getName(); - } - } - - /** - * Write the code of the method invocation of client method, and the conversion of parameters and return value. - * - * @param convenienceMethod the convenience method. - * @param protocolMethod the protocol method. - * @param invocationExpression the prepared expression of invocation on client method. - * @param methodBlock the code block. - */ - protected abstract void writeInvocationAndConversion( - ClientMethod convenienceMethod, ClientMethod protocolMethod, - String invocationExpression, - JavaBlock methodBlock, - Set typeReferenceStaticClasses); - - protected boolean isModelOrBuiltin(IType type) { - // TODO: other built-in types - return type == ClassType.STRING // string - || type == ClassType.OBJECT // unknown - || type == ClassType.BIG_DECIMAL // decimal - || (type instanceof PrimitiveType && type.asNullable() != ClassType.VOID) // boolean, int, float, etc. - || ClientModelUtil.isClientModel(type); // client model - } - - protected enum SupportedMimeType { - TEXT, - XML, - MULTIPART, - BINARY, - JSON; - - // azure-core SerializerEncoding.SUPPORTED_MIME_TYPES - private static final Map SUPPORTED_MIME_TYPES = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - static { - SUPPORTED_MIME_TYPES.put("text/xml", SupportedMimeType.XML); - SUPPORTED_MIME_TYPES.put("application/xml", SupportedMimeType.XML); - SUPPORTED_MIME_TYPES.put("application/json", SupportedMimeType.JSON); - SUPPORTED_MIME_TYPES.put("text/css", SupportedMimeType.TEXT); - SUPPORTED_MIME_TYPES.put("text/csv", SupportedMimeType.TEXT); - SUPPORTED_MIME_TYPES.put("text/html", SupportedMimeType.TEXT); - SUPPORTED_MIME_TYPES.put("text/javascript", SupportedMimeType.TEXT); - SUPPORTED_MIME_TYPES.put("text/plain", SupportedMimeType.TEXT); - // not in azure-core - SUPPORTED_MIME_TYPES.put("application/merge-patch+json", SupportedMimeType.JSON); - } - - public static SupportedMimeType getResponseKnownMimeType(Collection mediaTypes) { - // rfc https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.2 - - // Response adds a "application/json;q=0.9" if no "application/json" specified in media types. - // This is mostly for the error response which is in JSON, and is not included in this calculation. - - for (String mediaType : mediaTypes) { - // The declared mime type can be of the form "application/json; charset=utf-8" or "application/json" - // So, we have to check if the mediaType starts with the supported mime type - if (!mediaType.equals(MethodUtil.CONTENT_TYPE_APPLICATION_JSON_ERROR_WEIGHT)) { // skip the error media type - int semicolonIndex = mediaType.indexOf(';'); - String mediaTypeWithoutParameter = semicolonIndex >= 0 ? mediaType.substring(0, semicolonIndex) : mediaType; - - SupportedMimeType type = SUPPORTED_MIME_TYPES.entrySet().stream() - .filter(supportedMimeType -> mediaTypeWithoutParameter.equals(supportedMimeType.getKey())) - .map(Map.Entry::getValue) - .findFirst() - .orElse(null); - - if (mediaTypeWithoutParameter.startsWith("application/") && mediaTypeWithoutParameter.endsWith("+json")) { - // special handling for "+json", rfc https://datatracker.ietf.org/doc/html/rfc6839#section-3.1 - type = SupportedMimeType.JSON; - - // TODO: we may need to handle "+xml" as well - } - - if (type != null) { - return type; - } - } - } - return SupportedMimeType.BINARY; // BINARY if not recognized - } - } - - private static String expressionConvertToBinaryData(String name, IType type, String mediaType) { - SupportedMimeType mimeType = SupportedMimeType.getResponseKnownMimeType(Collections.singleton(mediaType)); - switch (mimeType) { - case TEXT: - return "BinaryData.fromString(" + name + ")"; - - case BINARY: - return name; - - default: - // JSON etc. - if (type == ClassType.BINARY_DATA) { - return name; - } else { - if (type == ClassType.BASE_64_URL) { - return "BinaryData.fromObject(Base64Url.encode(" + name + "))"; - } else if (type instanceof EnumType) { - return "BinaryData.fromObject(" + name + " == null ? null : " + name + "." + ((EnumType) type).getToMethodName() + "())"; - } else { - return "BinaryData.fromObject(" + name + ")"; - } - } - } - } - - private static void writeHeader(MethodParameter parameter, JavaBlock methodBlock) { - Consumer writeLine = javaBlock -> javaBlock.line( - String.format("requestOptions.setHeader(%1$s, %2$s);", - ModelTemplateHeaderHelper.getHttpHeaderNameInstanceExpression(parameter.getSerializedName()), - expressionConvertToString(parameter.getName(), parameter.getClientMethodParameter().getWireType(), parameter.getProxyMethodParameter()))); - if (!parameter.getClientMethodParameter().isRequired()) { - methodBlock.ifBlock(String.format("%s != null", parameter.getName()), writeLine); - } else { - writeLine.accept(methodBlock); - } - } - - private static void writeQueryParam(MethodParameter parameter, JavaBlock methodBlock) { - Consumer writeLine; - if (parameter.proxyMethodParameter.getExplode() && parameter.getClientMethodParameter().getWireType() instanceof IterableType) { - // multi - IType elementType = ((IterableType) parameter.getClientMethodParameter().getWireType()).getElementType(); - String elementTypeExpression = expressionConvertToString("paramItemValue", elementType, parameter.getProxyMethodParameter()); - writeLine = javaBlock -> { - String addQueryParamLine = getAddQueryParamExpression(parameter, elementTypeExpression); - - javaBlock.line(String.format("for (%1$s paramItemValue : %2$s) {", elementType, parameter.getName())); - javaBlock.indent(() -> { - if (elementType instanceof PrimitiveType) { - javaBlock.line(addQueryParamLine); - } else { - javaBlock.ifBlock("paramItemValue != null", ifBlock -> ifBlock.line(addQueryParamLine)); - } - }); - javaBlock.line("}"); + if (isJsonMergePatchOperation + && ClientModelUtil.isClientModel(parameterType) + && ClientModelUtil.isJsonMergePatchModel(ClientModelUtil.getClientModel(((ClassType) parameterType).getName()), JavaSettings.getInstance())) { + String variableName = writeParameterConversionExpressionWithJsonMergePatchEnabled(javaBlock, parameterType.toString(), parameter.getName(), expression); + javaBlock.line("requestOptions.setBody(" + variableName + ");"); + } else { + javaBlock.line("requestOptions.setBody(" + expression + ");"); + } }; - } else { - writeLine = javaBlock -> javaBlock.line( - getAddQueryParamExpression(parameter, - expressionConvertToString(parameter.getName(), parameter.getClientMethodParameter().getWireType(), parameter.getProxyMethodParameter()))); - } - if (!parameter.getClientMethodParameter().isRequired()) { - methodBlock.ifBlock(String.format("%s != null", parameter.getName()), writeLine); - } else { - writeLine.accept(methodBlock); - } - } - - private static String getAddQueryParamExpression(MethodParameter parameter, String variable) { - // TODO: generic not having 3rd parameter "encoded" - if (JavaSettings.getInstance().isBranded()) { - return String.format("requestOptions.addQueryParam(%1$s, %2$s, %3$s);", - ClassType.STRING.defaultValueExpression(parameter.getSerializedName()), - variable, - parameter.getProxyMethodParameter().getAlreadyEncoded()); - } else { - return String.format("requestOptions.addQueryParam(%1$s, %2$s);", - ClassType.STRING.defaultValueExpression(parameter.getSerializedName()), - variable); - } - } - - private static String expressionConvertToString(String name, IType type, ProxyMethodParameter parameter) { - if (type == ClassType.STRING) { - return name; - } else if (type instanceof EnumType) { - // enum - EnumType enumType = (EnumType) type; - if (enumType.getElementType() == ClassType.STRING) { - return name + ".toString()"; + if (!parameter.getClientMethodParameter().isRequired()) { + methodBlock.ifBlock(parameter.getName() + " != null", writeLine); } else { - return String.format("String.valueOf(%1$s.%2$s())", name, enumType.getToMethodName()); + writeLine.accept(methodBlock); } - } else if (type instanceof IterableType) { - if (parameter.getCollectionFormat() == CollectionFormat.MULTI && parameter.getExplode()) { - // multi, RestProxy will handle the array with "multipleQueryParams = true" - return name; - } else { - String delimiter = ClassType.STRING.defaultValueExpression(parameter.getCollectionFormat().getDelimiter()); - IType elementType = ((IterableType) type).getElementType(); - if (elementType instanceof EnumType) { - // EnumTypes should provide a toString implementation that represents the wire value. - // Circumvent the use of JacksonAdapter and handle this manually. - EnumType enumType = (EnumType) elementType; - // Not enums will be backed by Strings. Get the backing value before converting to string, this - // will prevent using the enum name rather than the enum value when it isn't a String-based - // enum. Ex, a long-based enum with value 100 called HIGH will return "100" rather than - // "HIGH". - String enumToString = enumType.getElementType() == ClassType.STRING - ? "paramItemValue" - : "paramItemValue == null ? null : paramItemValue." + enumType.getToMethodName() + "()"; - return name + ".stream()\n" + - " .map(paramItemValue -> Objects.toString(" + enumToString + ", \"\"))\n" + - " .collect(Collectors.joining(" + delimiter + "))"; - } else if (elementType == ClassType.STRING - || (elementType instanceof ClassType && ((ClassType) elementType).isBoxedType())) { - return name + ".stream()\n" + - " .map(paramItemValue -> Objects.toString(paramItemValue, \"\"))\n" + - " .collect(Collectors.joining(" + delimiter + "))"; - } else { - // Always use serializeIterable as Iterable supports both Iterable and List. - - // this logic depends on rawType of proxy method parameter be List - // alternative would be check wireType of client method parameter - IType elementWireType = parameter.getRawType() instanceof IterableType - ? ((IterableType) parameter.getRawType()).getElementType() - : elementType; - - String serializeIterableInput = name; - if (elementWireType != elementType) { - // convert List to List, if necessary - serializeIterableInput = String.format( - "%s.stream().map(paramItemValue -> %s).collect(Collectors.toList())", - name, elementWireType.convertFromClientType("paramItemValue")); - } - - // convert List to String - return String.format( - "JacksonAdapter.createDefaultSerializerAdapter().serializeIterable(%s, CollectionFormat.%s)", - serializeIterableInput, parameter.getCollectionFormat().toString().toUpperCase(Locale.ROOT)); - } - } - } else { - // primitive or date-time - String conversionExpression = type.convertFromClientType(name); - return String.format("String.valueOf(%s)", conversionExpression); + break; } + } } - private static String expressionConvertToType(String name, MethodParameter convenienceParameter, String mediaType) { - if (convenienceParameter.getProxyMethodParameter().getRequestParameterLocation() == RequestParameterLocation.BODY) { - IType bodyType = convenienceParameter.getProxyMethodParameter().getRawType(); - if (bodyType instanceof ClassType) { - ClientModel model = ClientModelUtil.getClientModel(bodyType.toString()); - // serialize model for multipart/form-data - if (model != null && ClientModelUtil.isMultipartModel(model)) { - return expressionMultipartFormDataToBinaryData(name, model); - } - } - return expressionConvertToBinaryData(name, convenienceParameter.getClientMethodParameter().getWireType(), mediaType); + // invocation with protocol method parameters and RequestOptions + String invocationExpression = protocolMethod.getMethodInputParameters().stream() + .map(p -> { + String parameterName = p.getName(); + String expression = parameterExpressionsMap.get(parameterName); + IType parameterRawType = p.getRawType(); + if (isJsonMergePatchOperation && ClientModelUtil.isClientModel(parameterRawType) + && RequestParameterLocation.BODY.equals(p.getRequestParameterLocation()) + && ClientModelUtil.isJsonMergePatchModel(ClientModelUtil.getClientModel(((ClassType) parameterRawType).getName()), JavaSettings.getInstance())) { + return writeParameterConversionExpressionWithJsonMergePatchEnabled(methodBlock, parameterRawType.toString(), parameterName, expression); } else { - IType type = convenienceParameter.getClientMethodParameter().getWireType(); - if (type instanceof EnumType) { - return expressionConvertToString(name, type, convenienceParameter.getProxyMethodParameter()); - } else if (type instanceof IterableType && ((IterableType) type).getElementType() instanceof EnumType) { - IType enumType = ((IterableType) type).getElementType(); - IType enumValueType = ((EnumType) enumType).getElementType().asNullable(); - if (enumValueType == ClassType.STRING) { - return String.format( - "%1$s.stream().map(paramItemValue -> Objects.toString(paramItemValue, \"\")).collect(Collectors.toList())", - name); - } else { - return String.format( - "%1$s.stream().map(paramItemValue -> paramItemValue == null ? \"\" : String.valueOf(paramItemValue.%2$s())).collect(Collectors.toList())", - name, ((EnumType) enumType).getToMethodName()); - } - } else { - return name; - } + return expression == null ? parameterName : expression; } + }) + .collect(Collectors.joining(", ")); + + // write the invocation of protocol method, and related type conversion + writeInvocationAndConversion(convenienceMethod, protocolMethod, invocationExpression, methodBlock, typeReferenceStaticClasses); + } + + + /** + * Write the validation for parameters against current api-version. + * + * @param parameters the parameters + * @param methodBlock the method block + */ + protected void writeValidationForVersioning(ClientMethod convenienceMethod, Set parameters, JavaBlock methodBlock) { + // validate parameter for versioning + for (MethodParameter parameter : parameters) { + if (parameter.getClientMethodParameter().getVersioning() != null && parameter.getClientMethodParameter().getVersioning().getAdded() != null) { + String condition = String.format( + "!Arrays.asList(%s).contains(serviceClient.getServiceVersion().getVersion())", + parameter.getClientMethodParameter().getVersioning().getAdded().stream().map(ClassType.STRING::defaultValueExpression).collect(Collectors.joining(", "))); + methodBlock.ifBlock(condition, ifBlock -> { + String exceptionExpression = String.format( + "new IllegalArgumentException(\"Parameter %1$s is only available in api-version %2$s.\")", + parameter.getName(), + String.join(", ", parameter.getClientMethodParameter().getVersioning().getAdded())); + writeThrowException(convenienceMethod.getType(), exceptionExpression, ifBlock); + }); + } + } + } + + abstract void writeThrowException(ClientMethodType methodType, String exceptionExpression, JavaBlock methodBlock); + + private static boolean isGroupByTransformation(MethodTransformationDetail detail) { + return !CoreUtils.isNullOrEmpty(detail.getParameterMappings()) + && detail.getParameterMappings().iterator().next().getOutputParameterPropertyName() == null; + } + + private static void writeParameterTransformation( + MethodTransformationDetail detail, + ClientMethod convenienceMethod, ClientMethod protocolMethod, + JavaBlock methodBlock, + Map parametersMap) { + + if (isGroupByTransformation(detail)) { + // grouping + + ParameterMapping mapping = detail.getParameterMappings().iterator().next(); + ClientMethodParameter sourceParameter = mapping.getInputParameter(); + + boolean sourceParameterInMethod = false; + for (MethodParameter parameter: parametersMap.keySet()) { + if (parameter.clientMethodParameter != null && parameter.clientMethodParameter.getName() != null + && Objects.equals(parameter.clientMethodParameter.getName(), sourceParameter.getName())) { + sourceParameterInMethod = true; + break; + } + } + + if (sourceParameterInMethod) { + // null check on input parameter + String assignmentExpression = "%1$s %2$s = %3$s.%4$s();"; + if (!sourceParameter.isRequired()) { + assignmentExpression = "%1$s %2$s = %3$s == null ? null : %3$s.%4$s();"; + } + + methodBlock.line(String.format(assignmentExpression, + detail.getOutParameter().getClientType(), + detail.getOutParameter().getName(), + sourceParameter.getName(), + CodeNamer.getModelNamer().modelPropertyGetterName(mapping.getInputParameterProperty()))); + + if (detail.getOutParameter().getRequestParameterLocation() != null) { + ClientMethodParameter clientMethodParameter = detail.getOutParameter(); + ProxyMethodParameter proxyMethodParameter = convenienceMethod.getProxyMethod().getAllParameters().stream() + .filter(p -> clientMethodParameter.getName().equals(CodeNamer.getEscapedReservedClientMethodParameterName(p.getName()))) + .findFirst().orElse(null); + if (proxyMethodParameter != null) { + MethodParameter methodParameter = new MethodParameter(proxyMethodParameter, clientMethodParameter); + parametersMap.put(methodParameter, findProtocolMethodParameterForConvenienceMethod(methodParameter, protocolMethod)); + } + } + } + } else { + // flatten (possible with grouping) + ClientMethodParameter targetParameter = detail.getOutParameter(); + if (targetParameter.getWireType() == ClassType.BINARY_DATA) { + IType targetType = targetParameter.getRawType(); + + StringBuilder ctorExpression = new StringBuilder(); + StringBuilder setterExpression = new StringBuilder(); + String targetParameterName = targetParameter.getName(); + String targetParameterObjectName = targetParameterName + "Obj"; + for (ParameterMapping mapping : detail.getParameterMappings()) { + String parameterName = mapping.getInputParameter().getName(); + + String inputPath = parameterName; + boolean propertyRequired = mapping.getInputParameter().isRequired(); + if (mapping.getInputParameterProperty() != null) { + inputPath = String.format("%s.%s()", mapping.getInputParameter().getName(), + CodeNamer.getModelNamer().modelPropertyGetterName(mapping.getInputParameterProperty())); + propertyRequired = mapping.getInputParameterProperty().isRequired(); + } + if (propertyRequired) { + // required + if (JavaSettings.getInstance().isRequiredFieldsAsConstructorArgs()) { + if (ctorExpression.length() > 0) { + ctorExpression.append(", "); + } + ctorExpression.append(inputPath); + } else { + setterExpression.append(".").append(mapping.getOutputParameterProperty().getSetterName()).append("(").append(inputPath).append(")"); + } + } else if (!convenienceMethod.getOnlyRequiredParameters()) { + // optional + setterExpression.append(".").append(mapping.getOutputParameterProperty().getSetterName()).append("(").append(inputPath).append(")"); + } + } + methodBlock.line(String.format("%1$s %2$s = new %1$s(%3$s)%4$s;", targetType, targetParameterObjectName, ctorExpression, setterExpression)); + + String expression = null; + if (targetParameter.getRawType() instanceof ClassType) { + ClientModel model = ClientModelUtil.getClientModel(targetParameter.getRawType().toString()); + // serialize model for multipart/form-data + if (model != null && ClientModelUtil.isMultipartModel(model)) { + expression = expressionMultipartFormDataToBinaryData(targetParameterObjectName, model); + } + } + if (expression == null) { + expression = expressionConvertToBinaryData(targetParameterObjectName, targetParameter.getRawType(), protocolMethod.getProxyMethod().getRequestContentType()); + } + methodBlock.line(String.format("BinaryData %1$s = %2$s;", targetParameterName, expression)); + } + } + } + + protected void addImports(Set imports, List convenienceMethods) { + // methods + JavaSettings settings = JavaSettings.getInstance(); + convenienceMethods.stream().flatMap(m -> m.getConvenienceMethods().stream()) + .forEach(m -> { + m.addImportsTo(imports, false, settings); + // hack, add wire type of parameters, as they are not added in ClientMethod, even when includeImplementationImports=true + for (ClientMethodParameter p : m.getParameters()) { + p.getWireType().addImportsTo(imports, false); + + // add imports from models, as some convenience API need to process model properties + if (p.getWireType() instanceof ClassType) { + ClientModel model = ClientModelUtil.getClientModel(p.getWireType().toString()); + if (model != null) { + model.addImportsTo(imports, settings); + } + } + } + }); + + ClassType.HTTP_HEADER_NAME.addImportsTo(imports, false); + ClassType.BINARY_DATA.addImportsTo(imports, false); + ClassType.REQUEST_OPTIONS.addImportsTo(imports, false); + imports.add(Collectors.class.getName()); + imports.add(Objects.class.getName()); + imports.add(FluxUtil.class.getName()); + + // collection format + imports.add(JacksonAdapter.class.getName()); + imports.add(CollectionFormat.class.getName()); + imports.add(TypeReference.class.getName()); + if (!JavaSettings.getInstance().isBranded()) { + imports.add(Type.class.getName()); + imports.add(ParameterizedType.class.getName()); } - private static String expressionMultipartFormDataToBinaryData(String name, ClientModel model) { - BiFunction nullableExpression = (propertyExpr, expr) -> propertyExpr + " == null ? null : " + expr; + // byte[] + ClassType.BASE_64_URL.addImportsTo(imports, false); + // flatten payload + imports.add(Map.class.getName()); + imports.add(HashMap.class.getName()); + + // MultipartFormDataHelper class + imports.add(settings.getPackage(settings.getImplementationSubpackage()) + "." + ClientModelUtil.MULTI_PART_FORM_DATA_HELPER_CLASS_NAME); + + // versioning + imports.add(Arrays.class.getName()); + + // JsonMergePatchHelper class + imports.add(settings.getPackage(settings.getImplementationSubpackage()) + "." + ClientModelUtil.JSON_MERGE_PATCH_HELPER_CLASS_NAME); + } + + protected void addGeneratedAnnotation(JavaType typeBlock) { + if (JavaSettings.getInstance().isBranded()) { + typeBlock.annotation(Annotation.GENERATED.getName()); + } else { + typeBlock.annotation(Annotation.METADATA.getName() + "(generated = true)"); + } + } + + /** + * Whether the convenience method should be included. + * + * @param method the convenience method. + * @return Whether include the convenience method. + */ + protected abstract boolean isMethodIncluded(ClientMethod method); + + /** + * Whether the convenience/protocol method should be included. + * + * @param method the convenience/protocol method. + * @return Whether include the convenience/protocol method. + */ + protected abstract boolean isMethodIncluded(ConvenienceMethod method); + + protected boolean isMethodAsync(ClientMethod method) { + return method.getType().name().contains("Async"); + } + + protected boolean isMethodVisible(ClientMethod method) { + return method.getMethodVisibility() == JavaVisibility.Public; + } + + protected String getMethodName(ClientMethod method) { + if (isMethodAsync(method)) { + return method.getName().endsWith("Async") + ? method.getName().substring(0, method.getName().length() - "Async".length()) + : method.getName(); + } else { + return method.getName(); + } + } + + /** + * Write the code of the method invocation of client method, and the conversion of parameters and return value. + * + * @param convenienceMethod the convenience method. + * @param protocolMethod the protocol method. + * @param invocationExpression the prepared expression of invocation on client method. + * @param methodBlock the code block. + */ + protected abstract void writeInvocationAndConversion( + ClientMethod convenienceMethod, ClientMethod protocolMethod, + String invocationExpression, + JavaBlock methodBlock, + Set typeReferenceStaticClasses); + + protected boolean isModelOrBuiltin(IType type) { + // TODO: other built-in types + return type == ClassType.STRING // string + || type == ClassType.OBJECT // unknown + || type == ClassType.BIG_DECIMAL // decimal + || (type instanceof PrimitiveType && type.asNullable() != ClassType.VOID) // boolean, int, float, etc. + || ClientModelUtil.isClientModel(type); // client model + } + + protected enum SupportedMimeType { + TEXT, + XML, + MULTIPART, + BINARY, + JSON; + + // azure-core SerializerEncoding.SUPPORTED_MIME_TYPES + private static final Map SUPPORTED_MIME_TYPES = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + static { + SUPPORTED_MIME_TYPES.put("text/xml", SupportedMimeType.XML); + SUPPORTED_MIME_TYPES.put("application/xml", SupportedMimeType.XML); + SUPPORTED_MIME_TYPES.put("application/json", SupportedMimeType.JSON); + SUPPORTED_MIME_TYPES.put("text/css", SupportedMimeType.TEXT); + SUPPORTED_MIME_TYPES.put("text/csv", SupportedMimeType.TEXT); + SUPPORTED_MIME_TYPES.put("text/html", SupportedMimeType.TEXT); + SUPPORTED_MIME_TYPES.put("text/javascript", SupportedMimeType.TEXT); + SUPPORTED_MIME_TYPES.put("text/plain", SupportedMimeType.TEXT); + // not in azure-core + SUPPORTED_MIME_TYPES.put("application/merge-patch+json", SupportedMimeType.JSON); + } + + public static SupportedMimeType getResponseKnownMimeType(Collection mediaTypes) { + // rfc https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.2 + + // Response adds a "application/json;q=0.9" if no "application/json" specified in media types. + // This is mostly for the error response which is in JSON, and is not included in this calculation. + + for (String mediaType : mediaTypes) { + // The declared mime type can be of the form "application/json; charset=utf-8" or "application/json" + // So, we have to check if the mediaType starts with the supported mime type + if (!mediaType.equals(MethodUtil.CONTENT_TYPE_APPLICATION_JSON_ERROR_WEIGHT)) { // skip the error media type + int semicolonIndex = mediaType.indexOf(';'); + String mediaTypeWithoutParameter = semicolonIndex >= 0 ? mediaType.substring(0, semicolonIndex) : mediaType; + + SupportedMimeType type = SUPPORTED_MIME_TYPES.entrySet().stream() + .filter(supportedMimeType -> mediaTypeWithoutParameter.equals(supportedMimeType.getKey())) + .map(Map.Entry::getValue) + .findFirst() + .orElse(null); + + if (mediaTypeWithoutParameter.startsWith("application/") && mediaTypeWithoutParameter.endsWith("+json")) { + // special handling for "+json", rfc https://datatracker.ietf.org/doc/html/rfc6839#section-3.1 + type = SupportedMimeType.JSON; + + // TODO: we may need to handle "+xml" as well + } + + if (type != null) { + return type; + } + } + } + return SupportedMimeType.BINARY; // BINARY if not recognized + } + } + + private static String expressionConvertToBinaryData(String name, IType type, String mediaType) { + SupportedMimeType mimeType = SupportedMimeType.getResponseKnownMimeType(Collections.singleton(mediaType)); + switch (mimeType) { + case TEXT: + return "BinaryData.fromString(" + name + ")"; + + case BINARY: + return name; + + default: + // JSON etc. + if (type == ClassType.BINARY_DATA) { + return name; + } else { + if (type == ClassType.BASE_64_URL) { + return "BinaryData.fromObject(Base64Url.encode(" + name + "))"; + } else if (type instanceof EnumType) { + return "BinaryData.fromObject(" + name + " == null ? null : " + name + "." + ((EnumType) type).getToMethodName() + "())"; + } else { + return "BinaryData.fromObject(" + name + ")"; + } + } + } + } + + private static void writeHeader(MethodParameter parameter, JavaBlock methodBlock) { + Consumer writeLine = javaBlock -> javaBlock.line( + String.format("requestOptions.setHeader(%1$s, %2$s);", + ModelTemplateHeaderHelper.getHttpHeaderNameInstanceExpression(parameter.getSerializedName()), + expressionConvertToString(parameter.getName(), parameter.getClientMethodParameter().getWireType(), parameter.getProxyMethodParameter()))); + if (!parameter.getClientMethodParameter().isRequired()) { + methodBlock.ifBlock(String.format("%s != null", parameter.getName()), writeLine); + } else { + writeLine.accept(methodBlock); + } + } + + private static void writeQueryParam(MethodParameter parameter, JavaBlock methodBlock) { + Consumer writeLine; + if (parameter.proxyMethodParameter.getExplode() && parameter.getClientMethodParameter().getWireType() instanceof IterableType) { + // multi + IType elementType = ((IterableType) parameter.getClientMethodParameter().getWireType()).getElementType(); + String elementTypeExpression = expressionConvertToString("paramItemValue", elementType, parameter.getProxyMethodParameter()); + writeLine = javaBlock -> { + String addQueryParamLine = getAddQueryParamExpression(parameter, elementTypeExpression); + + javaBlock.line(String.format("for (%1$s paramItemValue : %2$s) {", elementType, parameter.getName())); + javaBlock.indent(() -> { + if (elementType instanceof PrimitiveType) { + javaBlock.line(addQueryParamLine); + } else { + javaBlock.ifBlock("paramItemValue != null", ifBlock -> ifBlock.line(addQueryParamLine)); + } + }); + javaBlock.line("}"); + }; + } else { + writeLine = javaBlock -> javaBlock.line( + getAddQueryParamExpression(parameter, + expressionConvertToString(parameter.getName(), parameter.getClientMethodParameter().getWireType(), parameter.getProxyMethodParameter()))); + } + if (!parameter.getClientMethodParameter().isRequired()) { + methodBlock.ifBlock(String.format("%s != null", parameter.getName()), writeLine); + } else { + writeLine.accept(methodBlock); + } + } + + private static String getAddQueryParamExpression(MethodParameter parameter, String variable) { + // TODO: generic not having 3rd parameter "encoded" + if (JavaSettings.getInstance().isBranded()) { + return String.format("requestOptions.addQueryParam(%1$s, %2$s, %3$s);", + ClassType.STRING.defaultValueExpression(parameter.getSerializedName()), + variable, + parameter.getProxyMethodParameter().getAlreadyEncoded()); + } else { + return String.format("requestOptions.addQueryParam(%1$s, %2$s);", + ClassType.STRING.defaultValueExpression(parameter.getSerializedName()), + variable); + } + } + + private static String expressionConvertToString(String name, IType type, ProxyMethodParameter parameter) { + if (type == ClassType.STRING) { + return name; + } else if (type instanceof EnumType) { + // enum + EnumType enumType = (EnumType) type; + if (enumType.getElementType() == ClassType.STRING) { + return name + ".toString()"; + } else { + return String.format("String.valueOf(%1$s.%2$s())", name, enumType.getToMethodName()); + } + } else if (type instanceof IterableType) { + if (parameter.getCollectionFormat() == CollectionFormat.MULTI && parameter.getExplode()) { + // multi, RestProxy will handle the array with "multipleQueryParams = true" + return name; + } else { + String delimiter = ClassType.STRING.defaultValueExpression(parameter.getCollectionFormat().getDelimiter()); + IType elementType = ((IterableType) type).getElementType(); + if (elementType instanceof EnumType) { + // EnumTypes should provide a toString implementation that represents the wire value. + // Circumvent the use of JacksonAdapter and handle this manually. + EnumType enumType = (EnumType) elementType; + // Not enums will be backed by Strings. Get the backing value before converting to string, this + // will prevent using the enum name rather than the enum value when it isn't a String-based + // enum. Ex, a long-based enum with value 100 called HIGH will return "100" rather than + // "HIGH". + String enumToString = enumType.getElementType() == ClassType.STRING + ? "paramItemValue" + : "paramItemValue == null ? null : paramItemValue." + enumType.getToMethodName() + "()"; + return name + ".stream()\n" + + " .map(paramItemValue -> Objects.toString(" + enumToString + ", \"\"))\n" + + " .collect(Collectors.joining(" + delimiter + "))"; + } else if (elementType == ClassType.STRING + || (elementType instanceof ClassType && ((ClassType) elementType).isBoxedType())) { + return name + ".stream()\n" + + " .map(paramItemValue -> Objects.toString(paramItemValue, \"\"))\n" + + " .collect(Collectors.joining(" + delimiter + "))"; + } else { + // Always use serializeIterable as Iterable supports both Iterable and List. + + // this logic depends on rawType of proxy method parameter be List + // alternative would be check wireType of client method parameter + IType elementWireType = parameter.getRawType() instanceof IterableType + ? ((IterableType) parameter.getRawType()).getElementType() + : elementType; + + String serializeIterableInput = name; + if (elementWireType != elementType) { + // convert List to List, if necessary + serializeIterableInput = String.format( + "%s.stream().map(paramItemValue -> %s).collect(Collectors.toList())", + name, elementWireType.convertFromClientType("paramItemValue")); + } + + // convert List to String + return String.format( + "JacksonAdapter.createDefaultSerializerAdapter().serializeIterable(%s, CollectionFormat.%s)", + serializeIterableInput, parameter.getCollectionFormat().toString().toUpperCase(Locale.ROOT)); + } + } + } else { + // primitive or date-time + String conversionExpression = type.convertFromClientType(name); + return String.format("String.valueOf(%s)", conversionExpression); + } + } + + private static String expressionConvertToType(String name, MethodParameter convenienceParameter, String mediaType) { + if (convenienceParameter.getProxyMethodParameter().getRequestParameterLocation() == RequestParameterLocation.BODY) { + IType bodyType = convenienceParameter.getProxyMethodParameter().getRawType(); + if (bodyType instanceof ClassType) { + ClientModel model = ClientModelUtil.getClientModel(bodyType.toString()); // serialize model for multipart/form-data - StringBuilder builder = new StringBuilder().append("new MultipartFormDataHelper(requestOptions)"); - for (ClientModelProperty property : model.getProperties()) { - String propertyGetExpression = name + "." + property.getGetterName() + "()"; - if (!property.isReadOnly()) { - if (isMultipartModel(property.getWireType())) { - // file, usually application/octet-stream - - String fileExpression = propertyGetExpression + ".getContent()"; - String contentTypeExpression = propertyGetExpression + ".getContentType()"; - String filenameExpression = propertyGetExpression + ".getFilename()"; - if (!property.isRequired()) { - fileExpression = nullableExpression.apply(propertyGetExpression, fileExpression); - contentTypeExpression = nullableExpression.apply(propertyGetExpression, contentTypeExpression); - filenameExpression = nullableExpression.apply(propertyGetExpression, filenameExpression); - } - - builder.append(String.format( - ".serializeFileField(%1$s, %2$s, %3$s, %4$s)", - ClassType.STRING.defaultValueExpression(property.getSerializedName()), - fileExpression, - contentTypeExpression, - filenameExpression - )); - } else if (property.getWireType() instanceof ListType && isMultipartModel(((ListType) property.getWireType()).getElementType())) { - // file array - - // For now, we use 3 List, as we do not wish the Helper class refer to different ##FileDetails model. - // Later, if we switch to a shared class in azure-core, we can change the implementation. - String className = ((ListType) property.getWireType()).getElementType().toString(); - String streamExpressionFormat = "%1$s.stream().map(%2$s::%3$s).collect(Collectors.toList())"; - String fileExpression = String.format(streamExpressionFormat, - propertyGetExpression, className, "getContent"); - String contentTypeExpression = String.format(streamExpressionFormat, - propertyGetExpression, className, "getContentType"); - String filenameExpression = String.format(streamExpressionFormat, - propertyGetExpression, className, "getFilename"); - if (!property.isRequired()) { - fileExpression = nullableExpression.apply(propertyGetExpression, fileExpression); - contentTypeExpression = nullableExpression.apply(propertyGetExpression, contentTypeExpression); - filenameExpression = nullableExpression.apply(propertyGetExpression, filenameExpression); - } - - builder.append(String.format( - ".serializeFileFields(%1$s, %2$s, %3$s, %4$s)", - ClassType.STRING.defaultValueExpression(property.getSerializedName()), - fileExpression, - contentTypeExpression, - filenameExpression - )); - } else if (ClientModelUtil.isClientModel(property.getWireType()) - || property.getWireType() instanceof MapType - || property.getWireType() instanceof IterableType) { - // application/json - builder.append(String.format( - ".serializeJsonField(%1$s, %2$s)", - ClassType.STRING.defaultValueExpression(property.getSerializedName()), - propertyGetExpression - )); - } else { - // text/plain - String stringExpression = propertyGetExpression; - // convert to String - if (property.getWireType() instanceof PrimitiveType) { - stringExpression = String.format("String.valueOf(%s)", stringExpression); - } else if (property.getWireType() != ClassType.STRING) { - stringExpression = String.format("Objects.toString(%s)", stringExpression); - } - builder.append(String.format( - ".serializeTextField(%1$s, %2$s)", - ClassType.STRING.defaultValueExpression(property.getSerializedName()), - stringExpression - )); - } - } + if (model != null && ClientModelUtil.isMultipartModel(model)) { + return expressionMultipartFormDataToBinaryData(name, model); } - builder.append(".end().getRequestBody()"); - return builder.toString(); - } - - private static boolean isMultipartModel(IType type) { - if (ClientModelUtil.isClientModel(type)) { - return ClientModelUtil.isMultipartModel(ClientModelUtil.getClientModel(type.toString())); + } + return expressionConvertToBinaryData(name, convenienceParameter.getClientMethodParameter().getWireType(), mediaType); + } else { + IType type = convenienceParameter.getClientMethodParameter().getWireType(); + if (type instanceof EnumType) { + return expressionConvertToString(name, type, convenienceParameter.getProxyMethodParameter()); + } else if (type instanceof IterableType && ((IterableType) type).getElementType() instanceof EnumType) { + IType enumType = ((IterableType) type).getElementType(); + IType enumValueType = ((EnumType) enumType).getElementType().asNullable(); + if (enumValueType == ClassType.STRING) { + return String.format( + "%1$s.stream().map(paramItemValue -> Objects.toString(paramItemValue, \"\")).collect(Collectors.toList())", + name); } else { - return false; + return String.format( + "%1$s.stream().map(paramItemValue -> paramItemValue == null ? \"\" : String.valueOf(paramItemValue.%2$s())).collect(Collectors.toList())", + name, ((EnumType) enumType).getToMethodName()); } + } else { + return name; + } + } + } + + private static String expressionMultipartFormDataToBinaryData(String name, ClientModel model) { + BiFunction nullableExpression = (propertyExpr, expr) -> propertyExpr + " == null ? null : " + expr; + + // serialize model for multipart/form-data + StringBuilder builder = new StringBuilder().append("new MultipartFormDataHelper(requestOptions)"); + for (ClientModelProperty property : model.getProperties()) { + String propertyGetExpression = name + "." + property.getGetterName() + "()"; + if (!property.isReadOnly()) { + if (isMultipartModel(property.getWireType())) { + // file, usually application/octet-stream + + String fileExpression = propertyGetExpression + ".getContent()"; + String contentTypeExpression = propertyGetExpression + ".getContentType()"; + String filenameExpression = propertyGetExpression + ".getFilename()"; + if (!property.isRequired()) { + fileExpression = nullableExpression.apply(propertyGetExpression, fileExpression); + contentTypeExpression = nullableExpression.apply(propertyGetExpression, contentTypeExpression); + filenameExpression = nullableExpression.apply(propertyGetExpression, filenameExpression); + } + + builder.append(String.format( + ".serializeFileField(%1$s, %2$s, %3$s, %4$s)", + ClassType.STRING.defaultValueExpression(property.getSerializedName()), + fileExpression, + contentTypeExpression, + filenameExpression + )); + } else if (property.getWireType() instanceof ListType && isMultipartModel(((ListType) property.getWireType()).getElementType())) { + // file array + + // For now, we use 3 List, as we do not wish the Helper class refer to different ##FileDetails model. + // Later, if we switch to a shared class in azure-core, we can change the implementation. + String className = ((ListType) property.getWireType()).getElementType().toString(); + String streamExpressionFormat = "%1$s.stream().map(%2$s::%3$s).collect(Collectors.toList())"; + String fileExpression = String.format(streamExpressionFormat, + propertyGetExpression, className, "getContent"); + String contentTypeExpression = String.format(streamExpressionFormat, + propertyGetExpression, className, "getContentType"); + String filenameExpression = String.format(streamExpressionFormat, + propertyGetExpression, className, "getFilename"); + if (!property.isRequired()) { + fileExpression = nullableExpression.apply(propertyGetExpression, fileExpression); + contentTypeExpression = nullableExpression.apply(propertyGetExpression, contentTypeExpression); + filenameExpression = nullableExpression.apply(propertyGetExpression, filenameExpression); + } + + builder.append(String.format( + ".serializeFileFields(%1$s, %2$s, %3$s, %4$s)", + ClassType.STRING.defaultValueExpression(property.getSerializedName()), + fileExpression, + contentTypeExpression, + filenameExpression + )); + } else if (ClientModelUtil.isClientModel(property.getWireType()) + || property.getWireType() instanceof MapType + || property.getWireType() instanceof IterableType) { + // application/json + builder.append(String.format( + ".serializeJsonField(%1$s, %2$s)", + ClassType.STRING.defaultValueExpression(property.getSerializedName()), + propertyGetExpression + )); + } else { + // text/plain + String stringExpression = propertyGetExpression; + // convert to String + if (property.getWireType() instanceof PrimitiveType) { + stringExpression = String.format("String.valueOf(%s)", stringExpression); + } else if (property.getWireType() != ClassType.STRING) { + stringExpression = String.format("Objects.toString(%s)", stringExpression); + } + builder.append(String.format( + ".serializeTextField(%1$s, %2$s)", + ClassType.STRING.defaultValueExpression(property.getSerializedName()), + stringExpression + )); + } + } + } + builder.append(".end().getRequestBody()"); + return builder.toString(); + } + + private static boolean isMultipartModel(IType type) { + if (ClientModelUtil.isClientModel(type)) { + return ClientModelUtil.isMultipartModel(ClientModelUtil.getClientModel(type.toString())); + } else { + return false; + } + } + + private static Map findParametersForConvenienceMethod( + ClientMethod convenienceMethod, ClientMethod protocolMethod) { + Map parameterMap = new LinkedHashMap<>(); + List convenienceParameters = getParameters(convenienceMethod, true); + Map clientParameters = getParameters(protocolMethod, false).stream() + .collect(Collectors.toMap(MethodParameter::getSerializedName, Function.identity())); + for (MethodParameter convenienceParameter : convenienceParameters) { + String name = convenienceParameter.getSerializedName(); + parameterMap.put(convenienceParameter, clientParameters.get(name)); + } + return parameterMap; + } + + private static MethodParameter findProtocolMethodParameterForConvenienceMethod( + MethodParameter parameter, ClientMethod protocolMethod) { + List protocolParameters = getParameters(protocolMethod, false); + return protocolParameters.stream().filter(p -> Objects.equals(parameter.getSerializedName(), p.getSerializedName())).findFirst().orElse(null); + } + + private static List getParameters(ClientMethod method, boolean useAllParameters) { + List proxyMethodParameters = useAllParameters ? method.getProxyMethod().getAllParameters() : method.getProxyMethod().getParameters(); + Map proxyMethodParameterByClientParameterName = proxyMethodParameters.stream() + .collect(Collectors.toMap(p -> CodeNamer.getEscapedReservedClientMethodParameterName(p.getName()), Function.identity())); + return method.getMethodInputParameters().stream() + .filter(p -> !p.isConstant() && !p.isFromClient()) + .map(p -> { + ProxyMethodParameter proxyMethodParameter = proxyMethodParameterByClientParameterName.get(p.getName()); + if (proxyMethodParameter != null) { + if (p.getRequestParameterLocation() != proxyMethodParameter.getRequestParameterLocation()) { + proxyMethodParameter = null; + } + } + return new MethodParameter(proxyMethodParameter, p); + }) + .collect(Collectors.toList()); + } + + /** + * Writes the expression to convert a convenience parameter to a protocol parameter and wrap it in JsonMergePatchHelper. + * @param javaBlock + * @param convenientParameterTypeName + * @param convenientParameterName + * @param expression + * @return the name of the variable that holds the converted parameter + */ + private static String writeParameterConversionExpressionWithJsonMergePatchEnabled(JavaBlock javaBlock, String convenientParameterTypeName, String convenientParameterName, String expression) { + String variableName = convenientParameterName + "InBinaryData"; + javaBlock.line(String.format("JsonMergePatchHelper.get%1$sAccessor().prepareModelForJsonMergePatch(%2$s, true);", convenientParameterTypeName, convenientParameterName)); + javaBlock.line("BinaryData " + variableName + " = " + expression + ";"); + javaBlock.line("// BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization."); + javaBlock.line(variableName + ".getLength();"); + javaBlock.line(String.format("JsonMergePatchHelper.get%1$sAccessor().prepareModelForJsonMergePatch(%2$s, false);", convenientParameterTypeName, convenientParameterName)); + return variableName; + } + + protected static class MethodParameter { + + private final ProxyMethodParameter proxyMethodParameter; + private final ClientMethodParameter clientMethodParameter; + + public MethodParameter(ProxyMethodParameter proxyMethodParameter, ClientMethodParameter clientMethodParameter) { + this.proxyMethodParameter = proxyMethodParameter; + this.clientMethodParameter = clientMethodParameter; } - private static Map findParametersForConvenienceMethod( - ClientMethod convenienceMethod, ClientMethod protocolMethod) { - Map parameterMap = new LinkedHashMap<>(); - List convenienceParameters = getParameters(convenienceMethod, true); - Map clientParameters = getParameters(protocolMethod, false).stream() - .collect(Collectors.toMap(MethodParameter::getSerializedName, Function.identity())); - for (MethodParameter convenienceParameter : convenienceParameters) { - String name = convenienceParameter.getSerializedName(); - parameterMap.put(convenienceParameter, clientParameters.get(name)); - } - return parameterMap; + public ProxyMethodParameter getProxyMethodParameter() { + return proxyMethodParameter; } - private static MethodParameter findProtocolMethodParameterForConvenienceMethod( - MethodParameter parameter, ClientMethod protocolMethod) { - List protocolParameters = getParameters(protocolMethod, false); - return protocolParameters.stream().filter(p -> Objects.equals(parameter.getSerializedName(), p.getSerializedName())).findFirst().orElse(null); + public ClientMethodParameter getClientMethodParameter() { + return clientMethodParameter; } - private static List getParameters(ClientMethod method, boolean useAllParameters) { - List proxyMethodParameters = useAllParameters ? method.getProxyMethod().getAllParameters() : method.getProxyMethod().getParameters(); - Map proxyMethodParameterByClientParameterName = proxyMethodParameters.stream() - .collect(Collectors.toMap(p -> CodeNamer.getEscapedReservedClientMethodParameterName(p.getName()), Function.identity())); - return method.getMethodInputParameters().stream() - .filter(p -> !p.isConstant() && !p.isFromClient()) - .map(p -> new MethodParameter(proxyMethodParameterByClientParameterName.get(p.getName()), p)) - .collect(Collectors.toList()); + public String getName() { + return this.getClientMethodParameter().getName(); } - /** - * Writes the expression to convert a convenience parameter to a protocol parameter and wrap it in JsonMergePatchHelper. - * @param javaBlock - * @param convenientParameterTypeName - * @param convenientParameterName - * @param expression - * @return the name of the variable that holds the converted parameter - */ - private static String writeParameterConversionExpressionWithJsonMergePatchEnabled(JavaBlock javaBlock, String convenientParameterTypeName, String convenientParameterName, String expression) { - String variableName = convenientParameterName + "InBinaryData"; - javaBlock.line(String.format("JsonMergePatchHelper.get%1$sAccessor().prepareModelForJsonMergePatch(%2$s, true);", convenientParameterTypeName, convenientParameterName)); - javaBlock.line("BinaryData " + variableName + " = " + expression + ";"); - javaBlock.line("// BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization."); - javaBlock.line(variableName + ".getLength();"); - javaBlock.line(String.format("JsonMergePatchHelper.get%1$sAccessor().prepareModelForJsonMergePatch(%2$s, false);", convenientParameterTypeName, convenientParameterName)); - return variableName; - } - - protected static class MethodParameter { - - private final ProxyMethodParameter proxyMethodParameter; - private final ClientMethodParameter clientMethodParameter; - - public MethodParameter(ProxyMethodParameter proxyMethodParameter, ClientMethodParameter clientMethodParameter) { - this.proxyMethodParameter = proxyMethodParameter; - this.clientMethodParameter = clientMethodParameter; - } - - public ProxyMethodParameter getProxyMethodParameter() { - return proxyMethodParameter; - } - - public ClientMethodParameter getClientMethodParameter() { - return clientMethodParameter; - } - - public String getName() { - return this.getClientMethodParameter().getName(); - } - - public String getSerializedName() { - if (this.getProxyMethodParameter() == null) { - return null; - } else { - String name = this.getProxyMethodParameter().getRequestParameterName(); - if (name == null && this.getProxyMethodParameter().getRequestParameterLocation() == RequestParameterLocation.BODY) { - name = "__internal_request_BODY"; - } - return name; - } - } + public String getSerializedName() { + if (this.getProxyMethodParameter() == null) { + return null; + } else { + String name = this.getProxyMethodParameter().getRequestParameterName(); + if (name == null && this.getProxyMethodParameter().getRequestParameterLocation() == RequestParameterLocation.BODY) { + name = "__internal_request_BODY"; + } + return name; + } } + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ModelTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ModelTemplate.java index fad9ed30f..743564590 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ModelTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ModelTemplate.java @@ -4,6 +4,7 @@ package com.microsoft.typespec.http.client.generator.core.template; import com.microsoft.typespec.http.client.generator.core.extension.plugin.JavaSettings; +import com.microsoft.typespec.http.client.generator.core.implementation.PolymorphicDiscriminatorHandler; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.Annotation; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ArrayType; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClassType; @@ -57,823 +58,776 @@ import java.util.stream.Stream; */ public class ModelTemplate implements IJavaTemplate { - private static final String MISSING_SCHEMA = "MISSING·SCHEMA"; - private static final ModelTemplate INSTANCE = new ModelTemplate(); + private static final String MISSING_SCHEMA = "MISSING·SCHEMA"; + private static final ModelTemplate INSTANCE = new ModelTemplate(); - protected ModelTemplate() { + protected ModelTemplate() { + } + + public static ModelTemplate getInstance() { + return INSTANCE; + } + + public final void write(ClientModel model, JavaFile javaFile) { + if (model.getParentModelName() != null && model.getParentModelName().equals(model.getName())) { + throw new IllegalStateException("Parent model name is same as model name: " + model.getName()); } - public static ModelTemplate getInstance() { - return INSTANCE; + final boolean requireSerialization = modelRequireSerialization(model); + + JavaSettings settings = JavaSettings.getInstance(); + Set imports = settings.isStreamStyleSerialization() ? new StreamStyleImports() : new HashSet<>(); + + addImports(imports, model, settings); + + List propertyReferences = this.getClientModelPropertyReferences(model); + propertyReferences.forEach(p -> p.addImportsTo(imports, false)); + + if (!CoreUtils.isNullOrEmpty(model.getPropertyReferences())) { + if (settings.getClientFlattenAnnotationTarget() == JavaSettings.ClientFlattenAnnotationTarget.NONE) { + model.getPropertyReferences().forEach(p -> p.addImportsTo(imports, false)); + } + propertyReferences.addAll(model.getPropertyReferences()); } - public final void write(ClientModel model, JavaFile javaFile) { - if (model.getParentModelName() != null && model.getParentModelName().equals(model.getName())) { - throw new IllegalStateException("Parent model name is same as model name: " + model.getName()); + javaFile.declareImport(imports); + + javaFile.javadocComment(comment -> comment.description(model.getDescription())); + + final boolean hasDerivedModels = !model.getDerivedModels().isEmpty(); + final boolean immutableModel = ClientModelUtil.isImmutableOutputModel(model, settings); + boolean treatAsXml = model.isUsedInXml(); + + // Handle adding annotations if the model is polymorphic. + PolymorphicDiscriminatorHandler.addAnnotationToField(model, javaFile, settings); + + // Add class level annotations for serialization formats such as XML. + addClassLevelAnnotations(model, javaFile, settings); + + // Add Fluent or Immutable based on whether the model has any setters. + addFluentOrImmutableAnnotation(model, immutableModel, propertyReferences, javaFile, settings); + + List classModifiers = null; + if (!hasDerivedModels && !model.getNeedsFlatten()) { + classModifiers = Collections.singletonList(JavaModifier.Final); + } + + String classNameWithBaseType = model.getName(); + if (model.getParentModelName() != null) { + classNameWithBaseType += " extends " + model.getParentModelName(); + } else if (requireSerialization) { + classNameWithBaseType = addSerializationImplementations(classNameWithBaseType, model, settings); + } + + javaFile.publicClass(classModifiers, classNameWithBaseType, classBlock -> { + // If the model has any additional properties, needs to be flattened, and isn't being generated with + // stream-style serialization add a constant Pattern that will be used to escape the additional property + // keys. Certain versions of the JVM will compile a Pattern each time '.replace' is called which is very + // expensive. + if (model.getProperties().stream().anyMatch(ClientModelProperty::isAdditionalProperties) + && model.getNeedsFlatten() + && !settings.isStreamStyleSerialization()) { + addGeneratedAnnotation(classBlock); + classBlock.privateStaticFinalVariable("Pattern KEY_ESCAPER = Pattern.compile(\"\\\\.\");"); + } + + // If code is being generated with the behavior to return an empty byte array when the default value + // expression is null and the model has any array types that will need conversion within getter methods + // generate a static byte[] that will be returned instead of creating a new instance each get. + if (isGenerateConstantEmptyByteArray(model, settings)) { + classBlock.privateStaticFinalVariable("byte[] EMPTY_BYTE_ARRAY = new byte[0]"); + } + + // XML namespace constants + addXmlNamespaceConstants(model, classBlock); + + // Add polymorphic property + PolymorphicDiscriminatorHandler.declareField(model, classBlock, this::addGeneratedAnnotation, + discriminator -> addFieldAnnotations(model, discriminator, classBlock, settings), settings); + + // properties + addProperties(model, classBlock, settings); + + // add jsonMergePatch related properties and accessors + if (ClientModelUtil.isJsonMergePatchModel(model, settings)) { + addJsonMergePatchRelatedPropertyAndAccessors(classBlock, model); + } + + // constructor + JavaVisibility modelConstructorVisibility = immutableModel + ? (hasDerivedModels ? JavaVisibility.Protected : JavaVisibility.Private) + : JavaVisibility.Public; + addModelConstructor(model, modelConstructorVisibility, settings, classBlock); + + for (ClientModelProperty property : getFieldProperties(model, settings)) { + final boolean propertyIsReadOnly = immutableModel || property.isReadOnly(); + + IType propertyWireType = property.getWireType(); + IType propertyClientType = propertyWireType.getClientType(); + + JavaVisibility methodVisibility = property.getClientFlatten() + ? JavaVisibility.Private + : JavaVisibility.Public; + + if (!property.isPolymorphicDiscriminator() + || PolymorphicDiscriminatorHandler.generateGetter(model, property)) { + generateGetterJavadoc(classBlock, property); + addGeneratedAnnotation(classBlock); + if (property.isAdditionalProperties() && !settings.isStreamStyleSerialization()) { + classBlock.annotation("JsonAnyGetter"); + } + if (!propertyIsReadOnly) { + TemplateUtil.addJsonGetter(classBlock, settings, property.getSerializedName()); + } + + if (addOverrideAnnotationToGetter(methodVisibility, model, property, settings)) { + classBlock.annotation("Override"); + } + classBlock.method(methodVisibility, null, + propertyClientType + " " + getGetterName(model, property) + "()", + methodBlock -> addGetterMethod(propertyWireType, propertyClientType, property, treatAsXml, + methodBlock, settings)); } - final boolean requireSerialization = modelRequireSerialization(model); - - JavaSettings settings = JavaSettings.getInstance(); - Set imports = settings.isStreamStyleSerialization() ? new StreamStyleImports() : new HashSet<>(); - - addImports(imports, model, settings); - - List propertyReferences = this.getClientModelPropertyReferences(model); - propertyReferences.forEach(p -> p.addImportsTo(imports, false)); - - if (!CoreUtils.isNullOrEmpty(model.getPropertyReferences())) { - if (settings.getClientFlattenAnnotationTarget() == JavaSettings.ClientFlattenAnnotationTarget.NONE) { - model.getPropertyReferences().forEach(p -> p.addImportsTo(imports, false)); - } - propertyReferences.addAll(model.getPropertyReferences()); + if (ClientModelUtil.needsPublicSetter(property, settings) && !immutableModel) { + generateSetterJavadoc(classBlock, model, property); + addGeneratedAnnotation(classBlock); + TemplateUtil.addJsonSetter(classBlock, settings, property.getSerializedName()); + classBlock.method(methodVisibility, null, + model.getName() + " " + property.getSetterName() + "(" + propertyClientType + " " + property.getName() + ")", + methodBlock -> addSetterMethod(propertyWireType, propertyClientType, property, treatAsXml, + methodBlock, settings, ClientModelUtil.isJsonMergePatchModel(model, settings))); + } else { + // If stream-style serialization is being generated, some additional setters may need to be added to + // support read-only properties that aren't included in the constructor. + // Jackson handles this by reflectively setting the value in the parent model, but stream-style + // serialization doesn't perform reflective cracking like Jackson Databind does, so it needs a way + // to access the readonly property (aka one without a public setter method). + // + // The package-private setter is added when the property isn't included in the constructor and is + // defined by this model, except for JSON merge patch models as those use the access helper pattern + // to enable subtypes to set the property. + boolean streamStyle = settings.isStreamStyleSerialization(); + boolean hasDerivedTypes = !CoreUtils.isNullOrEmpty(model.getDerivedModels()); + boolean notIncludedInConstructor = !ClientModelUtil.includePropertyInConstructor(property, + settings); + boolean definedByModel = ClientModelUtil.modelDefinesProperty(model, property); + boolean modelIsJsonMergePatch = ClientModelUtil.isJsonMergePatchModel(model, settings); + if (hasDerivedTypes && notIncludedInConstructor && definedByModel + && streamStyle && !property.isPolymorphicDiscriminator() && !modelIsJsonMergePatch) { + generateSetterJavadoc(classBlock, model, property); + addGeneratedAnnotation(classBlock); + classBlock.method(JavaVisibility.PackagePrivate, null, + model.getName() + " " + property.getSetterName() + "(" + propertyClientType + " " + + property.getName() + ")", + methodBlock -> addSetterMethod(propertyWireType, propertyClientType, property, treatAsXml, + methodBlock, settings, + ClientModelUtil.isJsonMergePatchModel(model, settings))); + } } - javaFile.declareImport(imports); + // If the property is additional properties, and stream-style serialization isn't being used, add a + // package-private setter that Jackson can use to set values as it deserializes the key-value pairs. + if (property.isAdditionalProperties() && !settings.isStreamStyleSerialization()) { + addGeneratedAnnotation(classBlock); + classBlock.annotation("JsonAnySetter"); + MapType mapType = (MapType) property.getClientType(); + String methodSignature = "void " + property.getSetterName() + "(String key, " + + mapType.getValueType() + " value)"; + classBlock.packagePrivateMethod(methodSignature, methodBlock -> { + // The additional properties are null by default, so if this is the first time the value is + // being added create the containing map. + methodBlock.ifBlock(property.getName() + " == null", + ifBlock -> ifBlock.line(property.getName() + " = new LinkedHashMap<>();")); - javaFile.javadocComment(comment -> comment.description(model.getDescription())); - - final boolean hasDerivedModels = !model.getDerivedModels().isEmpty(); - final boolean immutableModel = isImmutableOutputModel(model, settings); - boolean treatAsXml = model.isUsedInXml(); - - // Handle adding annotations if the model is polymorphic. - handlePolymorphism(model, hasDerivedModels, javaFile); - - // Add class level annotations for serialization formats such as XML. - addClassLevelAnnotations(model, javaFile, settings); - - // Add Fluent or Immutable based on whether the model has any setters. - addFluentOrImmutableAnnotation(model, immutableModel, propertyReferences, javaFile, settings); - - List classModifiers = null; - if (!hasDerivedModels && !model.getNeedsFlatten()) { - classModifiers = Collections.singletonList(JavaModifier.Final); + String key = model.getNeedsFlatten() ? "KEY_ESCAPER.matcher(key).replaceAll(\".\")" : "key"; + methodBlock.line(property.getName() + ".put(" + key + ", value);"); + }); } + } - String classNameWithBaseType = model.getName(); - if (model.getParentModelName() != null) { - classNameWithBaseType += " extends " + model.getParentModelName(); - } else if (requireSerialization) { - classNameWithBaseType = addSerializationImplementations(classNameWithBaseType, model, settings); - } + // add setters to override parent setters + if (!immutableModel) { + List settersToOverride = getSuperSetters(model, settings, + propertyReferences); + for (ClientModelPropertyAccess parentProperty : settersToOverride) { + classBlock.javadocComment(JavaJavadocComment::inheritDoc); + addGeneratedAnnotation(classBlock); + classBlock.annotation("Override"); + String methodSignature = model.getName() + " " + parentProperty.getSetterName() + "(" + + parentProperty.getClientType() + " " + parentProperty.getName() + ")"; - javaFile.publicClass(classModifiers, classNameWithBaseType, classBlock -> { - // If the model has any additional properties, needs to be flattened, and isn't being generated with - // stream-style serialization add a constant Pattern that will be used to escape the additional property - // keys. Certain versions of the JVM will compile a Pattern each time '.replace' is called which is very - // expensive. - if (model.getProperties().stream().anyMatch(ClientModelProperty::isAdditionalProperties) - && model.getNeedsFlatten() - && !settings.isStreamStyleSerialization()) { - addGeneratedAnnotation(classBlock); - classBlock.privateStaticFinalVariable("Pattern KEY_ESCAPER = Pattern.compile(\"\\\\.\");"); - } - - // If code is being generated with the behavior to return an empty byte array when the default value - // expression is null and the model has any array types that will need conversion within getter methods - // generate a static byte[] that will be returned instead of creating a new instance each get. - if (isGenerateConstantEmptyByteArray(model, settings)) { - classBlock.privateStaticFinalVariable("byte[] EMPTY_BYTE_ARRAY = new byte[0]"); - } - - // XML namespace constants - addXmlNamespaceConstants(model, classBlock); - - // properties - addProperties(model, classBlock, settings); - - // add jsonMergePatch related properties and accessors + classBlock.publicMethod(methodSignature, methodBlock -> { + methodBlock.line( + "super." + parentProperty.getSetterName() + "(" + parentProperty.getName() + ");"); if (ClientModelUtil.isJsonMergePatchModel(model, settings)) { - addJsonMergePatchRelatedPropertyAndAccessors(classBlock, model); + methodBlock.line("this.updatedProperties.add(\"" + parentProperty.getName() + "\");"); } - - // constructor - JavaVisibility modelConstructorVisibility = immutableModel - ? (hasDerivedModels ? JavaVisibility.Protected : JavaVisibility.Private) - : JavaVisibility.Public; - addModelConstructor(model, modelConstructorVisibility, settings, classBlock); - - for (ClientModelProperty property : getFieldProperties(model, settings)) { - final boolean propertyIsReadOnly = immutableModel || property.isReadOnly(); - - IType propertyWireType = property.getWireType(); - IType propertyClientType = propertyWireType.getClientType(); - - JavaVisibility methodVisibility = property.getClientFlatten() - ? JavaVisibility.Private - : JavaVisibility.Public; - - generateGetterJavadoc(classBlock, property); - addGeneratedAnnotation(classBlock); - if (property.isAdditionalProperties() && !settings.isStreamStyleSerialization()) { - classBlock.annotation("JsonAnyGetter"); - } - if (!propertyIsReadOnly) { - TemplateUtil.addJsonGetter(classBlock, settings, property.getSerializedName()); - } - - boolean overridesParentGetter = overridesParentGetter(model, property, settings, methodVisibility); - if (overridesParentGetter) { - classBlock.annotation("Override"); - } - classBlock.method(methodVisibility, null, - propertyClientType + " " + getGetterName(model, property) + "()", - methodBlock -> addGetterMethod(propertyWireType, propertyClientType, property, treatAsXml, - methodBlock, settings)); - - if (ClientModelUtil.needsPublicSetter(property, settings) && !immutableModel) { - generateSetterJavadoc(classBlock, model, property); - addGeneratedAnnotation(classBlock); - TemplateUtil.addJsonSetter(classBlock, settings, property.getSerializedName()); - classBlock.method(methodVisibility, null, - model.getName() + " " + property.getSetterName() + "(" + propertyClientType + " " + property.getName() + ")", - methodBlock -> addSetterMethod(propertyWireType, propertyClientType, property, treatAsXml, - methodBlock, settings, ClientModelUtil.isJsonMergePatchModel(model, settings))); - } else { - // If stream-style serialization is being generated, some additional setters may need to be added to - // support read-only properties that aren't included in the constructor. - // Jackson handles this by reflectively setting the value in the parent model, but stream-style - // serialization doesn't perform reflective cracking like Jackson Databind does, so it needs a way - // to access the readonly property (aka one without a public setter method). - // - // The package-private setter is added when the property isn't included in the constructor and is - // defined by this model, except for JSON merge patch models as those use the access helper pattern - // to enable subtypes to set the property. - boolean streamStyle = settings.isStreamStyleSerialization(); - boolean hasDerivedTypes = !CoreUtils.isNullOrEmpty(model.getDerivedModels()); - boolean notIncludedInConstructor = !ClientModelUtil.includePropertyInConstructor(property, - settings); - boolean definedByModel = modelDefinesProperty(model, property); - boolean modelIsJsonMergePatch = ClientModelUtil.isJsonMergePatchModel(model, settings); - if (hasDerivedTypes && notIncludedInConstructor && definedByModel - && streamStyle && !property.isPolymorphicDiscriminator() && !modelIsJsonMergePatch) { - generateSetterJavadoc(classBlock, model, property); - addGeneratedAnnotation(classBlock); - classBlock.method(JavaVisibility.PackagePrivate, null, - model.getName() + " " + property.getSetterName() + "(" + propertyClientType + " " - + property.getName() + ")", - methodBlock -> addSetterMethod(propertyWireType, propertyClientType, property, treatAsXml, - methodBlock, settings, - ClientModelUtil.isJsonMergePatchModel(model, settings))); - } - } - - // If the property is additional properties, and stream-style serialization isn't being used, add a - // package-private setter that Jackson can use to set values as it deserializes the key-value pairs. - if (property.isAdditionalProperties() && !settings.isStreamStyleSerialization()) { - addGeneratedAnnotation(classBlock); - classBlock.annotation("JsonAnySetter"); - MapType mapType = (MapType) property.getClientType(); - String methodSignature = "void " + property.getSetterName() + "(String key, " - + mapType.getValueType() + " value)"; - classBlock.packagePrivateMethod(methodSignature, methodBlock -> { - // The additional properties are null by default, so if this is the first time the value is - // being added create the containing map. - methodBlock.ifBlock(property.getName() + " == null", - ifBlock -> ifBlock.line(property.getName() + " = new LinkedHashMap<>();")); - - String key = model.getNeedsFlatten() ? "KEY_ESCAPER.matcher(key).replaceAll(\".\")" : "key"; - methodBlock.line(property.getName() + ".put(" + key + ", value);"); - }); - } - } - - // add setters to override parent setters - if (!immutableModel) { - List settersToOverride = getSuperSetters(model, settings, - propertyReferences); - for (ClientModelPropertyAccess parentProperty : settersToOverride) { - classBlock.javadocComment(JavaJavadocComment::inheritDoc); - addGeneratedAnnotation(classBlock); - classBlock.annotation("Override"); - String methodSignature = model.getName() + " " + parentProperty.getSetterName() + "(" - + parentProperty.getClientType() + " " + parentProperty.getName() + ")"; - - classBlock.publicMethod(methodSignature, methodBlock -> { - methodBlock.line( - "super." + parentProperty.getSetterName() + "(" + parentProperty.getName() + ");"); - if (ClientModelUtil.isJsonMergePatchModel(model, settings)) { - methodBlock.line("this.updatedProperties.add(\"" + parentProperty.getName() + "\");"); - } - methodBlock.methodReturn("this"); - }); - } - } - - if (settings.getClientFlattenAnnotationTarget() == JavaSettings.ClientFlattenAnnotationTarget.NONE) { - // reference to properties from flattened client model - for (ClientModelPropertyReference propertyReference : propertyReferences) { - propertyReference = getLocalFlattenedModelPropertyReference(propertyReference); - if (propertyReference == null) { - continue; - } - - ClientModelPropertyAccess property = propertyReference.getReferenceProperty(); - ClientModelProperty targetProperty = propertyReference.getTargetProperty(); - - IType propertyClientType = property.getClientType(); - final boolean propertyIsReadOnly = immutableModel || property.isReadOnly(); - - if (propertyClientType instanceof PrimitiveType && !targetProperty.isRequired()) { - // since the property to flattened client model is optional, the flattened property should be optional - propertyClientType = propertyClientType.asNullable(); - } - final IType propertyClientTypeFinal = propertyClientType; - - // getter - generateGetterJavadoc(classBlock, property); - addGeneratedAnnotation(classBlock); - classBlock.publicMethod(propertyClientType + " " + propertyReference.getGetterName() + "()", methodBlock -> { - // use ternary operator to avoid directly return null - String ifClause = "this." + targetProperty.getGetterName() + "() == null"; - String nullClause = propertyClientTypeFinal.defaultValueExpression(); - String valueClause = "this." + targetProperty.getGetterName() + "()." + property.getGetterName() + "()"; - - methodBlock.methodReturn(ifClause + " ? " + nullClause + " : " + valueClause); - }); - - // setter - if (!propertyIsReadOnly) { - generateSetterJavadoc(classBlock, model, property); - addGeneratedAnnotation(classBlock); - ClientModelPropertyReference propertyReferenceFinal = propertyReference; - classBlock.publicMethod(String.format("%s %s(%s %s)", model.getName(), propertyReference.getSetterName(), propertyClientType, property.getName()), methodBlock -> { - methodBlock.ifBlock(String.format("this.%s() == null", targetProperty.getGetterName()), ifBlock -> - methodBlock.line(String.format("this.%s = new %s();", targetProperty.getName(), propertyReferenceFinal.getTargetModelType()))); - - methodBlock.line(String.format("this.%s().%s(%s);", targetProperty.getGetterName(), property.getSetterName(), property.getName())); - methodBlock.methodReturn("this"); - }); - } - } - } - - addPropertyValidations(classBlock, model, settings); - - if ((settings.isClientSideValidations() && settings.isUseClientLogger()) || model.isStronglyTypedHeader()) { - TemplateUtil.addClientLogger(classBlock, model.getName(), javaFile.getContents()); - } - - if (requireSerialization) { - writeStreamStyleSerialization(classBlock, model, settings); - } - }); - } - - /** - * Get the property reference referring to the local(field) flattened property. - * - * @param propertyReference propertyReference to check - * @return the property reference referring to the local(field) flattened property, null if it's not - */ - protected ClientModelPropertyReference getLocalFlattenedModelPropertyReference(ClientModelPropertyReference propertyReference) { - if (propertyReference.isFromFlattenedProperty()) { - return propertyReference; + methodBlock.methodReturn("this"); + }); } - // Not a flattening property, return null. - return null; - } + } - /** - * Whether the property's getter overrides parent getter. - * - * @param model the client model - * @param property the property to generate getter method - * @param settings {@link JavaSettings} instance - * @param methodVisibility - * @return whether the property's getter overrides parent getter - */ - protected boolean overridesParentGetter(ClientModel model, ClientModelProperty property, JavaSettings settings, JavaVisibility methodVisibility) { - // getter method of discriminator property in subclass is handled differently - return property.isPolymorphicDiscriminator() && !modelDefinesProperty(model, property) && methodVisibility == JavaVisibility.Public; - } - /** - * The model is immutable output if and only if the immutable output model setting is enabled and - * the usage of the model include output and does not include input. - * - * @param model the model to check - * @param settings JavaSettings instance - * @return whether the model is output-only immutable model - */ - static boolean isImmutableOutputModel(ClientModel model, JavaSettings settings) { - return (settings.isOutputModelImmutable() && ClientModelUtil.isOutputOnly(model)); - } + if (settings.getClientFlattenAnnotationTarget() == JavaSettings.ClientFlattenAnnotationTarget.NONE) { + // reference to properties from flattened client model + for (ClientModelPropertyReference propertyReference : propertyReferences) { + propertyReference = getLocalFlattenedModelPropertyReference(propertyReference); + if (propertyReference == null) { + continue; + } - private void addImports(Set imports, ClientModel model, JavaSettings settings) { - // If there is client side validation and the model will generate a ClientLogger to log the validation - // exceptions add an import of 'com.azure.core.util.logging.ClientLogger' and - // 'com.fasterxml.jackson.annotation.JsonIgnore'. - // - // These are added to support adding the ClientLogger and then to JsonIgnore the ClientLogger so it isn't - // included in serialization. - if (settings.isClientSideValidations() && settings.isUseClientLogger()) { - ClassType.CLIENT_LOGGER.addImportsTo(imports, false); - } + ClientModelPropertyAccess property = propertyReference.getReferenceProperty(); + ClientModelProperty targetProperty = propertyReference.getTargetProperty(); - addSerializationImports(imports, model, settings); + IType propertyClientType = property.getClientType(); + final boolean propertyIsReadOnly = immutableModel || property.isReadOnly(); - // Add HttpHeaders as an import when strongly-typed HTTP header objects use that as a constructor parameter. - if (model.isStronglyTypedHeader()) { - ClassType.HTTP_HEADERS.addImportsTo(imports, false); - ClassType.HTTP_HEADER_NAME.addImportsTo(imports, false); + if (propertyClientType instanceof PrimitiveType && !targetProperty.isRequired()) { + // since the property to flattened client model is optional, the flattened property should be optional + propertyClientType = propertyClientType.asNullable(); + } + final IType propertyClientTypeFinal = propertyClientType; - // Also add any potential imports needed to convert the header to the strong type. - // If the import isn't used it will be removed later on. - imports.add(Base64.class.getName()); - imports.add(LinkedHashMap.class.getName()); - imports.add(HttpHeader.class.getName()); - imports.add(UUID.class.getName()); - imports.add(URL.class.getName()); - imports.add(IOException.class.getName()); - imports.add(UncheckedIOException.class.getName()); - imports.add(ClientLogger.class.getName()); + // getter + generateGetterJavadoc(classBlock, property); + addGeneratedAnnotation(classBlock); + classBlock.publicMethod(propertyClientType + " " + propertyReference.getGetterName() + "()", methodBlock -> { + // use ternary operator to avoid directly return null + String ifClause = "this." + targetProperty.getGetterName() + "() == null"; + String nullClause = propertyClientTypeFinal.defaultValueExpression(); + String valueClause = "this." + targetProperty.getGetterName() + "()." + property.getGetterName() + "()"; - // JacksonAdapter will be removed in the future once model types are converted to using stream-style - // serialization. For now, it's needed to handle the rare scenario where the strong type is a non-Java - // base type. - imports.add(JacksonAdapter.class.getName()); - } + methodBlock.methodReturn(ifClause + " ? " + nullClause + " : " + valueClause); + }); - String lastParentName = model.getName(); - ClientModel parentModel = ClientModelUtil.getClientModel(model.getParentModelName()); - while (parentModel != null && !lastParentName.equals(parentModel.getName())) { - imports.addAll(parentModel.getImports()); - lastParentName = parentModel.getName(); - parentModel = ClientModelUtil.getClientModel(parentModel.getParentModelName()); - } + // setter + if (!propertyIsReadOnly) { + generateSetterJavadoc(classBlock, model, property); + addGeneratedAnnotation(classBlock); + ClientModelPropertyReference propertyReferenceFinal = propertyReference; + classBlock.publicMethod(String.format("%s %s(%s %s)", model.getName(), propertyReference.getSetterName(), propertyClientType, property.getName()), methodBlock -> { + methodBlock.ifBlock(String.format("this.%s() == null", targetProperty.getGetterName()), ifBlock -> + methodBlock.line(String.format("this.%s = new %s();", targetProperty.getName(), propertyReferenceFinal.getTargetModelType()))); - addGeneratedImport(imports); - - model.addImportsTo(imports, settings); - - // add Json merge patch related imports - if (ClientModelUtil.isJsonMergePatchModel(model, settings)) { - imports.add(settings.getPackage(settings.getImplementationSubpackage()) + "." + ClientModelUtil.JSON_MERGE_PATCH_HELPER_CLASS_NAME); - imports.add(Set.class.getName()); - imports.add(HashSet.class.getName()); - } - } - - protected void addSerializationImports(Set imports, ClientModel model, JavaSettings settings) { - imports.add("com.fasterxml.jackson.annotation.JsonCreator"); - - if (settings.isGettersAndSettersAnnotatedForSerialization()) { - imports.add("com.fasterxml.jackson.annotation.JsonGetter"); - imports.add("com.fasterxml.jackson.annotation.JsonSetter"); - } - - imports.add(Pattern.class.getName()); - } - - /** - * We generate super setters in child class if all of below conditions are met: - * 1. parent property has setter - * 2. child does not contain property that shadow this parent property, otherwise super setters - * will collide with child setters - * - * @see Issue 1320 - */ - protected List getSuperSetters(ClientModel model, JavaSettings settings, - List propertyReferences) { - Set modelPropertyNames = model.getProperties().stream().map(ClientModelProperty::getName) - .collect(Collectors.toSet()); - return propertyReferences.stream() - .filter(ClientModelPropertyReference::isFromParentModel) - .map(ClientModelPropertyReference::getReferenceProperty) - .filter(parentProperty -> { - // parent property doesn't have setter - if (!ClientModelUtil.needsPublicSetter(parentProperty, settings)) { - return false; - } - // child does not contain property that shadow this parent property - return !modelPropertyNames.contains(parentProperty.getName()); - } - ).collect(Collectors.toList()); - } - - /** - * Handles setting up Jackson polymorphism annotations. - * - * @param model The client model. - * @param hasDerivedModels Whether this model has children types. - * @param javaFile The JavaFile being generated. - */ - protected void handlePolymorphism(ClientModel model, boolean hasDerivedModels, JavaFile javaFile) { - // Model isn't polymorphic, no work to do here. - if (!model.isPolymorphic()) { - return; - } - - // After removing the concept of passing discriminator to children models and always doing it, there is no need - // to set the 'include' property of the JsonTypeInfo annotation. We use 'JsonTypeInfo.As.PROPERTY' as the value, - // which is the default value, so it doesn't need to be declared. - // And to support unknown subtypes, we always set a default implementation to the class being generated. - // And the discriminator is passed to child models, so the discriminator property needs to be set to visible. - String jsonTypeInfo = "JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = \"" - + model.getPolymorphicDiscriminatorName() + "\", defaultImpl = " + model.getName() - + ".class, visible = true)"; - - javaFile.annotation(jsonTypeInfo); - javaFile.annotation("JsonTypeName(\"" + model.getSerializedName() + "\")"); - - if (hasDerivedModels) { - javaFile.line("@JsonSubTypes({"); - javaFile.indent(() -> { - Function getDerivedTypeAnnotation = derivedType -> "@JsonSubTypes.Type(name = \"" - + derivedType.getSerializedName() + "\", value = " + derivedType.getName() + ".class)"; - - for (int i = 0; i != model.getDerivedModels().size() - 1; i++) { - ClientModel derivedModel = model.getDerivedModels().get(i); - javaFile.line(getDerivedTypeAnnotation.apply(derivedModel) + ','); - } - javaFile.line(getDerivedTypeAnnotation.apply(model.getDerivedModels() - .get(model.getDerivedModels().size() - 1))); + methodBlock.line(String.format("this.%s().%s(%s);", targetProperty.getGetterName(), property.getSetterName(), property.getName())); + methodBlock.methodReturn("this"); }); - javaFile.line("})"); + } } + } + + addPropertyValidations(classBlock, model, settings); + + if ((settings.isClientSideValidations() && settings.isUseClientLogger()) || model.isStronglyTypedHeader()) { + TemplateUtil.addClientLogger(classBlock, model.getName(), javaFile.getContents()); + } + + if (requireSerialization) { + writeStreamStyleSerialization(classBlock, model, settings); + } + }); + } + + private static boolean addOverrideAnnotationToGetter(JavaVisibility visibility, ClientModel model, + ClientModelProperty property, JavaSettings settings) { + if (visibility != JavaVisibility.Public) { + return false; } - /** - * Adds class level annotations such as XML root element, JsonFlatten based on the configurations of the model. - * - * @param model The client model. - * @param javaFile The Java class file. - * @param settings Autorest generation settings. - */ - protected void addClassLevelAnnotations(ClientModel model, JavaFile javaFile, JavaSettings settings) { - if (model.isUsedInXml()) { - if (!CoreUtils.isNullOrEmpty(model.getXmlNamespace())) { - javaFile.annotation("JacksonXmlRootElement(localName = \"" + model.getXmlName() + "\", " - + "namespace = \"" + model.getXmlNamespace() + "\")"); - } else { - javaFile.annotation("JacksonXmlRootElement(localName = \"" + model.getXmlName() + "\")"); - } - } - - if (settings.getClientFlattenAnnotationTarget() == JavaSettings.ClientFlattenAnnotationTarget.TYPE - && model.getNeedsFlatten()) { - javaFile.annotation("JsonFlatten"); - } + if (property.isPolymorphicDiscriminator() && model.isAllPolymorphicModelsInSamePackage()) { + return false; } - /** - * Adds Fluent or Immutable based on whether model has any setters. - * - * @param model The client model. - * @param immutableOutputModel The model is treated as immutable, as it is output only. - * @param propertyReferences The client model property reference. - * @param javaFile The Java class file. - * @param settings Autorest generation settings. - */ - private void addFluentOrImmutableAnnotation(ClientModel model, boolean immutableOutputModel, - List propertyReferences, JavaFile javaFile, JavaSettings settings) { - boolean fluent = !immutableOutputModel && Stream - .concat(model.getProperties().stream(), propertyReferences.stream()) - .anyMatch(p -> ClientModelUtil.needsPublicSetter(p, settings)); + if (ClientModelUtil.modelDefinesProperty(model, property)) { + return false; + } - if (JavaSettings.getInstance().isBranded()) { - if (fluent) { - javaFile.annotation("Fluent"); - } else { - javaFile.annotation("Immutable"); - } + return property.isPolymorphicDiscriminator() + || (settings.isStreamStyleSerialization() && ClientModelUtil.readOnlyNotInCtor(model, property, settings)); + } + + /** + * Get the property reference referring to the local(field) flattened property. + * + * @param propertyReference propertyReference to check + * @return the property reference referring to the local(field) flattened property, null if it's not + */ + protected ClientModelPropertyReference getLocalFlattenedModelPropertyReference(ClientModelPropertyReference propertyReference) { + if (propertyReference.isFromFlattenedProperty()) { + return propertyReference; + } + // Not a flattening property, return null. + return null; + } + + private void addImports(Set imports, ClientModel model, JavaSettings settings) { + // If there is client side validation and the model will generate a ClientLogger to log the validation + // exceptions add an import of 'com.azure.core.util.logging.ClientLogger' and + // 'com.fasterxml.jackson.annotation.JsonIgnore'. + // + // These are added to support adding the ClientLogger and then to JsonIgnore the ClientLogger so it isn't + // included in serialization. + if (settings.isClientSideValidations() && settings.isUseClientLogger()) { + ClassType.CLIENT_LOGGER.addImportsTo(imports, false); + } + + addSerializationImports(imports, model, settings); + + // Add HttpHeaders as an import when strongly-typed HTTP header objects use that as a constructor parameter. + if (model.isStronglyTypedHeader()) { + ClassType.HTTP_HEADERS.addImportsTo(imports, false); + ClassType.HTTP_HEADER_NAME.addImportsTo(imports, false); + + // Also add any potential imports needed to convert the header to the strong type. + // If the import isn't used it will be removed later on. + imports.add(Base64.class.getName()); + imports.add(LinkedHashMap.class.getName()); + imports.add(HttpHeader.class.getName()); + imports.add(UUID.class.getName()); + imports.add(URL.class.getName()); + imports.add(IOException.class.getName()); + imports.add(UncheckedIOException.class.getName()); + imports.add(ClientLogger.class.getName()); + + // JacksonAdapter will be removed in the future once model types are converted to using stream-style + // serialization. For now, it's needed to handle the rare scenario where the strong type is a non-Java + // base type. + imports.add(JacksonAdapter.class.getName()); + } + + String lastParentName = model.getName(); + ClientModel parentModel = ClientModelUtil.getClientModel(model.getParentModelName()); + while (parentModel != null && !lastParentName.equals(parentModel.getName())) { + imports.addAll(parentModel.getImports()); + lastParentName = parentModel.getName(); + parentModel = ClientModelUtil.getClientModel(parentModel.getParentModelName()); + } + + addGeneratedImport(imports); + + model.addImportsTo(imports, settings); + + // add Json merge patch related imports + if (ClientModelUtil.isJsonMergePatchModel(model, settings)) { + imports.add(settings.getPackage(settings.getImplementationSubpackage()) + "." + ClientModelUtil.JSON_MERGE_PATCH_HELPER_CLASS_NAME); + imports.add(Set.class.getName()); + imports.add(HashSet.class.getName()); + } + } + + protected void addSerializationImports(Set imports, ClientModel model, JavaSettings settings) { + imports.add("com.fasterxml.jackson.annotation.JsonCreator"); + + if (settings.isGettersAndSettersAnnotatedForSerialization()) { + imports.add("com.fasterxml.jackson.annotation.JsonGetter"); + imports.add("com.fasterxml.jackson.annotation.JsonSetter"); + } + + imports.add(Pattern.class.getName()); + } + + /** + * We generate super setters in child class if all of below conditions are met: + * 1. parent property has setter + * 2. child does not contain property that shadow this parent property, otherwise super setters + * will collide with child setters + * + * @see Issue 1320 + */ + protected List getSuperSetters(ClientModel model, JavaSettings settings, + List propertyReferences) { + Set modelPropertyNames = model.getProperties().stream().map(ClientModelProperty::getName) + .collect(Collectors.toSet()); + return propertyReferences.stream() + .filter(ClientModelPropertyReference::isFromParentModel) + .map(ClientModelPropertyReference::getReferenceProperty) + .filter(parentProperty -> { + // parent property doesn't have setter + if (!ClientModelUtil.needsPublicSetter(parentProperty, settings)) { + return false; + } + // child does not contain property that shadow this parent property + return !modelPropertyNames.contains(parentProperty.getName()); + } + ).collect(Collectors.toList()); + } + + /** + * Adds class level annotations such as XML root element, JsonFlatten based on the configurations of the model. + * + * @param model The client model. + * @param javaFile The Java class file. + * @param settings Autorest generation settings. + */ + protected void addClassLevelAnnotations(ClientModel model, JavaFile javaFile, JavaSettings settings) { + if (model.isUsedInXml()) { + if (!CoreUtils.isNullOrEmpty(model.getXmlNamespace())) { + javaFile.annotation("JacksonXmlRootElement(localName = \"" + model.getXmlName() + "\", " + + "namespace = \"" + model.getXmlNamespace() + "\")"); + } else { + javaFile.annotation("JacksonXmlRootElement(localName = \"" + model.getXmlName() + "\")"); + } + } + + if (settings.getClientFlattenAnnotationTarget() == JavaSettings.ClientFlattenAnnotationTarget.TYPE + && model.getNeedsFlatten()) { + javaFile.annotation("JsonFlatten"); + } + } + + /** + * Adds Fluent or Immutable based on whether model has any setters. + * + * @param model The client model. + * @param immutableOutputModel The model is treated as immutable, as it is output only. + * @param propertyReferences The client model property reference. + * @param javaFile The Java class file. + * @param settings Autorest generation settings. + */ + private void addFluentOrImmutableAnnotation(ClientModel model, boolean immutableOutputModel, + List propertyReferences, JavaFile javaFile, JavaSettings settings) { + boolean fluent = !immutableOutputModel && Stream + .concat(model.getProperties().stream(), propertyReferences.stream()) + .anyMatch(p -> ClientModelUtil.needsPublicSetter(p, settings)); + + if (JavaSettings.getInstance().isBranded()) { + if (fluent) { + javaFile.annotation("Fluent"); + } else { + javaFile.annotation("Immutable"); + } + } else { + if (fluent) { + javaFile.annotation("Metadata(conditions = {TypeConditions.FLUENT})"); + } else { + javaFile.annotation("Metadata(conditions = {TypeConditions.IMMUTABLE})"); + } + } + } + + /** + * Adds serialization implementations to the class signature. + * + * @param classSignature The class signature. + * @param model The client model. + * @param settings Autorest generation settings. + * @return The updated class signature with serialization implementations added. + */ + protected String addSerializationImplementations(String classSignature, ClientModel model, JavaSettings settings) { + // no-op as this is an entry point for subclasses of ModelTemplate that provide more specific code generation. + return classSignature; + } + + protected void addXmlNamespaceConstants(ClientModel model, JavaClass classBlock) { + // no-op as this is an entry point for subclasses of ModelTemplate that provide more specific code generation. + } + + /** + * Adds the property fields to a class. + * + * @param model The client model. + * @param classBlock The Java class. + * @param settings AutoRest configuration settings. + */ + private void addProperties(ClientModel model, JavaClass classBlock, JavaSettings settings) { + for (ClientModelProperty property : getFieldProperties(model, settings)) { + addProperty(property, model, classBlock, settings); + } + } + + private void addProperty(ClientModelProperty property, ClientModel model, JavaClass classBlock, + JavaSettings settings) { + String propertyName = property.getName(); + IType propertyType = property.getWireType(); + + String defaultValue; + if (property.isPolymorphicDiscriminator()) { + return; + } + + defaultValue = property.getDefaultValue(); + + String fieldSignature; + if (model.isUsedInXml()) { + if (property.isXmlWrapper()) { + if (!settings.isStreamStyleSerialization()) { + String xmlWrapperClassName = getPropertyXmlWrapperClassName(property); + classBlock.staticFinalClass(JavaVisibility.PackagePrivate, xmlWrapperClassName, + innerClass -> addXmlWrapperClass(innerClass, property, xmlWrapperClassName, settings)); + + fieldSignature = xmlWrapperClassName + " " + propertyName; } else { - if (fluent) { - javaFile.annotation("Metadata(conditions = {TypeConditions.FLUENT})"); - } else { - javaFile.annotation("Metadata(conditions = {TypeConditions.IMMUTABLE})"); - } + fieldSignature = propertyType + " " + propertyName; } - } - - /** - * Adds serialization implementations to the class signature. - * - * @param classSignature The class signature. - * @param model The client model. - * @param settings Autorest generation settings. - * @return The updated class signature with serialization implementations added. - */ - protected String addSerializationImplementations(String classSignature, ClientModel model, JavaSettings settings) { - // no-op as this is an entry point for subclasses of ModelTemplate that provide more specific code generation. - return classSignature; - } - - protected void addXmlNamespaceConstants(ClientModel model, JavaClass classBlock) { - // no-op as this is an entry point for subclasses of ModelTemplate that provide more specific code generation. - } - - /** - * Adds the property fields to a class. - * - * @param model The client model. - * @param classBlock The Java class. - * @param settings AutoRest configuration settings. - */ - private void addProperties(ClientModel model, JavaClass classBlock, JavaSettings settings) { - for (ClientModelProperty property : getFieldProperties(model, settings)) { - addProperty(property, model, classBlock, settings); - } - } - - private void addProperty(ClientModelProperty property, ClientModel model, JavaClass classBlock, - JavaSettings settings) { - String propertyName = property.getName(); - IType propertyType = property.getWireType(); - - String defaultValue; - if (property.isPolymorphicDiscriminator()) { - defaultValue = (property.getDefaultValue() == null) - ? property.getClientType().defaultValueExpression(model.getSerializedName()) - : property.getDefaultValue(); + } else if (propertyType instanceof ListType) { + fieldSignature = propertyType + " " + propertyName + " = new ArrayList<>()"; + } else { + // handle x-ms-client-default + // Only set the property to a default value if the property isn't included in the constructor. + // There can be cases with polymorphic discriminators where they have both a default value and are + // required, in which case the default value will be set in the constructor. + if (defaultValue != null + && (!ClientModelUtil.includePropertyInConstructor(property, settings) || property.isConstant())) { + fieldSignature = propertyType + " " + propertyName + " = " + defaultValue; } else { - defaultValue = property.getDefaultValue(); + fieldSignature = propertyType + " " + propertyName; } - - String fieldSignature; - if (model.isUsedInXml()) { - if (property.isXmlWrapper()) { - if (!settings.isStreamStyleSerialization()) { - String xmlWrapperClassName = getPropertyXmlWrapperClassName(property); - classBlock.staticFinalClass(JavaVisibility.PackagePrivate, xmlWrapperClassName, - innerClass -> addXmlWrapperClass(innerClass, property, xmlWrapperClassName, settings)); - - fieldSignature = xmlWrapperClassName + " " + propertyName; - } else { - fieldSignature = propertyType + " " + propertyName; - } - } else if (propertyType instanceof ListType) { - fieldSignature = propertyType + " " + propertyName + " = new ArrayList<>()"; - } else { - // handle x-ms-client-default - // Only set the property to a default value if the property isn't included in the constructor. - // There can be cases with polymorphic discriminators where they have both a default value and are - // required, in which case the default value will be set in the constructor. - if (defaultValue != null - && (!ClientModelUtil.includePropertyInConstructor(property, settings) || property.isConstant())) { - fieldSignature = propertyType + " " + propertyName + " = " + defaultValue; - } else { - fieldSignature = propertyType + " " + propertyName; - } - } + } + } else { + if (property.getClientFlatten() && property.isRequired() && property.getClientType() instanceof ClassType + && !ClientModelUtil.isImmutableOutputModel(ClientModelUtil.getDefiningModel( + ClientModelUtil.getClientModel(((ClassType) property.getClientType()).getName()), property), settings) + ) { + // if the property of flattened model is required, and isn't immutable output model(which doesn't have public constructor), + // initialize it + fieldSignature = propertyType + " " + propertyName + " = new " + propertyType + "()"; + } else { + // handle x-ms-client-default + // Only set the property to a default value if the property isn't included in the constructor. + // There can be cases with polymorphic discriminators where they have both a default value and are + // required, in which case the default value will be set in the constructor. + if (defaultValue != null + && (!ClientModelUtil.includePropertyInConstructor(property, settings) || property.isConstant())) { + fieldSignature = propertyType + " " + propertyName + " = " + defaultValue; } else { - if (property.getClientFlatten() && property.isRequired() && property.getClientType() instanceof ClassType - && !isImmutableOutputModel( - getDefiningModel( - ClientModelUtil.getClientModel(((ClassType) property.getClientType()).getName()), property), - settings) - ) { - // if the property of flattened model is required, and isn't immutable output model(which doesn't have public constructor), - // initialize it - fieldSignature = propertyType + " " + propertyName + " = new " + propertyType + "()"; - } else { - // handle x-ms-client-default - // Only set the property to a default value if the property isn't included in the constructor. - // There can be cases with polymorphic discriminators where they have both a default value and are - // required, in which case the default value will be set in the constructor. - if (defaultValue != null - && (!ClientModelUtil.includePropertyInConstructor(property, settings) || property.isConstant())) { - fieldSignature = propertyType + " " + propertyName + " = " + defaultValue; - } else { - fieldSignature = propertyType + " " + propertyName; - } - } - } - - classBlock.blockComment(comment -> comment.line(property.getDescription())); - - addGeneratedAnnotation(classBlock); - addFieldAnnotations(model, property, classBlock, settings); - - if (ClientModelUtil.includePropertyInConstructor(property, settings)) { - classBlock.privateFinalMemberVariable(fieldSignature); - } else { - classBlock.privateMemberVariable(fieldSignature); + fieldSignature = propertyType + " " + propertyName; } + } } - /** - * Get properties to generate as fields of the class. - * @param model the model to generate class of - * @param settings JavaSettings - * @return properties to generate as fields of the class - */ - protected List getFieldProperties(ClientModel model, JavaSettings settings) { - return Stream.concat( - model.getParentPolymorphicDiscriminators().stream(), - model.getProperties().stream() - ).collect(Collectors.toList()); + classBlock.blockComment(comment -> comment.line(property.getDescription())); + + addGeneratedAnnotation(classBlock); + addFieldAnnotations(model, property, classBlock, settings); + + if (ClientModelUtil.includePropertyInConstructor(property, settings)) { + classBlock.privateFinalMemberVariable(fieldSignature); + } else { + classBlock.privateMemberVariable(fieldSignature); + } + } + + /** + * Get properties to generate as fields of the class. + * @param model the model to generate class of + * @param settings JavaSettings + * @return properties to generate as fields of the class + */ + protected List getFieldProperties(ClientModel model, JavaSettings settings) { + return Stream.concat( + model.getParentPolymorphicDiscriminators().stream(), + model.getProperties().stream() + ).collect(Collectors.toList()); + } + + protected void addXmlWrapperClass(JavaClass classBlock, ClientModelProperty property, String wrapperClassName, + JavaSettings settings) { + // While using a wrapping class for XML elements that are wrapped may seem inconvenient it is required. + // There has been previous attempts to remove this by using JacksonXmlElementWrapper, which based on its + // documentation should cover this exact scenario, but it doesn't. Jackson unfortunately doesn't always + // respect the JacksonXmlRootName, or JsonRootName, value when handling types wrapped by an enumeration, + // such as List or Iterable. Instead, it uses the JacksonXmlProperty local name as the + // root XML node name for each element in the enumeration. There are configurations for ObjectMapper, and + // XmlMapper, that always forces Jackson to use the root name but those also add the class name as a root + // XML node name if the class doesn't have a root name annotation which results in an addition XML level + // resulting in invalid service XML. There is also one last work around to use JacksonXmlElementWrapper + // and JacksonXmlProperty together as the wrapper will configure the wrapper name and property will configure + // the element name but this breaks down in cases where the same element name is used in two different + // wrappers, a case being Storage BlockList which uses two block elements for its committed and uncommitted + // block lists. + IType propertyClientType = property.getWireType().getClientType(); + + String listElementName = property.getXmlListElementName(); + String jacksonAnnotation = CoreUtils.isNullOrEmpty(property.getXmlNamespace()) + ? "JacksonXmlProperty(localName = \"" + listElementName + "\")" + : "JacksonXmlProperty(localName = \"" + listElementName + "\", namespace = \"" + property.getXmlNamespace() + "\")"; + + classBlock.annotation(jacksonAnnotation); + classBlock.privateFinalMemberVariable(propertyClientType.toString(), "items"); + + classBlock.annotation("JsonCreator"); + classBlock.privateConstructor( + wrapperClassName + "(@" + jacksonAnnotation + " " + propertyClientType + " items)", + constructor -> constructor.line("this.items = items;")); + } + + /** + * Adds the annotations for a model field. + * + * @param model The model. + * @param property The property that represents the field. + * @param classBlock The Java class. + * @param settings Autorest generation settings. + */ + protected void addFieldAnnotations(ClientModel model, ClientModelProperty property, JavaClass classBlock, JavaSettings settings) { + if (settings.getClientFlattenAnnotationTarget() == JavaSettings.ClientFlattenAnnotationTarget.FIELD && property.getNeedsFlatten()) { + classBlock.annotation("JsonFlatten"); } - protected void addXmlWrapperClass(JavaClass classBlock, ClientModelProperty property, String wrapperClassName, - JavaSettings settings) { - // While using a wrapping class for XML elements that are wrapped may seem inconvenient it is required. - // There has been previous attempts to remove this by using JacksonXmlElementWrapper, which based on its - // documentation should cover this exact scenario, but it doesn't. Jackson unfortunately doesn't always - // respect the JacksonXmlRootName, or JsonRootName, value when handling types wrapped by an enumeration, - // such as List or Iterable. Instead, it uses the JacksonXmlProperty local name as the - // root XML node name for each element in the enumeration. There are configurations for ObjectMapper, and - // XmlMapper, that always forces Jackson to use the root name but those also add the class name as a root - // XML node name if the class doesn't have a root name annotation which results in an addition XML level - // resulting in invalid service XML. There is also one last work around to use JacksonXmlElementWrapper - // and JacksonXmlProperty together as the wrapper will configure the wrapper name and property will configure - // the element name but this breaks down in cases where the same element name is used in two different - // wrappers, a case being Storage BlockList which uses two block elements for its committed and uncommitted - // block lists. - IType propertyClientType = property.getWireType().getClientType(); - - String listElementName = property.getXmlListElementName(); - String jacksonAnnotation = CoreUtils.isNullOrEmpty(property.getXmlNamespace()) - ? "JacksonXmlProperty(localName = \"" + listElementName + "\")" - : "JacksonXmlProperty(localName = \"" + listElementName + "\", namespace = \"" + property.getXmlNamespace() + "\")"; - - classBlock.annotation(jacksonAnnotation); - classBlock.privateFinalMemberVariable(propertyClientType.toString(), "items"); - - classBlock.annotation("JsonCreator"); - classBlock.privateConstructor( - wrapperClassName + "(@" + jacksonAnnotation + " " + propertyClientType + " items)", - constructor -> constructor.line("this.items = items;")); + // If the property is a polymorphic discriminator for the class add the annotation @JsonTypeId. + // This will indicate to Jackson that the discriminator serialization is determined by the property + // instead of the class level @JsonTypeName annotation. This prevents the discriminator property from + // being serialized twice, once for the class level annotation and again for the property annotation. + if (property.isPolymorphicDiscriminator()) { + classBlock.annotation("JsonTypeId"); } - /** - * Adds the annotations for a model field. - * - * @param model The model. - * @param property The property that represents the field. - * @param classBlock The Java class. - * @param settings Autorest generation settings. - */ - protected void addFieldAnnotations(ClientModel model, ClientModelProperty property, JavaClass classBlock, JavaSettings settings) { - if (settings.getClientFlattenAnnotationTarget() == JavaSettings.ClientFlattenAnnotationTarget.FIELD && property.getNeedsFlatten()) { - classBlock.annotation("JsonFlatten"); - } - - // If the property is a polymorphic discriminator for the class add the annotation @JsonTypeId. - // This will indicate to Jackson that the discriminator serialization is determined by the property - // instead of the class level @JsonTypeName annotation. This prevents the discriminator property from - // being serialized twice, once for the class level annotation and again for the property annotation. - if (property.isPolymorphicDiscriminator()) { - classBlock.annotation("JsonTypeId"); - } - - if (settings.isDataPlaneClient() - && !property.isAdditionalProperties() - && property.getClientType() instanceof MapType - && ((MapType) (property.getClientType())).isValueNullable()) { - classBlock.annotation("JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)"); - } - - boolean treatAsXml = model.isUsedInXml(); - if (modelRequireSerialization(model)) { - if (!CoreUtils.isNullOrEmpty(property.getHeaderCollectionPrefix())) { - classBlock.annotation("HeaderCollection(\"" + property.getHeaderCollectionPrefix() + "\")"); - } else if (treatAsXml && property.isXmlAttribute()) { - classBlock.annotation("JacksonXmlProperty(localName = \"" + property.getXmlName() + "\", isAttribute = true)"); - } else if (treatAsXml && property.getXmlNamespace() != null && !property.getXmlNamespace().isEmpty()) { - classBlock.annotation("JacksonXmlProperty(localName = \"" + property.getXmlName() + "\", namespace = \"" + property.getXmlNamespace() + "\")"); - } else if (treatAsXml && property.isXmlText()) { - classBlock.annotation("JacksonXmlText"); - } else if (property.isAdditionalProperties()) { - classBlock.annotation("JsonIgnore"); - } else if (treatAsXml && property.getWireType() instanceof ListType && !property.isXmlWrapper()) { - classBlock.annotation("JsonProperty(\"" + property.getXmlListElementName() + "\")"); - } else if (!CoreUtils.isNullOrEmpty(property.getAnnotationArguments())) { - classBlock.annotation("JsonProperty(" + property.getAnnotationArguments() + ")"); - } - } + if (settings.isDataPlaneClient() + && !property.isAdditionalProperties() + && property.getClientType() instanceof MapType + && ((MapType) (property.getClientType())).isValueNullable()) { + classBlock.annotation("JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)"); } - /** - * Adds the model constructor to the Java class file. - * - * @param model The model. - * @param constructorVisibility The visibility of constructor. - * @param settings AutoRest settings. - * @param classBlock The Java class file. - */ - private void addModelConstructor(ClientModel model, JavaVisibility constructorVisibility, JavaSettings settings, - JavaClass classBlock) { - final boolean requireSerialization = modelRequireSerialization(model); + boolean treatAsXml = model.isUsedInXml(); + if (modelRequireSerialization(model)) { + if (!CoreUtils.isNullOrEmpty(property.getHeaderCollectionPrefix())) { + classBlock.annotation("HeaderCollection(\"" + property.getHeaderCollectionPrefix() + "\")"); + } else if (treatAsXml && property.isXmlAttribute()) { + classBlock.annotation("JacksonXmlProperty(localName = \"" + property.getXmlName() + "\", isAttribute = true)"); + } else if (treatAsXml && property.getXmlNamespace() != null && !property.getXmlNamespace().isEmpty()) { + classBlock.annotation("JacksonXmlProperty(localName = \"" + property.getXmlName() + "\", namespace = \"" + property.getXmlNamespace() + "\")"); + } else if (treatAsXml && property.isXmlText()) { + classBlock.annotation("JacksonXmlText"); + } else if (property.isAdditionalProperties()) { + classBlock.annotation("JsonIgnore"); + } else if (treatAsXml && property.getWireType() instanceof ListType && !property.isXmlWrapper()) { + classBlock.annotation("JsonProperty(\"" + property.getXmlListElementName() + "\")"); + } else if (!CoreUtils.isNullOrEmpty(property.getAnnotationArguments())) { + classBlock.annotation("JsonProperty(" + property.getAnnotationArguments() + ")"); + } + } + } - // Early out on custom strongly typed headers constructor as this has different handling that doesn't require - // inspecting the required and constant properties. - if (model.isStronglyTypedHeader()) { - ModelTemplateHeaderHelper.addCustomStronglyTypedHeadersConstructor(classBlock, model, settings); - return; + /** + * Adds the model constructor to the Java class file. + * + * @param model The model. + * @param constructorVisibility The visibility of constructor. + * @param settings AutoRest settings. + * @param classBlock The Java class file. + */ + private void addModelConstructor(ClientModel model, JavaVisibility constructorVisibility, JavaSettings settings, + JavaClass classBlock) { + final boolean requireSerialization = modelRequireSerialization(model); + + // Early out on custom strongly typed headers constructor as this has different handling that doesn't require + // inspecting the required and constant properties. + if (model.isStronglyTypedHeader()) { + ModelTemplateHeaderHelper.addCustomStronglyTypedHeadersConstructor(classBlock, model, settings); + return; + } + + // Get the required properties from the super class structure. + List requiredParentProperties = ClientModelUtil.getParentConstructorProperties(model, settings); + + // Required properties are those that are required but not constant. + List requiredProperties = new ArrayList<>(); + + for (ClientModelProperty property : model.getProperties()) { + // Property isn't required and won't be bucketed into either constant or required properties. + if (!property.isConstant() && !ClientModelUtil.includePropertyInConstructor(property, settings)) { + continue; + } + + // Property matches a parent property, don't need to include it twice. + if (requiredParentProperties.stream().anyMatch(p -> p.getName().equals(property.getName()))) { + continue; + } + + // Only include non-constant properties. + if (!property.isConstant()) { + requiredProperties.add(property); + } + } + + // Jackson requires a constructor with @JsonCreator, with parameters in wire type. Ref https://github.com/Azure/autorest.java/issues/2170 + boolean generatePrivateConstructorForJackson = false; + + // Description for the class is always the same, not matter whether there are required properties. + // If there are required properties, the required properties will extend the consumer to add param Javadocs. + Consumer javadocCommentConsumer = comment -> + comment.description("Creates an instance of " + model.getName() + " class."); + + final int constructorPropertiesStringBuilderCapacity = 128 * (requiredProperties.size() + requiredParentProperties.size()); + + // Use a StringBuilder with an initial capacity of 128 times the total number of required constructor properties. + // If there are no required constructor properties this will simply be zero and result in a no-args constructor + // being generated. + StringBuilder constructorProperties = + new StringBuilder(constructorPropertiesStringBuilderCapacity); + + StringBuilder superProperties = new StringBuilder(64 * requiredParentProperties.size()); + + if (settings.isRequiredFieldsAsConstructorArgs()) { + final boolean constructorParametersContainsMismatchWireType = + requiredProperties.stream().anyMatch(p -> ClientModelUtil.isWireTypeMismatch(p, true)) + || requiredParentProperties.stream().anyMatch(p -> ClientModelUtil.isWireTypeMismatch(p, true)); + + if (constructorParametersContainsMismatchWireType && !settings.isStreamStyleSerialization()) { + generatePrivateConstructorForJackson = requireSerialization; + } + + final boolean addJsonPropertyAnnotation = !(settings.isStreamStyleSerialization() || generatePrivateConstructorForJackson || !requireSerialization); + + // Properties required by the super class structure come first. + for (ClientModelProperty property : requiredParentProperties) { + if (constructorProperties.length() > 0) { + constructorProperties.append(", "); } - // Get the required properties from the super class structure. - List requiredParentProperties = ClientModelUtil.getParentConstructorProperties(model, settings); + addModelConstructorParameter(property, constructorProperties, addJsonPropertyAnnotation); - // Required properties are those that are required but not constant. - List requiredProperties = new ArrayList<>(); + javadocCommentConsumer = javadocCommentConsumer.andThen(comment -> comment.param(property.getName(), + "the " + property.getName() + " value to set")); - for (ClientModelProperty property : model.getProperties()) { - // Property isn't required and won't be bucketed into either constant or required properties. - if (!property.isConstant() && !ClientModelUtil.includePropertyInConstructor(property, settings)) { - continue; - } - - // Property matches a parent property, don't need to include it twice. - if (requiredParentProperties.stream().anyMatch(p -> p.getName().equals(property.getName()))) { - continue; - } - - // Only include non-constant properties. - if (!property.isConstant()) { - requiredProperties.add(property); - } + if (superProperties.length() > 0) { + superProperties.append(", "); } - // Jackson requires a constructor with @JsonCreator, with parameters in wire type. Ref https://github.com/Azure/autorest.java/issues/2170 - boolean generatePrivateConstructorForJackson = false; + superProperties.append(property.getName()); + } - // Description for the class is always the same, not matter whether there are required properties. - // If there are required properties, the required properties will extend the consumer to add param Javadocs. - Consumer javadocCommentConsumer = comment -> - comment.description("Creates an instance of " + model.getName() + " class."); - - final int constructorPropertiesStringBuilderCapacity = 128 * (requiredProperties.size() + requiredParentProperties.size()); - - // Use a StringBuilder with an initial capacity of 128 times the total number of required constructor properties. - // If there are no required constructor properties this will simply be zero and result in a no-args constructor - // being generated. - StringBuilder constructorProperties = - new StringBuilder(constructorPropertiesStringBuilderCapacity); - - StringBuilder superProperties = new StringBuilder(64 * requiredParentProperties.size()); - - if (settings.isRequiredFieldsAsConstructorArgs()) { - final boolean constructorParametersContainsMismatchWireType = - requiredProperties.stream().anyMatch(p -> ClientModelUtil.isWireTypeMismatch(p, true)) - || requiredParentProperties.stream().anyMatch(p -> ClientModelUtil.isWireTypeMismatch(p, true)); - - if (constructorParametersContainsMismatchWireType && !settings.isStreamStyleSerialization()) { - generatePrivateConstructorForJackson = requireSerialization; - } - - final boolean addJsonPropertyAnnotation = !(settings.isStreamStyleSerialization() || generatePrivateConstructorForJackson || !requireSerialization); - - // Properties required by the super class structure come first. - for (ClientModelProperty property : requiredParentProperties) { - if (constructorProperties.length() > 0) { - constructorProperties.append(", "); - } - - addModelConstructorParameter(property, constructorProperties, addJsonPropertyAnnotation); - - javadocCommentConsumer = javadocCommentConsumer.andThen(comment -> comment.param(property.getName(), - "the " + property.getName() + " value to set")); - - if (superProperties.length() > 0) { - superProperties.append(", "); - } - - superProperties.append(property.getName()); - } - - // Then properties required by this class come next. - for (ClientModelProperty property : requiredProperties) { - if (constructorProperties.length() > 0) { - constructorProperties.append(", "); - } - - addModelConstructorParameter(property, constructorProperties, addJsonPropertyAnnotation); - - javadocCommentConsumer = javadocCommentConsumer.andThen(comment -> comment.param(property.getName(), - "the " + property.getName() + " value to set")); - } + // Then properties required by this class come next. + for (ClientModelProperty property : requiredProperties) { + if (constructorProperties.length() > 0) { + constructorProperties.append(", "); } - // Add the Javadocs for the constructor. - classBlock.javadocComment(javadocCommentConsumer); + addModelConstructorParameter(property, constructorProperties, addJsonPropertyAnnotation); - addGeneratedAnnotation(classBlock); - // If there are any constructor arguments indicate that this is the JsonCreator. No args constructors are - // implicitly used as the JsonCreator if the class doesn't indicate one. - if (requireSerialization - && constructorProperties.length() > 0 && !settings.isStreamStyleSerialization() - // @JsonCreator will be on the other private constructor - && !generatePrivateConstructorForJackson) { - classBlock.annotation("JsonCreator"); - } + javadocCommentConsumer = javadocCommentConsumer.andThen(comment -> comment.param(property.getName(), + "the " + property.getName() + " value to set")); + } + } - // If immutableOutputModel, make the constructor private, so that adding required properties, or changing model to input-output will not have breaking changes. - // For user in test, they will need to mock the class. + // Add the Javadocs for the constructor. + classBlock.javadocComment(javadocCommentConsumer); - // If constructorProperties empty this just becomes an empty constructor. - classBlock.constructor(constructorVisibility, model.getName() + "(" + constructorProperties + ")", constructor -> { - // If there are super class properties, call super() first. - if (superProperties.length() > 0) { - constructor.line("super(" + superProperties + ");"); - } + addGeneratedAnnotation(classBlock); + // If there are any constructor arguments indicate that this is the JsonCreator. No args constructors are + // implicitly used as the JsonCreator if the class doesn't indicate one. + if (requireSerialization + && constructorProperties.length() > 0 && !settings.isStreamStyleSerialization() + // @JsonCreator will be on the other private constructor + && !generatePrivateConstructorForJackson) { + classBlock.annotation("JsonCreator"); + } - // If we're always adding the polymorphic discriminator to updated properties, may as well just make the - // serialization always add them. This will remove the need to track them, further reducing Set updating and - // querying, which can improve performance in high throughput scenarios. - // If there is a polymorphic discriminator , add a line to initialize the discriminator. + // If immutableOutputModel, make the constructor private, so that adding required properties, or changing model to input-output will not have breaking changes. + // For user in test, they will need to mock the class. + + // If constructorProperties empty this just becomes an empty constructor. + classBlock.constructor(constructorVisibility, model.getName() + "(" + constructorProperties + ")", constructor -> { + // If there are super class properties, call super() first. + if (superProperties.length() > 0) { + constructor.line("super(" + superProperties + ");"); + } + + // If we're always adding the polymorphic discriminator to updated properties, may as well just make the + // serialization always add them. This will remove the need to track them, further reducing Set updating and + // querying, which can improve performance in high throughput scenarios. + // If there is a polymorphic discriminator , add a line to initialize the discriminator. // ClientModelProperty polymorphicProperty = model.getPolymorphicDiscriminator(); // if (polymorphicProperty != null && !polymorphicProperty.isRequired()) { // if (ClientModelUtil.isJsonMergePatchModel(model, settings)) { @@ -885,537 +839,523 @@ public class ModelTemplate implements IJavaTemplate { // } // } - // constant properties should already be initialized in class variable definition + // constant properties should already be initialized in class variable definition // // Then, add all constant properties. // for (ClientModelProperty property : constantProperties) { // constructor.line(property.getName() + " = " + property.getDefaultValue() + ";"); // } - // Finally, add all required properties. - if (settings.isRequiredFieldsAsConstructorArgs()) { - for (ClientModelProperty property : requiredProperties) { - if (property.getClientType() != property.getWireType()) { - // If the property needs to be converted and the passed value is null, set the field to null as the - // converter will likely throw a NullPointerException. - // Otherwise, just convert the value. - constructor.ifBlock(property.getName() + " == null", - ifBlock -> ifBlock.line("this.%s = %s;", property.getName(), property.getWireType().defaultValueExpression())) - .elseBlock(elseBlock -> elseBlock.line("this.%s = %s;", - property.getName(), property.getWireType().convertFromClientType(property.getName()))); - } else { - constructor.line("this." + property.getName() + " = " + property.getWireType().convertFromClientType(property.getName()) + ";"); - } - } - } - }); - - if (generatePrivateConstructorForJackson) { - addGeneratedAnnotation(classBlock); - classBlock.annotation("JsonCreator"); - - StringBuilder constructorPropertiesAsWireType = - new StringBuilder(constructorPropertiesStringBuilderCapacity); - - StringBuilder constructorPropertiesInvokePublicConstructor = - new StringBuilder(constructorPropertiesStringBuilderCapacity); - - final Consumer addParameterInvokePublicConstructor = p -> { - if (constructorPropertiesInvokePublicConstructor.length() > 0) { - constructorPropertiesInvokePublicConstructor.append(", "); - } - - if (p.getWireType() == p.getClientType()) { - constructorPropertiesInvokePublicConstructor.append(p.getName()); - } else { - constructorPropertiesInvokePublicConstructor.append(p.getWireType().convertToClientType(p.getName())); - } - }; - - for (ClientModelProperty property : requiredParentProperties) { - if (constructorPropertiesAsWireType.length() > 0) { - constructorPropertiesAsWireType.append(", "); - } - - addModelConstructorParameterAsWireType(property, constructorPropertiesAsWireType); - - addParameterInvokePublicConstructor.accept(property); - } - for (ClientModelProperty property : requiredProperties) { - if (constructorPropertiesAsWireType.length() > 0) { - constructorPropertiesAsWireType.append(", "); - } - - addModelConstructorParameterAsWireType(property, constructorPropertiesAsWireType); - - addParameterInvokePublicConstructor.accept(property); - } - - classBlock.privateConstructor(model.getName() + "(" + constructorPropertiesAsWireType + ")", constructor -> { - constructor.line("this(" + constructorPropertiesInvokePublicConstructor + ");"); - }); - } - } - - /** - * Adds a constructor parameter to the constructor signature builder. - *

- * The parameter takes client type of property in constructor. - * - * @param property The client model property as constructor parameter. - * @param constructorSignatureBuilder The constructor signature builder. - * @param addJsonPropertyAnnotation whether to add {@code @JsonProperty} annotation on parameter. - */ - private static void addModelConstructorParameter(ClientModelProperty property, - StringBuilder constructorSignatureBuilder, boolean addJsonPropertyAnnotation) { - - if (addJsonPropertyAnnotation) { - constructorSignatureBuilder.append("@JsonProperty(").append(property.getAnnotationArguments()).append(") "); - } - constructorSignatureBuilder.append(property.getClientType()).append(" ").append(property.getName()); - } - - /** - * Adds a constructor parameter to the constructor signature builder. - *

- * The parameter takes wire type of property in constructor. - * - * @param property The client model property as constructor parameter. - * @param constructorSignatureBuilder The constructor signature builder. - */ - private static void addModelConstructorParameterAsWireType( - ClientModelProperty property, - StringBuilder constructorSignatureBuilder) { - - constructorSignatureBuilder - .append("@JsonProperty(").append(property.getAnnotationArguments()).append(") ") - .append(property.getWireType()).append(" ").append(property.getName()); - } - - /** - * Adds a getter method. - * - * @param propertyWireType The property wire type. - * @param propertyClientType The client property type. - * @param property The property. - * @param treatAsXml Whether the getter should treat the property as XML. - * @param methodBlock Where the getter method is being added. - * @param settings Java settings. - */ - private static void addGetterMethod(IType propertyWireType, IType propertyClientType, ClientModelProperty property, - boolean treatAsXml, JavaBlock methodBlock, JavaSettings settings) { - String sourceTypeName = propertyWireType.toString(); - String targetTypeName = propertyClientType.toString(); - String expression = "this." + property.getName(); - if (propertyWireType.equals(ArrayType.BYTE_ARRAY)) { - expression = TemplateHelper.getByteCloneExpression(expression); - } - - if (sourceTypeName.equals(targetTypeName)) { - if (treatAsXml && property.isXmlWrapper() && (property.getWireType() instanceof IterableType)) { - String thisGetName = "this." + property.getName(); - if (settings.isStreamStyleSerialization()) { - methodBlock.ifBlock(thisGetName + " == null", ifBlock -> - ifBlock.line(thisGetName + " = new ArrayList<>();")); - methodBlock.methodReturn("this." + property.getName()); - } else { - methodBlock.ifBlock(thisGetName + " == null", ifBlock -> - ifBlock.line("this.%s = new %s(new ArrayList<%s>());", property.getName(), - getPropertyXmlWrapperClassName(property), - ((GenericType) property.getWireType()).getTypeArguments()[0])); - methodBlock.methodReturn(thisGetName + ".items"); - } - } else { - methodBlock.methodReturn(expression); - } - } else { - // If the wire type was null, return null as the returned conversion could, and most likely would, result - // in a NullPointerException. - if (propertyWireType.isNullable()) { - methodBlock.ifBlock(expression + " == null", - ifBlock -> ifBlock.methodReturn(propertyClientType.defaultValueExpression())); - } - - // Return the conversion of the wire type to the client type. An example would be a wire type of - // DateTimeRfc1123 and a client type of OffsetDateTime (type a consumer would use), this makes the return - // "this.value.getDateTime()". - methodBlock.methodReturn(propertyWireType.convertToClientType(expression)); - } - } - - /** - * Adds a setter method. - * - * @param propertyWireType The property wire type. - * @param propertyClientType The client property type. - * @param property The property. - * @param treatAsXml Whether the setter should treat the property as XML. - * @param methodBlock Where the setter method is being added. - * @param isJsonMergePatchModel Whether the client model is a JSON merge patch model. - */ - private static void addSetterMethod(IType propertyWireType, IType propertyClientType, ClientModelProperty property, - boolean treatAsXml, JavaBlock methodBlock, JavaSettings settings, boolean isJsonMergePatchModel) { - String expression = (propertyClientType.equals(ArrayType.BYTE_ARRAY)) - ? TemplateHelper.getByteCloneExpression(property.getName()) - : property.getName(); - - if (propertyClientType != propertyWireType) { + // Finally, add all required properties. + if (settings.isRequiredFieldsAsConstructorArgs()) { + for (ClientModelProperty property : requiredProperties) { + if (property.getClientType() != property.getWireType()) { // If the property needs to be converted and the passed value is null, set the field to null as the // converter will likely throw a NullPointerException. // Otherwise, just convert the value. - methodBlock.ifBlock(property.getName() + " == null", - ifBlock -> ifBlock.line("this.%s = %s;", property.getName(), property.getWireType().defaultValueExpression())) - .elseBlock(elseBlock -> - elseBlock.line("this.%s = %s;", property.getName(), propertyWireType.convertFromClientType(expression))); + constructor.ifBlock(property.getName() + " == null", + ifBlock -> ifBlock.line("this.%s = %s;", property.getName(), property.getWireType().defaultValueExpression())) + .elseBlock(elseBlock -> elseBlock.line("this.%s = %s;", + property.getName(), property.getWireType().convertFromClientType(property.getName()))); + } else { + constructor.line("this." + property.getName() + " = " + property.getWireType().convertFromClientType(property.getName()) + ";"); + } + } + } + + PolymorphicDiscriminatorHandler.initializeInConstructor(model, constructor, settings); + }); + + if (generatePrivateConstructorForJackson) { + addGeneratedAnnotation(classBlock); + classBlock.annotation("JsonCreator"); + + StringBuilder constructorPropertiesAsWireType = + new StringBuilder(constructorPropertiesStringBuilderCapacity); + + StringBuilder constructorPropertiesInvokePublicConstructor = + new StringBuilder(constructorPropertiesStringBuilderCapacity); + + final Consumer addParameterInvokePublicConstructor = p -> { + if (constructorPropertiesInvokePublicConstructor.length() > 0) { + constructorPropertiesInvokePublicConstructor.append(", "); + } + + if (p.getWireType() == p.getClientType()) { + constructorPropertiesInvokePublicConstructor.append(p.getName()); } else { - if (treatAsXml && property.isXmlWrapper()) { - if (settings.isStreamStyleSerialization()) { - methodBlock.line("this." + property.getName() + " = " + expression + ";"); - } else { - methodBlock.line("this.%s = new %s(%s);", property.getName(), - getPropertyXmlWrapperClassName(property), expression); - } - } else { - methodBlock.line("this.%s = %s;", property.getName(), expression); - } + constructorPropertiesInvokePublicConstructor.append(p.getWireType().convertToClientType(p.getName())); + } + }; + + for (ClientModelProperty property : requiredParentProperties) { + if (constructorPropertiesAsWireType.length() > 0) { + constructorPropertiesAsWireType.append(", "); } - if (isJsonMergePatchModel) { - methodBlock.line("this.updatedProperties.add(\"" + property.getName() + "\");"); + addModelConstructorParameterAsWireType(property, constructorPropertiesAsWireType); + + addParameterInvokePublicConstructor.accept(property); + } + for (ClientModelProperty property : requiredProperties) { + if (constructorPropertiesAsWireType.length() > 0) { + constructorPropertiesAsWireType.append(", "); } - methodBlock.methodReturn("this"); + addModelConstructorParameterAsWireType(property, constructorPropertiesAsWireType); + + addParameterInvokePublicConstructor.accept(property); + } + + classBlock.privateConstructor(model.getName() + "(" + constructorPropertiesAsWireType + ")", constructor -> { + constructor.line("this(" + constructorPropertiesInvokePublicConstructor + ");"); + }); + } + } + + /** + * Adds a constructor parameter to the constructor signature builder. + *

+ * The parameter takes client type of property in constructor. + * + * @param property The client model property as constructor parameter. + * @param constructorSignatureBuilder The constructor signature builder. + * @param addJsonPropertyAnnotation whether to add {@code @JsonProperty} annotation on parameter. + */ + private static void addModelConstructorParameter(ClientModelProperty property, + StringBuilder constructorSignatureBuilder, boolean addJsonPropertyAnnotation) { + + if (addJsonPropertyAnnotation) { + constructorSignatureBuilder.append("@JsonProperty(").append(property.getAnnotationArguments()).append(") "); + } + constructorSignatureBuilder.append(property.getClientType()).append(" ").append(property.getName()); + } + + /** + * Adds a constructor parameter to the constructor signature builder. + *

+ * The parameter takes wire type of property in constructor. + * + * @param property The client model property as constructor parameter. + * @param constructorSignatureBuilder The constructor signature builder. + */ + private static void addModelConstructorParameterAsWireType( + ClientModelProperty property, + StringBuilder constructorSignatureBuilder) { + + constructorSignatureBuilder + .append("@JsonProperty(").append(property.getAnnotationArguments()).append(") ") + .append(property.getWireType()).append(" ").append(property.getName()); + } + + /** + * Adds a getter method. + * + * @param propertyWireType The property wire type. + * @param propertyClientType The client property type. + * @param property The property. + * @param treatAsXml Whether the getter should treat the property as XML. + * @param methodBlock Where the getter method is being added. + * @param settings Java settings. + */ + private static void addGetterMethod(IType propertyWireType, IType propertyClientType, ClientModelProperty property, + boolean treatAsXml, JavaBlock methodBlock, JavaSettings settings) { + String sourceTypeName = propertyWireType.toString(); + String targetTypeName = propertyClientType.toString(); + String expression = "this." + property.getName(); + if (propertyWireType.equals(ArrayType.BYTE_ARRAY)) { + expression = TemplateHelper.getByteCloneExpression(expression); } - private void addPropertyValidations(JavaClass classBlock, ClientModel model, JavaSettings settings) { - if (settings.isClientSideValidations()) { + if (sourceTypeName.equals(targetTypeName)) { + if (treatAsXml && property.isXmlWrapper() && (property.getWireType() instanceof IterableType)) { + String thisGetName = "this." + property.getName(); + if (settings.isStreamStyleSerialization()) { + methodBlock.ifBlock(thisGetName + " == null", ifBlock -> + ifBlock.line(thisGetName + " = new ArrayList<>();")); + methodBlock.methodReturn("this." + property.getName()); + } else { + methodBlock.ifBlock(thisGetName + " == null", ifBlock -> + ifBlock.line("this.%s = new %s(new ArrayList<%s>());", property.getName(), + getPropertyXmlWrapperClassName(property), + ((GenericType) property.getWireType()).getTypeArguments()[0])); + methodBlock.methodReturn(thisGetName + ".items"); + } + } else { + methodBlock.methodReturn(expression); + } + } else { + // If the wire type was null, return null as the returned conversion could, and most likely would, result + // in a NullPointerException. + if (propertyWireType.isNullable()) { + methodBlock.ifBlock(expression + " == null", + ifBlock -> ifBlock.methodReturn(propertyClientType.defaultValueExpression())); + } - // javadoc - classBlock.javadocComment((comment) -> { - comment.description("Validates the instance."); + // Return the conversion of the wire type to the client type. An example would be a wire type of + // DateTimeRfc1123 and a client type of OffsetDateTime (type a consumer would use), this makes the return + // "this.value.getDateTime()". + methodBlock.methodReturn(propertyWireType.convertToClientType(expression)); + } + } - comment.methodThrows("IllegalArgumentException", "thrown if the instance is not valid"); + /** + * Adds a setter method. + * + * @param propertyWireType The property wire type. + * @param propertyClientType The client property type. + * @param property The property. + * @param treatAsXml Whether the setter should treat the property as XML. + * @param methodBlock Where the setter method is being added. + * @param isJsonMergePatchModel Whether the client model is a JSON merge patch model. + */ + private static void addSetterMethod(IType propertyWireType, IType propertyClientType, ClientModelProperty property, + boolean treatAsXml, JavaBlock methodBlock, JavaSettings settings, boolean isJsonMergePatchModel) { + String expression = (propertyClientType.equals(ArrayType.BYTE_ARRAY)) + ? TemplateHelper.getByteCloneExpression(property.getName()) + : property.getName(); + + if (propertyClientType != propertyWireType) { + // If the property needs to be converted and the passed value is null, set the field to null as the + // converter will likely throw a NullPointerException. + // Otherwise, just convert the value. + methodBlock.ifBlock(property.getName() + " == null", + ifBlock -> ifBlock.line("this.%s = %s;", property.getName(), property.getWireType().defaultValueExpression())) + .elseBlock(elseBlock -> + elseBlock.line("this.%s = %s;", property.getName(), propertyWireType.convertFromClientType(expression))); + } else { + if (treatAsXml && property.isXmlWrapper()) { + if (settings.isStreamStyleSerialization()) { + methodBlock.line("this." + property.getName() + " = " + expression + ";"); + } else { + methodBlock.line("this.%s = new %s(%s);", property.getName(), + getPropertyXmlWrapperClassName(property), expression); + } + } else { + methodBlock.line("this.%s = %s;", property.getName(), expression); + } + } + + if (isJsonMergePatchModel) { + methodBlock.line("this.updatedProperties.add(\"" + property.getName() + "\");"); + } + + methodBlock.methodReturn("this"); + } + + private void addPropertyValidations(JavaClass classBlock, ClientModel model, JavaSettings settings) { + if (settings.isClientSideValidations()) { + + // javadoc + classBlock.javadocComment((comment) -> { + comment.description("Validates the instance."); + + comment.methodThrows("IllegalArgumentException", "thrown if the instance is not valid"); + }); + + if (this.parentModelHasValidate(model.getParentModelName())) { + classBlock.annotation("Override"); + } + classBlock.publicMethod("void validate()", methodBlock -> { + if (this.callParentValidate(model.getParentModelName())) { + methodBlock.line("super.validate();"); + } + for (ClientModelProperty property : getValidationProperties(model)) { + String validation = property.getClientType().validate(getGetterName(model, property) + "()"); + if (property.isRequired() && !property.isReadOnly() && !property.isConstant() && !(property.getClientType() instanceof PrimitiveType)) { + JavaIfBlock nullCheck = methodBlock.ifBlock(String.format("%s() == null", getGetterName(model, property)), ifBlock -> { + final String errorMessage = String.format("\"Missing required property %s in model %s\"", property.getName(), model.getName()); + if (settings.isUseClientLogger()) { + ifBlock.line( + "throw LOGGER.atError().log(new IllegalArgumentException(" + errorMessage + "));"); + } else { + ifBlock.line("throw new IllegalArgumentException(" + errorMessage + ");"); + } }); - - if (this.parentModelHasValidate(model.getParentModelName())) { - classBlock.annotation("Override"); + if (validation != null) { + nullCheck.elseBlock(elseBlock -> elseBlock.line(validation + ";")); } - classBlock.publicMethod("void validate()", methodBlock -> { - if (this.callParentValidate(model.getParentModelName())) { - methodBlock.line("super.validate();"); - } - for (ClientModelProperty property : getValidationProperties(model)) { - String validation = property.getClientType().validate(getGetterName(model, property) + "()"); - if (property.isRequired() && !property.isReadOnly() && !property.isConstant() && !(property.getClientType() instanceof PrimitiveType)) { - JavaIfBlock nullCheck = methodBlock.ifBlock(String.format("%s() == null", getGetterName(model, property)), ifBlock -> { - final String errorMessage = String.format("\"Missing required property %s in model %s\"", property.getName(), model.getName()); - if (settings.isUseClientLogger()) { - ifBlock.line( - "throw LOGGER.atError().log(new IllegalArgumentException(" + errorMessage + "));"); - } else { - ifBlock.line("throw new IllegalArgumentException(" + errorMessage + ");"); - } - }); - if (validation != null) { - nullCheck.elseBlock(elseBlock -> elseBlock.line(validation + ";")); - } - } else if (validation != null) { - methodBlock.ifBlock(getGetterName(model, property) + "() != null", - ifBlock -> ifBlock.line(validation + ";")); - } - } - }); + } else if (validation != null) { + methodBlock.ifBlock(getGetterName(model, property) + "() != null", + ifBlock -> ifBlock.line(validation + ";")); + } } + }); } + } - /** - * Extension for validation on parent model. - * - * @param parentModelName parent model name - * @return whether to call validate() on parent model - */ - protected boolean callParentValidate(String parentModelName) { - return parentModelHasValidate(parentModelName); - } + /** + * Extension for validation on parent model. + * + * @param parentModelName parent model name + * @return whether to call validate() on parent model + */ + protected boolean callParentValidate(String parentModelName) { + return parentModelHasValidate(parentModelName); + } - /** - * Gets properties to validate in `validate()` method. - * - * @param model the model to add `validate()` method - * @return properties to validate in `validate()` method - */ - protected List getValidationProperties(ClientModel model) { - return model.getProperties(); - } + /** + * Gets properties to validate in `validate()` method. + * + * @param model the model to add `validate()` method + * @return properties to validate in `validate()` method + */ + protected List getValidationProperties(ClientModel model) { + return model.getProperties(); + } - /** - * Gets the property XML wrapper class name. - * - * @param property The property that is getting its XML wrapper class name. - * @return The property XML wrapper class name. - */ - static String getPropertyXmlWrapperClassName(ClientModelProperty property) { - return property.getXmlName() + "Wrapper"; - } + /** + * Gets the property XML wrapper class name. + * + * @param property The property that is getting its XML wrapper class name. + * @return The property XML wrapper class name. + */ + static String getPropertyXmlWrapperClassName(ClientModelProperty property) { + return property.getXmlName() + "Wrapper"; + } - /** - * Extension for validation on parent model. - * - * @param parentModelName the parent model name - * @return Whether validate() exists in parent model. - */ - protected boolean parentModelHasValidate(String parentModelName) { - return parentModelName != null; - } + /** + * Extension for validation on parent model. + * + * @param parentModelName the parent model name + * @return Whether validate() exists in parent model. + */ + protected boolean parentModelHasValidate(String parentModelName) { + return parentModelName != null; + } - /** - * Extension for property getter method name. - * - * @param model the model - * @param property the property - * @return The property getter method name. - */ - protected String getGetterName(ClientModel model, ClientModelProperty property) { - return property.getGetterName(); - } + /** + * Extension for property getter method name. + * + * @param model the model + * @param property the property + * @return The property getter method name. + */ + protected String getGetterName(ClientModel model, ClientModelProperty property) { + return property.getGetterName(); + } - /** - * Extension for Fluent list of client model property reference. - * - * @param model the client model. - * @return the list of client model property reference. - */ - protected List getClientModelPropertyReferences(ClientModel model) { - List propertyReferences = new ArrayList<>(); - String lastParentName = model.getName(); - String parentModelName = model.getParentModelName(); - while (parentModelName != null && !lastParentName.equals(parentModelName)) { - ClientModel parentModel = ClientModelUtil.getClientModel(parentModelName); - if (parentModel != null) { - if (parentModel.getProperties() != null) { - parentModel.getProperties().stream() - .filter(p -> !p.getClientFlatten() && !p.isAdditionalProperties()) - .map(ClientModelPropertyReference::ofParentProperty) - .forEach(propertyReferences::add); - } - - if (parentModel.getPropertyReferences() != null) { - parentModel.getPropertyReferences().stream() - .filter(ClientModelPropertyReference::isFromFlattenedProperty) - .map(ClientModelPropertyReference::ofParentProperty) - .forEach(propertyReferences::add); - } - } - - lastParentName = parentModelName; - parentModelName = parentModel == null ? null : parentModel.getParentModelName(); - } - return propertyReferences; - } - - /** - * Checks whether to generate constant "private final static byte[] EMPTY_BYTE_ARRAY = new byte[0];" - * - * @param model the model - * @param settings Java settings - * @return Whether to generate the constant. - */ - private static boolean isGenerateConstantEmptyByteArray(ClientModel model, JavaSettings settings) { - if (!settings.isNullByteArrayMapsToEmptyArray()) { - return false; + /** + * Extension for Fluent list of client model property reference. + * + * @param model the client model. + * @return the list of client model property reference. + */ + protected List getClientModelPropertyReferences(ClientModel model) { + List propertyReferences = new ArrayList<>(); + String lastParentName = model.getName(); + String parentModelName = model.getParentModelName(); + while (parentModelName != null && !lastParentName.equals(parentModelName)) { + ClientModel parentModel = ClientModelUtil.getClientModel(parentModelName); + if (parentModel != null) { + if (parentModel.getProperties() != null) { + parentModel.getProperties().stream() + .filter(p -> !p.getClientFlatten() && !p.isAdditionalProperties()) + .map(ClientModelPropertyReference::ofParentProperty) + .forEach(propertyReferences::add); } - boolean ret = model.getProperties().stream() - .anyMatch(property -> property.getClientType() == ArrayType.BYTE_ARRAY - && property.getWireType() != property.getClientType()); - - if (!ret && !CoreUtils.isNullOrEmpty(model.getParentModelName())) { - ret = ClientModelUtil.getParentProperties(model).stream() - .anyMatch(property -> property.getClientType() == ArrayType.BYTE_ARRAY - && property.getWireType() != property.getClientType()); + if (parentModel.getPropertyReferences() != null) { + parentModel.getPropertyReferences().stream() + .filter(ClientModelPropertyReference::isFromFlattenedProperty) + .map(ClientModelPropertyReference::ofParentProperty) + .forEach(propertyReferences::add); } + } - // flatten properties - if (!ret && settings.getClientFlattenAnnotationTarget() == JavaSettings.ClientFlattenAnnotationTarget.NONE) { - // "return this.innerProperties() == null ? EMPTY_BYTE_ARRAY : this.innerProperties().property1();" - ret = model.getPropertyReferences().stream() - .filter(ClientModelPropertyReference::isFromFlattenedProperty) - .anyMatch(p -> p.getClientType() == ArrayType.BYTE_ARRAY); - } + lastParentName = parentModelName; + parentModelName = parentModel == null ? null : parentModel.getParentModelName(); + } + return propertyReferences; + } - return ret; + /** + * Checks whether to generate constant "private final static byte[] EMPTY_BYTE_ARRAY = new byte[0];" + * + * @param model the model + * @param settings Java settings + * @return Whether to generate the constant. + */ + private static boolean isGenerateConstantEmptyByteArray(ClientModel model, JavaSettings settings) { + if (!settings.isNullByteArrayMapsToEmptyArray()) { + return false; } - /** - * Checks whether the serialization code is required for the model. - * - * @param model the model. - * @return whether the serialization code is required for the model. - */ - private static boolean modelRequireSerialization(ClientModel model) { - // TODO (weidxu): any other case? "binary"? - return !ClientModelUtil.isMultipartModel(model) - // not GroupSchema - && !(model.getImplementationDetails() != null && model.getImplementationDetails().getUsages() != null && model.getImplementationDetails().getUsages().contains(ImplementationDetails.Usage.OPTIONS_GROUP)); + boolean ret = model.getProperties().stream() + .anyMatch(property -> property.getClientType() == ArrayType.BYTE_ARRAY + && property.getWireType() != property.getClientType()); + + if (!ret && !CoreUtils.isNullOrEmpty(model.getParentModelName())) { + ret = ClientModelUtil.getParentProperties(model).stream() + .anyMatch(property -> property.getClientType() == ArrayType.BYTE_ARRAY + && property.getWireType() != property.getClientType()); } - /** - * Writes stream-style serialization logic for serializing to and deserializing from the serialization format that - * the model uses. - * - * @param classBlock The class block where serialization methods will be written. - * @param model The model. - * @param settings Autorest generation settings. - */ - protected void writeStreamStyleSerialization(JavaClass classBlock, ClientModel model, JavaSettings settings) { - // No-op, meant for StreamSerializationModelTemplate. + // flatten properties + if (!ret && settings.getClientFlattenAnnotationTarget() == JavaSettings.ClientFlattenAnnotationTarget.NONE) { + // "return this.innerProperties() == null ? EMPTY_BYTE_ARRAY : this.innerProperties().property1();" + ret = model.getPropertyReferences().stream() + .filter(ClientModelPropertyReference::isFromFlattenedProperty) + .anyMatch(p -> p.getClientType() == ArrayType.BYTE_ARRAY); } - protected void addGeneratedImport(Set imports) { - if (JavaSettings.getInstance().isDataPlaneClient()) { - if (JavaSettings.getInstance().isBranded()) { - Annotation.GENERATED.addImportsTo(imports); - } else { - Annotation.METADATA.addImportsTo(imports); - } - } + return ret; + } + + /** + * Checks whether the serialization code is required for the model. + * + * @param model the model. + * @return whether the serialization code is required for the model. + */ + private static boolean modelRequireSerialization(ClientModel model) { + // TODO (weidxu): any other case? "binary"? + return !ClientModelUtil.isMultipartModel(model) + // not GroupSchema + && !(model.getImplementationDetails() != null && model.getImplementationDetails().getUsages() != null && model.getImplementationDetails().getUsages().contains(ImplementationDetails.Usage.OPTIONS_GROUP)); + } + + /** + * Writes stream-style serialization logic for serializing to and deserializing from the serialization format that + * the model uses. + * + * @param classBlock The class block where serialization methods will be written. + * @param model The model. + * @param settings Autorest generation settings. + */ + protected void writeStreamStyleSerialization(JavaClass classBlock, ClientModel model, JavaSettings settings) { + // No-op, meant for StreamSerializationModelTemplate. + } + + protected void addGeneratedImport(Set imports) { + if (JavaSettings.getInstance().isDataPlaneClient()) { + if (JavaSettings.getInstance().isBranded()) { + Annotation.GENERATED.addImportsTo(imports); + } else { + Annotation.METADATA.addImportsTo(imports); + } + } + } + + protected void addGeneratedAnnotation(JavaContext classBlock) { + if (JavaSettings.getInstance().isDataPlaneClient()) { + if (JavaSettings.getInstance().isBranded()) { + classBlock.annotation(Annotation.GENERATED.getName()); + } else { + classBlock.annotation(Annotation.METADATA.getName() + "(generated = true)"); + } + } + } + + // Javadoc for getter method + private static void generateGetterJavadoc(JavaClass classBlock, ClientModelPropertyAccess property) { + classBlock.javadocComment(comment -> { + comment.description("Get the " + property.getName() + " property: " + property.getDescription()); + comment.methodReturns("the " + property.getName() + " value"); + }); + } + + // Javadoc for setter method + private static void generateSetterJavadoc(JavaClass classBlock, ClientModel model, + ClientModelPropertyAccess property) { + classBlock.javadocComment((comment) -> { + if (property.getDescription() == null || property.getDescription().contains(MISSING_SCHEMA)) { + comment.description("Set the " + property.getName() + " property"); + } else { + comment.description("Set the " + property.getName() + " property: " + property.getDescription()); + } + if (property.isRequiredForCreate() && !property.isRequired()) { + comment.line("

Required when create the resource.

"); + } + comment.param(property.getName(), "the " + property.getName() + " value to set"); + comment.methodReturns("the " + model.getName() + " object itself."); + }); + } + + private static final class StreamStyleImports extends HashSet { + @Override + public boolean add(String s) { + if (s != null && s.contains("fasterxml")) { + return true; + } + + return super.add(s); + } + } + + /** + * Add json-merge-patch related flag and accessors. + */ + private void addJsonMergePatchRelatedPropertyAndAccessors(JavaClass classBlock, ClientModel model) { + if (!model.getImplementationDetails().isInput()) { + // Model doesn't get used in serialization, no need to add json merge patch related properties and + // accessors. + return; } - protected void addGeneratedAnnotation(JavaContext classBlock) { - if (JavaSettings.getInstance().isDataPlaneClient()) { - if (JavaSettings.getInstance().isBranded()) { - classBlock.annotation(Annotation.GENERATED.getName()); - } else { - classBlock.annotation(Annotation.METADATA.getName() + "(generated = true)"); - } - } + classBlock.javadocComment(comment -> + comment.description("Stores updated model property, the value is property name, not serialized name")); + addGeneratedAnnotation(classBlock); + classBlock.privateFinalMemberVariable("Set updatedProperties = new HashSet<>()"); + + if (model.isPolymorphic() && CoreUtils.isNullOrEmpty(model.getDerivedModels())) { + // Only polymorphic parent models generate an accessor. + // If it is the super most parent model, it will generate the prepareModelForJsonMergePatch method. + // Other parents need to generate setters for the properties that are used in json-merge-patch, used in + // deserialization to prevent these properties from always being included in serialization. + return; } - // Javadoc for getter method - private static void generateGetterJavadoc(JavaClass classBlock, ClientModelPropertyAccess property) { - classBlock.javadocComment(comment -> { - comment.description("Get the " + property.getName() + " property: " + property.getDescription()); - comment.methodReturns("the " + property.getName() + " value"); - }); + List setterProperties = !model.isPolymorphic() ? Collections.emptyList() + : model.getProperties().stream() + .filter(property -> !property.isConstant() && !property.isPolymorphicDiscriminator()) + .collect(Collectors.toList()); + + boolean rootParent = CoreUtils.isNullOrEmpty(model.getParentModelName()); + if (!rootParent && setterProperties.isEmpty()) { + // Model isn't the root parent and doesn't have any setter properties, no need to generate an accessor. + return; } - // Javadoc for setter method - private static void generateSetterJavadoc(JavaClass classBlock, ClientModel model, - ClientModelPropertyAccess property) { - classBlock.javadocComment((comment) -> { - if (property.getDescription() == null || property.getDescription().contains(MISSING_SCHEMA)) { - comment.description("Set the " + property.getName() + " property"); - } else { - comment.description("Set the " + property.getName() + " property: " + property.getDescription()); - } - if (property.isRequiredForCreate() && !property.isRequired()) { - comment.line("

Required when create the resource.

"); - } - comment.param(property.getName(), "the " + property.getName() + " value to set"); - comment.methodReturns("the " + model.getName() + " object itself."); - }); + if (rootParent) { + // Only the root model needs to have the jsonMergePatch property. + addGeneratedAnnotation(classBlock); + classBlock.privateMemberVariable("boolean jsonMergePatch"); } - private static final class StreamStyleImports extends HashSet { - @Override - public boolean add(String s) { - if (s != null && s.contains("fasterxml")) { - return true; - } - - return super.add(s); - } + if (rootParent) { + // setter + addGeneratedAnnotation(classBlock); + classBlock.privateMethod("void serializeAsJsonMergePatch(boolean jsonMergePatch)", + method -> method.line("this.jsonMergePatch = jsonMergePatch;")); } - /** - * Add json-merge-patch related flag and accessors. - */ - private void addJsonMergePatchRelatedPropertyAndAccessors(JavaClass classBlock, ClientModel model) { - if (!model.getImplementationDetails().isInput()) { - // Model doesn't get used in serialization, no need to add json merge patch related properties and - // accessors. - return; - } - - classBlock.javadocComment(comment -> - comment.description("Stores updated model property, the value is property name, not serialized name")); - addGeneratedAnnotation(classBlock); - classBlock.privateFinalMemberVariable("Set updatedProperties = new HashSet<>()"); - - if (model.isPolymorphic() && CoreUtils.isNullOrEmpty(model.getDerivedModels())) { - // Only polymorphic parent models generate an accessor. - // If it is the super most parent model, it will generate the prepareModelForJsonMergePatch method. - // Other parents need to generate setters for the properties that are used in json-merge-patch, used in - // deserialization to prevent these properties from always being included in serialization. - return; - } - - List setterProperties = !model.isPolymorphic() ? Collections.emptyList() - : model.getProperties().stream() - .filter(property -> !property.isConstant() && !property.isPolymorphicDiscriminator()) - .collect(Collectors.toList()); - - boolean rootParent = CoreUtils.isNullOrEmpty(model.getParentModelName()); - if (!rootParent && setterProperties.isEmpty()) { - // Model isn't the root parent and doesn't have any setter properties, no need to generate an accessor. - return; - } - + // static code block to access jsonMergePatch setter + classBlock.staticBlock(staticBlock -> { + String accessorName = model.getName() + "Accessor"; + staticBlock.line("JsonMergePatchHelper.set" + accessorName + "(new JsonMergePatchHelper." + accessorName + "() {"); + staticBlock.indent(() -> { if (rootParent) { - // Only the root model needs to have the jsonMergePatch property. - addGeneratedAnnotation(classBlock); - classBlock.privateMemberVariable("boolean jsonMergePatch"); + staticBlock.line("@Override"); + staticBlock.block("public " + model.getName() + " prepareModelForJsonMergePatch(" + model.getName() + + " model, boolean jsonMergePatchEnabled)", setJsonMergePatch -> { + staticBlock.line("model.serializeAsJsonMergePatch(jsonMergePatchEnabled);"); + staticBlock.line("return model;"); + }); + + staticBlock.line("@Override"); + staticBlock.block("public boolean isJsonMergePatch(" + model.getName() + " model)", + getJsonMergePatch -> getJsonMergePatch.line("return model.jsonMergePatch;")); } - if (rootParent) { - // setter - addGeneratedAnnotation(classBlock); - classBlock.privateMethod("void serializeAsJsonMergePatch(boolean jsonMergePatch)", - method -> method.line("this.jsonMergePatch = jsonMergePatch;")); + for (ClientModelProperty setter : setterProperties) { + staticBlock.line("@Override"); + staticBlock.block("public void " + setter.getSetterName() + "(" + model.getName() + + " model, " + setter.getWireType() + " " + setter.getName() + ")", + setField -> setField.line("model." + setter.getName() + " = " + setter.getName() + ";")); } + }); - // static code block to access jsonMergePatch setter - classBlock.staticBlock(staticBlock -> { - String accessorName = model.getName() + "Accessor"; - staticBlock.line("JsonMergePatchHelper.set" + accessorName + "(new JsonMergePatchHelper." + accessorName + "() {"); - staticBlock.indent(() -> { - if (rootParent) { - staticBlock.line("@Override"); - staticBlock.block("public " + model.getName() + " prepareModelForJsonMergePatch(" + model.getName() - + " model, boolean jsonMergePatchEnabled)", setJsonMergePatch -> { - staticBlock.line("model.serializeAsJsonMergePatch(jsonMergePatchEnabled);"); - staticBlock.line("return model;"); - }); - - staticBlock.line("@Override"); - staticBlock.block("public boolean isJsonMergePatch(" + model.getName() + " model)", - getJsonMergePatch -> getJsonMergePatch.line("return model.jsonMergePatch;")); - } - - for (ClientModelProperty setter : setterProperties) { - staticBlock.line("@Override"); - staticBlock.block("public void " + setter.getSetterName() + "(" + model.getName() - + " model, " + setter.getWireType() + " " + setter.getName() + ")", - setField -> setField.line("model." + setter.getName() + " = " + setter.getName() + ";")); - } - }); - - staticBlock.line("});"); - }); - } - - static boolean modelDefinesProperty(ClientModel model, ClientModelProperty property) { - return ClientModelUtil.getParentProperties(model).stream().noneMatch(parentProperty -> - Objects.equals(property.getSerializedName(), parentProperty.getSerializedName())); - } - - static ClientModel getDefiningModel(ClientModel model, ClientModelProperty property) { - ClientModel current = model; - while(current != null) { - if (modelDefinesProperty(current, property)) { - return current; - } - current = ClientModelUtil.getClientModel(current.getParentModelName()); - } - throw new IllegalArgumentException("unable to find defining model for property: " + property); - } + staticBlock.line("});"); + }); + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/StreamSerializationModelTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/StreamSerializationModelTemplate.java index 3af737c0a..00957dd21 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/StreamSerializationModelTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/StreamSerializationModelTemplate.java @@ -55,2302 +55,2483 @@ import static com.microsoft.typespec.http.client.generator.core.util.ClientModel * Writes a ClientModel to a JavaFile using stream-style serialization. */ public class StreamSerializationModelTemplate extends ModelTemplate { - private static final StreamSerializationModelTemplate INSTANCE = new StreamSerializationModelTemplate(); - private static final String READ_MANAGEMENT_ERROR_METHOD_NAME = "readManagementError"; + private static final StreamSerializationModelTemplate INSTANCE = new StreamSerializationModelTemplate(); + private static final String READ_MANAGEMENT_ERROR_METHOD_NAME = "readManagementError"; - // TODO (alzimmer): Future enhancements: - // - Create a utility class in the implementation package containing base serialization for polymorphic types. - // This will enable a central location for shared logic, reducing package size and hopefully JIT optimizations. - // - Convert all logic in this class to an instance type that is created with the ClientModel being generated. - // This will simplify all the APIs to just taking that type rather than passing bits of information from here - // and there everywhere, which require extensive changes each time a new feature is added. + // TODO (alzimmer): Future enhancements: + // - Create a utility class in the implementation package containing base serialization for polymorphic types. + // This will enable a central location for shared logic, reducing package size and hopefully JIT optimizations. + // - Convert all logic in this class to an instance type that is created with the ClientModel being generated. + // This will simplify all the APIs to just taking that type rather than passing bits of information from here + // and there everywhere, which require extensive changes each time a new feature is added. - protected StreamSerializationModelTemplate() { + protected StreamSerializationModelTemplate() { + } + + public static StreamSerializationModelTemplate getInstance() { + return INSTANCE; + } + + @Override + protected void addSerializationImports(Set imports, ClientModel model, JavaSettings settings) { + if (model.getXmlName() != null) { + imports.add(QName.class.getName()); + imports.add(XMLStreamException.class.getName()); + + imports.add(XmlSerializable.class.getName()); + imports.add(XmlWriter.class.getName()); + imports.add(XmlReader.class.getName()); + imports.add(XmlToken.class.getName()); + } else { + imports.add(IOException.class.getName()); + + ClassType.JSON_SERIALIZABLE.addImportsTo(imports, false); + ClassType.JSON_WRITER.addImportsTo(imports, false); + ClassType.JSON_READER.addImportsTo(imports, false); + ClassType.JSON_TOKEN.addImportsTo(imports, false); } - public static StreamSerializationModelTemplate getInstance() { - return INSTANCE; + ClassType.CORE_UTILS.addImportsTo(imports, false); + + imports.add(ArrayList.class.getName()); + imports.add(Base64.class.getName()); + imports.add(LinkedHashMap.class.getName()); + imports.add(List.class.getName()); + imports.add(Map.class.getName()); + imports.add(Objects.class.getName()); + } + + @Override + protected void addClassLevelAnnotations(ClientModel model, JavaFile javaFile, JavaSettings settings) { + // no-op as stream-style serialization doesn't add any class-level annotations. + } + + @Override + protected String addSerializationImplementations(String classSignature, ClientModel model, JavaSettings settings) { + if (!settings.isStreamStyleSerialization() || model.isStronglyTypedHeader()) { + return classSignature; } - @Override - protected void addSerializationImports(Set imports, ClientModel model, JavaSettings settings) { - if (model.getXmlName() != null) { - imports.add(QName.class.getName()); - imports.add(XMLStreamException.class.getName()); + String interfaceName = (model.getXmlName() != null) + ? XmlSerializable.class.getSimpleName() + : ClassType.JSON_SERIALIZABLE.getName(); - imports.add(XmlSerializable.class.getName()); - imports.add(XmlWriter.class.getName()); - imports.add(XmlReader.class.getName()); - imports.add(XmlToken.class.getName()); - } else { - imports.add(IOException.class.getName()); + return classSignature + " implements " + interfaceName + "<" + model.getName() + ">"; + } - ClassType.JSON_SERIALIZABLE.addImportsTo(imports, false); - ClassType.JSON_WRITER.addImportsTo(imports, false); - ClassType.JSON_READER.addImportsTo(imports, false); - ClassType.JSON_TOKEN.addImportsTo(imports, false); - } - - ClassType.CORE_UTILS.addImportsTo(imports, false); - - imports.add(ArrayList.class.getName()); - imports.add(Base64.class.getName()); - imports.add(LinkedHashMap.class.getName()); - imports.add(List.class.getName()); - imports.add(Map.class.getName()); - imports.add(Objects.class.getName()); + @Override + protected void addXmlNamespaceConstants(ClientModel model, JavaClass classBlock) { + if (model.getXmlName() == null) { + return; } - @Override - protected void handlePolymorphism(ClientModel model, boolean hasDerivedModels, JavaFile javaFile) { - // no-op as stream-style serialization doesn't need to add anything for polymorphic types. + Map constantMap = ClientModelUtil.xmlNamespaceToConstantMapping(model); + for (Map.Entry constant : constantMap.entrySet()) { + classBlock.privateStaticFinalVariable("String " + constant.getValue() + " = \"" + constant.getKey() + "\""); } + } - @Override - protected void addClassLevelAnnotations(ClientModel model, JavaFile javaFile, JavaSettings settings) { - // no-op as stream-style serialization doesn't add any class-level annotations. - } + static void xmlWrapperClassXmlSerializableImplementation(JavaClass classBlock, String wrapperClassName, + IType iterableType, String xmlRootElementName, String xmlRootElementNamespace, String xmlListElementName, + String xmlElementNameCamelCase, String xmlListElementNamespace, Consumer addGeneratedAnnotation) { + IType elementType = ((IterableType) iterableType).getElementType(); - @Override - protected String addSerializationImplementations(String classSignature, ClientModel model, JavaSettings settings) { - if (!settings.isStreamStyleSerialization() || model.isStronglyTypedHeader()) { - return classSignature; - } + addGeneratedAnnotation.accept(classBlock); + classBlock.annotation("Override"); + classBlock.publicMethod("XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException", + methodBlock -> methodBlock.methodReturn("toXml(xmlWriter, null)")); - String interfaceName = (model.getXmlName() != null) - ? XmlSerializable.class.getSimpleName() - : ClassType.JSON_SERIALIZABLE.getName(); + addGeneratedAnnotation.accept(classBlock); + classBlock.annotation("Override"); + classBlock.publicMethod("XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException", writerMethod -> { + writerMethod.line("rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? \"" + xmlRootElementName + "\" : rootElementName;"); + String writeStartElement = (xmlRootElementNamespace != null) + ? "xmlWriter.writeStartElement(\"" + xmlRootElementNamespace + "\", rootElementName);" + : "xmlWriter.writeStartElement(rootElementName);"; + writerMethod.line(writeStartElement); - return classSignature + " implements " + interfaceName + "<" + model.getName() + ">"; - } + writerMethod.ifBlock(xmlElementNameCamelCase + " != null", ifAction -> { + String xmlWrite = elementType.xmlSerializationMethodCall("xmlWriter", xmlListElementName, + xmlListElementNamespace, "element", false, false, false); + ifAction.line("for (%s element : %s) {", elementType, xmlElementNameCamelCase); + ifAction.indent(() -> ifAction.line(xmlWrite + ";")); + ifAction.line("}"); + }); - @Override - protected void addXmlNamespaceConstants(ClientModel model, JavaClass classBlock) { - if (model.getXmlName() == null) { - return; - } + writerMethod.methodReturn("xmlWriter.writeEndElement()"); + }); - Map constantMap = ClientModelUtil.xmlNamespaceToConstantMapping(model); - for (Map.Entry constant : constantMap.entrySet()) { - classBlock.privateStaticFinalVariable("String " + constant.getValue() + " = \"" + constant.getKey() + "\""); - } - } + addGeneratedAnnotation.accept(classBlock); + classBlock.publicStaticMethod(wrapperClassName + " fromXml(XmlReader xmlReader) throws XMLStreamException", + readerMethod -> readerMethod.methodReturn("fromXml(xmlReader, null)")); - static void xmlWrapperClassXmlSerializableImplementation(JavaClass classBlock, String wrapperClassName, - IType iterableType, String xmlRootElementName, String xmlRootElementNamespace, String xmlListElementName, - String xmlElementNameCamelCase, String xmlListElementNamespace, Consumer addGeneratedAnnotation) { - IType elementType = ((IterableType) iterableType).getElementType(); + addGeneratedAnnotation.accept(classBlock); + classBlock.publicStaticMethod(wrapperClassName + " fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException", readerMethod -> { + readerMethod.line("rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? \"" + xmlRootElementName + "\" : rootElementName;"); + String readObject = (xmlRootElementNamespace != null) + ? "return xmlReader.readObject(\"" + xmlRootElementNamespace + "\", rootElementName, reader -> {" + : "return xmlReader.readObject(rootElementName, reader -> {"; - addGeneratedAnnotation.accept(classBlock); - classBlock.annotation("Override"); - classBlock.publicMethod("XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException", - methodBlock -> methodBlock.methodReturn("toXml(xmlWriter, null)")); + readerMethod.line(readObject); + readerMethod.indent(() -> { + readerMethod.line(iterableType + " items = null;"); + readerMethod.line(); + readerMethod.line("while (reader.nextElement() != XmlToken.END_ELEMENT) {"); + readerMethod.indent(() -> { + readerMethod.line("QName elementName = reader.getElementName();"); + String condition = getXmlNameConditional(xmlListElementName, xmlListElementNamespace, "elementName", false); + readerMethod.line(); + readerMethod.ifBlock(condition, ifBlock -> { + ifBlock.ifBlock("items == null", ifBlock2 -> ifBlock2.line("items = new ArrayList<>();")); + ifBlock.line(); - addGeneratedAnnotation.accept(classBlock); - classBlock.annotation("Override"); - classBlock.publicMethod("XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException", writerMethod -> { - writerMethod.line("rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? \"" + xmlRootElementName + "\" : rootElementName;"); - String writeStartElement = (xmlRootElementNamespace != null) - ? "xmlWriter.writeStartElement(\"" + xmlRootElementNamespace + "\", rootElementName);" - : "xmlWriter.writeStartElement(rootElementName);"; - writerMethod.line(writeStartElement); - - writerMethod.ifBlock(xmlElementNameCamelCase + " != null", ifAction -> { - String xmlWrite = elementType.xmlSerializationMethodCall("xmlWriter", xmlListElementName, - xmlListElementNamespace, "element", false, false, false); - ifAction.line("for (%s element : %s) {", elementType, xmlElementNameCamelCase); - ifAction.indent(() -> ifAction.line(xmlWrite + ";")); - ifAction.line("}"); - }); - - writerMethod.methodReturn("xmlWriter.writeEndElement()"); + // TODO (alzimmer): Insert XML object reading logic. + ifBlock.line("items.add(" + getSimpleXmlDeserialization(elementType, "reader", null, null, + null, false) + ");"); + }).elseBlock(elseBlock -> elseBlock.line("reader.nextElement();")); }); + readerMethod.line("}"); - addGeneratedAnnotation.accept(classBlock); - classBlock.publicStaticMethod(wrapperClassName + " fromXml(XmlReader xmlReader) throws XMLStreamException", - readerMethod -> readerMethod.methodReturn("fromXml(xmlReader, null)")); + readerMethod.methodReturn("new " + wrapperClassName + "(items)"); + }); + readerMethod.line("});"); + }); + } - addGeneratedAnnotation.accept(classBlock); - classBlock.publicStaticMethod(wrapperClassName + " fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException", readerMethod -> { - readerMethod.line("rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? \"" + xmlRootElementName + "\" : rootElementName;"); - String readObject = (xmlRootElementNamespace != null) - ? "return xmlReader.readObject(\"" + xmlRootElementNamespace + "\", rootElementName, reader -> {" - : "return xmlReader.readObject(rootElementName, reader -> {"; + @Override + protected void addFieldAnnotations(ClientModel model, ClientModelProperty property, JavaClass classBlock, JavaSettings settings) { + // no-op as stream-style serialization doesn't add any field-level annotations. + } - readerMethod.line(readObject); - readerMethod.indent(() -> { - readerMethod.line(iterableType + " items = null;"); - readerMethod.line(); - readerMethod.line("while (reader.nextElement() != XmlToken.END_ELEMENT) {"); - readerMethod.indent(() -> { - readerMethod.line("QName elementName = reader.getElementName();"); - String condition = getXmlNameConditional(xmlListElementName, xmlListElementNamespace, "elementName", false); - readerMethod.line(); - readerMethod.ifBlock(condition, ifBlock -> { - ifBlock.ifBlock("items == null", ifBlock2 -> ifBlock2.line("items = new ArrayList<>();")); - ifBlock.line(); + @Override + protected void writeStreamStyleSerialization(JavaClass classBlock, ClientModel model, JavaSettings settings) { + // Early out as strongly-typed headers do their own thing. + if (model.isStronglyTypedHeader()) { + return; + } - // TODO (alzimmer): Insert XML object reading logic. - ifBlock.line("items.add(" + getSimpleXmlDeserialization(elementType, "reader", null, null, - null, false) + ");"); - }).elseBlock(elseBlock -> elseBlock.line("reader.nextElement();")); - }); - readerMethod.line("}"); + ClientModelPropertiesManager propertiesManager = new ClientModelPropertiesManager(model, settings); - readerMethod.methodReturn("new " + wrapperClassName + "(items)"); - }); - readerMethod.line("});"); + if (model.getXmlName() != null) { + writeToXml(classBlock, propertiesManager, Templates.getModelTemplate()::addGeneratedAnnotation); + writeFromXml(classBlock, model, propertiesManager, settings, + Templates.getModelTemplate()::addGeneratedAnnotation); + } else { + if (ClientModelUtil.isJsonMergePatchModel(model, settings)) { + writeToJson(classBlock, propertiesManager, true, Templates.getModelTemplate()::addGeneratedAnnotation); + writeToJsonMergePatch(classBlock, propertiesManager, + Templates.getModelTemplate()::addGeneratedAnnotation); + } else { + writeToJson(classBlock, propertiesManager, false, Templates.getModelTemplate()::addGeneratedAnnotation); + } + writeFromJson(classBlock, model, propertiesManager, settings, + Templates.getModelTemplate()::addGeneratedAnnotation); + if (isManagementErrorSubclass(model, settings)) { + writeManagementErrorDeserializationMethod(classBlock, propertiesManager, settings, + Templates.getModelTemplate()::addGeneratedAnnotation); + } + } + } + + /** + * For stream-style-serialization, we generate shadow properties for read-only properties that's not in constructor. + * @param model the model to generate class of + * @param settings JavaSettings + * @return properties to generate as fields of the class + */ + @Override + protected List getFieldProperties(ClientModel model, JavaSettings settings) { + List fieldProperties = super.getFieldProperties(model, settings); + + // If the model is polymorphic and all the models in the polymorphic hierarchy are in the same package we don't + // need to shade parent properties. + if (model.isPolymorphic() && model.isAllPolymorphicModelsInSamePackage()) { + return fieldProperties; + } + + Set propertySerializedNames = fieldProperties.stream().map(ClientModelProperty::getSerializedName) + .collect(Collectors.toSet()); + for (ClientModelProperty parentProperty : ClientModelUtil.getParentProperties(model, false)) { + if (propertySerializedNames.contains(parentProperty.getSerializedName())) { + continue; + } + propertySerializedNames.add(parentProperty.getSerializedName()); + if (!parentProperty.isPolymorphicDiscriminator() // parent discriminators are already passed to children, see @see in method javadoc + && ClientModelUtil.readOnlyNotInCtor(model, parentProperty, settings) // we shadow parent read-only properties in child class + || parentProperty.getClientFlatten()) { // we shadow parent flattened property in child class + fieldProperties.add(parentProperty); + } + } + return fieldProperties; + } + + /** + * Get the property reference referring to the local(field) flattened property. + * Additionally, in Stream-Style, parent property reference count as well. Since in Stream-Style, the flattened model property + * will be shadowed in child class. + * For example, for the property1FromParent collected by {@link #getClientModelPropertyReferences(ClientModel)} on model2, + * it looks like: + *
{@code
+   *         FlattenedProperties
+   *          - property1                    <--------------
+   *                                                       |
+   *         Model1                                        |
+   *          - innerProperties: FlattenProperties         |
+   *          - property1FromFlatten    ^    <--           |
+   *              - referenceProperty   |      |       ----|
+   *              - targetProperty    ---      |
+   *                                           |
+   *         Model2 extends Model1             |
+   *          (- property1FromParent)          |
+   *              - referenceProperty      ----|
+   *              - targetProperty -> null
+   * }
+   * 
+ * If called on property1FromParent collected from Model2, property1FromFlatten will be returned. + * If this method is called on property1FromFlatten collected from Model1, itself will be returned. + * + * @param propertyReference propertyReference collected by {@link #getClientModelPropertyReferences(ClientModel)} + * @return the property reference referring to the local(field) flattened property, or parent flattening property reference, + * null if neither + */ + @Override + protected ClientModelPropertyReference getLocalFlattenedModelPropertyReference(ClientModelPropertyReference propertyReference) { + if (propertyReference.isFromFlattenedProperty()) { + return propertyReference; + } else if (propertyReference.isFromParentModel()) { + ClientModelPropertyAccess parentProperty = propertyReference.getReferenceProperty(); // parent property + if (parentProperty instanceof ClientModelPropertyReference && ((ClientModelPropertyReference) parentProperty).isFromFlattenedProperty()) { + return (ClientModelPropertyReference) parentProperty; + } + } + // Not a flattening property, return null. + return null; + } + + @Override + protected List getSuperSetters(ClientModel model, JavaSettings settings, List propertyReferences) { + return super.getSuperSetters(model, settings, propertyReferences) + .stream() + // If the propertyReference is flattening property, then in Stream-Style we generate local getter/setter + // for it, thus we don't need to generate super setter. + .filter(propertyReference -> + !((propertyReference instanceof ClientModelPropertyReference) + && ((ClientModelPropertyReference) propertyReference).isFromFlattenedProperty())) + .collect(Collectors.toList()); + } + + @Override + protected boolean callParentValidate(String parentModelName) { + // in stream-style-serialization, since there are shadowing involved, we validate all properties locally + return false; + } + + @Override + protected List getValidationProperties(ClientModel model) { + // in stream-style-serialization, since there are shadowing involved, we validate all properties locally + return Stream.concat(model.getProperties().stream(), ClientModelUtil.getParentProperties(model).stream()) + .collect(Collectors.toList()); + } + + /** + * write toJson() method. + *

+ * If it is a JsonMergePatch model, toJson() should first check jsonMergePatch flag value and then do serialization + * accordingly. + * + * @param classBlock The class block to write the toJson method to. + * @param propertiesManager The properties manager for the model. + * @param isJsonMergePatch Whether the serialization is for a JSON merge patch. + * @param addGeneratedAnnotation The consumer to add the generated annotation to the class block. + */ + private static void writeToJson(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, + boolean isJsonMergePatch, Consumer addGeneratedAnnotation) { + boolean callToJsonSharedForParentProperties = !isJsonMergePatch + && propertiesManager.getModel().isAllPolymorphicModelsInSamePackage() + && !CoreUtils.isNullOrEmpty(propertiesManager.getModel().getParentModelName()); + boolean callToJsonSharedForThisProperties = !isJsonMergePatch + && propertiesManager.getModel().isAllPolymorphicModelsInSamePackage() + && propertiesManager.getModel().isPolymorphicParent(); + + classBlock.javadocComment(JavaJavadocComment::inheritDoc); + addGeneratedAnnotation.accept(classBlock); + classBlock.annotation("Override"); + classBlock.publicMethod("JsonWriter toJson(JsonWriter jsonWriter) throws IOException", methodBlock -> { + if (isJsonMergePatch) { + // If the model is the root parent use the JSON merge patch serialization tracking property directly, + // otherwise use the access helper to determine whether to use JSON merge patch serialization. + ClientModel rootParent = ClientModelUtil.getRootParent(propertiesManager.getModel()); + String ifStatement = (rootParent == propertiesManager.getModel()) + ? "jsonMergePatch" + : JSON_MERGE_PATCH_HELPER_CLASS_NAME + ".get" + rootParent.getName() + "Accessor().isJsonMergePatch(this)"; + + methodBlock.ifBlock(ifStatement, ifBlock -> ifBlock.methodReturn("toJsonMergePatch(jsonWriter)")) + .elseBlock(elseBlock -> serializeJsonProperties(methodBlock, propertiesManager, false, false, false)); + } else { + // For polymorphic models, when all models are contained in the same package, a package-private 'toJsonShared' + // method will be generated by parent models that handles serialization of properties defined by the parent + // model. + // So, if we have that case, we skip serializing the properties defined by the parent model(s) and instead call + // the 'toJsonShared' method to serialize those properties. And, for properties defined by this model, if the + // model is a parent model generate a 'toJsonShared' method to serialize those properties. + // + // At this time, due to implementation complexity and the low value add, JSON merge patch serialization won't + // support 'toJsonMergePatchShared'. JSON merge patch serialization has low usage, and combined with the low + // usage of polymorphism as well, there isn't a large expectation for this feature. + serializeJsonProperties(methodBlock, propertiesManager, false, callToJsonSharedForParentProperties, + callToJsonSharedForThisProperties); + } + }); + + // If this model is defining a 'toJsonShared' method, write it. + if (callToJsonSharedForThisProperties) { + classBlock.packagePrivateMethod("void toJsonShared(JsonWriter jsonWriter) throws IOException", methodBlock -> { + if (callToJsonSharedForParentProperties) { + methodBlock.line("super.toJsonShared(jsonWriter);"); + } + + serializeThisJsonProperties(propertiesManager, (property, fromSuper) -> serializeJsonProperty( + methodBlock, property, property.getSerializedName(), fromSuper, true, false), methodBlock, + callToJsonSharedForParentProperties); + }); + } + } + + /** + * write toJsonMergePatch() method + * + * @param classBlock The class block to write the toJsonMergePatch method to. + * @param propertiesManager The properties manager for the model. + * @param addGeneratedAnnotation The consumer to add the generated annotation to the class block. + */ + private static void writeToJsonMergePatch(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, + Consumer addGeneratedAnnotation) { + addGeneratedAnnotation.accept(classBlock); + classBlock.privateMethod("JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException", + methodBlock -> serializeJsonProperties(methodBlock, propertiesManager, true, false, false)); + } + + /** + * Serializes the properties of a model to JSON. + * @param methodBlock The method block to write the serialization method to. + * @param propertiesManager The properties manager for the model. + * @param isJsonMergePatch Whether the serialization is for a JSON merge patch. + */ + private static void serializeJsonProperties(JavaBlock methodBlock, ClientModelPropertiesManager propertiesManager, + boolean isJsonMergePatch, boolean callToJsonSharedForParentProperties, + boolean callToJsonSharedForThisProperties) { + methodBlock.line("jsonWriter.writeStartObject();"); + + // If we're calling toJsonShared for this model and for parent properties, this is an early out. + if (callToJsonSharedForParentProperties && callToJsonSharedForThisProperties) { + methodBlock.line("toJsonShared(jsonWriter);"); + methodBlock.methodReturn("jsonWriter.writeEndObject()"); + return; + } + + BiConsumer serializeJsonProperty = (property, fromSuper) -> serializeJsonProperty( + methodBlock, property, property.getSerializedName(), fromSuper, true, isJsonMergePatch); + + if (callToJsonSharedForParentProperties) { + methodBlock.line("toJsonShared(jsonWriter);"); + } else { + serializeParentJsonProperties(propertiesManager, serializeJsonProperty); + } + + if (callToJsonSharedForThisProperties) { + methodBlock.line("toJsonShared(jsonWriter);"); + } else { + serializeThisJsonProperties(propertiesManager, serializeJsonProperty, methodBlock, + callToJsonSharedForParentProperties); + } + + + methodBlock.methodReturn("jsonWriter.writeEndObject()"); + } + + private static void serializeParentJsonProperties(ClientModelPropertiesManager propertiesManager, + BiConsumer serializeJsonProperty) { + propertiesManager.getModel() + .getParentPolymorphicDiscriminators() + .forEach(discriminator -> serializeJsonProperty.accept(discriminator, false)); + propertiesManager.forEachSuperRequiredProperty(property -> serializeJsonProperty.accept(property, true)); + propertiesManager.forEachSuperSetterProperty(property -> serializeJsonProperty.accept(property, true)); + } + + private static void serializeThisJsonProperties(ClientModelPropertiesManager propertiesManager, + BiConsumer serializeJsonProperty, JavaBlock methodBlock, + boolean callToJsonSharedForParentProperties) { + Consumer wrappedSerializer = property -> { + // Skip serializing the polymorphic discriminator if 'toJsonShared' is called to serialize properties + // defined by the parent model(s), the polymorphic discriminator isn't defined by this property, and + // all polymorphic models are in the same package. + // In this scenario, the logic for polymorphism is that the defining model has a package-private, non-final + // field for the discriminator which is set by either the deserialization logic or the constructor. + if (callToJsonSharedForParentProperties && property.isPolymorphicDiscriminator() + && propertiesManager.getModel().isAllPolymorphicModelsInSamePackage() + && !propertiesManager.getModel().isPolymorphicDiscriminatorDefinedByModel()) { + return; + } + + serializeJsonProperty.accept(property, false); + }; + + propertiesManager.forEachRequiredProperty(wrappedSerializer); + propertiesManager.forEachSetterProperty(wrappedSerializer); + + handleFlattenedPropertiesSerialization(methodBlock, propertiesManager.getJsonFlattenedPropertiesTree(), false, + callToJsonSharedForParentProperties); + + if (getAdditionalPropertiesPropertyInModelOrFromSuper(propertiesManager) != null) { + String additionalPropertiesAccessExpr = propertiesManager.getAdditionalProperties() != null + ? propertiesManager.getAdditionalProperties().getName() + : propertiesManager.getSuperAdditionalPropertiesProperty().getGetterName() + "()"; + IType wireType = propertiesManager.getAdditionalProperties() != null + ? propertiesManager.getAdditionalProperties().getWireType() + : propertiesManager.getSuperAdditionalPropertiesProperty().getWireType(); + + methodBlock.ifBlock(additionalPropertiesAccessExpr + " != null", ifAction -> { + IType valueType = ((MapType) wireType).getValueType().asNullable(); + ifAction.line("for (Map.Entry additionalProperty : %s.entrySet()) {", valueType, additionalPropertiesAccessExpr); + ifAction.indent(() -> { + if (valueType == ClassType.BINARY_DATA) { + // Special handling for BinaryData + ifAction.line("jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue() == null ? null : additionalProperty.getValue().toObject(Object.class));"); + } else { + ifAction.line("jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue());"); + } }); + ifAction.line("}"); + }); + } + } + + /** + * Serializes a non-flattened, non-additional properties JSON property. + *

+ * If the JSON property needs to be flattened or is additional properties this is a no-op as those require special + * handling that will occur later. + * + * @param methodBlock The method handling serialization. + * @param property The property being serialized. + * @param serializedName The serialized JSON property name. Generally, this is just the {@code property property's} + * serialized name but if a flattened property is being serialized it'll be the last segment of the flattened JSON + * name. + * @param fromSuperType Whether the property is defined by a super type of the model. If the property is declared by + * a super type a getter method will be used to retrieve the value instead of accessing the field directly. + * @param ignoreFlattening Whether flattened properties should be skipped. Will only be false when handling the + * terminal location of a flattened structure. + * @param isJsonMergePatch Whether the serialization is for a JSON Merge Patch model. + */ + private static void serializeJsonProperty(JavaBlock methodBlock, ClientModelProperty property, + String serializedName, boolean fromSuperType, boolean ignoreFlattening, boolean isJsonMergePatch) { + if ((ignoreFlattening && property.getNeedsFlatten()) || property.isAdditionalProperties()) { + // Property will be handled later by flattened or additional properties serialization. + return; } - @Override - protected void addFieldAnnotations(ClientModel model, ClientModelProperty property, JavaClass classBlock, JavaSettings settings) { - // no-op as stream-style serialization doesn't add any field-level annotations. + if (property.isReadOnly() && !property.isPolymorphicDiscriminator()) { + // Non-polymorphic discriminator, readonly properties are never serialized. + return; } - @Override - protected void writeStreamStyleSerialization(JavaClass classBlock, ClientModel model, JavaSettings settings) { - // Early out as strongly-typed headers do their own thing. - if (model.isStronglyTypedHeader()) { - return; - } - - ClientModelPropertiesManager propertiesManager = new ClientModelPropertiesManager(model, settings); - - if (model.getXmlName() != null) { - writeToXml(classBlock, propertiesManager, Templates.getModelTemplate()::addGeneratedAnnotation); - writeFromXml(classBlock, model, propertiesManager, settings, - Templates.getModelTemplate()::addGeneratedAnnotation); - } else { - if (ClientModelUtil.isJsonMergePatchModel(model, settings)) { - writeToJson(classBlock, propertiesManager, true, Templates.getModelTemplate()::addGeneratedAnnotation); - writeToJsonMergePatch(classBlock, propertiesManager, - Templates.getModelTemplate()::addGeneratedAnnotation); - } else { - writeToJson(classBlock, propertiesManager, false, Templates.getModelTemplate()::addGeneratedAnnotation); - } - writeFromJson(classBlock, model, propertiesManager, settings, - Templates.getModelTemplate()::addGeneratedAnnotation); - if (isManagementErrorSubclass(model, settings)) { - writeManagementErrorDeserializationMethod(classBlock, propertiesManager, settings, - Templates.getModelTemplate()::addGeneratedAnnotation); - } - } - } - - /** - * For stream-style-serialization, we generate shadow properties for read-only properties that's not in constructor. - * @param model the model to generate class of - * @param settings JavaSettings - * @return properties to generate as fields of the class - * @see ModelMapper#passPolymorphicDiscriminatorToChildren - */ - @Override - protected List getFieldProperties(ClientModel model, JavaSettings settings) { - List fieldProperties = super.getFieldProperties(model, settings); - Set propertySerializedNames = fieldProperties.stream().map(ClientModelProperty::getSerializedName).collect(Collectors.toSet()); - for (ClientModelProperty parentProperty : ClientModelUtil.getParentProperties(model, false)) { - if (propertySerializedNames.contains(parentProperty.getSerializedName())) { - continue; - } - propertySerializedNames.add(parentProperty.getSerializedName()); - if (!parentProperty.isPolymorphicDiscriminator() // parent discriminators are already passed to children, see @see in method javadoc - && readOnlyNotInCtor(model, parentProperty, settings) // we shadow parent read-only properties in child class - || parentProperty.getClientFlatten()) { // we shadow parent flattened property in child class - fieldProperties.add(parentProperty); - } - } - return fieldProperties; - } - - /** - * In stream-style-serialization, parent's read-only properties are shadowed in child classes. - * - * @param model the client model - * @param property the property to generate getter - * @param settings {@link JavaSettings} instance - * @param methodVisibility - * @return whether the property's getter overrides parent getter - */ - @Override - protected boolean overridesParentGetter(ClientModel model, ClientModelProperty property, JavaSettings settings, JavaVisibility methodVisibility) { - return !modelDefinesProperty(model, property) && (property.isPolymorphicDiscriminator() || readOnlyNotInCtor(model, property, settings)) - && methodVisibility == JavaVisibility.Public; - } - - /** - * Get the property reference referring to the local(field) flattened property. - * Additionally, in Stream-Style, parent property reference count as well. Since in Stream-Style, the flattened model property - * will be shadowed in child class. - * For example, for the property1FromParent collected by {@link #getClientModelPropertyReferences(ClientModel)} on model2, - * it looks like: - *

{@code
-     *         FlattenedProperties
-     *          - property1                    <--------------
-     *                                                       |
-     *         Model1                                        |
-     *          - innerProperties: FlattenProperties         |
-     *          - property1FromFlatten    ^    <--           |
-     *              - referenceProperty   |      |       ----|
-     *              - targetProperty    ---      |
-     *                                           |
-     *         Model2 extends Model1             |
-     *          (- property1FromParent)          |
-     *              - referenceProperty      ----|
-     *              - targetProperty -> null
-     * }
-     * 
- * If called on property1FromParent collected from Model2, property1FromFlatten will be returned. - * If this method is called on property1FromFlatten collected from Model1, itself will be returned. - * - * @param propertyReference propertyReference collected by {@link #getClientModelPropertyReferences(ClientModel)} - * @return the property reference referring to the local(field) flattened property, or parent flattening property reference, - * null if neither - */ - @Override - protected ClientModelPropertyReference getLocalFlattenedModelPropertyReference(ClientModelPropertyReference propertyReference) { - if (propertyReference.isFromFlattenedProperty()) { - return propertyReference; - } else if (propertyReference.isFromParentModel()) { - ClientModelPropertyAccess parentProperty = propertyReference.getReferenceProperty(); // parent property - if (parentProperty instanceof ClientModelPropertyReference && ((ClientModelPropertyReference) parentProperty).isFromFlattenedProperty()) { - return (ClientModelPropertyReference) parentProperty; - } - } - // Not a flattening property, return null. - return null; - } - - @Override - protected List getSuperSetters(ClientModel model, JavaSettings settings, List propertyReferences) { - return super.getSuperSetters(model, settings, propertyReferences) - .stream() - // If the propertyReference is flattening property, then in Stream-Style we generate local getter/setter - // for it, thus we don't need to generate super setter. - .filter(propertyReference -> - !((propertyReference instanceof ClientModelPropertyReference) - && ((ClientModelPropertyReference) propertyReference).isFromFlattenedProperty())) - .collect(Collectors.toList()); - } - - private static boolean readOnlyNotInCtor(ClientModel model, ClientModelProperty property, JavaSettings settings) { - return // not required and in constructor - !(property.isRequired() && settings.isRequiredFieldsAsConstructorArgs()) - && ( - // must be read-only and not appear in constructor - (property.isReadOnly() && !settings.isIncludeReadOnlyInConstructorArgs()) - // immutable output model only has package-private setters, making its properties read-only - || isImmutableOutputModel(getDefiningModel(model, property), settings)); - } - - @Override - protected boolean callParentValidate(String parentModelName) { - // in stream-style-serialization, since there are shadowing involved, we validate all properties locally - return false; - } - - @Override - protected List getValidationProperties(ClientModel model) { - // in stream-style-serialization, since there are shadowing involved, we validate all properties locally - return Stream.concat(model.getProperties().stream(), ClientModelUtil.getParentProperties(model).stream()) - .collect(Collectors.toList()); - } - - /** - * write toJson() method. - *

- * If it is a JsonMergePatch model, toJson() should first check jsonMergePatch flag value and then do serialization - * accordingly. - * - * @param classBlock The class block to write the toJson method to. - * @param propertiesManager The properties manager for the model. - * @param isJsonMergePatch Whether the serialization is for a JSON merge patch. - * @param addGeneratedAnnotation The consumer to add the generated annotation to the class block. - */ - private static void writeToJson(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, - boolean isJsonMergePatch, Consumer addGeneratedAnnotation) { - classBlock.javadocComment(JavaJavadocComment::inheritDoc); - addGeneratedAnnotation.accept(classBlock); - classBlock.annotation("Override"); - classBlock.publicMethod("JsonWriter toJson(JsonWriter jsonWriter) throws IOException", methodBlock -> { - if (isJsonMergePatch) { - // If the model is the root parent use the JSON merge patch serialization tracking property directly, - // otherwise use the access helper to determine whether to use JSON merge patch serialization. - ClientModel rootParent = ClientModelUtil.getRootParent(propertiesManager.getModel()); - String ifStatement = (rootParent == propertiesManager.getModel()) - ? "jsonMergePatch" - : JSON_MERGE_PATCH_HELPER_CLASS_NAME + ".get" + rootParent.getName() + "Accessor().isJsonMergePatch(this)"; - - methodBlock.ifBlock(ifStatement, ifBlock -> ifBlock.methodReturn("toJsonMergePatch(jsonWriter)")) - .elseBlock(elseBlock -> serializeJsonProperties(methodBlock, propertiesManager, false)); - } else { - serializeJsonProperties(methodBlock, propertiesManager, false); - } + if (isJsonMergePatch) { + if (!property.isPolymorphicDiscriminator()) { + methodBlock.ifBlock("updatedProperties.contains(\"" + property.getName() + "\")", codeBlock -> { + if (property.getClientType().isNullable()) { + codeBlock.ifBlock(getPropertyGetterStatement(property, fromSuperType) + " == null", + ifBlock -> ifBlock.line("jsonWriter.writeNullField(\"" + property.getSerializedName() + "\");")) + .elseBlock(elseBlock -> serializeJsonProperty(codeBlock, property, serializedName, fromSuperType, true)); + } else { + serializeJsonProperty(codeBlock, property, serializedName, fromSuperType, true, false); + } }); + } else { + serializeJsonProperty(methodBlock, property, serializedName, fromSuperType, true); + } + } else { + serializeJsonProperty(methodBlock, property, serializedName, fromSuperType, false); + } + } + + /** + * Serializes a non-flattened, non-additional properties JSON property. + *

+ * If the JSON property needs to be flattened or is additional properties this is a no-op as those require special + * handling that will occur later. + * + * @param methodBlock The method handling serialization. + * @param property The property being serialized. + * @param serializedName The serialized JSON property name. Generally, this is just the {@code property property's} + * serialized name but if a flattened property is being serialized it'll be the last segment of the flattened JSON + * name. + * @param fromSuperType Whether the property is defined by a super type of the model. If the property is declared by + * a super type a getter method will be used to retrieve the value instead of accessing the field directly. + * @param isJsonMergePatch Whether the serialization is for a JSON Merge Patch model. + */ + private static void serializeJsonProperty(JavaBlock methodBlock, ClientModelProperty property, + String serializedName, boolean fromSuperType, boolean isJsonMergePatch) { + IType clientType = property.getClientType(); + IType wireType = property.getWireType(); + String propertyValueGetter = getPropertyGetterStatement(property, fromSuperType); + + // Attempt to determine whether the wire type is simple serialization. + // This is primitives, boxed primitives, a small set of string based models, and other ClientModels. + String fieldSerializationMethod = wireType.jsonSerializationMethodCall("jsonWriter", serializedName, + propertyValueGetter, isJsonMergePatch); + if (wireType == ClassType.BINARY_DATA) { + // Special handling for BinaryData (instead of using "serializationMethodBase" and "serializationValueGetterModifier") + // The reason is that some backend would fail the request on "null" value (e.g. OpenAI) + String writeBinaryDataExpr = "jsonWriter.writeUntypedField(\"" + serializedName + "\", " + propertyValueGetter + ".toObject(Object.class));"; + if (!property.isRequired()) { + methodBlock.ifBlock(propertyValueGetter + " != null", ifAction -> ifAction.line(writeBinaryDataExpr)); + } else { + methodBlock.line(writeBinaryDataExpr); + } + } else if (fieldSerializationMethod != null) { + if (isJsonMergePatch && wireType instanceof ClassType && ((ClassType) wireType).isSwaggerType()) { + methodBlock.line("JsonMergePatchHelper.get" + clientType.toString() + "Accessor().prepareModelForJsonMergePatch(" + propertyValueGetter + ", true);"); + } + if (fromSuperType && clientType != wireType && clientType.isNullable()) { + // If the property is from a super type and the client type is different from the wire type then a null + // check is required to prevent a NullPointerException when converting the value. + methodBlock.ifBlock(property.getGetterName() + "() != null", + ifAction -> ifAction.line(fieldSerializationMethod + ";")); + } else { + methodBlock.line(fieldSerializationMethod + ";"); + } + if (isJsonMergePatch && wireType instanceof ClassType && ((ClassType) wireType).isSwaggerType()) { + methodBlock.line("JsonMergePatchHelper.get" + clientType.toString() + "Accessor().prepareModelForJsonMergePatch(" + propertyValueGetter + ", false);"); + } + } else if (wireType == ClassType.OBJECT) { + methodBlock.line("jsonWriter.writeUntypedField(\"" + serializedName + "\", " + propertyValueGetter + ");"); + } else if (wireType instanceof IterableType) { + serializeJsonContainerProperty(methodBlock, "writeArrayField", wireType, ((IterableType) wireType).getElementType(), + serializedName, propertyValueGetter, 0, isJsonMergePatch); + } else if (wireType instanceof MapType) { + // Assumption is that the key type for the Map is a String. This may not always hold true and when that + // becomes reality this will need to be reworked to handle that case. + serializeJsonContainerProperty(methodBlock, "writeMapField", wireType, ((MapType) wireType).getValueType(), + serializedName, propertyValueGetter, 0, isJsonMergePatch); + } else { + // TODO (alzimmer): Resolve this as deserialization logic generation needs to handle all cases. + throw new RuntimeException("Unknown wire type " + wireType + " in serialization. Need to add support for it."); + } + } + + /** + * Helper function to get property getter statement. + *

+ * If the value is from super type, then we will return "getProperty()", otherwise, return "this.property" + * + * @param property The property being serialized. + * @param fromSuperType Whether the property is defined by a super type of the model. + * @return The property getter statement. + */ + private static String getPropertyGetterStatement(ClientModelProperty property, boolean fromSuperType) { + IType clientType = property.getClientType(); + IType wireType = property.getWireType(); + if (fromSuperType) { + return (clientType != wireType) + ? wireType.convertFromClientType(property.getGetterName() + "()") : property.getGetterName() + "()"; + } else { + return "this." + property.getName(); + } + } + + /** + * Helper method to serialize a JSON container property (such as {@link List} and {@link Map}). + * + * @param methodBlock The method handling serialization. + * @param utilityMethod The method aiding in the serialization of the container. + * @param containerType The container type. + * @param elementType The element type for the container, for a {@link List} this is the element type and for a + * {@link Map} this is the value type. + * @param serializedName The serialized property name. + * @param propertyValueGetter The property or property getter for the field being serialized. + * @param depth Depth of recursion for container types, such as {@code Map>} would be 0 when + * {@code Map} is being handled and then 1 when {@code List} is being handled. + * @param isJsonMergePatch Whether the serialization is for a JSON Merge Patch model. + */ + private static void serializeJsonContainerProperty(JavaBlock methodBlock, String utilityMethod, IType containerType, + IType elementType, String serializedName, String propertyValueGetter, int depth, boolean isJsonMergePatch) { + String callingWriterName = depth == 0 ? "jsonWriter" : (depth == 1) ? "writer" : "writer" + (depth - 1); + String lambdaWriterName = depth == 0 ? "writer" : "writer" + depth; + String elementName = depth == 0 ? "element" : "element" + depth; + String valueSerializationMethod = elementType.jsonSerializationMethodCall(lambdaWriterName, null, elementName, + isJsonMergePatch); + String serializeValue = depth == 0 ? propertyValueGetter + : ((depth == 1) ? "element" : "element" + (depth - 1)); + + // First call into serialize container property will need to write the property name. Subsequent calls must + // not write the property name as that would be invalid, ex "myList":["myList":["innerListElement"]]. + if (depth == 0) { + // Container property shouldn't be written if it's null. + methodBlock.line("%s.%s(\"%s\", %s, (%s, %s) -> ", callingWriterName, utilityMethod, serializedName, + serializeValue, lambdaWriterName, elementName); + } else { + // But the inner container should be written if it's null. + methodBlock.line("%s.%s(%s, (%s, %s) -> ", callingWriterName, utilityMethod, serializeValue, + lambdaWriterName, elementName); } - /** - * write toJsonMergePatch() method - * - * @param classBlock The class block to write the toJsonMergePatch method to. - * @param propertiesManager The properties manager for the model. - * @param addGeneratedAnnotation The consumer to add the generated annotation to the class block. - */ - private static void writeToJsonMergePatch(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, - Consumer addGeneratedAnnotation) { - addGeneratedAnnotation.accept(classBlock); - classBlock.privateMethod("JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException", - methodBlock -> serializeJsonProperties(methodBlock, propertiesManager, true)); - } - - /** - * Serializes the properties of a model to JSON. - * @param methodBlock The method block to write the serialization method to. - * @param propertiesManager The properties manager for the model. - * @param isJsonMergePatch Whether the serialization is for a JSON merge patch. - */ - private static void serializeJsonProperties(JavaBlock methodBlock, ClientModelPropertiesManager propertiesManager, - boolean isJsonMergePatch) { - methodBlock.line("jsonWriter.writeStartObject();"); - - BiConsumer serializeJsonProperty = (property, fromSuper) -> serializeJsonProperty( - methodBlock, property, property.getSerializedName(), fromSuper, true, isJsonMergePatch); - - propertiesManager.getModel().getParentPolymorphicDiscriminators() - .forEach(discriminator -> serializeJsonProperty.accept(discriminator, false)); - propertiesManager.forEachSuperRequiredProperty(property -> serializeJsonProperty.accept(property, true)); - propertiesManager.forEachSuperSetterProperty(property -> serializeJsonProperty.accept(property, true)); - propertiesManager.forEachRequiredProperty(property -> serializeJsonProperty.accept(property, false)); - propertiesManager.forEachSetterProperty(property -> serializeJsonProperty.accept(property, false)); - - handleFlattenedPropertiesSerialization(methodBlock, propertiesManager.getJsonFlattenedPropertiesTree(), isJsonMergePatch); - - if (getAdditionalPropertiesPropertyInModelOrFromSuper(propertiesManager) != null) { - String additionalPropertiesAccessExpr = propertiesManager.getAdditionalProperties() != null - ? propertiesManager.getAdditionalProperties().getName() - : propertiesManager.getSuperAdditionalPropertiesProperty().getGetterName() + "()"; - IType wireType = propertiesManager.getAdditionalProperties() != null - ? propertiesManager.getAdditionalProperties().getWireType() - : propertiesManager.getSuperAdditionalPropertiesProperty().getWireType(); - - methodBlock.ifBlock(additionalPropertiesAccessExpr + " != null", ifAction -> { - IType valueType = ((MapType) wireType).getValueType().asNullable(); - ifAction.line("for (Map.Entry additionalProperty : %s.entrySet()) {", valueType, additionalPropertiesAccessExpr); - ifAction.indent(() -> { - if (valueType == ClassType.BINARY_DATA) { - // Special handling for BinaryData - ifAction.line("jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue() == null ? null : additionalProperty.getValue().toObject(Object.class));"); - } else { - ifAction.line("jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue());"); - } - }); - ifAction.line("}"); - }); - } - - methodBlock.methodReturn("jsonWriter.writeEndObject()"); - } - - /** - * Serializes a non-flattened, non-additional properties JSON property. - *

- * If the JSON property needs to be flattened or is additional properties this is a no-op as those require special - * handling that will occur later. - * - * @param methodBlock The method handling serialization. - * @param property The property being serialized. - * @param serializedName The serialized JSON property name. Generally, this is just the {@code property property's} - * serialized name but if a flattened property is being serialized it'll be the last segment of the flattened JSON - * name. - * @param fromSuperType Whether the property is defined by a super type of the model. If the property is declared by - * a super type a getter method will be used to retrieve the value instead of accessing the field directly. - * @param ignoreFlattening Whether flattened properties should be skipped. Will only be false when handling the - * terminal location of a flattened structure. - * @param isJsonMergePatch Whether the serialization is for a JSON Merge Patch model. - */ - private static void serializeJsonProperty(JavaBlock methodBlock, ClientModelProperty property, - String serializedName, boolean fromSuperType, boolean ignoreFlattening, boolean isJsonMergePatch) { - if ((ignoreFlattening && property.getNeedsFlatten()) || property.isAdditionalProperties()) { - // Property will be handled later by flattened or additional properties serialization. - return; - } - - if (property.isReadOnly() && !property.isPolymorphicDiscriminator()) { - // Non-polymorphic discriminator, readonly properties are never serialized. - return; - } - - if (isJsonMergePatch) { - if (!property.isPolymorphicDiscriminator()) { - methodBlock.ifBlock("updatedProperties.contains(\"" + property.getName() + "\")", codeBlock -> { - if (property.getClientType().isNullable()) { - codeBlock.ifBlock(getPropertyGetterStatement(property, fromSuperType) + " == null", - ifBlock -> ifBlock.line("jsonWriter.writeNullField(\"" + property.getSerializedName() + "\");")) - .elseBlock(elseBlock -> serializeJsonProperty(codeBlock, property, serializedName, fromSuperType, true)); - } else { - serializeJsonProperty(codeBlock, property, serializedName, fromSuperType, true, false); - } - }); - } else { - serializeJsonProperty(methodBlock, property, serializedName, fromSuperType, true); + methodBlock.indent(() -> { + if (valueSerializationMethod != null) { + if (isJsonMergePatch && containerType instanceof MapType) { + methodBlock.block("", codeBlock -> codeBlock.ifBlock(elementName + "!= null", ifBlock -> { + if (elementType instanceof ClassType && ((ClassType) elementType).isSwaggerType()) { + methodBlock.line("JsonMergePatchHelper.get" + ((ClassType) elementType).getName() + "Accessor().prepareModelForJsonMergePatch(" + elementName + ", true);"); } + ifBlock.line(valueSerializationMethod + ";"); + if (elementType instanceof ClassType && ((ClassType) elementType).isSwaggerType()) { + methodBlock.line("JsonMergePatchHelper.get" + ((ClassType) elementType).getName() + "Accessor().prepareModelForJsonMergePatch(" + elementName + ", false);"); + } + }).elseBlock(elseBlock -> elseBlock.line(lambdaWriterName + ".writeNull();"))); } else { - serializeJsonProperty(methodBlock, property, serializedName, fromSuperType, false); + methodBlock.line(valueSerializationMethod); } + } else if (elementType == ClassType.OBJECT) { + methodBlock.line(lambdaWriterName + ".writeUntyped(" + elementName + ")"); + } else if (elementType instanceof IterableType) { + serializeJsonContainerProperty(methodBlock, "writeArray", elementType, ((IterableType) elementType).getElementType(), + serializedName, propertyValueGetter, depth + 1, isJsonMergePatch); + } else if (elementType instanceof MapType) { + // Assumption is that the key type for the Map is a String. This may not always hold true and when that + // becomes reality this will need to be reworked to handle that case. + serializeJsonContainerProperty(methodBlock, "writeMap", elementType, ((MapType) elementType).getValueType(), + serializedName, propertyValueGetter, depth + 1, isJsonMergePatch); + } else if (elementType == ClassType.BINARY_DATA) { + methodBlock.line(lambdaWriterName + ".writeUntyped(" + elementName + ")"); + } else { + throw new RuntimeException("Unknown value type " + elementType + " in " + containerType + + " serialization. Need to add support for it."); + } + }); + + if (depth > 0) { + methodBlock.line(")"); + } else { + methodBlock.line(");"); } + } - /** - * Serializes a non-flattened, non-additional properties JSON property. - *

- * If the JSON property needs to be flattened or is additional properties this is a no-op as those require special - * handling that will occur later. - * - * @param methodBlock The method handling serialization. - * @param property The property being serialized. - * @param serializedName The serialized JSON property name. Generally, this is just the {@code property property's} - * serialized name but if a flattened property is being serialized it'll be the last segment of the flattened JSON - * name. - * @param fromSuperType Whether the property is defined by a super type of the model. If the property is declared by - * a super type a getter method will be used to retrieve the value instead of accessing the field directly. - * @param isJsonMergePatch Whether the serialization is for a JSON Merge Patch model. - */ - private static void serializeJsonProperty(JavaBlock methodBlock, ClientModelProperty property, - String serializedName, boolean fromSuperType, boolean isJsonMergePatch) { - IType clientType = property.getClientType(); - IType wireType = property.getWireType(); - String propertyValueGetter = getPropertyGetterStatement(property, fromSuperType); - - // Attempt to determine whether the wire type is simple serialization. - // This is primitives, boxed primitives, a small set of string based models, and other ClientModels. - String fieldSerializationMethod = wireType.jsonSerializationMethodCall("jsonWriter", serializedName, - propertyValueGetter, isJsonMergePatch); - if (wireType == ClassType.BINARY_DATA) { - // Special handling for BinaryData (instead of using "serializationMethodBase" and "serializationValueGetterModifier") - // The reason is that some backend would fail the request on "null" value (e.g. OpenAI) - String writeBinaryDataExpr = "jsonWriter.writeUntypedField(\"" + serializedName + "\", " + propertyValueGetter + ".toObject(Object.class));"; - if (!property.isRequired()) { - methodBlock.ifBlock(propertyValueGetter + " != null", ifAction -> ifAction.line(writeBinaryDataExpr)); - } else { - methodBlock.line(writeBinaryDataExpr); - } - } else if (fieldSerializationMethod != null) { - if (isJsonMergePatch && wireType instanceof ClassType && ((ClassType) wireType).isSwaggerType()) { - methodBlock.line("JsonMergePatchHelper.get" + clientType.toString() + "Accessor().prepareModelForJsonMergePatch(" + propertyValueGetter + ", true);"); - } - if (fromSuperType && clientType != wireType && clientType.isNullable()) { - // If the property is from a super type and the client type is different from the wire type then a null - // check is required to prevent a NullPointerException when converting the value. - methodBlock.ifBlock(property.getGetterName() + "() != null", - ifAction -> ifAction.line(fieldSerializationMethod + ";")); - } else { - methodBlock.line(fieldSerializationMethod + ";"); - } - if (isJsonMergePatch && wireType instanceof ClassType && ((ClassType) wireType).isSwaggerType()) { - methodBlock.line("JsonMergePatchHelper.get" + clientType.toString() + "Accessor().prepareModelForJsonMergePatch(" + propertyValueGetter + ", false);"); - } - } else if (wireType == ClassType.OBJECT) { - methodBlock.line("jsonWriter.writeUntypedField(\"" + serializedName + "\", " + propertyValueGetter + ");"); - } else if (wireType instanceof IterableType) { - serializeJsonContainerProperty(methodBlock, "writeArrayField", wireType, ((IterableType) wireType).getElementType(), - serializedName, propertyValueGetter, 0, isJsonMergePatch); - } else if (wireType instanceof MapType) { - // Assumption is that the key type for the Map is a String. This may not always hold true and when that - // becomes reality this will need to be reworked to handle that case. - serializeJsonContainerProperty(methodBlock, "writeMapField", wireType, ((MapType) wireType).getValueType(), - serializedName, propertyValueGetter, 0, isJsonMergePatch); - } else { - // TODO (alzimmer): Resolve this as deserialization logic generation needs to handle all cases. - throw new RuntimeException("Unknown wire type " + wireType + " in serialization. Need to add support for it."); - } + /** + * Helper method to serialize flattened properties in a model. + *

+ * Flattened properties are unique as for each level of flattening they'll create a JSON sub-object. But before a + * sub-object is created any field needs to be checked for either being a primitive value or non-null. Primitive + * values are usually serialized no matter their value so those will automatically trigger the JSON sub-object to be + * created, nullable values will be checked for being non-null. + *

+ * In addition to primitive or non-null checking fields, all properties from the same JSON sub-object must be + * written at the same time to prevent an invalid JSON structure. For example if a model has three flattened + * properties with JSON paths "im.flattened", "im.deeper.flattened", and "im.deeper.flattenedtoo" this will create + * the following structure: + * + *

+   * im -> flattened
+   *     | deeper -> flattened
+   *               | flattenedtoo
+   * 
+ * + * So, "im.deeper.flattened" and "im.deeper.flattenedtoo" will need to be serialized at the same time to get the + * correct JSON where there is only one "im: deeper" JSON sub-object. + * + * @param methodBlock The method handling serialization. + * @param flattenedProperties The flattened properties structure. + * @param isJsonMergePatch Whether the serialization is for a JSON merge patch model. + */ + private static void handleFlattenedPropertiesSerialization(JavaBlock methodBlock, + JsonFlattenedPropertiesTree flattenedProperties, boolean isJsonMergePatch, + boolean callToJsonSharedForParentProperties) { + // The initial call to handle flattened properties is using the base node which is just a holder. + for (JsonFlattenedPropertiesTree flattened : flattenedProperties.getChildrenNodes().values()) { + handleFlattenedPropertiesSerializationHelper(methodBlock, flattened, isJsonMergePatch, + callToJsonSharedForParentProperties); } + } - /** - * Helper function to get property getter statement. - *

- * If the value is from super type, then we will return "getProperty()", otherwise, return "this.property" - * - * @param property The property being serialized. - * @param fromSuperType Whether the property is defined by a super type of the model. - * @return The property getter statement. - */ - private static String getPropertyGetterStatement(ClientModelProperty property, boolean fromSuperType) { - IType clientType = property.getClientType(); - IType wireType = property.getWireType(); - if (fromSuperType) { - return (clientType != wireType) - ? wireType.convertFromClientType(property.getGetterName() + "()") : property.getGetterName() + "()"; - } else { - return "this." + property.getName(); - } - } + private static void handleFlattenedPropertiesSerializationHelper(JavaBlock methodBlock, + JsonFlattenedPropertiesTree flattenedProperties, boolean isJsonMergePatch, + boolean callToJsonSharedForParentProperties) { + ClientModelPropertyWithMetadata flattenedProperty = flattenedProperties.getProperty(); + if (flattenedProperty != null) { + // This is a terminal location, only need to add property serialization. + serializeJsonProperty(methodBlock, flattenedProperty.getProperty(), flattenedProperties.getNodeName(), + flattenedProperty.isFromSuperClass(), false, isJsonMergePatch); + } else { + // Otherwise this is an intermediate location. + // Check for either any of the properties in this subtree being primitives or add an if block checking that + // any of the properties are non-null. + List propertiesInFlattenedGroup = + getClientModelPropertiesInJsonTree(flattenedProperties); + boolean hasPrimitivePropertyInGroup = false; + boolean allPropertiesInGroupFromParent = true; + for (ClientModelPropertyWithMetadata propertyInFlattenedGroup : propertiesInFlattenedGroup) { + hasPrimitivePropertyInGroup |= propertyInFlattenedGroup.getProperty().getWireType() instanceof PrimitiveType; + allPropertiesInGroupFromParent &= propertyInFlattenedGroup.isFromSuperClass(); + } - /** - * Helper method to serialize a JSON container property (such as {@link List} and {@link Map}). - * - * @param methodBlock The method handling serialization. - * @param utilityMethod The method aiding in the serialization of the container. - * @param containerType The container type. - * @param elementType The element type for the container, for a {@link List} this is the element type and for a - * {@link Map} this is the value type. - * @param serializedName The serialized property name. - * @param propertyValueGetter The property or property getter for the field being serialized. - * @param depth Depth of recursion for container types, such as {@code Map>} would be 0 when - * {@code Map} is being handled and then 1 when {@code List} is being handled. - * @param isJsonMergePatch Whether the serialization is for a JSON Merge Patch model. - */ - private static void serializeJsonContainerProperty(JavaBlock methodBlock, String utilityMethod, IType containerType, - IType elementType, String serializedName, String propertyValueGetter, int depth, boolean isJsonMergePatch) { - String callingWriterName = depth == 0 ? "jsonWriter" : (depth == 1) ? "writer" : "writer" + (depth - 1); - String lambdaWriterName = depth == 0 ? "writer" : "writer" + depth; - String elementName = depth == 0 ? "element" : "element" + depth; - String valueSerializationMethod = elementType.jsonSerializationMethodCall(lambdaWriterName, null, elementName, - isJsonMergePatch); - String serializeValue = depth == 0 ? propertyValueGetter - : ((depth == 1) ? "element" : "element" + (depth - 1)); + if (callToJsonSharedForParentProperties && allPropertiesInGroupFromParent) { + // If all properties in the flattened group are from the parent model, then the call to the parent's + // 'toJsonShared' method will serialize the properties, skip writing serialization logic for this + // method. + return; + } - // First call into serialize container property will need to write the property name. Subsequent calls must - // not write the property name as that would be invalid, ex "myList":["myList":["innerListElement"]]. - if (depth == 0) { - // Container property shouldn't be written if it's null. - methodBlock.line("%s.%s(\"%s\", %s, (%s, %s) -> ", callingWriterName, utilityMethod, serializedName, - serializeValue, lambdaWriterName, elementName); - } else { - // But the inner container should be written if it's null. - methodBlock.line("%s.%s(%s, (%s, %s) -> ", callingWriterName, utilityMethod, serializeValue, - lambdaWriterName, elementName); - } - - methodBlock.indent(() -> { - if (valueSerializationMethod != null) { - if (isJsonMergePatch && containerType instanceof MapType) { - methodBlock.block("", codeBlock -> codeBlock.ifBlock(elementName + "!= null", ifBlock -> { - if (elementType instanceof ClassType && ((ClassType) elementType).isSwaggerType()) { - methodBlock.line("JsonMergePatchHelper.get" + ((ClassType) elementType).getName() + "Accessor().prepareModelForJsonMergePatch(" + elementName + ", true);"); - } - ifBlock.line(valueSerializationMethod + ";"); - if (elementType instanceof ClassType && ((ClassType) elementType).isSwaggerType()) { - methodBlock.line("JsonMergePatchHelper.get" + ((ClassType) elementType).getName() + "Accessor().prepareModelForJsonMergePatch(" + elementName + ", false);"); - } - }).elseBlock(elseBlock -> elseBlock.line(lambdaWriterName + ".writeNull();"))); - } else { - methodBlock.line(valueSerializationMethod); - } - } else if (elementType == ClassType.OBJECT) { - methodBlock.line(lambdaWriterName + ".writeUntyped(" + elementName + ")"); - } else if (elementType instanceof IterableType) { - serializeJsonContainerProperty(methodBlock, "writeArray", elementType, ((IterableType) elementType).getElementType(), - serializedName, propertyValueGetter, depth + 1, isJsonMergePatch); - } else if (elementType instanceof MapType) { - // Assumption is that the key type for the Map is a String. This may not always hold true and when that - // becomes reality this will need to be reworked to handle that case. - serializeJsonContainerProperty(methodBlock, "writeMap", elementType, ((MapType) elementType).getValueType(), - serializedName, propertyValueGetter, depth + 1, isJsonMergePatch); - } else if (elementType == ClassType.BINARY_DATA) { - methodBlock.line(lambdaWriterName + ".writeUntyped(" + elementName + ")"); - } else { - throw new RuntimeException("Unknown value type " + elementType + " in " + containerType - + " serialization. Need to add support for it."); - } - }); - - if (depth > 0) { - methodBlock.line(")"); - } else { - methodBlock.line(");"); - } - } - - /** - * Helper method to serialize flattened properties in a model. - *

- * Flattened properties are unique as for each level of flattening they'll create a JSON sub-object. But before a - * sub-object is created any field needs to be checked for either being a primitive value or non-null. Primitive - * values are usually serialized no matter their value so those will automatically trigger the JSON sub-object to be - * created, nullable values will be checked for being non-null. - *

- * In addition to primitive or non-null checking fields, all properties from the same JSON sub-object must be - * written at the same time to prevent an invalid JSON structure. For example if a model has three flattened - * properties with JSON paths "im.flattened", "im.deeper.flattened", and "im.deeper.flattenedtoo" this will create - * the following structure: - * - *

-     * im -> flattened
-     *     | deeper -> flattened
-     *               | flattenedtoo
-     * 
- * - * So, "im.deeper.flattened" and "im.deeper.flattenedtoo" will need to be serialized at the same time to get the - * correct JSON where there is only one "im: deeper" JSON sub-object. - * - * @param methodBlock The method handling serialization. - * @param flattenedProperties The flattened properties structure. - * @param isJsonMergePatch Whether the serialization is for a JSON merge patch model. - */ - private static void handleFlattenedPropertiesSerialization(JavaBlock methodBlock, - JsonFlattenedPropertiesTree flattenedProperties, boolean isJsonMergePatch) { - // The initial call to handle flattened properties is using the base node which is just a holder. + if (hasPrimitivePropertyInGroup) { + // Simple case where the flattened group has a primitive type where non-null checking doesn't need + // to be done. + methodBlock.line("jsonWriter.writeStartObject(\"" + flattenedProperties.getNodeName() + "\");"); for (JsonFlattenedPropertiesTree flattened : flattenedProperties.getChildrenNodes().values()) { - handleFlattenedPropertiesSerializationHelper(methodBlock, flattened, isJsonMergePatch); + handleFlattenedPropertiesSerializationHelper(methodBlock, flattened, isJsonMergePatch, + callToJsonSharedForParentProperties); } - } + methodBlock.line("jsonWriter.writeEndObject();"); + } else { + // Complex case where all properties in the flattened group are nullable and a check needs to be made + // if any value is non-null. + String condition = propertiesInFlattenedGroup.stream() + .map(property -> (property.isFromSuperClass()) + ? property.getProperty().getGetterName() + "() != null" + : property.getProperty().getName() + " != null") + .collect(Collectors.joining(" || ")); - private static void handleFlattenedPropertiesSerializationHelper(JavaBlock methodBlock, - JsonFlattenedPropertiesTree flattenedProperties, boolean isJsonMergePatch) { - ClientModelPropertyWithMetadata flattenedProperty = flattenedProperties.getProperty(); - if (flattenedProperty != null) { - // This is a terminal location, only need to add property serialization. - serializeJsonProperty(methodBlock, flattenedProperty.getProperty(), flattenedProperties.getNodeName(), - flattenedProperty.isFromSuperClass(), false, isJsonMergePatch); - } else { - // Otherwise this is an intermediate location. - // Check for either any of the properties in this subtree being primitives or add an if block checking that - // any of the properties are non-null. - List propertiesInFlattenedGroup = - getClientModelPropertiesInJsonTree(flattenedProperties); - boolean hasPrimitivePropertyInGroup = propertiesInFlattenedGroup.stream() - .map(property -> property.getProperty().getWireType()) - .anyMatch(wireType -> wireType instanceof PrimitiveType); - - if (hasPrimitivePropertyInGroup) { - // Simple case where the flattened group has a primitive type where non-null checking doesn't need - // to be done. - methodBlock.line("jsonWriter.writeStartObject(\"" + flattenedProperties.getNodeName() + "\");"); - for (JsonFlattenedPropertiesTree flattened : flattenedProperties.getChildrenNodes().values()) { - handleFlattenedPropertiesSerializationHelper(methodBlock, flattened, isJsonMergePatch); - } - methodBlock.line("jsonWriter.writeEndObject();"); - } else { - // Complex case where all properties in the flattened group are nullable and a check needs to be made - // if any value is non-null. - String condition = propertiesInFlattenedGroup.stream() - .map(property -> (property.isFromSuperClass()) - ? property.getProperty().getGetterName() + "() != null" - : property.getProperty().getName() + " != null") - .collect(Collectors.joining(" || ")); - - methodBlock.ifBlock(condition, ifAction -> { - ifAction.line("jsonWriter.writeStartObject(\"" + flattenedProperties.getNodeName() + "\");"); - for (JsonFlattenedPropertiesTree flattened : flattenedProperties.getChildrenNodes().values()) { - handleFlattenedPropertiesSerializationHelper(ifAction, flattened, isJsonMergePatch); - } - ifAction.line("jsonWriter.writeEndObject();"); - }); - } - } - } - - /* - * Writes the fromJson(JsonReader) implementation. - */ - private void writeFromJson(JavaClass classBlock, ClientModel model, - ClientModelPropertiesManager propertiesManager, JavaSettings settings, - Consumer addGeneratedAnnotation) { - // All classes will create a public fromJson(JsonReader) method that initiates reading. - // How the implementation looks depends on whether the type is a super type, subtype, both, or is a - // stand-alone type. - // - // Intermediate types, those that are both a super type and subtype, will pass null as the type discriminator - // value. This is done as super types are written to only support themselves or their subtypes, passing a - // discriminator into its own super type would confuse this scenario. For example, one of the test Swaggers - // generates the following hierarchy - // - // Fish - // Salmon Shark - // SmartSalmon Sawshark GoblinShark Cookiecuttershark - // - // If Salmon called into Fish with its discriminator and an error occurred it would mention the Shark subtypes - // as potential legal values for deserialization, confusing the Salmon deserializer. So, calling into Salmon - // will only attempt to handle Salmon and SmartSalmon, and same goes for Shark with Shark, Sawshark, - // GoblinShark, and Cookiecuttershark. It's only Fish that will handle all subtypes, as this is the most generic - // super type. This also creates a well-defined bounds for code generation in regard to type hierarchies. - // - // In a real scenario someone deserializing to Salmon should have an exception about discriminator types - // if the JSON payload is a Shark and not get a ClassCastException as it'd be more confusing on why a Shark - // was trying to be converted to a Salmon. - if (isSuperTypeWithDiscriminator(model)) { - writeSuperTypeFromJson(classBlock, model, propertiesManager, settings, addGeneratedAnnotation); - } else { - writeTerminalTypeFromJson(classBlock, propertiesManager, settings, addGeneratedAnnotation); - } - } - - /* - * Writes the readManagementError(JsonReader) implementation for ManagementError subclass. - */ - private void writeManagementErrorDeserializationMethod(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, - JavaSettings settings, Consumer addGeneratedAnnotation) { - addGeneratedAnnotation.accept(classBlock); - classBlock.staticMethod( - JavaVisibility.Private, - propertiesManager.getModel().getName() + " " + READ_MANAGEMENT_ERROR_METHOD_NAME + "(JsonReader jsonReader) throws IOException", - methodBlock -> readJsonObjectMethodBody(methodBlock, - deserializationBlock -> writeFromJsonDeserialization0(deserializationBlock, propertiesManager, settings))); - } - - /** - * Writes a super type's {@code fromJson(JsonReader)} method. - * - * @param classBlock The class having {@code fromJson(JsonReader)} written to it. - * @param model The Autorest representation of the model. - * @param propertiesManager The properties for the model. - * @param settings The Autorest generation settings. - * @param addGeneratedAnnotation Callback that adds {@code @Generated} annotation to a code block. - */ - private void writeSuperTypeFromJson(JavaClass classBlock, ClientModel model, - ClientModelPropertiesManager propertiesManager, JavaSettings settings, - Consumer addGeneratedAnnotation) { - // Handling polymorphic fields while determining which subclass, or the class itself, to deserialize handles the - // discriminator type always as a String. This is permissible as the found discriminator is never being used in - // a setter or for setting a field, unlike in the actual deserialization method where it needs to be the same - // type as the field. - String fieldNameVariableName = propertiesManager.getJsonReaderFieldNameVariableName(); - ClientModelPropertyWithMetadata discriminatorProperty = propertiesManager.getDiscriminatorProperty(); - readJsonObject(classBlock, propertiesManager, false, methodBlock -> { - // For now, reading polymorphic types will always buffer the current object. - // In the future this can be enhanced to switch if the first property is the discriminator field and to use - // a Map to contain all properties found while searching for the discriminator field. - // TODO (alzimmer): Need to handle non-string wire type discriminator types. - methodBlock.line("String discriminatorValue = null;"); - methodBlock.tryBlock("JsonReader readerToUse = reader.bufferObject()", tryStatement -> { - tryStatement.line("readerToUse.nextToken(); // Prepare for reading"); - tryStatement.line("while (readerToUse.nextToken() != JsonToken.END_OBJECT) {"); - tryStatement.increaseIndent(); - tryStatement.line("String " + fieldNameVariableName + " = readerToUse.getFieldName();"); - tryStatement.line("readerToUse.nextToken();"); - tryStatement.ifBlock( - "\"" + discriminatorProperty.getProperty().getSerializedName() + "\".equals(" + fieldNameVariableName + ")", - ifStatement -> { - ifStatement.line("discriminatorValue = readerToUse.getString();"); - ifStatement.line("break;"); - }).elseBlock(elseBlock -> elseBlock.line("readerToUse.skipChildren();")); - - tryStatement.decreaseIndent(); - tryStatement.line("}"); - - tryStatement.line("// Use the discriminator value to determine which subtype should be deserialized."); - - // Add deserialization for the super type itself. - JavaIfBlock ifBlock = null; - - // Add deserialization for all child types. - List childTypes = getAllChildTypes(model, new ArrayList<>()); - for (ClientModel childType : childTypes) { - // Determine which serialization method to use based on whether the child type is also a polymorphic - // parent and the child shares the same polymorphic discriminator as this model. - // If the child and parent have different discriminator names then the child will need to be - // deserialized checking the multi-level polymorphic discriminator. - // Using the nested discriminator sample, there is - // Fish : kind - // - Salmon : kind - // - Shark : sharktype - // - Sawshark : sharktype - // So, if deserialization enters Fish and the "kind" is "Shark" then it needs to check the - // "sharktype" to determine if it's a Sawshark or another subtype of Shark. - boolean sameDiscriminator = Objects.equals(childType.getPolymorphicDiscriminatorName(), - model.getPolymorphicDiscriminatorName()); - - if (!sameDiscriminator && !Objects.equals(childType.getParentModelName(), model.getName())) { - // Child model and parent model don't share the same discriminator and the child isn't a direct - // child of the parent model, so skip this child model. This is done as the child model should - // be deserialized by the subtype that defines the different polymorphic discriminator. Using - // the sample above, Fish can't use "kind" to deserialize to a Shark subtype, it needs to use - // "sharktype". - continue; - } - - String deserializationMethod = (isSuperTypeWithDiscriminator(childType) && sameDiscriminator) - ? ".fromJsonKnownDiscriminator(readerToUse.reset())" - : ".fromJson(readerToUse.reset())"; - - ifBlock = ifOrElseIf(tryStatement, ifBlock, - "\"" + childType.getSerializedName() + "\".equals(discriminatorValue)", - ifStatement -> ifStatement.methodReturn(childType.getName() + deserializationMethod)); - } - - if (ifBlock == null) { - tryStatement.methodReturn("fromJsonKnownDiscriminator(readerToUse.reset())"); - } else { - ifBlock.elseBlock( - elseBlock -> elseBlock.methodReturn("fromJsonKnownDiscriminator(readerToUse.reset())")); - } - }); - }, addGeneratedAnnotation); - - readJsonObject(classBlock, propertiesManager, true, - methodBlock -> writeFromJsonDeserialization(methodBlock, propertiesManager, settings), - addGeneratedAnnotation); - } - - private static List getAllChildTypes(ClientModel model, List childTypes) { - for (ClientModel childType : model.getDerivedModels()) { - childTypes.add(childType); - if (!CoreUtils.isNullOrEmpty(childType.getDerivedModels())) { - getAllChildTypes(childType, childTypes); - } - } - - return childTypes; - } - - /** - * Gets the additionalProperty model property from this model or its superclass. - * - * @param propertiesManager The properties for the model. - * @return the additionalProperty model property from this model or its superclass. - */ - private static ClientModelProperty getAdditionalPropertiesPropertyInModelOrFromSuper( - ClientModelPropertiesManager propertiesManager) { - return propertiesManager.getAdditionalProperties() != null - ? propertiesManager.getAdditionalProperties() - : propertiesManager.getSuperAdditionalPropertiesProperty(); - } - - /** - * Writes a terminal type's {@code fromJson(JsonReader)} method. - *

- * A terminal type is either a type without polymorphism or is the terminal type in a polymorphic hierarchy. - * - * @param classBlock The class having {@code fromJson(JsonReader)} written to it. - * @param propertiesManager The properties for the model. - * @param settings The Autorest generation settings. - * @param addGeneratedAnnotation Callback that adds {@code @Generated} annotation to a code block. - */ - private void writeTerminalTypeFromJson(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, - JavaSettings settings, Consumer addGeneratedAnnotation) { - readJsonObject(classBlock, propertiesManager, false, - methodBlock -> writeFromJsonDeserialization(methodBlock, propertiesManager, settings), - addGeneratedAnnotation); - } - - private void writeFromJsonDeserialization(JavaBlock methodBlock, - ClientModelPropertiesManager propertiesManager, JavaSettings settings) { - // Add the deserialization logic. - methodBlock.indent(() -> { - if (isManagementErrorSubclass(propertiesManager.getModel(), settings)) { - writeManagementErrorAdaption(methodBlock, propertiesManager); - } else { - writeFromJsonDeserialization0(methodBlock, propertiesManager, settings); - } + methodBlock.ifBlock(condition, ifAction -> { + ifAction.line("jsonWriter.writeStartObject(\"" + flattenedProperties.getNodeName() + "\");"); + for (JsonFlattenedPropertiesTree flattened : flattenedProperties.getChildrenNodes().values()) { + handleFlattenedPropertiesSerializationHelper(ifAction, flattened, isJsonMergePatch, + callToJsonSharedForParentProperties); + } + ifAction.line("jsonWriter.writeEndObject();"); }); + } + } + } + + /* + * Writes the fromJson(JsonReader) implementation. + */ + private void writeFromJson(JavaClass classBlock, ClientModel model, + ClientModelPropertiesManager propertiesManager, JavaSettings settings, + Consumer addGeneratedAnnotation) { + // All classes will create a public fromJson(JsonReader) method that initiates reading. + // How the implementation looks depends on whether the type is a super type, subtype, both, or is a + // stand-alone type. + // + // Intermediate types, those that are both a super type and subtype, will pass null as the type discriminator + // value. This is done as super types are written to only support themselves or their subtypes, passing a + // discriminator into its own super type would confuse this scenario. For example, one of the test Swaggers + // generates the following hierarchy + // + // Fish + // Salmon Shark + // SmartSalmon Sawshark GoblinShark Cookiecuttershark + // + // If Salmon called into Fish with its discriminator and an error occurred it would mention the Shark subtypes + // as potential legal values for deserialization, confusing the Salmon deserializer. So, calling into Salmon + // will only attempt to handle Salmon and SmartSalmon, and same goes for Shark with Shark, Sawshark, + // GoblinShark, and Cookiecuttershark. It's only Fish that will handle all subtypes, as this is the most generic + // super type. This also creates a well-defined bounds for code generation in regard to type hierarchies. + // + // In a real scenario someone deserializing to Salmon should have an exception about discriminator types + // if the JSON payload is a Shark and not get a ClassCastException as it'd be more confusing on why a Shark + // was trying to be converted to a Salmon. + if (isSuperTypeWithDiscriminator(model)) { + writeSuperTypeFromJson(classBlock, model, propertiesManager, settings, addGeneratedAnnotation); + } else { + writeTerminalTypeFromJson(classBlock, propertiesManager, settings, addGeneratedAnnotation); + } + } + + /* + * Writes the readManagementError(JsonReader) implementation for ManagementError subclass. + */ + private void writeManagementErrorDeserializationMethod(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, + JavaSettings settings, Consumer addGeneratedAnnotation) { + addGeneratedAnnotation.accept(classBlock); + classBlock.staticMethod( + JavaVisibility.Private, + propertiesManager.getModel().getName() + " " + READ_MANAGEMENT_ERROR_METHOD_NAME + "(JsonReader jsonReader) throws IOException", + methodBlock -> readJsonObjectMethodBody(methodBlock, + deserializationBlock -> writeFromJsonDeserialization0(deserializationBlock, propertiesManager, settings))); + } + + /** + * Writes a super type's {@code fromJson(JsonReader)} method. + * + * @param classBlock The class having {@code fromJson(JsonReader)} written to it. + * @param model The Autorest representation of the model. + * @param propertiesManager The properties for the model. + * @param settings The Autorest generation settings. + * @param addGeneratedAnnotation Callback that adds {@code @Generated} annotation to a code block. + */ + private void writeSuperTypeFromJson(JavaClass classBlock, ClientModel model, + ClientModelPropertiesManager propertiesManager, JavaSettings settings, + Consumer addGeneratedAnnotation) { + // Handling polymorphic fields while determining which subclass, or the class itself, to deserialize handles the + // discriminator type always as a String. This is permissible as the found discriminator is never being used in + // a setter or for setting a field, unlike in the actual deserialization method where it needs to be the same + // type as the field. + String fieldNameVariableName = propertiesManager.getJsonReaderFieldNameVariableName(); + ClientModelPropertyWithMetadata discriminatorProperty = propertiesManager.getDiscriminatorProperty(); + readJsonObject(classBlock, propertiesManager, false, methodBlock -> { + // For now, reading polymorphic types will always buffer the current object. + // In the future this can be enhanced to switch if the first property is the discriminator field and to use + // a Map to contain all properties found while searching for the discriminator field. + // TODO (alzimmer): Need to handle non-string wire type discriminator types. + methodBlock.line("String discriminatorValue = null;"); + methodBlock.tryBlock("JsonReader readerToUse = reader.bufferObject()", tryStatement -> { + tryStatement.line("readerToUse.nextToken(); // Prepare for reading"); + tryStatement.line("while (readerToUse.nextToken() != JsonToken.END_OBJECT) {"); + tryStatement.increaseIndent(); + tryStatement.line("String " + fieldNameVariableName + " = readerToUse.getFieldName();"); + tryStatement.line("readerToUse.nextToken();"); + tryStatement.ifBlock( + "\"" + discriminatorProperty.getProperty().getSerializedName() + "\".equals(" + fieldNameVariableName + ")", + ifStatement -> { + ifStatement.line("discriminatorValue = readerToUse.getString();"); + ifStatement.line("break;"); + }).elseBlock(elseBlock -> elseBlock.line("readerToUse.skipChildren();")); + + tryStatement.decreaseIndent(); + tryStatement.line("}"); + + tryStatement.line("// Use the discriminator value to determine which subtype should be deserialized."); + + // Add deserialization for the super type itself. + JavaIfBlock ifBlock = null; + + // Add deserialization for all child types. + List childTypes = getAllChildTypes(model, new ArrayList<>()); + for (ClientModel childType : childTypes) { + // Determine which serialization method to use based on whether the child type is also a polymorphic + // parent and the child shares the same polymorphic discriminator as this model. + // If the child and parent have different discriminator names then the child will need to be + // deserialized checking the multi-level polymorphic discriminator. + // Using the nested discriminator sample, there is + // Fish : kind + // - Salmon : kind + // - Shark : sharktype + // - Sawshark : sharktype + // So, if deserialization enters Fish and the "kind" is "Shark" then it needs to check the + // "sharktype" to determine if it's a Sawshark or another subtype of Shark. + boolean sameDiscriminator = Objects.equals(childType.getPolymorphicDiscriminatorName(), + model.getPolymorphicDiscriminatorName()); + + if (!sameDiscriminator && !Objects.equals(childType.getParentModelName(), model.getName())) { + // Child model and parent model don't share the same discriminator and the child isn't a direct + // child of the parent model, so skip this child model. This is done as the child model should + // be deserialized by the subtype that defines the different polymorphic discriminator. Using + // the sample above, Fish can't use "kind" to deserialize to a Shark subtype, it needs to use + // "sharktype". + continue; + } + + String deserializationMethod = (isSuperTypeWithDiscriminator(childType) && sameDiscriminator) + ? ".fromJsonKnownDiscriminator(readerToUse.reset())" + : ".fromJson(readerToUse.reset())"; + + ifBlock = ifOrElseIf(tryStatement, ifBlock, + "\"" + childType.getSerializedName() + "\".equals(discriminatorValue)", + ifStatement -> ifStatement.methodReturn(childType.getName() + deserializationMethod)); + } + + if (ifBlock == null) { + tryStatement.methodReturn("fromJsonKnownDiscriminator(readerToUse.reset())"); + } else { + ifBlock.elseBlock( + elseBlock -> elseBlock.methodReturn("fromJsonKnownDiscriminator(readerToUse.reset())")); + } + }); + }, addGeneratedAnnotation, settings); + + readJsonObject(classBlock, propertiesManager, true, + methodBlock -> writeFromJsonDeserialization(methodBlock, propertiesManager, settings), + addGeneratedAnnotation, settings); + } + + private static List getAllChildTypes(ClientModel model, List childTypes) { + for (ClientModel childType : model.getDerivedModels()) { + childTypes.add(childType); + if (!CoreUtils.isNullOrEmpty(childType.getDerivedModels())) { + getAllChildTypes(childType, childTypes); + } } - private static void writeManagementErrorAdaption(JavaBlock methodBlock, ClientModelPropertiesManager propertiesManager) { - methodBlock.line("JsonReader bufferedReader = reader.bufferObject();"); - methodBlock.line("bufferedReader.nextToken();"); + return childTypes; + } - String fieldNameVariableName = propertiesManager.getJsonReaderFieldNameVariableName(); - addReaderWhileLoop("bufferedReader", methodBlock, true, fieldNameVariableName, false, whileBlock -> { - methodBlock - .ifBlock("\"error\".equals(" + fieldNameVariableName + ")", ifAction -> { - ifAction.line("return " + READ_MANAGEMENT_ERROR_METHOD_NAME + "(bufferedReader);"); - }).elseBlock(elseAction -> { - elseAction.line("bufferedReader.skipChildren();"); - }); + /** + * Gets the additionalProperty model property from this model or its superclass. + * + * @param propertiesManager The properties for the model. + * @return the additionalProperty model property from this model or its superclass. + */ + private static ClientModelProperty getAdditionalPropertiesPropertyInModelOrFromSuper( + ClientModelPropertiesManager propertiesManager) { + return propertiesManager.getAdditionalProperties() != null + ? propertiesManager.getAdditionalProperties() + : propertiesManager.getSuperAdditionalPropertiesProperty(); + } + + /** + * Writes a terminal type's {@code fromJson(JsonReader)} method. + *

+ * A terminal type is either a type without polymorphism or is the terminal type in a polymorphic hierarchy. + * + * @param classBlock The class having {@code fromJson(JsonReader)} written to it. + * @param propertiesManager The properties for the model. + * @param settings The Autorest generation settings. + * @param addGeneratedAnnotation Callback that adds {@code @Generated} annotation to a code block. + */ + private void writeTerminalTypeFromJson(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, + JavaSettings settings, Consumer addGeneratedAnnotation) { + readJsonObject(classBlock, propertiesManager, false, + methodBlock -> writeFromJsonDeserialization(methodBlock, propertiesManager, settings), + addGeneratedAnnotation, settings); + } + + private void writeFromJsonDeserialization(JavaBlock methodBlock, + ClientModelPropertiesManager propertiesManager, JavaSettings settings) { + // Add the deserialization logic. + methodBlock.indent(() -> { + if (isManagementErrorSubclass(propertiesManager.getModel(), settings)) { + writeManagementErrorAdaption(methodBlock, propertiesManager); + } else { + writeFromJsonDeserialization0(methodBlock, propertiesManager, settings); + } + }); + } + + private static void writeManagementErrorAdaption(JavaBlock methodBlock, ClientModelPropertiesManager propertiesManager) { + methodBlock.line("JsonReader bufferedReader = reader.bufferObject();"); + methodBlock.line("bufferedReader.nextToken();"); + + String fieldNameVariableName = propertiesManager.getJsonReaderFieldNameVariableName(); + addReaderWhileLoop("bufferedReader", methodBlock, true, fieldNameVariableName, false, whileBlock -> + methodBlock.ifBlock("\"error\".equals(" + fieldNameVariableName + ")", + ifAction -> ifAction.line("return " + READ_MANAGEMENT_ERROR_METHOD_NAME + "(bufferedReader);")) + .elseBlock(elseAction -> elseAction.line("bufferedReader.skipChildren();"))); + + methodBlock.methodReturn(READ_MANAGEMENT_ERROR_METHOD_NAME + "(bufferedReader.reset())"); + } + + private static void writeFromJsonDeserialization0(JavaBlock methodBlock, + ClientModelPropertiesManager propertiesManager, JavaSettings settings) { + // Initialize local variables to track what has been deserialized. + initializeLocalVariables(methodBlock, propertiesManager, false, settings); + + boolean polymorphicJsonMergePatchScenario = propertiesManager.getModel().isPolymorphic() + && ClientModelUtil.isJsonMergePatchModel(propertiesManager.getModel(), settings); + boolean useFromJsonShared = canUseFromJsonShared(propertiesManager); + + String fieldNameVariableName = propertiesManager.getJsonReaderFieldNameVariableName(); + + // Add the outermost while loop to read the JSON object. + addReaderWhileLoop(methodBlock, true, fieldNameVariableName, false, whileBlock -> { + if (useFromJsonShared && propertiesManager.getModel().isPolymorphicParent()) { + // If we can use 'fromJsonShared' and this model is a super type, then we can use a customized + // 'fromJson' / 'fromJsonKnownDiscriminator' method to handle deserialization. + // This will generate the following logic: + // + // if (!fromJsonShared(reader, fieldName, deserializedModel)) { + // handleUnknownProperty + // } + String ifBlockCondition = "!" + propertiesManager.getModel().getName() + ".fromJsonShared(reader, " + + fieldNameVariableName + ", " + propertiesManager.getDeserializedModelName() + ")"; + methodBlock.ifBlock(ifBlockCondition, + ifBlock -> generateUnknownFieldLogic(ifBlock, null, propertiesManager)); + return; + } + + // Loop over all properties and generate their deserialization handling. + AtomicReference ifBlockReference = new AtomicReference<>(null); + + BiConsumer consumer = (property, fromSuper) -> + handleJsonPropertyDeserialization(propertiesManager.getModel(), property, + propertiesManager.getDeserializedModelName(), whileBlock, ifBlockReference, + fieldNameVariableName, fromSuper, propertiesManager.hasConstructorArguments(), settings, + polymorphicJsonMergePatchScenario, false); + + Map modelPropertyMap = new HashMap<>(); + for (ClientModelProperty parentProperty : ClientModelUtil.getParentProperties(propertiesManager.getModel())) { + modelPropertyMap.put(parentProperty.getName(), parentProperty); + } + for (ClientModelProperty property : propertiesManager.getModel().getProperties()) { + modelPropertyMap.put(property.getName(), property); + } + + if (useFromJsonShared) { + // If this model is a subtype, and 'fromJsonShared' can be used, instead of generating the + // deserialization of the parent model(s) in 'fromJson' call to the parent class's 'fromJsonShared'. + String ifBlockCondition = propertiesManager.getModel().getParentModelName() + ".fromJsonShared(reader, " + + fieldNameVariableName + ", " + propertiesManager.getDeserializedModelName() + ")"; + ifBlockReference.set(methodBlock.ifBlock(ifBlockCondition, ifBlock -> ifBlock.line("continue;"))); + } else { + // Child classes may contain properties that shadow parents' ones. + // Thus, we only take the shadowing ones, not the ones shadowed. + Map superRequiredToDeserialized = new LinkedHashMap<>(); + propertiesManager.forEachSuperRequiredProperty(property -> { + if (!property.isConstant() && modelPropertyMap.get(property.getName()) == property) { + superRequiredToDeserialized.put(property.getName(), property); + } }); + superRequiredToDeserialized.values().forEach(property -> consumer.accept(property, true)); - methodBlock.methodReturn(READ_MANAGEMENT_ERROR_METHOD_NAME + "(bufferedReader.reset())"); + // Child classes may contain properties that shadow parents' ones. + // Thus, we only take the shadowing ones, not the ones shadowed. + Map superSettersToDeserialized = new LinkedHashMap<>(); + propertiesManager.forEachSuperSetterProperty(property -> { + if (!property.isConstant() && modelPropertyMap.get(property.getName()) == property) { + superSettersToDeserialized.put(property.getName(), property); + } + }); + superSettersToDeserialized.values().forEach(property -> consumer.accept(property, true)); + } + + generateThisFromJson(propertiesManager, ifBlockReference, consumer, methodBlock, settings, + polymorphicJsonMergePatchScenario, false, useFromJsonShared); + + // All properties have been checked for, add an else block that will either ignore unknown properties + // or add them into an additional properties bag. + generateUnknownFieldLogic(whileBlock, ifBlockReference.get(), propertiesManager); + }); + + // Add the validation and return logic. + handleReadReturn(methodBlock, propertiesManager.getModel().getName(), propertiesManager, settings); + } + + private static void generateThisFromJson(ClientModelPropertiesManager propertiesManager, + AtomicReference ifBlockReference, BiConsumer consumer, + JavaBlock methodBlock, JavaSettings settings, boolean polymorphicJsonMergePatchScenario, + boolean isFromJsonShared, boolean usingFromJsonShared) { + propertiesManager.forEachRequiredProperty(property -> { + if (property.isConstant()) { + return; + } + + if (skipDeserializingParentDefinedDiscriminator(usingFromJsonShared, isFromJsonShared, propertiesManager, + property)) { + return; + } + + consumer.accept(property, false); + }); + propertiesManager.forEachSetterProperty(property -> { + if (skipDeserializingParentDefinedDiscriminator(usingFromJsonShared, isFromJsonShared, propertiesManager, + property)) { + return; + } + + consumer.accept(property, false); + }); + + JavaIfBlock ifBlock = ifBlockReference.get(); + + // Add flattened properties if we aren't using 'fromJsonShared' or some of the flattened properties are defined + // by this model. + if (!usingFromJsonShared || !propertiesManager.isAllFlattenedPropertiesFromParent()) { + handleFlattenedPropertiesDeserialization(propertiesManager.getJsonFlattenedPropertiesTree(), methodBlock, + ifBlock, propertiesManager.getAdditionalProperties(), + propertiesManager.getJsonReaderFieldNameVariableName(), propertiesManager.hasConstructorArguments(), + settings, polymorphicJsonMergePatchScenario, isFromJsonShared); + } + } + + private static boolean skipDeserializingParentDefinedDiscriminator(boolean usingFromJsonShared, + boolean isFromJsonShared, ClientModelPropertiesManager propertiesManager, ClientModelProperty property) { + // If this type is using 'fromJsonShared' from the parent model, skip deserializing polymorphic + // discriminators if it is defined by a parent model. + return (usingFromJsonShared + || (isFromJsonShared && !CoreUtils.isNullOrEmpty(propertiesManager.getModel().getParentModelName()))) + && property.isPolymorphicDiscriminator() + && !propertiesManager.getModel().isPolymorphicDiscriminatorDefinedByModel(); + } + + private static void generateUnknownFieldLogic(JavaBlock whileBlock, JavaIfBlock ifBlock, + ClientModelPropertiesManager propertiesManager) { + ClientModelProperty additionalProperty = getAdditionalPropertiesPropertyInModelOrFromSuper(propertiesManager); + handleUnknownJsonFieldDeserialization(whileBlock, ifBlock, additionalProperty, + propertiesManager.getJsonReaderFieldNameVariableName()); + } + + /** + * Whether the given model is subclass of ManagementError, which needs special deserialization adaption. + * @param model the model to check + * @param settings JavaSettings instance + * @return whether the given model is subclass of ManagementError + */ + protected boolean isManagementErrorSubclass(ClientModel model, JavaSettings settings) { + return false; + } + + /** + * Adds a static method to the class with the signature that handles reading the JSON string into the object type. + *

+ * If {@code superTypeReading} is true the method will be package-private and named + * {@code fromJsonWithKnownDiscriminator} instead of being public and named {@code fromJson}. This is done as super + * types use their {@code fromJson} method to determine the discriminator value and pass the reader to the specific + * type being deserialized. The specific type being deserialized may be the super type itself, so it cannot pass to + * {@code fromJson} as this will be a circular call and if the specific type being deserialized is an intermediate + * type (a type having both super and subclasses) it will attempt to perform discriminator validation which has + * already been done. + * + * @param classBlock The class where the {@code fromJson} method is being written. + * @param propertiesManager Properties information about the object being deserialized. + * @param superTypeReading Whether the object reading is for a super type. + * @param deserializationBlock Logic for deserializing the object. + * @param addGeneratedAnnotation Callback that adds {@code @Generated} annotation to a code block. + */ + private static void readJsonObject(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, + boolean superTypeReading, Consumer deserializationBlock, + Consumer addGeneratedAnnotation, JavaSettings settings) { + JavaVisibility visibility = superTypeReading ? JavaVisibility.PackagePrivate : JavaVisibility.Public; + String methodName = superTypeReading ? "fromJsonKnownDiscriminator" : "fromJson"; + + String modelName = propertiesManager.getModel().getName(); + boolean hasRequiredProperties = propertiesManager.hasRequiredProperties(); + + if (!superTypeReading) { + classBlock.javadocComment(javadocComment -> { + javadocComment.description("Reads an instance of " + modelName + " from the JsonReader."); + javadocComment.param("jsonReader", "The JsonReader being read."); + javadocComment.methodReturns("An instance of " + modelName + " if the JsonReader was pointing to an " + + "instance of it, or null if it was pointing to JSON null."); + + if (hasRequiredProperties) { + javadocComment.methodThrows("IllegalStateException", + "If the deserialized JSON object was missing any required properties."); + } + + javadocComment.methodThrows("IOException", "If an error occurs while reading the " + modelName + "."); + }); } - private static void writeFromJsonDeserialization0(JavaBlock methodBlock, ClientModelPropertiesManager propertiesManager, JavaSettings settings) { - // Initialize local variables to track what has been deserialized. - initializeLocalVariables(methodBlock, propertiesManager, false, settings); + addGeneratedAnnotation.accept(classBlock); + classBlock.staticMethod(visibility, modelName + " " + methodName + "(JsonReader jsonReader) throws IOException", + methodBlock -> readJsonObjectMethodBody(methodBlock, deserializationBlock)); + if (superTypeReading + && canUseFromJsonShared(propertiesManager) + && propertiesManager.getModel().isPolymorphicParent()) { + // Add a package-private 'fromJsonShared' method that can handle deserializing properties defined in the parent + // class. + String fieldName = propertiesManager.getJsonReaderFieldNameVariableName(); + String modelDeserializedName = propertiesManager.getDeserializedModelName(); + String methodDefinition = "boolean fromJsonShared(JsonReader reader, String " + fieldName + ", " + + modelName + " " + modelDeserializedName + ") throws IOException"; + addGeneratedAnnotation.accept(classBlock); + classBlock.staticMethod(JavaVisibility.PackagePrivate, methodDefinition, methodBlock -> { boolean polymorphicJsonMergePatchScenario = propertiesManager.getModel().isPolymorphic() - && ClientModelUtil.isJsonMergePatchModel(propertiesManager.getModel(), settings); + && ClientModelUtil.isJsonMergePatchModel(propertiesManager.getModel(), settings); - String fieldNameVariableName = propertiesManager.getJsonReaderFieldNameVariableName(); - - // Add the outermost while loop to read the JSON object. - addReaderWhileLoop(methodBlock, true, fieldNameVariableName, false, whileBlock -> { - // Loop over all properties and generate their deserialization handling. - AtomicReference ifBlockReference = new AtomicReference<>(null); - - BiConsumer consumer = (property, fromSuper) -> - handleJsonPropertyDeserialization(propertiesManager.getModel(), property, - propertiesManager.getDeserializedModelName(), whileBlock, ifBlockReference, - fieldNameVariableName, fromSuper, propertiesManager.hasConstructorArguments(), settings, - polymorphicJsonMergePatchScenario); - - Map modelPropertyMap = new HashMap<>(); - for (ClientModelProperty parentProperty : ClientModelUtil.getParentProperties(propertiesManager.getModel())) { - modelPropertyMap.put(parentProperty.getName(), parentProperty); - } - for (ClientModelProperty property : propertiesManager.getModel().getProperties()) { - modelPropertyMap.put(property.getName(), property); - } - - // Child classes may contain properties that shadow parents' ones. - // Thus, we only take the shadowing ones, not the ones shadowed. - Map superRequiredToDeserialized = new LinkedHashMap<>(); - propertiesManager.forEachSuperRequiredProperty(property -> { - if (!property.isConstant() && modelPropertyMap.get(property.getName()) == property) { - superRequiredToDeserialized.put(property.getName(), property); - } - }); - superRequiredToDeserialized.values().forEach(property -> consumer.accept(property, true)); - - // Child classes may contain properties that shadow parents' ones. - // Thus, we only take the shadowing ones, not the ones shadowed. - Map superSettersToDeserialized = new LinkedHashMap<>(); - propertiesManager.forEachSuperSetterProperty(property -> { - if (!property.isConstant() && modelPropertyMap.get(property.getName()) == property) { - superSettersToDeserialized.put(property.getName(), property); - } - }); - superSettersToDeserialized.values().forEach(property -> consumer.accept(property, true)); - - propertiesManager.forEachRequiredProperty(property -> { - if (property.isConstant()) { - return; - } - consumer.accept(property, false); - }); - propertiesManager.forEachSetterProperty(property -> consumer.accept(property, false)); - - JavaIfBlock ifBlock = ifBlockReference.get(); - - handleFlattenedPropertiesDeserialization(propertiesManager.getJsonFlattenedPropertiesTree(), - methodBlock, ifBlock, propertiesManager.getAdditionalProperties(), - propertiesManager.getJsonReaderFieldNameVariableName(), propertiesManager.hasConstructorArguments(), - settings, polymorphicJsonMergePatchScenario); - - // All properties have been checked for, add an else block that will either ignore unknown properties - // or add them into an additional properties bag. - ClientModelProperty additionalProperty = getAdditionalPropertiesPropertyInModelOrFromSuper(propertiesManager); - handleUnknownJsonFieldDeserialization(whileBlock, ifBlock, additionalProperty, - propertiesManager.getJsonReaderFieldNameVariableName()); - }); - - // Add the validation and return logic. - handleReadReturn(methodBlock, propertiesManager.getModel().getName(), propertiesManager, settings); - } - - /** - * Whether the given model is subclass of ManagementError, which needs special deserialization adaption. - * @param model the model to check - * @param settings JavaSettings instance - * @return whether the given model is subclass of ManagementError - */ - protected boolean isManagementErrorSubclass(ClientModel model, JavaSettings settings) { - return false; - } - - /** - * Adds a static method to the class with the signature that handles reading the JSON string into the object type. - *

- * If {@code superTypeReading} is true the method will be package-private and named - * {@code fromJsonWithKnownDiscriminator} instead of being public and named {@code fromJson}. This is done as super - * types use their {@code fromJson} method to determine the discriminator value and pass the reader to the specific - * type being deserialized. The specific type being deserialized may be the super type itself, so it cannot pass to - * {@code fromJson} as this will be a circular call and if the specific type being deserialized is an intermediate - * type (a type having both super and subclasses) it will attempt to perform discriminator validation which has - * already been done. - * - * @param classBlock The class where the {@code fromJson} method is being written. - * @param propertiesManager Properties information about the object being deserialized. - * @param superTypeReading Whether the object reading is for a super type. - * @param deserializationBlock Logic for deserializing the object. - * @param addGeneratedAnnotation Callback that adds {@code @Generated} annotation to a code block. - */ - private static void readJsonObject(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, - boolean superTypeReading, Consumer deserializationBlock, - Consumer addGeneratedAnnotation) { - JavaVisibility visibility = superTypeReading ? JavaVisibility.PackagePrivate : JavaVisibility.Public; - String methodName = superTypeReading ? "fromJsonKnownDiscriminator" : "fromJson"; - - String modelName = propertiesManager.getModel().getName(); - boolean hasRequiredProperties = propertiesManager.hasRequiredProperties(); - - if (!superTypeReading) { - classBlock.javadocComment(javadocComment -> { - javadocComment.description("Reads an instance of " + modelName + " from the JsonReader."); - javadocComment.param("jsonReader", "The JsonReader being read."); - javadocComment.methodReturns("An instance of " + modelName + " if the JsonReader was pointing to an " - + "instance of it, or null if it was pointing to JSON null."); - - String throwsStatement = null; - if (hasRequiredProperties) { - throwsStatement = "If the deserialized JSON object was missing any required properties."; - } - - if (throwsStatement != null) { - javadocComment.methodThrows("IllegalStateException", throwsStatement); - } - - javadocComment.methodThrows("IOException", "If an error occurs while reading the " + modelName + "."); - }); + AtomicReference ifBlockReference = new AtomicReference<>(); + if (!CoreUtils.isNullOrEmpty(propertiesManager.getModel().getParentModelName())) { + String callToSuperFromJsonShared = propertiesManager.getModel().getParentModelName() + + ".fromJsonShared(reader, " + propertiesManager.getJsonReaderFieldNameVariableName() + ", " + + propertiesManager.getDeserializedModelName() + ")"; + ifBlockReference.set(methodBlock.ifBlock(callToSuperFromJsonShared, + ifBlock -> ifBlock.methodReturn("true"))); } - addGeneratedAnnotation.accept(classBlock); - classBlock.staticMethod(visibility, modelName + " " + methodName + "(JsonReader jsonReader) throws IOException", methodBlock -> { - readJsonObjectMethodBody(methodBlock, deserializationBlock); + BiConsumer consumer + = (property, fromSuper) -> handleJsonPropertyDeserialization(propertiesManager.getModel(), property, + modelDeserializedName, methodBlock, ifBlockReference, fieldName, fromSuper, + propertiesManager.hasConstructorArguments(), settings, polymorphicJsonMergePatchScenario, true); + generateThisFromJson(propertiesManager, ifBlockReference, consumer, methodBlock, settings, + polymorphicJsonMergePatchScenario, true, false); + + methodBlock.methodReturn("false"); + }); + } + } + + private static void readJsonObjectMethodBody(JavaBlock methodBlock, Consumer deserializationBlock) { + // For now, use the basic readObject which will return null if the JsonReader is pointing to JsonToken.NULL. + // + // Support for a default value if null will need to be supported and for objects that get their value + // from a JSON value instead of JSON object or are an array type. + methodBlock.line("return jsonReader.readObject(reader -> {"); + deserializationBlock.accept(methodBlock); + methodBlock.line("});"); + } + + private static boolean canUseFromJsonShared(ClientModelPropertiesManager propertiesManager) { + // If the model is part of a polymorphic hierarchy and all models in the polymorphic hierarchy are in the same + // package we can generate a package-private 'toJsonShared' method that can handle deserializing properties + // defined in the parent class(es). + // This will prevent duplicating the deserialization logic for parent properties in each subclass. + return !propertiesManager.hasConstructorArguments() + && propertiesManager.getModel().isAllPolymorphicModelsInSamePackage(); + } + + /** + * Initializes the local variables needed to maintain what has been deserialized. + * + * @param methodBlock The method handling deserialization. + * @param propertiesManager The property manager for the model. + */ + private static void initializeLocalVariables(JavaBlock methodBlock, ClientModelPropertiesManager propertiesManager, + boolean isXml, JavaSettings settings) { + if (propertiesManager.hasConstructorArguments()) { + if (isXml) { + // XML only needs to initialize the XML element properties. XML attribute properties are initialized with + // their XML value. + propertiesManager.forEachSuperXmlElement(element -> initializeLocalVariable(methodBlock, element, true, + settings)); + propertiesManager.forEachXmlElement(element -> initializeLocalVariable(methodBlock, element, false, + settings)); + } else { + propertiesManager.forEachSuperRequiredProperty(property -> { + if (property.isConstant()) { + // Constants are never deserialized. + return; + } + initializeLocalVariable(methodBlock, property, true, settings); }); + propertiesManager.forEachSuperSetterProperty(property -> { + if (ClientModelUtil.readOnlyNotInCtor(propertiesManager.getModel(), property, settings)) { + initializeShadowPropertyLocalVariable(methodBlock, property); + } else { + initializeLocalVariable(methodBlock, property, true, settings); + } + }); + propertiesManager.forEachRequiredProperty(property -> { + if (property.isConstant()) { + // Constants are never deserialized. + return; + } + initializeLocalVariable(methodBlock, property, false, settings); + }); + propertiesManager.forEachSetterProperty(property -> initializeLocalVariable(methodBlock, property, + false, settings)); + } + } else { + String modelName = propertiesManager.getModel().getName(); + methodBlock.line(modelName + " " + propertiesManager.getDeserializedModelName() + " = new " + + modelName + "();"); } - private static void readJsonObjectMethodBody(JavaBlock methodBlock, Consumer deserializationBlock) { - // For now, use the basic readObject which will return null if the JsonReader is pointing to JsonToken.NULL. - // - // Support for a default value if null will need to be supported and for objects that get their value - // from a JSON value instead of JSON object or are an array type. - methodBlock.line("return jsonReader.readObject(reader -> {"); + ClientModelProperty additionalProperty = getAdditionalPropertiesPropertyInModelOrFromSuper(propertiesManager); + if (additionalProperty != null) { + initializeLocalVariable(methodBlock, additionalProperty, false, settings); + } + } - deserializationBlock.accept(methodBlock); + /* + * Shadow properties from parent should be initialized as wired type. + */ + private static void initializeShadowPropertyLocalVariable(JavaBlock methodBlock, ClientModelProperty property) { + IType type = property.getWireType(); + String defaultValue = property.isPolymorphicDiscriminator() + ? property.getDefaultValue() : type.defaultValueExpression(); + methodBlock.line(type + " " + property.getName() + " = " + defaultValue + ";"); + } + private static void initializeLocalVariable(JavaBlock methodBlock, ClientModelProperty property, boolean fromSuper, + JavaSettings settings) { + if (includePropertyInConstructor(property, settings) && !settings.isDisableRequiredJsonAnnotation()) { + // Required properties need an additional boolean variable to indicate they've been found. + methodBlock.line("boolean " + property.getName() + "Found = false;"); + } + + // Always instantiate the local variable. + // If the property is part of the constructor or set by a setter method from the super class, initialize the + // local variable with the client type. Otherwise, initialize as the wire type to prevent multiple conversions + // between wire and client types. + IType type = (includePropertyInConstructor(property, settings) || fromSuper) + ? property.getClientType() : property.getWireType(); + String defaultValue = property.isPolymorphicDiscriminator() + ? property.getDefaultValue() : type.defaultValueExpression(); + methodBlock.line(type + " " + property.getName() + " = " + defaultValue + ";"); + } + + /** + * Adds the while loop that handles reading the JSON object until it is fully consumed. + * + * @param methodBlock The method handling deserialization. + * @param initializeFieldNameVariable Whether the {@code fieldNameVariableName} variable needs to be initialized. If + * this is a nested while loop the variable doesn't need to be initialized. + * @param fieldNameVariableName The name for the variable that tracks the JSON field name. + * @param isXml Whether the reader while loop is for XML reading. + * @param whileBlock The consumer that adds deserialization logic into the while loop. + */ + private static void addReaderWhileLoop(JavaBlock methodBlock, boolean initializeFieldNameVariable, + String fieldNameVariableName, boolean isXml, Consumer whileBlock) { + addReaderWhileLoop("reader", methodBlock, initializeFieldNameVariable, fieldNameVariableName, + isXml, whileBlock); + } + + /** + * Adds the while loop that handles reading the JSON object until it is fully consumed. + * + * @param readerVariableName The name of the local reader variable. + * @param methodBlock The method handling deserialization. + * @param initializeFieldNameVariable Whether the {@code fieldNameVariableName} variable needs to be initialized. If + * this is a nested while loop the variable doesn't need to be initialized. + * @param fieldNameVariableName The name for the variable that tracks the JSON field name. + * @param isXml Whether the reader while loop is for XML reading. + * @param whileBlock The consumer that adds deserialization logic into the while loop. + */ + private static void addReaderWhileLoop(String readerVariableName, JavaBlock methodBlock, boolean initializeFieldNameVariable, + String fieldNameVariableName, boolean isXml, Consumer whileBlock) { + String whileCheck = isXml + ? readerVariableName + ".nextElement() != XmlToken.END_ELEMENT" + : readerVariableName + ".nextToken() != JsonToken.END_OBJECT"; + + methodBlock.block("while (" + whileCheck + ")", whileAction -> { + String fieldNameInitialization = ""; + if (initializeFieldNameVariable) { + fieldNameInitialization = isXml ? "QName" : "String"; + } + + methodBlock.line("%s %s = %s.get%sName();", fieldNameInitialization, fieldNameVariableName, + readerVariableName, isXml ? "Element" : "Field"); + + if (!isXml) { + methodBlock.line(readerVariableName + ".nextToken();"); + } + methodBlock.line(""); + + whileBlock.accept(methodBlock); + }); + } + + private static void handleJsonPropertyDeserialization(ClientModel model, ClientModelProperty property, + String modelVariableName, JavaBlock methodBlock, AtomicReference ifBlockReference, + String fieldNameVariableName, boolean fromSuper, boolean hasConstructorArguments, JavaSettings settings, + boolean polymorphicJsonMergePatchScenario, boolean isFromJsonShared) { + // Property will be handled later by flattened deserialization. + if (property.getNeedsFlatten()) { + return; + } + + JavaIfBlock ifBlock = ifBlockReference.get(); + ifBlock = handleJsonPropertyDeserialization(model, property, modelVariableName, methodBlock, ifBlock, + fieldNameVariableName, fromSuper, hasConstructorArguments, settings, polymorphicJsonMergePatchScenario, + isFromJsonShared); + + ifBlockReference.set(ifBlock); + } + + private static JavaIfBlock handleJsonPropertyDeserialization(ClientModel model, ClientModelProperty property, + String modelVariableName, JavaBlock methodBlock, JavaIfBlock ifBlock, String fieldNameVariableName, + boolean fromSuper, boolean hasConstructorArguments, JavaSettings settings, + boolean polymorphicJsonMergePatchScenario, boolean isFromJsonShared) { + String jsonPropertyName = property.getSerializedName(); + if (CoreUtils.isNullOrEmpty(jsonPropertyName)) { + return ifBlock; + } + + return ifOrElseIf(methodBlock, ifBlock, "\"" + jsonPropertyName + "\".equals(" + fieldNameVariableName + ")", + deserializationBlock -> { + generateJsonDeserializationLogic(deserializationBlock, modelVariableName, model, property, fromSuper, + hasConstructorArguments, settings, polymorphicJsonMergePatchScenario); + if (isFromJsonShared) { + deserializationBlock.methodReturn("true"); + } + }); + } + + private static void handleFlattenedPropertiesDeserialization( + JsonFlattenedPropertiesTree flattenedProperties, JavaBlock methodBlock, JavaIfBlock ifBlock, + ClientModelProperty additionalProperties, String fieldNameVariableName, boolean hasConstructorArguments, + JavaSettings settings, boolean polymorphicJsonMergePatchScenario, boolean isFromJsonShared) { + // The initial call to handle flattened properties is using the base node which is just a holder. + for (JsonFlattenedPropertiesTree structure : flattenedProperties.getChildrenNodes().values()) { + handleFlattenedPropertiesDeserializationHelper(structure, methodBlock, ifBlock, additionalProperties, + fieldNameVariableName, hasConstructorArguments, settings, polymorphicJsonMergePatchScenario, + isFromJsonShared, 0); + } + } + + private static JavaIfBlock handleFlattenedPropertiesDeserializationHelper( + JsonFlattenedPropertiesTree flattenedProperties, JavaBlock methodBlock, JavaIfBlock ifBlock, + ClientModelProperty additionalProperties, String fieldNameVariableName, boolean hasConstructorArguments, + JavaSettings settings, boolean polymorphicJsonMergePatchScenario, boolean isFromJsonShared, int depth) { + ClientModelPropertyWithMetadata propertyWithMetadata = flattenedProperties.getProperty(); + if (propertyWithMetadata != null) { + String modelVariableName = "deserialized" + propertyWithMetadata.getModel().getName(); + + // This is a terminal location, so only need to handle checking for the property name. + return ifOrElseIf(methodBlock, ifBlock, + "\"" + flattenedProperties.getNodeName() + "\".equals(" + fieldNameVariableName + ")", + deserializationBlock -> generateJsonDeserializationLogic(deserializationBlock, modelVariableName, + propertyWithMetadata.getModel(), propertyWithMetadata.getProperty(), + propertyWithMetadata.isFromSuperClass(), hasConstructorArguments, settings, + polymorphicJsonMergePatchScenario)); + } else { + // Otherwise this is an intermediate location and a while loop reader needs to be added. + return ifOrElseIf(methodBlock, ifBlock, + "\"" + flattenedProperties.getNodeName() + "\".equals(" + fieldNameVariableName + ") && reader.currentToken() == JsonToken.START_OBJECT", + ifAction -> { + addReaderWhileLoop(ifAction, false, fieldNameVariableName, false, whileBlock -> { + JavaIfBlock innerIfBlock = null; + for (JsonFlattenedPropertiesTree structure : flattenedProperties.getChildrenNodes().values()) { + innerIfBlock = handleFlattenedPropertiesDeserializationHelper(structure, methodBlock, + innerIfBlock, additionalProperties, fieldNameVariableName, hasConstructorArguments, + settings, polymorphicJsonMergePatchScenario, isFromJsonShared, depth + 1); + } + + handleUnknownJsonFieldDeserialization(whileBlock, innerIfBlock, additionalProperties, + fieldNameVariableName); + }); + + if (isFromJsonShared && depth == 0) { + // Flattening will handle skipping and additional properties itself. + ifAction.methodReturn("true"); + } + }); + } + } + + private static void generateJsonDeserializationLogic(JavaBlock deserializationBlock, String modelVariableName, + ClientModel model, ClientModelProperty property, boolean fromSuper, boolean hasConstructorArguments, JavaSettings settings, + boolean polymorphicJsonMergePatchScenario) { + IType wireType = property.getWireType(); + IType clientType = property.getClientType(); + + // Attempt to determine whether the wire type is simple deserialization. + // This is primitives, boxed primitives, a small set of string based models, and other ClientModels. + String simpleDeserialization = getSimpleJsonDeserialization(wireType, "reader"); + if (simpleDeserialization != null) { + // Need to convert the wire type to the client type for constructors. + // Need to convert the wire type to the client type for public setters. + boolean convertToClientType = (clientType != wireType) + && (includePropertyInConstructor(property, settings) || (fromSuper && !ClientModelUtil.readOnlyNotInCtor(model, property, settings))); + BiConsumer simpleDeserializationConsumer = (logic, block) -> { + if (!hasConstructorArguments) { + handleSettingDeserializedValue(block, modelVariableName, model, property, logic, fromSuper, + polymorphicJsonMergePatchScenario); + } else { + block.line(property.getName() + " = " + logic + ";"); + } + }; + + if (convertToClientType) { + // If the wire type is nullable don't attempt to call the convert to client type until it's known that + // a value was deserialized. This protects against cases such as UnixTimeLong where the wire type is + // Long and the client type of OffsetDateTime. This is converted using Instant.ofEpochMilli(long) which + // would result in a null if the Long is null, which is already guarded using + // reader.readNullable(nonNullReader -> Instant.ofEpochMillis(nonNullReader.readLong())) but this itself + // returns null which would have been passed to OffsetDateTime.ofInstant(Instant, ZoneId) which would + // have thrown a NullPointerException. + if (wireType.isNullable()) { + // Check if the property is required, if so use a holder name as there will be an existing holder + // variable for the value that will be used in the constructor. + String holderName = property.getName() + "Holder"; + deserializationBlock.line(wireType + " " + holderName + " = " + simpleDeserialization + ";"); + deserializationBlock.ifBlock(holderName + " != null", ifBlock -> + simpleDeserializationConsumer.accept(wireType.convertToClientType(holderName), ifBlock)); + } else { + simpleDeserializationConsumer.accept(wireType.convertToClientType(simpleDeserialization), + deserializationBlock); + } + } else { + simpleDeserializationConsumer.accept(simpleDeserialization, deserializationBlock); + } + } else if (wireType == ClassType.OBJECT) { + if (!hasConstructorArguments) { + handleSettingDeserializedValue(deserializationBlock, modelVariableName, model, property, + "reader.readUntyped()", fromSuper, polymorphicJsonMergePatchScenario); + } else { + deserializationBlock.line(property.getName() + " = reader.readUntyped();"); + } + } else if (wireType instanceof IterableType) { + if (!hasConstructorArguments) { + deserializationBlock.text(property.getClientType() + " "); + } + + deserializationBlock.text(property.getName() + " = "); + deserializeJsonContainerProperty(deserializationBlock, "readArray", wireType, + ((IterableType) wireType).getElementType(), ((IterableType) clientType).getElementType(), 0); + + if (!hasConstructorArguments) { + handleSettingDeserializedValue(deserializationBlock, modelVariableName, model, property, + property.getName(), fromSuper, polymorphicJsonMergePatchScenario); + } + } else if (wireType instanceof MapType) { + if (!hasConstructorArguments) { + deserializationBlock.text(property.getClientType() + " "); + } + + // Assumption is that the key type for the Map is a String. This may not always hold true and when that + // becomes reality this will need to be reworked to handle that case. + deserializationBlock.text(property.getName() + " = "); + deserializeJsonContainerProperty(deserializationBlock, "readMap", wireType, + ((MapType) wireType).getValueType(), ((MapType) clientType).getValueType(), 0); + + if (!hasConstructorArguments) { + handleSettingDeserializedValue(deserializationBlock, modelVariableName, model, property, + property.getName(), fromSuper, polymorphicJsonMergePatchScenario); + } + } else { + // TODO (alzimmer): Resolve this as deserialization logic generation needs to handle all cases. + throw new RuntimeException("Unknown wire type " + wireType + ". Need to add support for it."); + } + + // If the property was required, mark it as found. + if (includePropertyInConstructor(property, settings) && !settings.isDisableRequiredJsonAnnotation()) { + deserializationBlock.line(property.getName() + "Found = true;"); + } + } + + /** + * Helper method to deserialize a container property (such as {@link List} and {@link Map}). + * + * @param methodBlock The method handling deserialization. + * @param utilityMethod The method aiding in the deserialization of the container. + * @param containerType The container type. + * @param elementWireType The element type for the container, for a {@link List} this is the element type and for a + * {@link Map} this is the value type. + * @param depth Depth of recursion for container types, such as {@code Map>} would be 0 when + * {@code Map} is being handled and then 1 when {@code List} is being handled. + */ + private static void deserializeJsonContainerProperty(JavaBlock methodBlock, String utilityMethod, IType containerType, + IType elementWireType, IType elementClientType, int depth) { + String callingReaderName = depth == 0 ? "reader" : "reader" + depth; + String lambdaReaderName = "reader" + (depth + 1); + String valueDeserializationMethod = getSimpleJsonDeserialization(elementWireType, lambdaReaderName); + boolean convertToClientType = (elementClientType != elementWireType); + boolean useCodeBlockLambda = valueDeserializationMethod != null && elementWireType.isNullable() + && convertToClientType; + + if (useCodeBlockLambda) { + methodBlock.line(callingReaderName + "." + utilityMethod + "(" + lambdaReaderName + " -> {"); + } else { + methodBlock.line(callingReaderName + "." + utilityMethod + "(" + lambdaReaderName + " ->"); + } + methodBlock.indent(() -> { + if (valueDeserializationMethod != null) { + if (convertToClientType) { + // If the wire type is nullable don't attempt to call the convert to client type until it's known that + // a value was deserialized. This protects against cases such as UnixTimeLong where the wire type is + // Long and the client type of OffsetDateTime. This is converted using Instant.ofEpochMilli(long) which + // would result in a null if the Long is null, which is already guarded using + // reader.readNullable(nonNullReader -> Instant.ofEpochMillis(nonNullReader.readLong())) but this itself + // returns null which would have been passed to OffsetDateTime.ofInstant(Instant, ZoneId) which would + // have thrown a NullPointerException. + if (elementWireType.isNullable()) { + // Check if the property is required, if so use a holder name as there will be an existing holder + // variable for the value that will be used in the constructor. + String holderName = lambdaReaderName + "ValueHolder"; + methodBlock.line(elementWireType + " " + holderName + " = " + valueDeserializationMethod + ";"); + methodBlock.ifBlock(holderName + " != null", + ifBlock -> ifBlock.methodReturn(elementWireType.convertToClientType(holderName))) + .elseBlock(elseBlock -> elseBlock.methodReturn("null")); + } else { + methodBlock.line(elementWireType.convertToClientType(valueDeserializationMethod)); + } + } else { + methodBlock.line(valueDeserializationMethod); + } + } else if (elementWireType == ClassType.OBJECT) { + methodBlock.line(lambdaReaderName + ".readUntyped()"); + } else if (elementWireType instanceof IterableType) { + deserializeJsonContainerProperty(methodBlock, "readArray", elementWireType, + ((IterableType) elementWireType).getElementType(), + ((IterableType) elementClientType).getElementType(), depth + 1); + } else if (elementWireType instanceof MapType) { + // Assumption is that the key type for the Map is a String. This may not always hold true and when that + // becomes reality this will need to be reworked to handle that case. + deserializeJsonContainerProperty(methodBlock, "readMap", elementWireType, + ((MapType) elementWireType).getValueType(), ((MapType) elementClientType).getValueType(), + depth + 1); + } else if (elementWireType == ClassType.BINARY_DATA) { + methodBlock.line(lambdaReaderName + ".readUntyped()"); + } else { + throw new RuntimeException("Unknown value type " + elementWireType + " in " + containerType + + " serialization. Need to add support for it."); + } + }); + + if (useCodeBlockLambda) { + if (depth > 0) { + methodBlock.line("})"); + } else { methodBlock.line("});"); + } + } else { + if (depth > 0) { + methodBlock.line(")"); + } else { + methodBlock.line(");"); + } + } + } + + private static String getSimpleJsonDeserialization(IType wireType, String readerName) { + return (wireType instanceof ClassType && ((ClassType) wireType).isSwaggerType()) + ? wireType + ".fromJson(" + readerName + ")" + : wireType.jsonDeserializationMethod(readerName); + } + + private static void handleUnknownJsonFieldDeserialization(JavaBlock methodBlock, JavaIfBlock ifBlock, + ClientModelProperty additionalProperties, String fieldNameVariableName) { + Consumer unknownFieldConsumer = javaBlock -> { + if (additionalProperties != null) { + javaBlock.ifBlock(additionalProperties.getName() + " == null", + ifAction -> ifAction.line(additionalProperties.getName() + " = new LinkedHashMap<>();")); + javaBlock.line(); + + // Assumption, additional properties is a Map of String-Object + IType valueType = ((MapType) additionalProperties.getWireType()).getValueType(); + if (valueType == ClassType.OBJECT) { + // String fieldName should be a local variable accessible in this spot of code. + javaBlock.line(additionalProperties.getName() + ".put(" + fieldNameVariableName + ", reader.readUntyped());"); + } else if (valueType instanceof IterableType) { + // The case that element is a List + String varName = additionalProperties.getName() + "ArrayItem"; + javaBlock.text(valueType + " " + varName + " = "); + deserializeJsonContainerProperty(javaBlock, "readArray", valueType, + ((IterableType) valueType).getElementType(), ((IterableType) valueType).getElementType(), 0); + javaBlock.line(additionalProperties.getName() + ".put(" + fieldNameVariableName + ", " + varName + ");"); + } else { + // Another assumption, the additional properties value type is simple. + javaBlock.line(additionalProperties.getName() + ".put(" + fieldNameVariableName + ", " + + getSimpleJsonDeserialization(valueType, "reader") + ");"); + } + } else { + javaBlock.line("reader.skipChildren();"); + } + }; + + if (ifBlock == null) { + unknownFieldConsumer.accept(methodBlock); + } else { + ifBlock.elseBlock(unknownFieldConsumer); + } + } + + /** + * Handles validating that all required properties have been found and creating the return type. + *

+ * Properties are split into two concepts, required and optional properties, and those concepts are split into an + * additional two groups, properties declared by super types and by the model type. + * + * @param methodBlock The method handling deserialization. + * @param modelName The name of the model. + * @param propertiesManager The property manager for the model. + */ + private static void handleReadReturn(JavaBlock methodBlock, String modelName, + ClientModelPropertiesManager propertiesManager, JavaSettings settings) { + StringBuilder constructorArgs = new StringBuilder(); + + propertiesManager.forEachSuperConstructorProperty(arg -> addConstructorParameter(constructorArgs, arg.getName())); + propertiesManager.forEachConstructorProperty(arg -> addConstructorParameter(constructorArgs, arg.getName())); + + // If there are required properties of any type we must check that all required fields were found. + if (propertiesManager.hasRequiredProperties()) { + StringBuilder ifStatementBuilder = new StringBuilder(); + propertiesManager.forEachSuperRequiredProperty(property -> addRequiredCheck(ifStatementBuilder, property, settings)); + propertiesManager.forEachRequiredProperty(property -> addRequiredCheck(ifStatementBuilder, property, settings)); + + if (ifStatementBuilder.length() > 0) { + methodBlock.ifBlock(ifStatementBuilder.toString(), ifAction -> + createObjectAndReturn(methodBlock, modelName, constructorArgs.toString(), propertiesManager, settings)); + + if (propertiesManager.getRequiredPropertiesCount() == 1) { + StringBuilder stringBuilder = new StringBuilder(); + propertiesManager.forEachSuperRequiredProperty(property -> stringBuilder.append(property.getSerializedName())); + propertiesManager.forEachRequiredProperty(property -> stringBuilder.append(property.getSerializedName())); + methodBlock.line("throw new IllegalStateException(\"Missing required property: " + stringBuilder + "\");"); + } else { + methodBlock.line("List missingProperties = new ArrayList<>();"); + propertiesManager.forEachSuperRequiredProperty(property -> addFoundValidationIfCheck(methodBlock, property, settings)); + propertiesManager.forEachRequiredProperty(property -> addFoundValidationIfCheck(methodBlock, property, settings)); + + methodBlock.line(); + methodBlock.line("throw new IllegalStateException(\"Missing required property/properties: \" + String.join(\", \", missingProperties));"); + } + } else { + createObjectAndReturn(methodBlock, modelName, constructorArgs.toString(), propertiesManager, settings); + } + } else { + createObjectAndReturn(methodBlock, modelName, constructorArgs.toString(), propertiesManager, settings); + } + } + + private static void createObjectAndReturn(JavaBlock methodBlock, String modelName, String constructorArgs, + ClientModelPropertiesManager propertiesManager, JavaSettings settings) { + boolean polymorphicJsonMergePatchScenario = propertiesManager.getModel().isPolymorphic() + && ClientModelUtil.isJsonMergePatchModel(propertiesManager.getModel(), settings); + if (propertiesManager.hasConstructorArguments()) { + if (propertiesManager.getSetterPropertiesCount() == 0 + && propertiesManager.getReadOnlyPropertiesCount() == 0 + && propertiesManager.getAdditionalProperties() == null + && propertiesManager.getSuperAdditionalPropertiesProperty() == null) { + methodBlock.methodReturn("new " + modelName + "(" + constructorArgs + ")"); + return; + } + + methodBlock.line(modelName + " " + propertiesManager.getDeserializedModelName() + " = new " + modelName + + "(" + constructorArgs + ");"); + + BiConsumer handleSettingDeserializedValue = (property, fromSuper) -> + handleSettingDeserializedValue(methodBlock, propertiesManager.getDeserializedModelName(), + propertiesManager.getModel(), property, property.getName(), fromSuper, + polymorphicJsonMergePatchScenario); + + propertiesManager.forEachSuperReadOnlyProperty(property -> handleSettingDeserializedValue.accept(property, true)); + propertiesManager.forEachSuperSetterProperty(property -> handleSettingDeserializedValue.accept(property, true)); + propertiesManager.forEachReadOnlyProperty(property -> handleSettingDeserializedValue.accept(property, false)); + propertiesManager.forEachSetterProperty(property -> handleSettingDeserializedValue.accept(property, false)); } - /** - * Initializes the local variables needed to maintain what has been deserialized. - * - * @param methodBlock The method handling deserialization. - * @param propertiesManager The property manager for the model. - */ - private static void initializeLocalVariables(JavaBlock methodBlock, ClientModelPropertiesManager propertiesManager, - boolean isXml, JavaSettings settings) { - if (propertiesManager.hasConstructorArguments()) { - if (isXml) { - // XML only needs to initialize the XML element properties. XML attribute properties are initialized with - // their XML value. - propertiesManager.forEachSuperXmlElement(element -> initializeLocalVariable(methodBlock, element, true, - settings)); - propertiesManager.forEachXmlElement(element -> initializeLocalVariable(methodBlock, element, false, - settings)); - } else { - propertiesManager.forEachSuperRequiredProperty(property -> { - if (property.isConstant()) { - // Constants are never deserialized. - return; - } - initializeLocalVariable(methodBlock, property, true, settings); - }); - propertiesManager.forEachSuperSetterProperty(property -> { - if (readOnlyNotInCtor(propertiesManager.getModel(), property, settings)) { - initializeShadowPropertyLocalVariable(methodBlock, property); - } else { - initializeLocalVariable(methodBlock, property, true, settings); - } - }); - propertiesManager.forEachRequiredProperty(property -> { - if (property.isConstant()) { - // Constants are never deserialized. - return; - } - initializeLocalVariable(methodBlock, property, false, settings); - }); - propertiesManager.forEachSetterProperty(property -> initializeLocalVariable(methodBlock, property, - false, settings)); - } + if (propertiesManager.getAdditionalProperties() != null) { + handleSettingDeserializedValue(methodBlock, propertiesManager.getDeserializedModelName(), + propertiesManager.getModel(), propertiesManager.getAdditionalProperties(), + propertiesManager.getAdditionalProperties().getName(), false, polymorphicJsonMergePatchScenario); + } else if (propertiesManager.getSuperAdditionalPropertiesProperty() != null) { + handleSettingDeserializedValue(methodBlock, propertiesManager.getDeserializedModelName(), + propertiesManager.getModel(), propertiesManager.getSuperAdditionalPropertiesProperty(), + propertiesManager.getSuperAdditionalPropertiesProperty().getName(), true, + polymorphicJsonMergePatchScenario); + } + + methodBlock.line(); + methodBlock.methodReturn(propertiesManager.getDeserializedModelName()); + } + + private static void addConstructorParameter(StringBuilder constructor, String parameterName) { + if (constructor.length() > 0) { + constructor.append(", "); + } + + constructor.append(parameterName); + } + + private static void addRequiredCheck(StringBuilder ifCheck, ClientModelProperty property, JavaSettings settings) { + // XML attributes and text don't need checks. + if (property.isXmlAttribute() || property.isXmlText() || !includePropertyInConstructor(property, settings)) { + return; + } + + // Constants are ignored during deserialization. + if (property.isConstant()) { + return; + } + + // Required properties aren't being validated for being found. + if (settings.isDisableRequiredJsonAnnotation()) { + return; + } + + if (ifCheck.length() > 0) { + ifCheck.append(" && "); + } + + ifCheck.append(property.getName()).append("Found"); + } + + private static void addFoundValidationIfCheck(JavaBlock methodBlock, ClientModelProperty property, + JavaSettings settings) { + // XML attributes and text don't need checks. + if (property.isXmlAttribute() || property.isXmlText() || !includePropertyInConstructor(property, settings)) { + return; + } + + // Constants are ignored during deserialization. + if (property.isConstant()) { + return; + } + + // Required properties aren't being validated for being found. + if (settings.isDisableRequiredJsonAnnotation()) { + return; + } + + methodBlock.ifBlock("!" + property.getName() + "Found", + ifAction -> ifAction.line("missingProperties.add(\"" + property.getSerializedName() + "\");")); + } + + private static void handleSettingDeserializedValue(JavaBlock methodBlock, String modelVariableName, + ClientModel model, ClientModelProperty property, String value, boolean fromSuper, + boolean polymorphicJsonMergePatchScenario) { + // If the property is defined in a super class use the setter as this will be able to set the value in the + // super class. + if (fromSuper + // If the property is flattened or read-only from parent, it will be shadowed in child class. + && (!ClientModelUtil.readOnlyNotInCtor(model, property, JavaSettings.getInstance()) && !property.getClientFlatten())) { + if (polymorphicJsonMergePatchScenario) { + // Polymorphic JSON merge patch needs special handling as the setter methods are used to track whether + // the property is included in patch serialization. To prevent deserialization from requiring parent + // defined properties to always be included in serialization, access helpers are used to set the value + // without marking the property as included in the patch. + ClientModel definingModel = definingModel(model, property); + methodBlock.line("JsonMergePatchHelper.get" + definingModel.getName() + "Accessor()." + + property.getSetterName() + "(" + modelVariableName + ", " + value + ");"); + } else { + methodBlock.line(modelVariableName + "." + property.getSetterName() + "(" + value + ");"); + } + } else { + methodBlock.line(modelVariableName + "." + property.getName() + " = " + value + ";"); + } + } + + private static boolean isSuperTypeWithDiscriminator(ClientModel child) { + return !CoreUtils.isNullOrEmpty(child.getPolymorphicDiscriminatorName()) + && !CoreUtils.isNullOrEmpty(child.getDerivedModels()); + } + + // TODO (alzimmer): This is a very inefficient design where we're using the ClientModelProperty to find which model + // in the polymorphic hierarchy defines it, but this is a simple bootstrapping method rather than a larger + // re-architecting. + private static ClientModel definingModel(ClientModel model, ClientModelProperty property) { + while (model != null) { + if (model.getProperties().stream().anyMatch(prop -> Objects.equals(prop.getName(), property.getName()))) { + return model; + } + model = ClientModelUtil.getClientModel(model.getParentModelName()); + } + + throw new IllegalStateException("No ClientModel in the polymorphic hierarchy define this property, this should never happen."); + } + + /** + * Helper method for adding a base if condition or an else if condition. + * + * @param baseBlock Base code block where an if condition would be added. + * @param ifBlock If block where an else if condition would be added. + * @param condition The conditional statement. + * @param action The conditional action. + * @return An if block for further chaining. + */ + private static JavaIfBlock ifOrElseIf(JavaBlock baseBlock, JavaIfBlock ifBlock, String condition, + Consumer action) { + return (ifBlock == null) ? baseBlock.ifBlock(condition, action) : ifBlock.elseIfBlock(condition, action); + } + + private static void writeToXml(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, + Consumer addGeneratedAnnotation) { + addGeneratedAnnotation.accept(classBlock); + classBlock.annotation("Override"); + classBlock.publicMethod("XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException", + methodBlock -> methodBlock.methodReturn("toXml(xmlWriter, null)")); + + addGeneratedAnnotation.accept(classBlock); + classBlock.annotation("Override"); + classBlock.publicMethod("XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException", methodBlock -> { + String modelXmlName = propertiesManager.getXmlRootElementName(); + methodBlock.line("rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? \"" + modelXmlName + "\" : rootElementName;"); + methodBlock.line("xmlWriter.writeStartElement(rootElementName);"); + + String modelXmlNamespace = propertiesManager.getXmlRootElementNamespace(); + if (modelXmlNamespace != null) { + methodBlock.line("xmlWriter.writeNamespace(" + propertiesManager.getXmlNamespaceConstant(modelXmlNamespace) + ");"); + } + + propertiesManager.forEachXmlNamespaceWithPrefix((prefix, namespace) -> + methodBlock.line("xmlWriter.writeNamespace(\"" + prefix + "\", " + propertiesManager.getXmlNamespaceConstant(namespace) + ");")); + + // Assumption for XML is polymorphic discriminators are attributes. + if (propertiesManager.getDiscriminatorProperty() != null) { + serializeXml(methodBlock, propertiesManager.getDiscriminatorProperty().getProperty(), false, + propertiesManager); + } + + propertiesManager.forEachSuperXmlAttribute(property -> serializeXml(methodBlock, property, true, propertiesManager)); + propertiesManager.forEachXmlAttribute(property -> serializeXml(methodBlock, property, false, propertiesManager)); + + // Valid XML should only either have elements or text. + if (propertiesManager.hasXmlElements()) { + propertiesManager.forEachSuperXmlElement(property -> serializeXml(methodBlock, property, true, propertiesManager)); + propertiesManager.forEachXmlElement(property -> serializeXml(methodBlock, property, false, propertiesManager)); + } else { + propertiesManager.forEachSuperXmlText(property -> serializeXml(methodBlock, property, true, propertiesManager)); + propertiesManager.forEachXmlText(property -> serializeXml(methodBlock, property, false, propertiesManager)); + } + + methodBlock.methodReturn("xmlWriter.writeEndElement()"); + }); + } + + /** + * Serializes an XML element. + * + * @param methodBlock The method handling serialization. + * @param element The XML element being serialized. + * @param fromSuperType Whether the property is defined in the super type. + */ + private static void serializeXml(JavaBlock methodBlock, ClientModelProperty element, boolean fromSuperType, + ClientModelPropertiesManager propertiesManager) { + IType clientType = element.getClientType(); + IType wireType = element.getWireType(); + String propertyValueGetter; + if (fromSuperType) { + propertyValueGetter = (clientType != wireType) + ? wireType.convertFromClientType(element.getGetterName() + "()") + : element.getGetterName() + "()"; + } else { + propertyValueGetter = "this." + element.getName(); + } + + // Attempt to determine whether the wire type is simple serialization. + // This is primitives, boxed primitives, a small set of string based models, and other ClientModels. + String xmlSerializationMethodCall = wireType.xmlSerializationMethodCall("xmlWriter", element.getXmlName(), + propertiesManager.getXmlNamespaceConstant(element.getXmlNamespace()), propertyValueGetter, + element.isXmlAttribute(), false, true); + if (xmlSerializationMethodCall != null) { + Consumer serializationLogic = javaBlock -> { + // XML text has special handling. + if (element.isXmlText()) { + javaBlock.line("xmlWriter.writeString(" + propertyValueGetter + ");"); } else { - String modelName = propertiesManager.getModel().getName(); - methodBlock.line(modelName + " " + propertiesManager.getDeserializedModelName() + " = new " - + modelName + "();"); + javaBlock.line(xmlSerializationMethodCall + ";"); + } + }; + + // If the property is from a super type and the client type is different from the wire type then a null + // check is required to prevent a NullPointerException when converting the value. + if (fromSuperType && clientType != wireType && clientType.isNullable()) { + methodBlock.ifBlock(propertyValueGetter + " != null", serializationLogic); + } else { + serializationLogic.accept(methodBlock); + } + } else if (wireType instanceof ClassType && ((ClassType) wireType).isSwaggerType()) { + methodBlock.line("xmlWriter.writeXml(" + propertyValueGetter + ");"); + } else if (wireType instanceof IterableType) { + IType elementType = ((IterableType) wireType).getElementType(); + + methodBlock.ifBlock(propertyValueGetter + " != null", ifAction -> { + if (element.isXmlWrapper()) { + String writeStartElement = element.getXmlNamespace() == null + ? "xmlWriter.writeStartElement(\"" + element.getXmlName() + "\");" + : "xmlWriter.writeStartElement(" + propertiesManager.getXmlNamespaceConstant(element.getXmlNamespace()) + ", \"" + element.getXmlName() + "\");"; + ifAction.line(writeStartElement); } + String xmlWrite = elementType.xmlSerializationMethodCall("xmlWriter", element.getXmlListElementName(), + propertiesManager.getXmlNamespaceConstant(element.getXmlListElementNamespace()), "element", false, + false, true); + ifAction.line("for (%s element : %s) {", elementType, propertyValueGetter); + ifAction.indent(() -> ifAction.line(xmlWrite + ";")); + ifAction.line("}"); + + if (element.isXmlWrapper()) { + ifAction.line("xmlWriter.writeEndElement();"); + } + }); + } else if (wireType instanceof MapType) { + // Assumption is that the key type for the Map is a String. This may not always hold true and when that + // becomes reality this will need to be reworked to handle that case. + IType valueType = ((MapType) wireType).getValueType(); + + methodBlock.ifBlock(propertyValueGetter + " != null", ifAction -> { + ifAction.line("xmlWriter.writeStartElement(\"" + element.getXmlName() + "\");"); + + if (valueType instanceof ClassType && ((ClassType) valueType).isSwaggerType()) { + String writeStartElement = (element.getXmlNamespace() != null) + ? "xmlWriter.writeStartElement(" + propertiesManager.getXmlNamespaceConstant(element.getXmlNamespace()) + ", key);" + : "xmlWriter.writeStartElement(key);"; + + ifAction.line("for (Map.Entry entry : %s.entrySet()) {", valueType, propertyValueGetter); + ifAction.indent(() -> { + ifAction.line(writeStartElement); + ifAction.line("xmlWriter.writeXml(entry.getValue());"); + ifAction.line("xmlWriter.writeEndElement();"); + }); + ifAction.line("}"); + } else { + String xmlWrite = valueType.xmlSerializationMethodCall("xmlWriter", "entry.getKey()", + propertiesManager.getXmlNamespaceConstant(element.getXmlNamespace()), "entry.getValue()", false, + true, true); + + ifAction.line("for (Map.Entry entry : %s.entrySet()) {", valueType, propertyValueGetter); + ifAction.indent(() -> ifAction.line(xmlWrite + ";")); + ifAction.line("}"); + } + + ifAction.line("xmlWriter.writeEndElement();"); + }); + } else { + // TODO (alzimmer): Resolve this as serialization logic generation needs to handle all cases. + throw new RuntimeException("Unknown wire type " + wireType + " in XML element serialization. " + + "Need to add support for it."); + } + } + + private static void writeFromXml(JavaClass classBlock, ClientModel model, + ClientModelPropertiesManager propertiesManager, JavaSettings settings, + Consumer addGeneratedAnnotation) { + if (isSuperTypeWithDiscriminator(model)) { + writeSuperTypeFromXml(classBlock, model, propertiesManager, settings, addGeneratedAnnotation); + } else { + writeTerminalTypeFromXml(classBlock, propertiesManager, settings, addGeneratedAnnotation); + } + } + + /** + * Writes a super type's {@code fromXml(XmlReader)} method. + * + * @param classBlock The class having {@code fromXml(XmlReader)} written to it. + * @param model The Autorest representation of the model. + * @param propertiesManager The properties for the model. + * @param settings The Autorest generation settings. + * @param addGeneratedAnnotation Consumer for adding the generated annotation to the class. + */ + private static void writeSuperTypeFromXml(JavaClass classBlock, ClientModel model, + ClientModelPropertiesManager propertiesManager, JavaSettings settings, + Consumer addGeneratedAnnotation) { + // Handling polymorphic fields while determining which subclass, or the class itself, to deserialize handles the + // discriminator type always as a String. This is permissible as the found discriminator is never being used in + // a setter or for setting a field, unlike in the actual deserialization method where it needs to be the same + // type as the field. + ClientModelProperty discriminatorProperty = propertiesManager.getDiscriminatorProperty().getProperty(); + readXmlObject(classBlock, propertiesManager, false, methodBlock -> { + // Assumption for now for XML, only XML properties are used for handling inheritance. + // If this found to be wrong in the future copy the concept of bufferObject and resettable from azure-json + // into azure-xml as bufferElement and resettable. + methodBlock.line("// Get the XML discriminator attribute."); + if (discriminatorProperty.getXmlNamespace() != null) { + methodBlock.line("String discriminatorValue = reader.getStringAttribute(" + + propertiesManager.getXmlNamespaceConstant(discriminatorProperty.getXmlNamespace()) + ", " + + "\"" + discriminatorProperty.getSerializedName() + "\");"); + } else { + methodBlock.line("String discriminatorValue = reader.getStringAttribute(" + + "\"" + discriminatorProperty.getSerializedName() + "\");"); + } + + methodBlock.line("// Use the discriminator value to determine which subtype should be deserialized."); + + // Add deserialization for the super type itself. + JavaIfBlock ifBlock = null; + + // Add deserialization for all child types. + List childTypes = getAllChildTypes(model, new ArrayList<>()); + for (ClientModel childType : childTypes) { + ifBlock = ifOrElseIf(methodBlock, ifBlock, "\"" + childType.getSerializedName() + "\".equals(discriminatorValue)", + ifStatement -> ifStatement.methodReturn(childType.getName() + (isSuperTypeWithDiscriminator(childType) + ? ".fromXmlInternal(reader, finalRootElementName)" + : ".fromXml(reader, finalRootElementName)"))); + } + + if (ifBlock == null) { + methodBlock.methodReturn("fromXmlInternal(reader, finalRootElementName)"); + } else { + ifBlock.elseBlock(elseBlock -> elseBlock.methodReturn("fromXmlInternal(reader, finalRootElementName)")); + } + }, addGeneratedAnnotation); + + readXmlObject(classBlock, propertiesManager, true, + methodBlock -> writeFromXmlDeserialization(methodBlock, propertiesManager, settings), + addGeneratedAnnotation); + } + + /** + * Adds a static method to the class with the signature that handles reading the XML string into the object type. + *

+ * If {@code superTypeReading} is true the method will be package-private and named + * {@code fromXmlWithKnownDiscriminator} instead of being public and named {@code fromXml}. This is done as super + * types use their {@code fromXml} method to determine the discriminator value and pass the reader to the specific + * type being deserialized. The specific type being deserialized may be the super type itself, so it cannot pass to + * {@code fromXml} as this will be a circular call and if the specific type being deserialized is an intermediate + * type (a type having both super and subclasses) it will attempt to perform discriminator validation which has + * already been done. + * + * @param classBlock The class where the {@code fromXml} method is being written. + * @param propertiesManager Properties information about the object being deserialized. + * @param superTypeReading Whether the object reading is for a super type. + * @param deserializationBlock Logic for deserializing the object. + * @param addGeneratedAnnotation Consumer for adding the generated annotation to the class. + */ + private static void readXmlObject(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, + boolean superTypeReading, Consumer deserializationBlock, + Consumer addGeneratedAnnotation) { + JavaVisibility visibility = superTypeReading ? JavaVisibility.PackagePrivate : JavaVisibility.Public; + String methodName = superTypeReading ? "fromXmlInternal" : "fromXml"; + + String modelName = propertiesManager.getModel().getName(); + boolean hasRequiredProperties = propertiesManager.hasConstructorArguments(); + boolean isPolymorphic = propertiesManager.getDiscriminatorProperty() != null + && CoreUtils.isNullOrEmpty(propertiesManager.getModel().getDerivedModels()); + + if (!superTypeReading) { + fromXmlJavadoc(classBlock, modelName, false, hasRequiredProperties, isPolymorphic); + addGeneratedAnnotation.accept(classBlock); + classBlock.publicStaticMethod(modelName + " fromXml(XmlReader xmlReader) throws XMLStreamException", + methodBlock -> methodBlock.methodReturn("fromXml(xmlReader, null)")); + + fromXmlJavadoc(classBlock, modelName, true, hasRequiredProperties, isPolymorphic); + } + + addGeneratedAnnotation.accept(classBlock); + classBlock.staticMethod(visibility, modelName + " " + methodName + "(XmlReader xmlReader, String rootElementName) throws XMLStreamException", methodBlock -> { + // For now, use the basic readObject which will return null if the XmlReader is pointing to JsonToken.NULL. + // + // Support for a default value if null will need to be supported and for objects that get their value + // from a JSON value instead of JSON object or are an array type. + String requiredElementName = propertiesManager.getXmlRootElementName(); + String requiredNamespace = propertiesManager.getXmlRootElementNamespace(); + + methodBlock.line("String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? " + + "\"" + requiredElementName + "\" : rootElementName;"); + if (requiredNamespace != null) { + methodBlock.line("return xmlReader.readObject(" + propertiesManager.getXmlNamespaceConstant(requiredNamespace) + ", finalRootElementName, reader -> {"); + } else { + methodBlock.line("return xmlReader.readObject(finalRootElementName, reader -> {"); + } + + deserializationBlock.accept(methodBlock); + + methodBlock.line("});"); + }); + } + + private static void fromXmlJavadoc(JavaClass classBlock, String modelName, boolean hasRootElementName, + boolean hasRequiredProperties, boolean isPolymorphic) { + classBlock.javadocComment(javadocComment -> { + javadocComment.description("Reads an instance of " + modelName + " from the XmlReader."); + javadocComment.param("xmlReader", "The XmlReader being read."); + if (hasRootElementName) { + javadocComment.param("rootElementName", "Optional root element name to override the default defined " + + "by the model. Used to support cases where the model can deserialize from different root element " + + "names."); + } + javadocComment.methodReturns("An instance of " + modelName + " if the XmlReader was pointing to an " + + "instance of it, or null if it was pointing to XML null."); + + // TODO (alzimmer): Make the throws statement more descriptive by including the polymorphic + // discriminator property name and the required property names. For now this covers the base functionality. + String throwsStatement = null; + if (hasRequiredProperties && isPolymorphic) { + throwsStatement = "If the deserialized XML object was missing any required properties or the " + + "polymorphic discriminator value is invalid."; + } else if (hasRequiredProperties) { + throwsStatement = "If the deserialized XML object was missing any required properties."; + } else if (isPolymorphic) { + throwsStatement = "If the deserialized XML object has an invalid polymorphic discriminator value."; + } + + if (throwsStatement != null) { + javadocComment.methodThrows("IllegalStateException", throwsStatement); + } + + javadocComment.methodThrows("XMLStreamException", "If an error occurs while reading the " + modelName + "."); + }); + } + + /** + * Writes a terminal type's {@code fromXml(XmlReader)} method. + *

+ * A terminal type is either a type without polymorphism or is the terminal type in a polymorphic hierarchy. + * + * @param classBlock The class having {@code fromXml(XmlReader)} written to it. + * @param propertiesManager The properties for the model. + * @param settings The Autorest generation settings. + * @param addGeneratedAnnotation Consumer for adding the generated annotation to the class. + */ + private static void writeTerminalTypeFromXml(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, + JavaSettings settings, Consumer addGeneratedAnnotation) { + readXmlObject(classBlock, propertiesManager, false, + methodBlock -> writeFromXmlDeserialization(methodBlock, propertiesManager, settings), + addGeneratedAnnotation); + } + + private static void writeFromXmlDeserialization(JavaBlock methodBlock, + ClientModelPropertiesManager propertiesManager, JavaSettings settings) { + + // Add the deserialization logic. + methodBlock.indent(() -> { + // Initialize local variables to track what has been deserialized. + initializeLocalVariables(methodBlock, propertiesManager, true, settings); + + // Assumption for XML is polymorphic discriminators are attributes. + if (propertiesManager.getDiscriminatorProperty() != null) { + deserializeXmlAttribute(methodBlock, propertiesManager.getDiscriminatorProperty().getProperty(), + propertiesManager, false); + } + + // Read the XML attribute properties first. + propertiesManager.forEachSuperXmlAttribute(attribute -> deserializeXmlAttribute(methodBlock, attribute, + propertiesManager, true)); + propertiesManager.forEachXmlAttribute(attribute -> deserializeXmlAttribute(methodBlock, attribute, + propertiesManager, false)); + + // Read the XML text next. + propertiesManager.forEachSuperXmlText(text -> deserializeXmlText(methodBlock, text, propertiesManager, true)); + propertiesManager.forEachXmlText(text -> deserializeXmlText(methodBlock, text, propertiesManager, false)); + + // Model didn't have any XML elements, return early. + String fieldNameVariableName = propertiesManager.getXmlReaderNameVariableName(); + if (!propertiesManager.hasXmlElements()) { + // If the model was attributes only a simplified read loop is needed to ensure the end element token + // is reached. + if (!propertiesManager.hasXmlTexts()) { + methodBlock.block("while (reader.nextElement() != XmlToken.END_ELEMENT)", + whileBlock -> whileBlock.line("reader.skipElement();")); + } + return; + } + + // Add the outermost while loop to read the JSON object. + addReaderWhileLoop(methodBlock, true, fieldNameVariableName, true, whileBlock -> { + JavaIfBlock ifBlock = null; + + if (propertiesManager.getDiscriminatorProperty() != null + && !propertiesManager.getDiscriminatorProperty().getProperty().isXmlAttribute()) { + ClientModelProperty discriminatorProperty = propertiesManager.getDiscriminatorProperty() + .getProperty(); + String ifStatement = String.format("\"%s\".equals(%s)", propertiesManager.getExpectedDiscriminator(), + fieldNameVariableName); + + ifBlock = methodBlock.ifBlock(ifStatement, ifAction -> { + ifAction.line("String %s = reader.getStringElement().getLocalPart();", discriminatorProperty.getName()); + String ifStatement2 = String.format("!%s.equals(%s)", discriminatorProperty.getDefaultValue(), + discriminatorProperty.getName()); + ifAction.ifBlock(ifStatement2, ifAction2 -> ifAction2.line( + "throw new IllegalStateException(\"'%s' was expected to be non-null and equal to '\"%s\"'. " + + "The found '%s' was '\" + %s + \"'.\");", + discriminatorProperty.getSerializedName(), propertiesManager.getExpectedDiscriminator(), + discriminatorProperty.getSerializedName(), discriminatorProperty.getName())); + }); + } + + // Loop over all properties and generate their deserialization handling. + AtomicReference ifBlockReference = new AtomicReference<>(ifBlock); + propertiesManager.forEachSuperXmlElement(element -> handleXmlPropertyDeserialization(element, + whileBlock, ifBlockReference, fieldNameVariableName, propertiesManager, true, settings)); + propertiesManager.forEachXmlElement(element -> handleXmlPropertyDeserialization(element, whileBlock, + ifBlockReference, fieldNameVariableName, propertiesManager, false, settings)); + + ifBlock = ifBlockReference.get(); + + // All properties have been checked for, add an else block that will either ignore unknown properties + // or add them into an additional properties bag. ClientModelProperty additionalProperty = getAdditionalPropertiesPropertyInModelOrFromSuper(propertiesManager); - if (additionalProperty != null) { - initializeLocalVariable(methodBlock, additionalProperty, false, settings); - } + handleUnknownXmlFieldDeserialization(whileBlock, ifBlock, additionalProperty, + propertiesManager.getXmlReaderNameVariableName()); + }); + }); + + // Add the validation and return logic. + handleReadReturn(methodBlock, propertiesManager.getModel().getName(), propertiesManager, settings); + } + + private static void deserializeXmlAttribute(JavaBlock methodBlock, ClientModelProperty attribute, + ClientModelPropertiesManager propertiesManager, boolean fromSuper) { + String xmlAttributeDeserialization = getSimpleXmlDeserialization(attribute.getWireType(), "reader", null, + attribute.getXmlName(), propertiesManager.getXmlNamespaceConstant(attribute.getXmlNamespace()), true); + + if (attribute.isPolymorphicDiscriminator() + && CoreUtils.isNullOrEmpty(propertiesManager.getModel().getDerivedModels())) { + // Only validate the discriminator if the model has no derived models. + // Super types will deserialize as themselves if the discriminator doesn't match what's expected. + methodBlock.line("String discriminatorValue = " + xmlAttributeDeserialization + ";"); + String ifStatement = String.format("!%s.equals(discriminatorValue)", attribute.getDefaultValue()); + methodBlock.ifBlock(ifStatement, ifAction2 -> ifAction2.line( + "throw new IllegalStateException(\"'%s' was expected to be non-null and equal to '%s'. " + + "The found '%s' was '\" + discriminatorValue + \"'.\");", + attribute.getSerializedName(), propertiesManager.getExpectedDiscriminator(), + attribute.getSerializedName())); + + xmlAttributeDeserialization = "discriminatorValue"; } - /* - * Shadow properties from parent should be initialized as wired type. - */ - private static void initializeShadowPropertyLocalVariable(JavaBlock methodBlock, ClientModelProperty property) { - IType type = property.getWireType(); - String defaultValue = property.isPolymorphicDiscriminator() - ? property.getDefaultValue() : type.defaultValueExpression(); - methodBlock.line(type + " " + property.getName() + " = " + defaultValue + ";"); + if (propertiesManager.hasConstructorArguments()) { + methodBlock.line("%s %s = %s;", attribute.getClientType(), attribute.getName(), xmlAttributeDeserialization); + } else { + handleSettingDeserializedValue(methodBlock, propertiesManager.getDeserializedModelName(), + propertiesManager.getModel(), attribute, xmlAttributeDeserialization, fromSuper, false); + } + } + + private static void deserializeXmlText(JavaBlock methodBlock, ClientModelProperty text, + ClientModelPropertiesManager propertiesManager, boolean fromSuper) { + String xmlTextDeserialization = getSimpleXmlDeserialization(text.getWireType(), "reader", null, null, null, false); + if (propertiesManager.hasConstructorArguments()) { + methodBlock.line(text.getClientType() + " " + text.getName() + " = " + xmlTextDeserialization + ";"); + } else { + handleSettingDeserializedValue(methodBlock, propertiesManager.getDeserializedModelName(), + propertiesManager.getModel(), text, xmlTextDeserialization, fromSuper, false); + } + } + + private static void handleXmlPropertyDeserialization(ClientModelProperty property, JavaBlock methodBlock, + AtomicReference ifBlockReference, String fieldNameVariableName, + ClientModelPropertiesManager propertiesManager, boolean fromSuper, JavaSettings settings) { + // Property will be handled later by flattened deserialization. + // XML should never have flattening. + if (property.getNeedsFlatten()) { + return; } - private static void initializeLocalVariable(JavaBlock methodBlock, ClientModelProperty property, boolean fromSuper, - JavaSettings settings) { - if (includePropertyInConstructor(property, settings) && !settings.isDisableRequiredJsonAnnotation()) { - // Required properties need an additional boolean variable to indicate they've been found. - methodBlock.line("boolean " + property.getName() + "Found = false;"); - } + JavaIfBlock ifBlock = ifBlockReference.get(); + ifBlock = handleXmlPropertyDeserialization(property, methodBlock, ifBlock, fieldNameVariableName, + propertiesManager, fromSuper, settings); - // Always instantiate the local variable. - // If the property is part of the constructor or set by a setter method from the super class, initialize the - // local variable with the client type. Otherwise, initialize as the wire type to prevent multiple conversions - // between wire and client types. - IType type = (includePropertyInConstructor(property, settings) || fromSuper) - ? property.getClientType() : property.getWireType(); - String defaultValue = property.isPolymorphicDiscriminator() - ? property.getDefaultValue() : type.defaultValueExpression(); - methodBlock.line(type + " " + property.getName() + " = " + defaultValue + ";"); + ifBlockReference.set(ifBlock); + } + + private static JavaIfBlock handleXmlPropertyDeserialization(ClientModelProperty property, JavaBlock methodBlock, + JavaIfBlock ifBlock, String fieldNameVariableName, ClientModelPropertiesManager propertiesManager, + boolean fromSuper, JavaSettings settings) { + String xmlElementName = (property.getClientType() instanceof IterableType && !property.isXmlWrapper()) + ? property.getXmlListElementName() : property.getXmlName(); + String xmlNamespace = propertiesManager.getXmlNamespaceConstant(property.getXmlNamespace()); + + if (CoreUtils.isNullOrEmpty(xmlElementName)) { + return ifBlock; } - /** - * Adds the while loop that handles reading the JSON object until it is fully consumed. - * - * @param methodBlock The method handling deserialization. - * @param initializeFieldNameVariable Whether the {@code fieldNameVariableName} variable needs to be initialized. If - * this is a nested while loop the variable doesn't need to be initialized. - * @param fieldNameVariableName The name for the variable that tracks the JSON field name. - * @param isXml Whether the reader while loop is for XML reading. - * @param whileBlock The consumer that adds deserialization logic into the while loop. - */ - private static void addReaderWhileLoop(JavaBlock methodBlock, boolean initializeFieldNameVariable, - String fieldNameVariableName, boolean isXml, Consumer whileBlock) { - addReaderWhileLoop("reader", methodBlock, initializeFieldNameVariable, fieldNameVariableName, - isXml, whileBlock); - } + String condition = getXmlNameConditional(xmlElementName, xmlNamespace, fieldNameVariableName, true); + return ifOrElseIf(methodBlock, ifBlock, condition, + deserializationBlock -> generateXmlDeserializationLogic(deserializationBlock, property, propertiesManager, + fromSuper, settings)); + } - /** - * Adds the while loop that handles reading the JSON object until it is fully consumed. - * - * @param readerVariableName The name of the local reader variable. - * @param methodBlock The method handling deserialization. - * @param initializeFieldNameVariable Whether the {@code fieldNameVariableName} variable needs to be initialized. If - * this is a nested while loop the variable doesn't need to be initialized. - * @param fieldNameVariableName The name for the variable that tracks the JSON field name. - * @param isXml Whether the reader while loop is for XML reading. - * @param whileBlock The consumer that adds deserialization logic into the while loop. - */ - private static void addReaderWhileLoop(String readerVariableName, JavaBlock methodBlock, boolean initializeFieldNameVariable, - String fieldNameVariableName, boolean isXml, Consumer whileBlock) { - String whileCheck = isXml - ? readerVariableName + ".nextElement() != XmlToken.END_ELEMENT" - : readerVariableName + ".nextToken() != JsonToken.END_OBJECT"; + private static void generateXmlDeserializationLogic(JavaBlock deserializationBlock, ClientModelProperty property, + ClientModelPropertiesManager propertiesManager, boolean fromSuper, JavaSettings settings) { + IType wireType = property.getWireType(); - methodBlock.block("while (" + whileCheck + ")", whileAction -> { - String fieldNameInitialization = ""; - if (initializeFieldNameVariable) { - fieldNameInitialization = isXml ? "QName" : "String"; - } + // Attempt to determine whether the wire type is simple deserialization. + // This is primitives, boxed primitives, a small set of string based models, and other ClientModels. + String simpleDeserialization = getSimpleXmlDeserialization(wireType, "reader", property.getXmlName(), null, + null, false); + if (simpleDeserialization != null) { + if (propertiesManager.hasConstructorArguments()) { + deserializationBlock.line(property.getName() + " = " + simpleDeserialization + ";"); + } else { + handleSettingDeserializedValue(deserializationBlock, propertiesManager.getDeserializedModelName(), + propertiesManager.getModel(), property, simpleDeserialization, fromSuper, false); + } + } else if (wireType instanceof IterableType) { + IType elementType = ((IterableType) wireType).getElementType(); + boolean sameNames = Objects.equals(property.getXmlName(), property.getXmlListElementName()); + String elementDeserialization = getSimpleXmlDeserialization(elementType, "reader", + sameNames ? property.getXmlName() : property.getXmlListElementName(), null, null, false); + String fieldAccess; + if (propertiesManager.hasConstructorArguments()) { + // Cases with constructor arguments will have a local variable based on the name of the property. + fieldAccess = property.getName(); + } else if (fromSuper) { + // Cases where the property is from the super type will need to access the getter. + fieldAccess = propertiesManager.getDeserializedModelName() + "." + property.getGetterName() + "()"; + } else { + // Otherwise access the property directly. + fieldAccess = propertiesManager.getDeserializedModelName() + "." + property.getName(); + } - methodBlock.line("%s %s = %s.get%sName();", fieldNameInitialization, fieldNameVariableName, - readerVariableName, isXml ? "Element" : "Field"); + if (!property.isXmlWrapper()) { + deserializationBlock.line(fieldAccess + ".add(" + elementDeserialization + ");"); + } else { + deserializationBlock.block("while (reader.nextElement() != XmlToken.END_ELEMENT)", whileBlock -> { + whileBlock.line("elementName = reader.getElementName();"); + String condition = getXmlNameConditional(property.getXmlListElementName(), + propertiesManager.getXmlNamespaceConstant(property.getXmlListElementNamespace()), "elementName", + true); + whileBlock.ifBlock(condition, ifBlock -> { + // TODO (alzimmer): Handle nested container types when needed. + ifBlock.ifBlock(fieldAccess + " == null", ifStatement -> { + if (fromSuper) { + ifStatement.line(propertiesManager.getDeserializedModelName() + "." + property.getSetterName() + + "(new ArrayList<>());"); + } else { + ifStatement.line(fieldAccess + " = new ArrayList<>();"); + } + }); - if (!isXml) { - methodBlock.line(readerVariableName + ".nextToken();"); - } - methodBlock.line(""); - - whileBlock.accept(methodBlock); + ifBlock.line(fieldAccess + ".add(" + elementDeserialization + ");"); + }) + .elseBlock(elseBlock -> elseBlock.line("reader.skipElement();")); }); + } + } else if (wireType instanceof MapType) { + IType valueType = ((MapType) wireType).getValueType(); + String fieldAccess = propertiesManager.hasConstructorArguments() + ? property.getName() + : propertiesManager.getDeserializedModelName() + "." + property.getName(); + + String valueDeserialization = getSimpleXmlDeserialization(valueType, "reader", property.getXmlName(), null, + null, false); + deserializationBlock.block("while (reader.nextElement() != XmlToken.END_ELEMENT)", whileBlock -> { + // TODO (alzimmer): Handle nested container types when needed. + // Assumption is that the key type for the Map is a String. This may not always hold true and when that + // becomes reality this will need to be reworked to handle that case. + whileBlock.ifBlock(fieldAccess + " == null", + ifStatement -> ifStatement.line(fieldAccess + " = new LinkedHashMap<>();")); + + whileBlock.line(fieldAccess + ".put(reader.getElementName().getLocalPart(), " + valueDeserialization + ");"); + }); + } else { + // TODO (alzimmer): Resolve this as deserialization logic generation needs to handle all cases. + throw new RuntimeException("Unknown wire type " + wireType + ". Need to add support for it."); } - private static void handleJsonPropertyDeserialization(ClientModel model, ClientModelProperty property, - String modelVariableName, JavaBlock methodBlock, AtomicReference ifBlockReference, - String fieldNameVariableName, boolean fromSuper, boolean hasConstructorArguments, JavaSettings settings, - boolean polymorphicJsonMergePatchScenario) { - // Property will be handled later by flattened deserialization. - if (property.getNeedsFlatten()) { - return; - } - - JavaIfBlock ifBlock = ifBlockReference.get(); - ifBlock = handleJsonPropertyDeserialization(model, property, modelVariableName, methodBlock, ifBlock, - fieldNameVariableName, fromSuper, hasConstructorArguments, settings, polymorphicJsonMergePatchScenario); - - ifBlockReference.set(ifBlock); + // If the property was required, mark it as found. + if (includePropertyInConstructor(property, settings) && !settings.isDisableRequiredJsonAnnotation()) { + deserializationBlock.line(property.getName() + "Found = true;"); } + } - private static JavaIfBlock handleJsonPropertyDeserialization(ClientModel model, ClientModelProperty property, - String modelVariableName, JavaBlock methodBlock, JavaIfBlock ifBlock, String fieldNameVariableName, - boolean fromSuper, boolean hasConstructorArguments, JavaSettings settings, - boolean polymorphicJsonMergePatchScenario) { - String jsonPropertyName = property.getSerializedName(); - if (CoreUtils.isNullOrEmpty(jsonPropertyName)) { - return ifBlock; - } + private static void handleUnknownXmlFieldDeserialization(JavaBlock methodBlock, JavaIfBlock ifBlock, + ClientModelProperty additionalProperties, String fieldNameVariableName) { + Consumer unknownFieldConsumer = javaBlock -> { + if (additionalProperties != null) { + javaBlock.ifBlock(additionalProperties.getName() + " == null", + ifAction -> ifAction.line(additionalProperties.getName() + " = new LinkedHashMap<>();")); + javaBlock.line(); - return ifOrElseIf(methodBlock, ifBlock, "\"" + jsonPropertyName + "\".equals(" + fieldNameVariableName + ")", - deserializationBlock -> generateJsonDeserializationLogic(deserializationBlock, modelVariableName, model, - property, fromSuper, hasConstructorArguments, settings, polymorphicJsonMergePatchScenario)); - } - - private static void handleFlattenedPropertiesDeserialization( - JsonFlattenedPropertiesTree flattenedProperties, JavaBlock methodBlock, JavaIfBlock ifBlock, - ClientModelProperty additionalProperties, String fieldNameVariableName, boolean hasConstructorArguments, - JavaSettings settings, boolean polymorphicJsonMergePatchScenario) { - // The initial call to handle flattened properties is using the base node which is just a holder. - for (JsonFlattenedPropertiesTree structure : flattenedProperties.getChildrenNodes().values()) { - handleFlattenedPropertiesDeserializationHelper(structure, methodBlock, ifBlock, additionalProperties, - fieldNameVariableName, hasConstructorArguments, settings, polymorphicJsonMergePatchScenario); - } - } - - private static JavaIfBlock handleFlattenedPropertiesDeserializationHelper( - JsonFlattenedPropertiesTree flattenedProperties, JavaBlock methodBlock, JavaIfBlock ifBlock, - ClientModelProperty additionalProperties, String fieldNameVariableName, boolean hasConstructorArguments, - JavaSettings settings, boolean polymorphicJsonMergePatchScenario) { - ClientModelPropertyWithMetadata propertyWithMetadata = flattenedProperties.getProperty(); - if (propertyWithMetadata != null) { - String modelVariableName = "deserialized" + propertyWithMetadata.getModel().getName(); - - // This is a terminal location, so only need to handle checking for the property name. - return ifOrElseIf(methodBlock, ifBlock, - "\"" + flattenedProperties.getNodeName() + "\".equals(" + fieldNameVariableName + ")", - deserializationBlock -> generateJsonDeserializationLogic(deserializationBlock, modelVariableName, - propertyWithMetadata.getModel(), propertyWithMetadata.getProperty(), - propertyWithMetadata.isFromSuperClass(), hasConstructorArguments, settings, - polymorphicJsonMergePatchScenario)); + // Assumption, additional properties is a Map of String-Object + IType valueType = ((MapType) additionalProperties.getWireType()).getValueType(); + if (valueType == ClassType.OBJECT) { + // String fieldName should be a local variable accessible in this spot of code. + javaBlock.line(additionalProperties.getName() + ".put(" + fieldNameVariableName + ", reader.readUntyped());"); } else { - // Otherwise this is an intermediate location and a while loop reader needs to be added. - return ifOrElseIf(methodBlock, ifBlock, - "\"" + flattenedProperties.getNodeName() + "\".equals(" + fieldNameVariableName + ") && reader.currentToken() == JsonToken.START_OBJECT", - ifAction -> addReaderWhileLoop(ifAction, false, fieldNameVariableName, false, whileBlock -> { - JavaIfBlock innerIfBlock = null; - for (JsonFlattenedPropertiesTree structure : flattenedProperties.getChildrenNodes().values()) { - innerIfBlock = handleFlattenedPropertiesDeserializationHelper(structure, methodBlock, - innerIfBlock, additionalProperties, fieldNameVariableName, hasConstructorArguments, - settings, polymorphicJsonMergePatchScenario); - } - - handleUnknownJsonFieldDeserialization(whileBlock, innerIfBlock, additionalProperties, - fieldNameVariableName); - })); + // Another assumption, the additional properties value type is simple. + javaBlock.line(additionalProperties.getName() + ".put(" + fieldNameVariableName + ", " + + getSimpleXmlDeserialization(valueType, "reader", null, null, null, false) + ");"); } + } else { + javaBlock.line("reader.skipElement();"); + } + }; + + if (ifBlock == null) { + unknownFieldConsumer.accept(methodBlock); + } else { + ifBlock.elseBlock(unknownFieldConsumer); + } + } + + private static String getSimpleXmlDeserialization(IType wireType, String readerName, String elementName, + String attributeName, String attributeNamespace, boolean namespaceIsConstant) { + if (wireType instanceof ClassType && ((ClassType) wireType).isSwaggerType()) { + return CoreUtils.isNullOrEmpty(elementName) + ? wireType + ".fromXml(" + readerName + ")" + : wireType + ".fromXml(" + readerName + ", \"" + elementName + "\")"; + } else { + return wireType.xmlDeserializationMethod(readerName, attributeName, attributeNamespace, namespaceIsConstant); + } + } + + private static List getClientModelPropertiesInJsonTree( + JsonFlattenedPropertiesTree tree) { + if (tree.getProperty() != null) { + // Terminal node only contains a property. + return Collections.singletonList(tree.getProperty()); + } else { + List treeProperties = new ArrayList<>(); + for (JsonFlattenedPropertiesTree childNode : tree.getChildrenNodes().values()) { + treeProperties.addAll(getClientModelPropertiesInJsonTree(childNode)); + } + + return treeProperties; + } + } + + private static String getXmlNameConditional(String localPart, String namespace, String elementName, + boolean namespaceIsConstant) { + String condition = "\"" + localPart + "\".equals(" + elementName + ".getLocalPart())"; + if (!CoreUtils.isNullOrEmpty(namespace)) { + if (namespaceIsConstant) { + condition += " && " + namespace + ".equals(" + elementName + ".getNamespaceURI())"; + } else { + condition += " && \"" + namespace + "\".equals(" + elementName + ".getNamespaceURI())"; + } } - private static void generateJsonDeserializationLogic(JavaBlock deserializationBlock, String modelVariableName, - ClientModel model, ClientModelProperty property, boolean fromSuper, boolean hasConstructorArguments, JavaSettings settings, - boolean polymorphicJsonMergePatchScenario) { - IType wireType = property.getWireType(); - IType clientType = property.getClientType(); - - // Attempt to determine whether the wire type is simple deserialization. - // This is primitives, boxed primitives, a small set of string based models, and other ClientModels. - String simpleDeserialization = getSimpleJsonDeserialization(wireType, "reader"); - if (simpleDeserialization != null) { - // Need to convert the wire type to the client type for constructors. - // Need to convert the wire type to the client type for public setters. - boolean convertToClientType = (clientType != wireType) - && (includePropertyInConstructor(property, settings) || (fromSuper && !readOnlyNotInCtor(model, property, settings))); - BiConsumer simpleDeserializationConsumer = (logic, block) -> { - if (!hasConstructorArguments) { - handleSettingDeserializedValue(block, modelVariableName, model, property, logic, fromSuper, - polymorphicJsonMergePatchScenario); - } else { - block.line(property.getName() + " = " + logic + ";"); - } - }; - - if (convertToClientType) { - // If the wire type is nullable don't attempt to call the convert to client type until it's known that - // a value was deserialized. This protects against cases such as UnixTimeLong where the wire type is - // Long and the client type of OffsetDateTime. This is converted using Instant.ofEpochMilli(long) which - // would result in a null if the Long is null, which is already guarded using - // reader.readNullable(nonNullReader -> Instant.ofEpochMillis(nonNullReader.readLong())) but this itself - // returns null which would have been passed to OffsetDateTime.ofInstant(Instant, ZoneId) which would - // have thrown a NullPointerException. - if (wireType.isNullable()) { - // Check if the property is required, if so use a holder name as there will be an existing holder - // variable for the value that will be used in the constructor. - String holderName = property.getName() + "Holder"; - deserializationBlock.line(wireType + " " + holderName + " = " + simpleDeserialization + ";"); - deserializationBlock.ifBlock(holderName + " != null", ifBlock -> - simpleDeserializationConsumer.accept(wireType.convertToClientType(holderName), ifBlock)); - } else { - simpleDeserializationConsumer.accept(wireType.convertToClientType(simpleDeserialization), - deserializationBlock); - } - } else { - simpleDeserializationConsumer.accept(simpleDeserialization, deserializationBlock); - } - } else if (wireType == ClassType.OBJECT) { - if (!hasConstructorArguments) { - handleSettingDeserializedValue(deserializationBlock, modelVariableName, model, property, - "reader.readUntyped()", fromSuper, polymorphicJsonMergePatchScenario); - } else { - deserializationBlock.line(property.getName() + " = reader.readUntyped();"); - } - } else if (wireType instanceof IterableType) { - if (!hasConstructorArguments) { - deserializationBlock.text(property.getClientType() + " "); - } - - deserializationBlock.text(property.getName() + " = "); - deserializeJsonContainerProperty(deserializationBlock, "readArray", wireType, - ((IterableType) wireType).getElementType(), ((IterableType) clientType).getElementType(), 0); - - if (!hasConstructorArguments) { - handleSettingDeserializedValue(deserializationBlock, modelVariableName, model, property, - property.getName(), fromSuper, polymorphicJsonMergePatchScenario); - } - } else if (wireType instanceof MapType) { - if (!hasConstructorArguments) { - deserializationBlock.text(property.getClientType() + " "); - } - - // Assumption is that the key type for the Map is a String. This may not always hold true and when that - // becomes reality this will need to be reworked to handle that case. - deserializationBlock.text(property.getName() + " = "); - deserializeJsonContainerProperty(deserializationBlock, "readMap", wireType, - ((MapType) wireType).getValueType(), ((MapType) clientType).getValueType(), 0); - - if (!hasConstructorArguments) { - handleSettingDeserializedValue(deserializationBlock, modelVariableName, model, property, - property.getName(), fromSuper, polymorphicJsonMergePatchScenario); - } - } else { - // TODO (alzimmer): Resolve this as deserialization logic generation needs to handle all cases. - throw new RuntimeException("Unknown wire type " + wireType + ". Need to add support for it."); - } - - // If the property was required, mark it as found. - if (includePropertyInConstructor(property, settings) && !settings.isDisableRequiredJsonAnnotation()) { - deserializationBlock.line(property.getName() + "Found = true;"); - } - } - - /** - * Helper method to deserialize a container property (such as {@link List} and {@link Map}). - * - * @param methodBlock The method handling deserialization. - * @param utilityMethod The method aiding in the deserialization of the container. - * @param containerType The container type. - * @param elementWireType The element type for the container, for a {@link List} this is the element type and for a - * {@link Map} this is the value type. - * @param depth Depth of recursion for container types, such as {@code Map>} would be 0 when - * {@code Map} is being handled and then 1 when {@code List} is being handled. - */ - private static void deserializeJsonContainerProperty(JavaBlock methodBlock, String utilityMethod, IType containerType, - IType elementWireType, IType elementClientType, int depth) { - String callingReaderName = depth == 0 ? "reader" : "reader" + depth; - String lambdaReaderName = "reader" + (depth + 1); - String valueDeserializationMethod = getSimpleJsonDeserialization(elementWireType, lambdaReaderName); - boolean convertToClientType = (elementClientType != elementWireType); - boolean useCodeBlockLambda = valueDeserializationMethod != null && elementWireType.isNullable() - && convertToClientType; - - if (useCodeBlockLambda) { - methodBlock.line(callingReaderName + "." + utilityMethod + "(" + lambdaReaderName + " -> {"); - } else { - methodBlock.line(callingReaderName + "." + utilityMethod + "(" + lambdaReaderName + " ->"); - } - methodBlock.indent(() -> { - if (valueDeserializationMethod != null) { - if (convertToClientType) { - // If the wire type is nullable don't attempt to call the convert to client type until it's known that - // a value was deserialized. This protects against cases such as UnixTimeLong where the wire type is - // Long and the client type of OffsetDateTime. This is converted using Instant.ofEpochMilli(long) which - // would result in a null if the Long is null, which is already guarded using - // reader.readNullable(nonNullReader -> Instant.ofEpochMillis(nonNullReader.readLong())) but this itself - // returns null which would have been passed to OffsetDateTime.ofInstant(Instant, ZoneId) which would - // have thrown a NullPointerException. - if (elementWireType.isNullable()) { - // Check if the property is required, if so use a holder name as there will be an existing holder - // variable for the value that will be used in the constructor. - String holderName = lambdaReaderName + "ValueHolder"; - methodBlock.line(elementWireType + " " + holderName + " = " + valueDeserializationMethod + ";"); - methodBlock.ifBlock(holderName + " != null", - ifBlock -> ifBlock.methodReturn(elementWireType.convertToClientType(holderName))) - .elseBlock(elseBlock -> elseBlock.methodReturn("null")); - } else { - methodBlock.line(elementWireType.convertToClientType(valueDeserializationMethod)); - } - } else { - methodBlock.line(valueDeserializationMethod); - } - } else if (elementWireType == ClassType.OBJECT) { - methodBlock.line(lambdaReaderName + ".readUntyped()"); - } else if (elementWireType instanceof IterableType) { - deserializeJsonContainerProperty(methodBlock, "readArray", elementWireType, - ((IterableType) elementWireType).getElementType(), - ((IterableType) elementClientType).getElementType(), depth + 1); - } else if (elementWireType instanceof MapType) { - // Assumption is that the key type for the Map is a String. This may not always hold true and when that - // becomes reality this will need to be reworked to handle that case. - deserializeJsonContainerProperty(methodBlock, "readMap", elementWireType, - ((MapType) elementWireType).getValueType(), ((MapType) elementClientType).getValueType(), - depth + 1); - } else if (elementWireType == ClassType.BINARY_DATA) { - methodBlock.line(lambdaReaderName + ".readUntyped()"); - } else { - throw new RuntimeException("Unknown value type " + elementWireType + " in " + containerType - + " serialization. Need to add support for it."); - } - }); - - if (useCodeBlockLambda) { - if (depth > 0) { - methodBlock.line("})"); - } else { - methodBlock.line("});"); - } - } else { - if (depth > 0) { - methodBlock.line(")"); - } else { - methodBlock.line(");"); - } - } - } - - private static String getSimpleJsonDeserialization(IType wireType, String readerName) { - return (wireType instanceof ClassType && ((ClassType) wireType).isSwaggerType()) - ? wireType + ".fromJson(" + readerName + ")" - : wireType.jsonDeserializationMethod(readerName); - } - - private static void handleUnknownJsonFieldDeserialization(JavaBlock methodBlock, JavaIfBlock ifBlock, - ClientModelProperty additionalProperties, String fieldNameVariableName) { - Consumer unknownFieldConsumer = javaBlock -> { - if (additionalProperties != null) { - javaBlock.ifBlock(additionalProperties.getName() + " == null", - ifAction -> ifAction.line(additionalProperties.getName() + " = new LinkedHashMap<>();")); - javaBlock.line(); - - // Assumption, additional properties is a Map of String-Object - IType valueType = ((MapType) additionalProperties.getWireType()).getValueType(); - if (valueType == ClassType.OBJECT) { - // String fieldName should be a local variable accessible in this spot of code. - javaBlock.line(additionalProperties.getName() + ".put(" + fieldNameVariableName + ", reader.readUntyped());"); - } else if (valueType instanceof IterableType) { - // The case that element is a List - String varName = additionalProperties.getName() + "ArrayItem"; - javaBlock.text(valueType + " " + varName + " = "); - deserializeJsonContainerProperty(javaBlock, "readArray", valueType, - ((IterableType) valueType).getElementType(), ((IterableType) valueType).getElementType(), 0); - javaBlock.line(additionalProperties.getName() + ".put(" + fieldNameVariableName + ", " + varName + ");"); - } else { - // Another assumption, the additional properties value type is simple. - javaBlock.line(additionalProperties.getName() + ".put(" + fieldNameVariableName + ", " - + getSimpleJsonDeserialization(valueType, "reader") + ");"); - } - } else { - javaBlock.line("reader.skipChildren();"); - } - }; - - if (ifBlock == null) { - unknownFieldConsumer.accept(methodBlock); - } else { - ifBlock.elseBlock(unknownFieldConsumer); - } - } - - /** - * Handles validating that all required properties have been found and creating the return type. - *

- * Properties are split into two concepts, required and optional properties, and those concepts are split into an - * additional two groups, properties declared by super types and by the model type. - * - * @param methodBlock The method handling deserialization. - * @param modelName The name of the model. - * @param propertiesManager The property manager for the model. - */ - private static void handleReadReturn(JavaBlock methodBlock, String modelName, - ClientModelPropertiesManager propertiesManager, JavaSettings settings) { - StringBuilder constructorArgs = new StringBuilder(); - - propertiesManager.forEachSuperConstructorProperty(arg -> addConstructorParameter(constructorArgs, arg.getName())); - propertiesManager.forEachConstructorProperty(arg -> addConstructorParameter(constructorArgs, arg.getName())); - - // If there are required properties of any type we must check that all required fields were found. - if (propertiesManager.hasRequiredProperties()) { - StringBuilder ifStatementBuilder = new StringBuilder(); - propertiesManager.forEachSuperRequiredProperty(property -> addRequiredCheck(ifStatementBuilder, property, settings)); - propertiesManager.forEachRequiredProperty(property -> addRequiredCheck(ifStatementBuilder, property, settings)); - - if (ifStatementBuilder.length() > 0) { - methodBlock.ifBlock(ifStatementBuilder.toString(), ifAction -> - createObjectAndReturn(methodBlock, modelName, constructorArgs.toString(), propertiesManager, settings)); - - if (propertiesManager.getRequiredPropertiesCount() == 1) { - StringBuilder stringBuilder = new StringBuilder(); - propertiesManager.forEachSuperRequiredProperty(property -> stringBuilder.append(property.getSerializedName())); - propertiesManager.forEachRequiredProperty(property -> stringBuilder.append(property.getSerializedName())); - methodBlock.line("throw new IllegalStateException(\"Missing required property: " + stringBuilder + "\");"); - } else { - methodBlock.line("List missingProperties = new ArrayList<>();"); - propertiesManager.forEachSuperRequiredProperty(property -> addFoundValidationIfCheck(methodBlock, property, settings)); - propertiesManager.forEachRequiredProperty(property -> addFoundValidationIfCheck(methodBlock, property, settings)); - - methodBlock.line(); - methodBlock.line("throw new IllegalStateException(\"Missing required property/properties: \" + String.join(\", \", missingProperties));"); - } - } else { - createObjectAndReturn(methodBlock, modelName, constructorArgs.toString(), propertiesManager, settings); - } - } else { - createObjectAndReturn(methodBlock, modelName, constructorArgs.toString(), propertiesManager, settings); - } - } - - private static void createObjectAndReturn(JavaBlock methodBlock, String modelName, String constructorArgs, - ClientModelPropertiesManager propertiesManager, JavaSettings settings) { - boolean polymorphicJsonMergePatchScenario = propertiesManager.getModel().isPolymorphic() - && ClientModelUtil.isJsonMergePatchModel(propertiesManager.getModel(), settings); - if (propertiesManager.hasConstructorArguments()) { - if (propertiesManager.getSetterPropertiesCount() == 0 - && propertiesManager.getReadOnlyPropertiesCount() == 0 - && propertiesManager.getAdditionalProperties() == null - && propertiesManager.getSuperAdditionalPropertiesProperty() == null) { - methodBlock.methodReturn("new " + modelName + "(" + constructorArgs + ")"); - return; - } - - methodBlock.line(modelName + " " + propertiesManager.getDeserializedModelName() + " = new " + modelName - + "(" + constructorArgs + ");"); - - BiConsumer handleSettingDeserializedValue = (property, fromSuper) -> - handleSettingDeserializedValue(methodBlock, propertiesManager.getDeserializedModelName(), - propertiesManager.getModel(), property, property.getName(), fromSuper, - polymorphicJsonMergePatchScenario); - - propertiesManager.forEachSuperReadOnlyProperty(property -> handleSettingDeserializedValue.accept(property, true)); - propertiesManager.forEachSuperSetterProperty(property -> handleSettingDeserializedValue.accept(property, true)); - propertiesManager.forEachReadOnlyProperty(property -> handleSettingDeserializedValue.accept(property, false)); - propertiesManager.forEachSetterProperty(property -> handleSettingDeserializedValue.accept(property, false)); - } - - if (propertiesManager.getAdditionalProperties() != null) { - handleSettingDeserializedValue(methodBlock, propertiesManager.getDeserializedModelName(), - propertiesManager.getModel(), propertiesManager.getAdditionalProperties(), - propertiesManager.getAdditionalProperties().getName(), false, polymorphicJsonMergePatchScenario); - } else if (propertiesManager.getSuperAdditionalPropertiesProperty() != null) { - handleSettingDeserializedValue(methodBlock, propertiesManager.getDeserializedModelName(), - propertiesManager.getModel(), propertiesManager.getSuperAdditionalPropertiesProperty(), - propertiesManager.getSuperAdditionalPropertiesProperty().getName(), true, - polymorphicJsonMergePatchScenario); - } - - methodBlock.line(); - methodBlock.methodReturn(propertiesManager.getDeserializedModelName()); - } - - private static void addConstructorParameter(StringBuilder constructor, String parameterName) { - if (constructor.length() > 0) { - constructor.append(", "); - } - - constructor.append(parameterName); - } - - private static void addRequiredCheck(StringBuilder ifCheck, ClientModelProperty property, JavaSettings settings) { - // XML attributes and text don't need checks. - if (property.isXmlAttribute() || property.isXmlText() || !includePropertyInConstructor(property, settings)) { - return; - } - - // Constants are ignored during deserialization. - if (property.isConstant()) { - return; - } - - // Required properties aren't being validated for being found. - if (settings.isDisableRequiredJsonAnnotation()) { - return; - } - - if (ifCheck.length() > 0) { - ifCheck.append(" && "); - } - - ifCheck.append(property.getName()).append("Found"); - } - - private static void addFoundValidationIfCheck(JavaBlock methodBlock, ClientModelProperty property, - JavaSettings settings) { - // XML attributes and text don't need checks. - if (property.isXmlAttribute() || property.isXmlText() || !includePropertyInConstructor(property, settings)) { - return; - } - - // Constants are ignored during deserialization. - if (property.isConstant()) { - return; - } - - // Required properties aren't being validated for being found. - if (settings.isDisableRequiredJsonAnnotation()) { - return; - } - - methodBlock.ifBlock("!" + property.getName() + "Found", - ifAction -> ifAction.line("missingProperties.add(\"" + property.getSerializedName() + "\");")); - } - - private static void handleSettingDeserializedValue(JavaBlock methodBlock, String modelVariableName, - ClientModel model, ClientModelProperty property, String value, boolean fromSuper, - boolean polymorphicJsonMergePatchScenario) { - // If the property is defined in a super class use the setter as this will be able to set the value in the - // super class. - if (fromSuper - // If the property is flattened or read-only from parent, it will be shadowed in child class. - && (!readOnlyNotInCtor(model, property, JavaSettings.getInstance()) && !property.getClientFlatten())) { - if (polymorphicJsonMergePatchScenario) { - // Polymorphic JSON merge patch needs special handling as the setter methods are used to track whether - // the property is included in patch serialization. To prevent deserialization from requiring parent - // defined properties to always be included in serialization, access helpers are used to set the value - // without marking the property as included in the patch. - ClientModel definingModel = definingModel(model, property); - methodBlock.line("JsonMergePatchHelper.get" + definingModel.getName() + "Accessor()." - + property.getSetterName() + "(" + modelVariableName + ", " + value + ");"); - } else { - methodBlock.line(modelVariableName + "." + property.getSetterName() + "(" + value + ");"); - } - } else { - methodBlock.line(modelVariableName + "." + property.getName() + " = " + value + ";"); - } - } - - private static boolean isSuperTypeWithDiscriminator(ClientModel child) { - return !CoreUtils.isNullOrEmpty(child.getPolymorphicDiscriminatorName()) - && !CoreUtils.isNullOrEmpty(child.getDerivedModels()); - } - - // TODO (alzimmer): This is a very inefficient design where we're using the ClientModelProperty to find which model - // in the polymorphic hierarchy defines it, but this is a simple bootstrapping method rather than a larger - // re-architecting. - private static ClientModel definingModel(ClientModel model, ClientModelProperty property) { - while (model != null) { - if (model.getProperties().stream().anyMatch(prop -> Objects.equals(prop.getName(), property.getName()))) { - return model; - } - model = ClientModelUtil.getClientModel(model.getParentModelName()); - } - - throw new IllegalStateException("No ClientModel in the polymorphic hierarchy define this property, this should never happen."); - } - - /** - * Helper method for adding a base if condition or an else if condition. - * - * @param baseBlock Base code block where an if condition would be added. - * @param ifBlock If block where an else if condition would be added. - * @param condition The conditional statement. - * @param action The conditional action. - * @return An if block for further chaining. - */ - private static JavaIfBlock ifOrElseIf(JavaBlock baseBlock, JavaIfBlock ifBlock, String condition, - Consumer action) { - return (ifBlock == null) ? baseBlock.ifBlock(condition, action) : ifBlock.elseIfBlock(condition, action); - } - - private static void writeToXml(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, - Consumer addGeneratedAnnotation) { - addGeneratedAnnotation.accept(classBlock); - classBlock.annotation("Override"); - classBlock.publicMethod("XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException", - methodBlock -> methodBlock.methodReturn("toXml(xmlWriter, null)")); - - addGeneratedAnnotation.accept(classBlock); - classBlock.annotation("Override"); - classBlock.publicMethod("XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException", methodBlock -> { - String modelXmlName = propertiesManager.getXmlRootElementName(); - methodBlock.line("rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? \"" + modelXmlName + "\" : rootElementName;"); - methodBlock.line("xmlWriter.writeStartElement(rootElementName);"); - - String modelXmlNamespace = propertiesManager.getXmlRootElementNamespace(); - if (modelXmlNamespace != null) { - methodBlock.line("xmlWriter.writeNamespace(" + propertiesManager.getXmlNamespaceConstant(modelXmlNamespace) + ");"); - } - - propertiesManager.forEachXmlNamespaceWithPrefix((prefix, namespace) -> - methodBlock.line("xmlWriter.writeNamespace(\"" + prefix + "\", " + propertiesManager.getXmlNamespaceConstant(namespace) + ");")); - - // Assumption for XML is polymorphic discriminators are attributes. - if (propertiesManager.getDiscriminatorProperty() != null) { - serializeXml(methodBlock, propertiesManager.getDiscriminatorProperty().getProperty(), false, - propertiesManager); - } - - propertiesManager.forEachSuperXmlAttribute(property -> serializeXml(methodBlock, property, true, propertiesManager)); - propertiesManager.forEachXmlAttribute(property -> serializeXml(methodBlock, property, false, propertiesManager)); - - // Valid XML should only either have elements or text. - if (propertiesManager.hasXmlElements()) { - propertiesManager.forEachSuperXmlElement(property -> serializeXml(methodBlock, property, true, propertiesManager)); - propertiesManager.forEachXmlElement(property -> serializeXml(methodBlock, property, false, propertiesManager)); - } else { - propertiesManager.forEachSuperXmlText(property -> serializeXml(methodBlock, property, true, propertiesManager)); - propertiesManager.forEachXmlText(property -> serializeXml(methodBlock, property, false, propertiesManager)); - } - - methodBlock.methodReturn("xmlWriter.writeEndElement()"); - }); - } - - /** - * Serializes an XML element. - * - * @param methodBlock The method handling serialization. - * @param element The XML element being serialized. - * @param fromSuperType Whether the property is defined in the super type. - */ - private static void serializeXml(JavaBlock methodBlock, ClientModelProperty element, boolean fromSuperType, - ClientModelPropertiesManager propertiesManager) { - IType clientType = element.getClientType(); - IType wireType = element.getWireType(); - String propertyValueGetter; - if (fromSuperType) { - propertyValueGetter = (clientType != wireType) - ? wireType.convertFromClientType(element.getGetterName() + "()") - : element.getGetterName() + "()"; - } else { - propertyValueGetter = "this." + element.getName(); - } - - // Attempt to determine whether the wire type is simple serialization. - // This is primitives, boxed primitives, a small set of string based models, and other ClientModels. - String xmlSerializationMethodCall = wireType.xmlSerializationMethodCall("xmlWriter", element.getXmlName(), - propertiesManager.getXmlNamespaceConstant(element.getXmlNamespace()), propertyValueGetter, - element.isXmlAttribute(), false, true); - if (xmlSerializationMethodCall != null) { - Consumer serializationLogic = javaBlock -> { - // XML text has special handling. - if (element.isXmlText()) { - javaBlock.line("xmlWriter.writeString(" + propertyValueGetter + ");"); - } else { - javaBlock.line(xmlSerializationMethodCall + ";"); - } - }; - - // If the property is from a super type and the client type is different from the wire type then a null - // check is required to prevent a NullPointerException when converting the value. - if (fromSuperType && clientType != wireType && clientType.isNullable()) { - methodBlock.ifBlock(propertyValueGetter + " != null", serializationLogic); - } else { - serializationLogic.accept(methodBlock); - } - } else if (wireType instanceof ClassType && ((ClassType) wireType).isSwaggerType()) { - methodBlock.line("xmlWriter.writeXml(" + propertyValueGetter + ");"); - } else if (wireType instanceof IterableType) { - IType elementType = ((IterableType) wireType).getElementType(); - - methodBlock.ifBlock(propertyValueGetter + " != null", ifAction -> { - if (element.isXmlWrapper()) { - String writeStartElement = element.getXmlNamespace() == null - ? "xmlWriter.writeStartElement(\"" + element.getXmlName() + "\");" - : "xmlWriter.writeStartElement(" + propertiesManager.getXmlNamespaceConstant(element.getXmlNamespace()) + ", \"" + element.getXmlName() + "\");"; - ifAction.line(writeStartElement); - } - - String xmlWrite = elementType.xmlSerializationMethodCall("xmlWriter", element.getXmlListElementName(), - propertiesManager.getXmlNamespaceConstant(element.getXmlListElementNamespace()), "element", false, - false, true); - ifAction.line("for (%s element : %s) {", elementType, propertyValueGetter); - ifAction.indent(() -> ifAction.line(xmlWrite + ";")); - ifAction.line("}"); - - if (element.isXmlWrapper()) { - ifAction.line("xmlWriter.writeEndElement();"); - } - }); - } else if (wireType instanceof MapType) { - // Assumption is that the key type for the Map is a String. This may not always hold true and when that - // becomes reality this will need to be reworked to handle that case. - IType valueType = ((MapType) wireType).getValueType(); - - methodBlock.ifBlock(propertyValueGetter + " != null", ifAction -> { - ifAction.line("xmlWriter.writeStartElement(\"" + element.getXmlName() + "\");"); - - if (valueType instanceof ClassType && ((ClassType) valueType).isSwaggerType()) { - String writeStartElement = (element.getXmlNamespace() != null) - ? "xmlWriter.writeStartElement(" + propertiesManager.getXmlNamespaceConstant(element.getXmlNamespace()) + ", key);" - : "xmlWriter.writeStartElement(key);"; - - ifAction.line("for (Map.Entry entry : %s.entrySet()) {", valueType, propertyValueGetter); - ifAction.indent(() -> { - ifAction.line(writeStartElement); - ifAction.line("xmlWriter.writeXml(entry.getValue());"); - ifAction.line("xmlWriter.writeEndElement();"); - }); - ifAction.line("}"); - } else { - String xmlWrite = valueType.xmlSerializationMethodCall("xmlWriter", "entry.getKey()", - propertiesManager.getXmlNamespaceConstant(element.getXmlNamespace()), "entry.getValue()", false, - true, true); - - ifAction.line("for (Map.Entry entry : %s.entrySet()) {", valueType, propertyValueGetter); - ifAction.indent(() -> ifAction.line(xmlWrite + ";")); - ifAction.line("}"); - } - - ifAction.line("xmlWriter.writeEndElement();"); - }); - } else { - // TODO (alzimmer): Resolve this as serialization logic generation needs to handle all cases. - throw new RuntimeException("Unknown wire type " + wireType + " in XML element serialization. " - + "Need to add support for it."); - } - } - - private static void writeFromXml(JavaClass classBlock, ClientModel model, - ClientModelPropertiesManager propertiesManager, JavaSettings settings, - Consumer addGeneratedAnnotation) { - if (isSuperTypeWithDiscriminator(model)) { - writeSuperTypeFromXml(classBlock, model, propertiesManager, settings, addGeneratedAnnotation); - } else { - writeTerminalTypeFromXml(classBlock, propertiesManager, settings, addGeneratedAnnotation); - } - } - - /** - * Writes a super type's {@code fromXml(XmlReader)} method. - * - * @param classBlock The class having {@code fromXml(XmlReader)} written to it. - * @param model The Autorest representation of the model. - * @param propertiesManager The properties for the model. - * @param settings The Autorest generation settings. - * @param addGeneratedAnnotation Consumer for adding the generated annotation to the class. - */ - private static void writeSuperTypeFromXml(JavaClass classBlock, ClientModel model, - ClientModelPropertiesManager propertiesManager, JavaSettings settings, - Consumer addGeneratedAnnotation) { - // Handling polymorphic fields while determining which subclass, or the class itself, to deserialize handles the - // discriminator type always as a String. This is permissible as the found discriminator is never being used in - // a setter or for setting a field, unlike in the actual deserialization method where it needs to be the same - // type as the field. - ClientModelProperty discriminatorProperty = propertiesManager.getDiscriminatorProperty().getProperty(); - readXmlObject(classBlock, propertiesManager, false, methodBlock -> { - // Assumption for now for XML, only XML properties are used for handling inheritance. - // If this found to be wrong in the future copy the concept of bufferObject and resettable from azure-json - // into azure-xml as bufferElement and resettable. - methodBlock.line("// Get the XML discriminator attribute."); - if (discriminatorProperty.getXmlNamespace() != null) { - methodBlock.line("String discriminatorValue = reader.getStringAttribute(" - + propertiesManager.getXmlNamespaceConstant(discriminatorProperty.getXmlNamespace()) + ", " - + "\"" + discriminatorProperty.getSerializedName() + "\");"); - } else { - methodBlock.line("String discriminatorValue = reader.getStringAttribute(" - + "\"" + discriminatorProperty.getSerializedName() + "\");"); - } - - methodBlock.line("// Use the discriminator value to determine which subtype should be deserialized."); - - // Add deserialization for the super type itself. - JavaIfBlock ifBlock = null; - - // Add deserialization for all child types. - List childTypes = getAllChildTypes(model, new ArrayList<>()); - for (ClientModel childType : childTypes) { - ifBlock = ifOrElseIf(methodBlock, ifBlock, "\"" + childType.getSerializedName() + "\".equals(discriminatorValue)", - ifStatement -> ifStatement.methodReturn(childType.getName() + (isSuperTypeWithDiscriminator(childType) - ? ".fromXmlInternal(reader, finalRootElementName)" - : ".fromXml(reader, finalRootElementName)"))); - } - - if (ifBlock == null) { - methodBlock.methodReturn("fromXmlInternal(reader, finalRootElementName)"); - } else { - ifBlock.elseBlock(elseBlock -> elseBlock.methodReturn("fromXmlInternal(reader, finalRootElementName)")); - } - }, addGeneratedAnnotation); - - readXmlObject(classBlock, propertiesManager, true, - methodBlock -> writeFromXmlDeserialization(methodBlock, propertiesManager, settings), - addGeneratedAnnotation); - } - - /** - * Adds a static method to the class with the signature that handles reading the XML string into the object type. - *

- * If {@code superTypeReading} is true the method will be package-private and named - * {@code fromXmlWithKnownDiscriminator} instead of being public and named {@code fromXml}. This is done as super - * types use their {@code fromXml} method to determine the discriminator value and pass the reader to the specific - * type being deserialized. The specific type being deserialized may be the super type itself, so it cannot pass to - * {@code fromXml} as this will be a circular call and if the specific type being deserialized is an intermediate - * type (a type having both super and subclasses) it will attempt to perform discriminator validation which has - * already been done. - * - * @param classBlock The class where the {@code fromXml} method is being written. - * @param propertiesManager Properties information about the object being deserialized. - * @param superTypeReading Whether the object reading is for a super type. - * @param deserializationBlock Logic for deserializing the object. - * @param addGeneratedAnnotation Consumer for adding the generated annotation to the class. - */ - private static void readXmlObject(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, - boolean superTypeReading, Consumer deserializationBlock, - Consumer addGeneratedAnnotation) { - JavaVisibility visibility = superTypeReading ? JavaVisibility.PackagePrivate : JavaVisibility.Public; - String methodName = superTypeReading ? "fromXmlInternal" : "fromXml"; - - String modelName = propertiesManager.getModel().getName(); - boolean hasRequiredProperties = propertiesManager.hasConstructorArguments(); - boolean isPolymorphic = propertiesManager.getDiscriminatorProperty() != null - && CoreUtils.isNullOrEmpty(propertiesManager.getModel().getDerivedModels()); - - if (!superTypeReading) { - fromXmlJavadoc(classBlock, modelName, false, hasRequiredProperties, isPolymorphic); - addGeneratedAnnotation.accept(classBlock); - classBlock.publicStaticMethod(modelName + " fromXml(XmlReader xmlReader) throws XMLStreamException", - methodBlock -> methodBlock.methodReturn("fromXml(xmlReader, null)")); - - fromXmlJavadoc(classBlock, modelName, true, hasRequiredProperties, isPolymorphic); - } - - addGeneratedAnnotation.accept(classBlock); - classBlock.staticMethod(visibility, modelName + " " + methodName + "(XmlReader xmlReader, String rootElementName) throws XMLStreamException", methodBlock -> { - // For now, use the basic readObject which will return null if the XmlReader is pointing to JsonToken.NULL. - // - // Support for a default value if null will need to be supported and for objects that get their value - // from a JSON value instead of JSON object or are an array type. - String requiredElementName = propertiesManager.getXmlRootElementName(); - String requiredNamespace = propertiesManager.getXmlRootElementNamespace(); - - methodBlock.line("String finalRootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? " - + "\"" + requiredElementName + "\" : rootElementName;"); - if (requiredNamespace != null) { - methodBlock.line("return xmlReader.readObject(" + propertiesManager.getXmlNamespaceConstant(requiredNamespace) + ", finalRootElementName, reader -> {"); - } else { - methodBlock.line("return xmlReader.readObject(finalRootElementName, reader -> {"); - } - - deserializationBlock.accept(methodBlock); - - methodBlock.line("});"); - }); - } - - private static void fromXmlJavadoc(JavaClass classBlock, String modelName, boolean hasRootElementName, - boolean hasRequiredProperties, boolean isPolymorphic) { - classBlock.javadocComment(javadocComment -> { - javadocComment.description("Reads an instance of " + modelName + " from the XmlReader."); - javadocComment.param("xmlReader", "The XmlReader being read."); - if (hasRootElementName) { - javadocComment.param("rootElementName", "Optional root element name to override the default defined " - + "by the model. Used to support cases where the model can deserialize from different root element " - + "names."); - } - javadocComment.methodReturns("An instance of " + modelName + " if the XmlReader was pointing to an " - + "instance of it, or null if it was pointing to XML null."); - - // TODO (alzimmer): Make the throws statement more descriptive by including the polymorphic - // discriminator property name and the required property names. For now this covers the base functionality. - String throwsStatement = null; - if (hasRequiredProperties && isPolymorphic) { - throwsStatement = "If the deserialized XML object was missing any required properties or the " - + "polymorphic discriminator value is invalid."; - } else if (hasRequiredProperties) { - throwsStatement = "If the deserialized XML object was missing any required properties."; - } else if (isPolymorphic) { - throwsStatement = "If the deserialized XML object has an invalid polymorphic discriminator value."; - } - - if (throwsStatement != null) { - javadocComment.methodThrows("IllegalStateException", throwsStatement); - } - - javadocComment.methodThrows("XMLStreamException", "If an error occurs while reading the " + modelName + "."); - }); - } - - /** - * Writes a terminal type's {@code fromXml(XmlReader)} method. - *

- * A terminal type is either a type without polymorphism or is the terminal type in a polymorphic hierarchy. - * - * @param classBlock The class having {@code fromXml(XmlReader)} written to it. - * @param propertiesManager The properties for the model. - * @param settings The Autorest generation settings. - * @param addGeneratedAnnotation Consumer for adding the generated annotation to the class. - */ - private static void writeTerminalTypeFromXml(JavaClass classBlock, ClientModelPropertiesManager propertiesManager, - JavaSettings settings, Consumer addGeneratedAnnotation) { - readXmlObject(classBlock, propertiesManager, false, - methodBlock -> writeFromXmlDeserialization(methodBlock, propertiesManager, settings), - addGeneratedAnnotation); - } - - private static void writeFromXmlDeserialization(JavaBlock methodBlock, - ClientModelPropertiesManager propertiesManager, JavaSettings settings) { - - // Add the deserialization logic. - methodBlock.indent(() -> { - // Initialize local variables to track what has been deserialized. - initializeLocalVariables(methodBlock, propertiesManager, true, settings); - - // Assumption for XML is polymorphic discriminators are attributes. - if (propertiesManager.getDiscriminatorProperty() != null) { - deserializeXmlAttribute(methodBlock, propertiesManager.getDiscriminatorProperty().getProperty(), - propertiesManager, false); - } - - // Read the XML attribute properties first. - propertiesManager.forEachSuperXmlAttribute(attribute -> deserializeXmlAttribute(methodBlock, attribute, - propertiesManager, true)); - propertiesManager.forEachXmlAttribute(attribute -> deserializeXmlAttribute(methodBlock, attribute, - propertiesManager, false)); - - // Read the XML text next. - propertiesManager.forEachSuperXmlText(text -> deserializeXmlText(methodBlock, text, propertiesManager, true)); - propertiesManager.forEachXmlText(text -> deserializeXmlText(methodBlock, text, propertiesManager, false)); - - // Model didn't have any XML elements, return early. - String fieldNameVariableName = propertiesManager.getXmlReaderNameVariableName(); - if (!propertiesManager.hasXmlElements()) { - // If the model was attributes only a simplified read loop is needed to ensure the end element token - // is reached. - if (!propertiesManager.hasXmlTexts()) { - methodBlock.block("while (reader.nextElement() != XmlToken.END_ELEMENT)", - whileBlock -> whileBlock.line("reader.skipElement();")); - } - return; - } - - // Add the outermost while loop to read the JSON object. - addReaderWhileLoop(methodBlock, true, fieldNameVariableName, true, whileBlock -> { - JavaIfBlock ifBlock = null; - - if (propertiesManager.getDiscriminatorProperty() != null - && !propertiesManager.getDiscriminatorProperty().getProperty().isXmlAttribute()) { - ClientModelProperty discriminatorProperty = propertiesManager.getDiscriminatorProperty() - .getProperty(); - String ifStatement = String.format("\"%s\".equals(%s)", propertiesManager.getExpectedDiscriminator(), - fieldNameVariableName); - - ifBlock = methodBlock.ifBlock(ifStatement, ifAction -> { - ifAction.line("String %s = reader.getStringElement().getLocalPart();", discriminatorProperty.getName()); - String ifStatement2 = String.format("!%s.equals(%s)", discriminatorProperty.getDefaultValue(), - discriminatorProperty.getName()); - ifAction.ifBlock(ifStatement2, ifAction2 -> ifAction2.line( - "throw new IllegalStateException(\"'%s' was expected to be non-null and equal to '\"%s\"'. " - + "The found '%s' was '\" + %s + \"'.\");", - discriminatorProperty.getSerializedName(), propertiesManager.getExpectedDiscriminator(), - discriminatorProperty.getSerializedName(), discriminatorProperty.getName())); - }); - } - - // Loop over all properties and generate their deserialization handling. - AtomicReference ifBlockReference = new AtomicReference<>(ifBlock); - propertiesManager.forEachSuperXmlElement(element -> handleXmlPropertyDeserialization(element, - whileBlock, ifBlockReference, fieldNameVariableName, propertiesManager, true, settings)); - propertiesManager.forEachXmlElement(element -> handleXmlPropertyDeserialization(element, whileBlock, - ifBlockReference, fieldNameVariableName, propertiesManager, false, settings)); - - ifBlock = ifBlockReference.get(); - - // All properties have been checked for, add an else block that will either ignore unknown properties - // or add them into an additional properties bag. - ClientModelProperty additionalProperty = getAdditionalPropertiesPropertyInModelOrFromSuper(propertiesManager); - handleUnknownXmlFieldDeserialization(whileBlock, ifBlock, additionalProperty, - propertiesManager.getXmlReaderNameVariableName()); - }); - }); - - // Add the validation and return logic. - handleReadReturn(methodBlock, propertiesManager.getModel().getName(), propertiesManager, settings); - } - - private static void deserializeXmlAttribute(JavaBlock methodBlock, ClientModelProperty attribute, - ClientModelPropertiesManager propertiesManager, boolean fromSuper) { - String xmlAttributeDeserialization = getSimpleXmlDeserialization(attribute.getWireType(), "reader", null, - attribute.getXmlName(), propertiesManager.getXmlNamespaceConstant(attribute.getXmlNamespace()), true); - - if (attribute.isPolymorphicDiscriminator() - && CoreUtils.isNullOrEmpty(propertiesManager.getModel().getDerivedModels())) { - // Only validate the discriminator if the model has no derived models. - // Super types will deserialize as themselves if the discriminator doesn't match what's expected. - methodBlock.line("String discriminatorValue = " + xmlAttributeDeserialization + ";"); - String ifStatement = String.format("!%s.equals(discriminatorValue)", attribute.getDefaultValue()); - methodBlock.ifBlock(ifStatement, ifAction2 -> ifAction2.line( - "throw new IllegalStateException(\"'%s' was expected to be non-null and equal to '%s'. " - + "The found '%s' was '\" + discriminatorValue + \"'.\");", - attribute.getSerializedName(), propertiesManager.getExpectedDiscriminator(), - attribute.getSerializedName())); - - xmlAttributeDeserialization = "discriminatorValue"; - } - - if (propertiesManager.hasConstructorArguments()) { - methodBlock.line("%s %s = %s;", attribute.getClientType(), attribute.getName(), xmlAttributeDeserialization); - } else { - handleSettingDeserializedValue(methodBlock, propertiesManager.getDeserializedModelName(), - propertiesManager.getModel(), attribute, xmlAttributeDeserialization, fromSuper, false); - } - } - - private static void deserializeXmlText(JavaBlock methodBlock, ClientModelProperty text, - ClientModelPropertiesManager propertiesManager, boolean fromSuper) { - String xmlTextDeserialization = getSimpleXmlDeserialization(text.getWireType(), "reader", null, null, null, false); - if (propertiesManager.hasConstructorArguments()) { - methodBlock.line(text.getClientType() + " " + text.getName() + " = " + xmlTextDeserialization + ";"); - } else { - handleSettingDeserializedValue(methodBlock, propertiesManager.getDeserializedModelName(), - propertiesManager.getModel(), text, xmlTextDeserialization, fromSuper, false); - } - } - - private static void handleXmlPropertyDeserialization(ClientModelProperty property, JavaBlock methodBlock, - AtomicReference ifBlockReference, String fieldNameVariableName, - ClientModelPropertiesManager propertiesManager, boolean fromSuper, JavaSettings settings) { - // Property will be handled later by flattened deserialization. - // XML should never have flattening. - if (property.getNeedsFlatten()) { - return; - } - - JavaIfBlock ifBlock = ifBlockReference.get(); - ifBlock = handleXmlPropertyDeserialization(property, methodBlock, ifBlock, fieldNameVariableName, - propertiesManager, fromSuper, settings); - - ifBlockReference.set(ifBlock); - } - - private static JavaIfBlock handleXmlPropertyDeserialization(ClientModelProperty property, JavaBlock methodBlock, - JavaIfBlock ifBlock, String fieldNameVariableName, ClientModelPropertiesManager propertiesManager, - boolean fromSuper, JavaSettings settings) { - String xmlElementName = (property.getClientType() instanceof IterableType && !property.isXmlWrapper()) - ? property.getXmlListElementName() : property.getXmlName(); - String xmlNamespace = propertiesManager.getXmlNamespaceConstant(property.getXmlNamespace()); - - if (CoreUtils.isNullOrEmpty(xmlElementName)) { - return ifBlock; - } - - String condition = getXmlNameConditional(xmlElementName, xmlNamespace, fieldNameVariableName, true); - return ifOrElseIf(methodBlock, ifBlock, condition, - deserializationBlock -> generateXmlDeserializationLogic(deserializationBlock, property, propertiesManager, - fromSuper, settings)); - } - - private static void generateXmlDeserializationLogic(JavaBlock deserializationBlock, ClientModelProperty property, - ClientModelPropertiesManager propertiesManager, boolean fromSuper, JavaSettings settings) { - IType wireType = property.getWireType(); - - // Attempt to determine whether the wire type is simple deserialization. - // This is primitives, boxed primitives, a small set of string based models, and other ClientModels. - String simpleDeserialization = getSimpleXmlDeserialization(wireType, "reader", property.getXmlName(), null, - null, false); - if (simpleDeserialization != null) { - if (propertiesManager.hasConstructorArguments()) { - deserializationBlock.line(property.getName() + " = " + simpleDeserialization + ";"); - } else { - handleSettingDeserializedValue(deserializationBlock, propertiesManager.getDeserializedModelName(), - propertiesManager.getModel(), property, simpleDeserialization, fromSuper, false); - } - } else if (wireType instanceof IterableType) { - IType elementType = ((IterableType) wireType).getElementType(); - boolean sameNames = Objects.equals(property.getXmlName(), property.getXmlListElementName()); - String elementDeserialization = getSimpleXmlDeserialization(elementType, "reader", - sameNames ? property.getXmlName() : property.getXmlListElementName(), null, null, false); - String fieldAccess; - if (propertiesManager.hasConstructorArguments()) { - // Cases with constructor arguments will have a local variable based on the name of the property. - fieldAccess = property.getName(); - } else if (fromSuper) { - // Cases where the property is from the super type will need to access the getter. - fieldAccess = propertiesManager.getDeserializedModelName() + "." + property.getGetterName() + "()"; - } else { - // Otherwise access the property directly. - fieldAccess = propertiesManager.getDeserializedModelName() + "." + property.getName(); - } - - if (!property.isXmlWrapper()) { - deserializationBlock.line(fieldAccess + ".add(" + elementDeserialization + ");"); - } else { - deserializationBlock.block("while (reader.nextElement() != XmlToken.END_ELEMENT)", whileBlock -> { - whileBlock.line("elementName = reader.getElementName();"); - String condition = getXmlNameConditional(property.getXmlListElementName(), - propertiesManager.getXmlNamespaceConstant(property.getXmlListElementNamespace()), "elementName", - true); - whileBlock.ifBlock(condition, ifBlock -> { - // TODO (alzimmer): Handle nested container types when needed. - ifBlock.ifBlock(fieldAccess + " == null", ifStatement -> { - if (fromSuper) { - ifStatement.line(propertiesManager.getDeserializedModelName() + "." + property.getSetterName() - + "(new ArrayList<>());"); - } else { - ifStatement.line(fieldAccess + " = new ArrayList<>();"); - } - }); - - ifBlock.line(fieldAccess + ".add(" + elementDeserialization + ");"); - }) - .elseBlock(elseBlock -> elseBlock.line("reader.skipElement();")); - }); - } - } else if (wireType instanceof MapType) { - IType valueType = ((MapType) wireType).getValueType(); - String fieldAccess = propertiesManager.hasConstructorArguments() - ? property.getName() - : propertiesManager.getDeserializedModelName() + "." + property.getName(); - - String valueDeserialization = getSimpleXmlDeserialization(valueType, "reader", property.getXmlName(), null, - null, false); - deserializationBlock.block("while (reader.nextElement() != XmlToken.END_ELEMENT)", whileBlock -> { - // TODO (alzimmer): Handle nested container types when needed. - // Assumption is that the key type for the Map is a String. This may not always hold true and when that - // becomes reality this will need to be reworked to handle that case. - whileBlock.ifBlock(fieldAccess + " == null", - ifStatement -> ifStatement.line(fieldAccess + " = new LinkedHashMap<>();")); - - whileBlock.line(fieldAccess + ".put(reader.getElementName().getLocalPart(), " + valueDeserialization + ");"); - }); - } else { - // TODO (alzimmer): Resolve this as deserialization logic generation needs to handle all cases. - throw new RuntimeException("Unknown wire type " + wireType + ". Need to add support for it."); - } - - // If the property was required, mark it as found. - if (includePropertyInConstructor(property, settings) && !settings.isDisableRequiredJsonAnnotation()) { - deserializationBlock.line(property.getName() + "Found = true;"); - } - } - - private static void handleUnknownXmlFieldDeserialization(JavaBlock methodBlock, JavaIfBlock ifBlock, - ClientModelProperty additionalProperties, String fieldNameVariableName) { - Consumer unknownFieldConsumer = javaBlock -> { - if (additionalProperties != null) { - javaBlock.ifBlock(additionalProperties.getName() + " == null", - ifAction -> ifAction.line(additionalProperties.getName() + " = new LinkedHashMap<>();")); - javaBlock.line(); - - // Assumption, additional properties is a Map of String-Object - IType valueType = ((MapType) additionalProperties.getWireType()).getValueType(); - if (valueType == ClassType.OBJECT) { - // String fieldName should be a local variable accessible in this spot of code. - javaBlock.line(additionalProperties.getName() + ".put(" + fieldNameVariableName + ", reader.readUntyped());"); - } else { - // Another assumption, the additional properties value type is simple. - javaBlock.line(additionalProperties.getName() + ".put(" + fieldNameVariableName + ", " - + getSimpleXmlDeserialization(valueType, "reader", null, null, null, false) + ");"); - } - } else { - javaBlock.line("reader.skipElement();"); - } - }; - - if (ifBlock == null) { - unknownFieldConsumer.accept(methodBlock); - } else { - ifBlock.elseBlock(unknownFieldConsumer); - } - } - - private static String getSimpleXmlDeserialization(IType wireType, String readerName, String elementName, - String attributeName, String attributeNamespace, boolean namespaceIsConstant) { - if (wireType instanceof ClassType && ((ClassType) wireType).isSwaggerType()) { - return CoreUtils.isNullOrEmpty(elementName) - ? wireType + ".fromXml(" + readerName + ")" - : wireType + ".fromXml(" + readerName + ", \"" + elementName + "\")"; - } else { - return wireType.xmlDeserializationMethod(readerName, attributeName, attributeNamespace, namespaceIsConstant); - } - } - - private static List getClientModelPropertiesInJsonTree( - JsonFlattenedPropertiesTree tree) { - if (tree.getProperty() != null) { - // Terminal node only contains a property. - return Collections.singletonList(tree.getProperty()); - } else { - List treeProperties = new ArrayList<>(); - for (JsonFlattenedPropertiesTree childNode : tree.getChildrenNodes().values()) { - treeProperties.addAll(getClientModelPropertiesInJsonTree(childNode)); - } - - return treeProperties; - } - } - - private static String getXmlNameConditional(String localPart, String namespace, String elementName, - boolean namespaceIsConstant) { - String condition = "\"" + localPart + "\".equals(" + elementName + ".getLocalPart())"; - if (!CoreUtils.isNullOrEmpty(namespace)) { - if (namespaceIsConstant) { - condition += " && " + namespace + ".equals(" + elementName + ".getNamespaceURI())"; - } else { - condition += " && \"" + namespace + "\".equals(" + elementName + ".getNamespaceURI())"; - } - } - - return condition; - } + return condition; + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/example/ClientMethodExampleWriter.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/example/ClientMethodExampleWriter.java index 40724019b..540d9990a 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/example/ClientMethodExampleWriter.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/example/ClientMethodExampleWriter.java @@ -47,360 +47,362 @@ import java.util.stream.Collectors; public class ClientMethodExampleWriter { - private final Set imports = new HashSet<>(); - private final BiConsumer methodBodyWriter; - private final Consumer responseAssertionWriter; - private final ModelExampleWriter.ExampleNodeModelInitializationVisitor nodeVisitor = new ModelExampleWriter.ExampleNodeModelInitializationVisitor(); + private final Set imports = new HashSet<>(); + private final BiConsumer methodBodyWriter; + private final Consumer responseAssertionWriter; + private final ModelExampleWriter.ExampleNodeModelInitializationVisitor nodeVisitor = new ModelExampleWriter.ExampleNodeModelInitializationVisitor(); - public ClientMethodExampleWriter(ClientMethod method, String clientVarName, ProxyMethodExample proxyMethodExample){ + public ClientMethodExampleWriter(ClientMethod method, String clientVarName, ProxyMethodExample proxyMethodExample){ - List methodParameters = MethodUtil.getParameters(method, true); - List exampleNodes = methodParameters - .stream() - .map(methodParameter -> parseNodeFromParameter(method, proxyMethodExample, methodParameter)) - .collect(Collectors.toList()); + List methodParameters = MethodUtil.getParameters(method, true); + List exampleNodes = methodParameters + .stream() + .map(methodParameter -> parseNodeFromParameter(method, proxyMethodExample, methodParameter)) + .collect(Collectors.toList()); - String parameterInvocations = exampleNodes.stream() - .map(nodeVisitor::accept) - .collect(Collectors.joining(", ")); + String parameterInvocations = exampleNodes.stream() + .map(nodeVisitor::accept) + .collect(Collectors.joining(", ")); - // assertion - this.imports.add("org.junit.jupiter.api.Assertions"); - imports.add(LongRunningOperationStatus.class.getName()); - ClassType.HTTP_HEADER_NAME.addImportsTo(imports, false); + // assertion + this.imports.add("org.junit.jupiter.api.Assertions"); + imports.add(LongRunningOperationStatus.class.getName()); + ClassType.HTTP_HEADER_NAME.addImportsTo(imports, false); - method.getReturnValue().getType().addImportsTo(imports, false); + method.getReturnValue().getType().addImportsTo(imports, false); - methodBodyWriter = (methodBlock, isTestCode) -> { - StringBuilder methodInvocation = new StringBuilder(); + methodBodyWriter = (methodBlock, isTestCode) -> { + StringBuilder methodInvocation = new StringBuilder(); - if (method.getReturnValue().getType().asNullable() != ClassType.VOID) { - String assignment = String.format("%s %s = ", method.getReturnValue().getType(), "response"); - methodInvocation.append(assignment); - } + if (method.getReturnValue().getType().asNullable() != ClassType.VOID) { + String assignment = String.format("%s %s = ", method.getReturnValue().getType(), "response"); + methodInvocation.append(assignment); + } - String methodCall = String.format("%s.%s(%s)", - clientVarName, - method.getName(), - parameterInvocations); - if (isTestCode) { - if (method.getType() == ClientMethodType.LongRunningBeginSync) { - methodCall = "setPlaybackSyncPollerPollInterval(" + methodCall + ")"; - } else if (method.getType() == ClientMethodType.LongRunningBeginAsync) { - methodCall = "setPlaybackPollerFluxPollInterval(" + methodCall + ")"; - } - } - methodInvocation.append(methodCall).append(";"); - - methodBlock.line(methodInvocation.toString()); - }; - responseAssertionWriter = methodBlock -> { - ProxyMethodExample.Response response = proxyMethodExample.getPrimaryResponse(); - if (response != null) { - IType returnType = method.getReturnValue().getType(); - if (returnType instanceof GenericType) { - GenericType responseType = (GenericType) returnType; - if (SyncPoller.class.getSimpleName().equals(responseType.getName())) { - // SyncPoller<> - - if (response.getStatusCode() / 100 == 2) { - methodBlock.line(); - methodBlock.line("// response assertion"); - // it should have a 202 leading to SUCCESSFULLY_COMPLETED - // but x-ms-examples usually does not include the final result - methodBlock.line("Assertions.assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, response.waitForCompletion().getStatus());"); - } - } else if (PagedIterable.class.getSimpleName().equals(responseType.getName())) { - // PagedIterable<> - - methodBlock.line(); - methodBlock.line("// response assertion"); - // assert status code - methodBlock.line(String.format("Assertions.assertEquals(%1$s, response.iterableByPage().iterator().next().getStatusCode());", response.getStatusCode())); - // assert headers - response.getHttpHeaders().stream().forEach(header -> { - String expectedValueStr = ClassType.STRING.defaultValueExpression(header.getValue()); - String keyStr = ClassType.STRING.defaultValueExpression(header.getName()); - methodBlock.line(String.format("Assertions.assertEquals(%1$s, response.iterableByPage().iterator().next().getHeaders().get(HttpHeaderName.fromString(%2$s)).getValue());", expectedValueStr, keyStr)); - }); - // assert JSON of first item, or assert count=0 - if (method.getProxyMethod().getResponseContentTypes() != null - && method.getProxyMethod().getResponseContentTypes().contains(ContentType.APPLICATION_JSON) - && responseType.getTypeArguments().length > 0 - && ClientModelUtil.isClientModel(responseType.getTypeArguments()[0]) - && method.getMethodPageDetails() != null - && response.getBody() instanceof Map) { - Map bodyMap = (Map) response.getBody(); - if (bodyMap.containsKey(method.getMethodPageDetails().getSerializedItemName())) { - Object items = bodyMap.get(method.getMethodPageDetails().getSerializedItemName()); - if (items instanceof List) { - List itemArray = (List) items; - if (itemArray.isEmpty()) { - methodBlock.line("Assertions.assertEquals(0, response.stream().count());"); - } else { - Object firstItem = itemArray.iterator().next(); - methodBlock.line("%s firstItem = %s;", responseType.getTypeArguments()[0], "response.iterator().next()"); - writeModelAssertion(methodBlock, nodeVisitor, responseType.getTypeArguments()[0], responseType.getTypeArguments()[0], firstItem, "firstItem", true); - } - } - } - } - } - } else if (ClassType.BOOLEAN.equals(returnType.asNullable()) && HttpMethod.HEAD.equals(method.getProxyMethod().getHttpMethod())) { - methodBlock.line(); - methodBlock.line("// response assertion"); - if (response.getStatusCode() == 200) { - methodBlock.line("Assertions.assertTrue(response);"); - } else if (response.getStatusCode() == 404) { - methodBlock.line("Assertions.assertFalse(response)"); - } - } else if (!ClassType.VOID.equals(returnType.asNullable())){ - methodBlock.line(); - methodBlock.line("// response assertion"); - writeModelAssertion(methodBlock, nodeVisitor, returnType, returnType, response.getBody(), "response", true); - } - } else { - methodBlock.line(); - methodBlock.line("// response assertion"); - methodBlock.line("Assertions.assertNotNull(response);"); - } - }; - - addNecessaryImports(); - } - - private void addNecessaryImports() { - // write dummy, allow nodeVisitor to collect all necessary imports - responseAssertionWriter.accept(new JavaBlock(new JavaFileContents())); - this.imports.addAll(nodeVisitor.getImports()); - } - - /** - * Write assertions for the given model and its example value. - * - * @param methodBlock the method block to write assertions to - * @param nodeVisitor node visitor for example values - * @param modelClientType client type of the model - * @param modelWireType wire type of the model - * @param modelValue example value of the model - * @param modelReference reference of the model that can be used to access the model in generated code - * @param rootModel whether the model is in the root of the response - */ - private void writeModelAssertion(JavaBlock methodBlock, ModelExampleWriter.ExampleNodeModelInitializationVisitor nodeVisitor, - IType modelClientType, IType modelWireType, Object modelValue, String modelReference, boolean rootModel) { - if (modelValue != null) { - modelClientType.addImportsTo(this.imports, false); - if (modelWireType != null) { - modelWireType.addImportsTo(this.imports, false); - } - if (isClientModel(modelClientType, modelValue)) { - methodBlock.line("Assertions.assertNotNull(%s);", modelReference); - // Client Model - ClassType modelClassType = (ClassType) modelClientType; - ClientModel clientModel = ClientModelUtil.getClientModel(modelClassType.getName()); - if (clientModel.getProperties() != null) { - for (ClientModelProperty property : clientModel.getProperties()) { - String serializedName = property.getSerializedName(); - Object propertyValue = ((Map) modelValue).get(serializedName); - if (propertyValue != null) { - if (rootModel) { - methodBlock.line("// verify property \"%s\"", property.getName()); - } - String propertyGetter = String.format("%s.%s()", modelReference, property.getGetterName()); - if (isClientModel(property.getClientType(), propertyValue) || isList(property.getClientType(), propertyValue)) { - String propertyReference = String.format("%s%s", modelReference, CodeNamer.toPascalCase(property.getName())); - methodBlock.line("%s %s = %s;", property.getClientType(), propertyReference, propertyGetter); - writeModelAssertion(methodBlock, nodeVisitor, property.getClientType(), property.getWireType(), propertyValue, propertyReference, false); - } else { - writeModelAssertion(methodBlock, nodeVisitor, property.getClientType(), property.getWireType(), propertyValue, propertyGetter, false); - } - } - } - } - } else if (isList(modelClientType, modelValue)) { - // List - List values = (List) modelValue; - if (values.size() > 0) { - ListType listType = (ListType) modelClientType; - IType elementType = listType.getElementType(); - Object firstItemValue = values.iterator().next(); - if (firstItemValue != null) { - String firstItemGetter = String.format("%s.iterator().next()", modelReference); - if (isClientModel(elementType, firstItemValue) || isList(elementType, firstItemValue)) { - String firstItemReference = String.format("%s%s", modelReference, "FirstItem"); - methodBlock.line("%s %s = %s;", elementType, firstItemReference, firstItemGetter); - writeModelAssertion(methodBlock, nodeVisitor, elementType, elementType, values.iterator().next(), firstItemReference, rootModel); - } else { - writeModelAssertion(methodBlock, nodeVisitor, elementType, elementType, values.iterator().next(), firstItemGetter, rootModel); - } - } - } else { - methodBlock.line("Assertions.assertEquals(0, %s);", String.format("%s.size()", modelReference)); - } - } else if (modelClientType instanceof PrimitiveType || modelClientType instanceof EnumType - || ClassType.STRING.equals(modelClientType) || ClassType.URL.equals(modelClientType) - || (modelClientType instanceof ClassType && ((ClassType) modelClientType).isBoxedType())) { - // simple models that can be compared by "Assertions.assertEquals()" - methodBlock.line(String.format( - "Assertions.assertEquals(%s, %s);", - nodeVisitor.accept(ModelExampleUtil.parseNode(modelClientType, modelWireType, modelValue)), - modelReference - )); - } else { - methodBlock.line("Assertions.assertNotNull(%s);", modelReference); - } + String methodCall = String.format("%s.%s(%s)", + clientVarName, + method.getName(), + parameterInvocations); + if (isTestCode) { + if (method.getType() == ClientMethodType.LongRunningBeginSync) { + methodCall = "setPlaybackSyncPollerPollInterval(" + methodCall + ")"; + } else if (method.getType() == ClientMethodType.LongRunningBeginAsync) { + methodCall = "setPlaybackPollerFluxPollInterval(" + methodCall + ")"; } - } + } + methodInvocation.append(methodCall).append(";"); - private boolean isList(IType modelClientType, Object modelValue) { - return modelClientType instanceof ListType && modelValue instanceof List; - } + methodBlock.line(methodInvocation.toString()); + }; + responseAssertionWriter = methodBlock -> { + ProxyMethodExample.Response response = proxyMethodExample.getPrimaryResponse(); + if (response != null) { + IType returnType = method.getReturnValue().getType(); + if (returnType instanceof GenericType) { + GenericType responseType = (GenericType) returnType; + if (SyncPoller.class.getSimpleName().equals(responseType.getName())) { + // SyncPoller<> - private boolean isClientModel(IType modelClientType, Object modelValue) { - return modelClientType instanceof ClassType - && ClientModelUtil.isClientModel(modelClientType) - && modelValue instanceof Map; - } + if (response.getStatusCode() / 100 == 2) { + methodBlock.line(); + methodBlock.line("// response assertion"); + // it should have a 202 leading to SUCCESSFULLY_COMPLETED + // but x-ms-examples usually does not include the final result + methodBlock.line("Assertions.assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, response.waitForCompletion().getStatus());"); + } + } else if (PagedIterable.class.getSimpleName().equals(responseType.getName())) { + // PagedIterable<> - /** - * Parse example node from given parameter, taking into account parameter grouping. - * - * @param convenienceMethod the convenience method to generate example for - * @param proxyMethodExample the proxy method example - * @param methodParameter mapped convenience method parameter to protocol(proxy) method parameter - * @return example node - */ - private ExampleNode parseNodeFromParameter(ClientMethod convenienceMethod, ProxyMethodExample proxyMethodExample, MethodParameter methodParameter) { - if (isGroupingParameter(convenienceMethod, methodParameter)) { - // grouping, possible with flattening first - - // group example values into a map - Map exampleValue = new HashMap<>(); - for (MethodTransformationDetail detail : convenienceMethod.getMethodTransformationDetails()) { - for (ParameterMapping parameterMapping : detail.getParameterMappings()) { - if (parameterMapping.getOutputParameterPropertyName() != null) { - // this is a flattened property, so put flattening(real parameter) value - - // output parameter's name is the "escaped reserved client method parameter name" of the real parameter's serialized name - // since flattened parameter is always in body, we can deal with that explicitly - ClientMethodParameter outputParameter = detail.getOutParameter(); - Map flattenedParameterValue = getFlattenedBodyParameterExampleValue(proxyMethodExample, outputParameter); - if (flattenedParameterValue != null) { - exampleValue.putAll(flattenedParameterValue); - } - // since it's flattened property, all parameterMappings share the same outputParameter(real parameter) - // we only need to put example value once, which is the flattened(real) parameter's value - break; - } else { - // Group property's "serializedName" is the real parameter's "serializedName" on the wire. - // This implicit equivalence is defined in emitter and preserved in mapping client method. - String serializedParameterName = parameterMapping.getInputParameterProperty().getSerializedName(); - ClientMethodParameter parameter = detail.getOutParameter(); - exampleValue.put(serializedParameterName, - ModelExampleUtil.getParameterExampleValue( - proxyMethodExample, serializedParameterName, parameter.getRequestParameterLocation())); - } + methodBlock.line(); + methodBlock.line("// response assertion"); + // assert status code + methodBlock.line(String.format("Assertions.assertEquals(%1$s, response.iterableByPage().iterator().next().getStatusCode());", response.getStatusCode())); + // assert headers + response.getHttpHeaders().stream().forEach(header -> { + String expectedValueStr = ClassType.STRING.defaultValueExpression(header.getValue()); + String keyStr = ClassType.STRING.defaultValueExpression(header.getName()); + methodBlock.line(String.format("Assertions.assertEquals(%1$s, response.iterableByPage().iterator().next().getHeaders().get(HttpHeaderName.fromString(%2$s)).getValue());", expectedValueStr, keyStr)); + }); + // assert JSON of first item, or assert count=0 + if (method.getProxyMethod().getResponseContentTypes() != null + && method.getProxyMethod().getResponseContentTypes().contains(ContentType.APPLICATION_JSON) + && responseType.getTypeArguments().length > 0 + && ClientModelUtil.isClientModel(responseType.getTypeArguments()[0]) + && method.getMethodPageDetails() != null + && response.getBody() instanceof Map) { + Map bodyMap = (Map) response.getBody(); + if (bodyMap.containsKey(method.getMethodPageDetails().getSerializedItemName())) { + Object items = bodyMap.get(method.getMethodPageDetails().getSerializedItemName()); + if (items instanceof List) { + List itemArray = (List) items; + if (itemArray.isEmpty()) { + methodBlock.line("Assertions.assertEquals(0, response.stream().count());"); + } else { + Object firstItem = itemArray.iterator().next(); + methodBlock.line("%s firstItem = %s;", responseType.getTypeArguments()[0], "response.iterator().next()"); + writeModelAssertion(methodBlock, nodeVisitor, responseType.getTypeArguments()[0], responseType.getTypeArguments()[0], firstItem, "firstItem", true); + } } + } } - IType type = methodParameter.getClientMethodParameter().getClientType(); - IType wireType = methodParameter.getClientMethodParameter().getWireType(); - return ModelExampleUtil.parseNode(type, wireType, exampleValue); - } else if (isFlattenParameter(convenienceMethod, methodParameter)) { - // flatten, no grouping - ClientMethodParameter outputParameter = convenienceMethod.getMethodTransformationDetails().iterator().next().getOutParameter(); - Map realParameterValue = getFlattenedBodyParameterExampleValue(proxyMethodExample, outputParameter); + } + } else if (ClassType.BOOLEAN.equals(returnType.asNullable()) && HttpMethod.HEAD.equals(method.getProxyMethod().getHttpMethod())) { + methodBlock.line(); + methodBlock.line("// response assertion"); + if (response.getStatusCode() == 200) { + methodBlock.line("Assertions.assertTrue(response);"); + } else if (response.getStatusCode() == 404) { + methodBlock.line("Assertions.assertFalse(response)"); + } + } else if (!ClassType.VOID.equals(returnType.asNullable())){ + methodBlock.line(); + methodBlock.line("// response assertion"); + writeModelAssertion(methodBlock, nodeVisitor, returnType, returnType, response.getBody(), "response", true); + } + } else { + methodBlock.line(); + methodBlock.line("// response assertion"); + methodBlock.line("Assertions.assertNotNull(response);"); + } + }; - IType type = methodParameter.getClientMethodParameter().getClientType(); - IType wireType = methodParameter.getClientMethodParameter().getWireType(); + addNecessaryImports(); + } - ParameterMapping parameterMapping = convenienceMethod.getMethodTransformationDetails().iterator().next() - .getParameterMappings() - .stream() - .filter(mapping -> Objects.equals(mapping.getInputParameter().getName(), methodParameter.getClientMethodParameter().getName())) - .findFirst().orElse(null); + private void addNecessaryImports() { + // write dummy, allow nodeVisitor to collect all necessary imports + responseAssertionWriter.accept(new JavaBlock(new JavaFileContents())); + this.imports.addAll(nodeVisitor.getImports()); + } - Object methodParameterValue = null; - if (realParameterValue != null && parameterMapping != null) { - methodParameterValue = realParameterValue.get(parameterMapping.getOutputParameterProperty().getSerializedName()); + /** + * Write assertions for the given model and its example value. + * + * @param methodBlock the method block to write assertions to + * @param nodeVisitor node visitor for example values + * @param modelClientType client type of the model + * @param modelWireType wire type of the model + * @param modelValue example value of the model + * @param modelReference reference of the model that can be used to access the model in generated code + * @param rootModel whether the model is in the root of the response + */ + private void writeModelAssertion(JavaBlock methodBlock, ModelExampleWriter.ExampleNodeModelInitializationVisitor nodeVisitor, + IType modelClientType, IType modelWireType, Object modelValue, String modelReference, boolean rootModel) { + if (modelValue != null) { + modelClientType.addImportsTo(this.imports, false); + if (modelWireType != null) { + modelWireType.addImportsTo(this.imports, false); + } + if (isClientModel(modelClientType, modelValue)) { + methodBlock.line("Assertions.assertNotNull(%s);", modelReference); + // Client Model + ClassType modelClassType = (ClassType) modelClientType; + ClientModel clientModel = ClientModelUtil.getClientModel(modelClassType.getName()); + if (clientModel.getProperties() != null) { + for (ClientModelProperty property : clientModel.getProperties()) { + String serializedName = property.getSerializedName(); + Object propertyValue = ((Map) modelValue).get(serializedName); + if (propertyValue != null) { + if (rootModel) { + methodBlock.line("// verify property \"%s\"", property.getName()); + } + String propertyGetter = String.format("%s.%s()", modelReference, property.getGetterName()); + if (isClientModel(property.getClientType(), propertyValue) || isList(property.getClientType(), propertyValue)) { + String propertyReference = String.format("%s%s", modelReference, CodeNamer.toPascalCase(property.getName())); + methodBlock.line("%s %s = %s;", property.getClientType(), propertyReference, propertyGetter); + writeModelAssertion(methodBlock, nodeVisitor, property.getClientType(), property.getWireType(), propertyValue, propertyReference, false); + } else { + writeModelAssertion(methodBlock, nodeVisitor, property.getClientType(), property.getWireType(), propertyValue, propertyGetter, false); + } } - return ModelExampleUtil.parseNode(type, wireType, methodParameterValue); + } + } + } else if (isList(modelClientType, modelValue)) { + // List + List values = (List) modelValue; + if (values.size() > 0) { + ListType listType = (ListType) modelClientType; + IType elementType = listType.getElementType(); + Object firstItemValue = values.iterator().next(); + if (firstItemValue != null) { + String firstItemGetter = String.format("%s.iterator().next()", modelReference); + if (isClientModel(elementType, firstItemValue) || isList(elementType, firstItemValue)) { + String firstItemReference = String.format("%s%s", modelReference, "FirstItem"); + methodBlock.line("%s %s = %s;", elementType, firstItemReference, firstItemGetter); + writeModelAssertion(methodBlock, nodeVisitor, elementType, elementType, values.iterator().next(), firstItemReference, rootModel); + } else { + writeModelAssertion(methodBlock, nodeVisitor, elementType, elementType, values.iterator().next(), firstItemGetter, rootModel); + } + } } else { - return ModelExampleUtil.parseNodeFromParameter(proxyMethodExample, methodParameter); + methodBlock.line("Assertions.assertEquals(0, %s);", String.format("%s.size()", modelReference)); } + } else if (modelClientType instanceof PrimitiveType || modelClientType instanceof EnumType + || ClassType.STRING.equals(modelClientType) || ClassType.URL.equals(modelClientType) + || (modelClientType instanceof ClassType && ((ClassType) modelClientType).isBoxedType())) { + // simple models that can be compared by "Assertions.assertEquals()" + methodBlock.line(String.format( + "Assertions.assertEquals(%s, %s);", + nodeVisitor.accept(ModelExampleUtil.parseNode(modelClientType, modelWireType, modelValue)), + modelReference + )); + } else { + methodBlock.line("Assertions.assertNotNull(%s);", modelReference); + } } + } - @SuppressWarnings("unchecked") - private Map getFlattenedBodyParameterExampleValue(ProxyMethodExample example, ClientMethodParameter clientMethodParameter) { - String clientMethodParameterName = clientMethodParameter.getName(); - Function getParameterValue = (parameterSerializedName) -> example.getParameters().entrySet() - .stream().filter( - p -> CodeNamer.getEscapedReservedClientMethodParameterName(p.getKey()) - .equalsIgnoreCase(parameterSerializedName)) - .map(Map.Entry::getValue) - .findFirst() - .orElse(null); - ProxyMethodExample.ParameterValue parameterValue = getParameterValue.apply(clientMethodParameterName); + private boolean isList(IType modelClientType, Object modelValue) { + return modelClientType instanceof ListType && modelValue instanceof List; + } - if (parameterValue == null && clientMethodParameter.getRequestParameterLocation() == RequestParameterLocation.BODY && !"body".equalsIgnoreCase(clientMethodParameterName)) { - // fallback, "body" is commonly used in example JSON for request body - clientMethodParameterName = "body"; - parameterValue = getParameterValue.apply(clientMethodParameterName); + private boolean isClientModel(IType modelClientType, Object modelValue) { + return modelClientType instanceof ClassType + && ClientModelUtil.isClientModel(modelClientType) + && modelValue instanceof Map; + } + + /** + * Parse example node from given parameter, taking into account parameter grouping. + * + * @param convenienceMethod the convenience method to generate example for + * @param proxyMethodExample the proxy method example + * @param methodParameter mapped convenience method parameter to protocol(proxy) method parameter + * @return example node + */ + private ExampleNode parseNodeFromParameter(ClientMethod convenienceMethod, ProxyMethodExample proxyMethodExample, MethodParameter methodParameter) { + ExampleNode node; + if (isGroupingParameter(convenienceMethod, methodParameter)) { + // grouping, possible with flattening first + + // group example values into a map + Map exampleValue = new HashMap<>(); + for (MethodTransformationDetail detail : convenienceMethod.getMethodTransformationDetails()) { + for (ParameterMapping parameterMapping : detail.getParameterMappings()) { + if (parameterMapping.getOutputParameterPropertyName() != null) { + // this is a flattened property, so put flattening(real parameter) value + + // output parameter's name is the "escaped reserved client method parameter name" of the real parameter's serialized name + // since flattened parameter is always in body, we can deal with that explicitly + ClientMethodParameter outputParameter = detail.getOutParameter(); + Map flattenedParameterValue = getFlattenedBodyParameterExampleValue(proxyMethodExample, outputParameter); + if (flattenedParameterValue != null) { + exampleValue.putAll(flattenedParameterValue); + } + // since it's flattened property, all parameterMappings share the same outputParameter(real parameter) + // we only need to put example value once, which is the flattened(real) parameter's value + break; + } else { + // Group property's "serializedName" is the real parameter's "serializedName" on the wire. + // This implicit equivalence is defined in emitter and preserved in mapping client method. + String serializedParameterName = parameterMapping.getInputParameterProperty().getSerializedName(); + ClientMethodParameter parameter = detail.getOutParameter(); + exampleValue.put(serializedParameterName, + ModelExampleUtil.getParameterExampleValue( + proxyMethodExample, serializedParameterName, parameter.getRequestParameterLocation())); + } } + } + IType type = methodParameter.getClientMethodParameter().getClientType(); + IType wireType = methodParameter.getClientMethodParameter().getWireType(); + node = ModelExampleUtil.parseNode(type, wireType, exampleValue); + } else if (isFlattenParameter(convenienceMethod, methodParameter)) { + // flatten, no grouping + ClientMethodParameter outputParameter = convenienceMethod.getMethodTransformationDetails().iterator().next().getOutParameter(); + Map realParameterValue = getFlattenedBodyParameterExampleValue(proxyMethodExample, outputParameter); - return parameterValue == null ? null : (Map) parameterValue.getObjectValue(); + IType type = methodParameter.getClientMethodParameter().getClientType(); + IType wireType = methodParameter.getClientMethodParameter().getWireType(); + + ParameterMapping parameterMapping = convenienceMethod.getMethodTransformationDetails().iterator().next() + .getParameterMappings() + .stream() + .filter(mapping -> Objects.equals(mapping.getInputParameter().getName(), methodParameter.getClientMethodParameter().getName())) + .findFirst().orElse(null); + + Object methodParameterValue = null; + if (realParameterValue != null && parameterMapping != null) { + methodParameterValue = realParameterValue.get(parameterMapping.getOutputParameterProperty().getSerializedName()); + } + node = ModelExampleUtil.parseNode(type, wireType, methodParameterValue); + } else { + node = ModelExampleUtil.parseNodeFromParameter(proxyMethodExample, methodParameter); + } + return node; + } + + @SuppressWarnings("unchecked") + private Map getFlattenedBodyParameterExampleValue(ProxyMethodExample example, ClientMethodParameter clientMethodParameter) { + String clientMethodParameterName = clientMethodParameter.getName(); + Function getParameterValue = (parameterSerializedName) -> example.getParameters().entrySet() + .stream().filter( + p -> CodeNamer.getEscapedReservedClientMethodParameterName(p.getKey()) + .equalsIgnoreCase(parameterSerializedName)) + .map(Map.Entry::getValue) + .findFirst() + .orElse(null); + ProxyMethodExample.ParameterValue parameterValue = getParameterValue.apply(clientMethodParameterName); + + if (parameterValue == null && clientMethodParameter.getRequestParameterLocation() == RequestParameterLocation.BODY && !"body".equalsIgnoreCase(clientMethodParameterName)) { + // fallback, "body" is commonly used in example JSON for request body + clientMethodParameterName = "body"; + parameterValue = getParameterValue.apply(clientMethodParameterName); } - private boolean isGroupingParameter(ClientMethod convenienceMethod, MethodParameter methodParameter) { - List details = convenienceMethod.getMethodTransformationDetails(); - if (CoreUtils.isNullOrEmpty(details) || details.size() <= 1) { - return false; - } + return parameterValue == null ? null : (Map) parameterValue.getObjectValue(); + } - return details.stream().allMatch( - detail -> - !CoreUtils.isNullOrEmpty(detail.getParameterMappings()) - && detail.getOutParameter() != null - && - // same name - detail.getParameterMappings() - .stream() - .allMatch(mapping -> Objects.equals( - mapping.getInputParameter().getName(), - methodParameter.getClientMethodParameter().getName())) - ); + private boolean isGroupingParameter(ClientMethod convenienceMethod, MethodParameter methodParameter) { + List details = convenienceMethod.getMethodTransformationDetails(); + if (CoreUtils.isNullOrEmpty(details) || details.size() <= 1) { + return false; } - private boolean isFlattenParameter(ClientMethod convenienceMethod, MethodParameter methodParameter) { - List details = convenienceMethod.getMethodTransformationDetails(); - if (CoreUtils.isNullOrEmpty(details) || details.size() != 1) { - return false; - } - return details.stream().anyMatch( - detail -> - !CoreUtils.isNullOrEmpty(detail.getParameterMappings()) - && detail.getOutParameter() != null - && detail.getParameterMappings().stream() - .allMatch(mapping -> mapping.getOutputParameterPropertyName() != null - && mapping.getInputParameterProperty() == null) - && detail.getParameterMappings() - .stream() - .anyMatch(mapping -> Objects.equals(methodParameter.getClientMethodParameter().getName(), mapping.getInputParameter().getName())) - ); - } + return details.stream().allMatch( + detail -> + !CoreUtils.isNullOrEmpty(detail.getParameterMappings()) + && detail.getOutParameter() != null + && + // same name + detail.getParameterMappings() + .stream() + .allMatch(mapping -> Objects.equals( + mapping.getInputParameter().getName(), + methodParameter.getClientMethodParameter().getName())) + ); + } - public Set getImports() { - return new HashSet<>(this.imports); + private boolean isFlattenParameter(ClientMethod convenienceMethod, MethodParameter methodParameter) { + List details = convenienceMethod.getMethodTransformationDetails(); + if (CoreUtils.isNullOrEmpty(details) || details.size() != 1) { + return false; } + return details.stream().anyMatch( + detail -> + !CoreUtils.isNullOrEmpty(detail.getParameterMappings()) + && detail.getOutParameter() != null + && detail.getParameterMappings().stream() + .allMatch(mapping -> mapping.getOutputParameterPropertyName() != null + && mapping.getInputParameterProperty() == null) + && detail.getParameterMappings() + .stream() + .anyMatch(mapping -> Objects.equals(methodParameter.getClientMethodParameter().getName(), mapping.getInputParameter().getName())) + ); + } - public void writeClientMethodInvocation(JavaBlock javaBlock, boolean isTestCode) { - methodBodyWriter.accept(javaBlock, isTestCode); - } + public Set getImports() { + return new HashSet<>(this.imports); + } - public Set getHelperFeatures() { - return new HashSet<>(nodeVisitor.getHelperFeatures()); - } + public void writeClientMethodInvocation(JavaBlock javaBlock, boolean isTestCode) { + methodBodyWriter.accept(javaBlock, isTestCode); + } - public void writeAssertion(JavaBlock methodBlock) { - responseAssertionWriter.accept(methodBlock); - } + public Set getHelperFeatures() { + return new HashSet<>(nodeVisitor.getHelperFeatures()); + } + + public void writeAssertion(JavaBlock methodBlock) { + responseAssertionWriter.accept(methodBlock); + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/example/ModelExampleWriter.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/example/ModelExampleWriter.java index 238f3f4c9..0fb7eefeb 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/example/ModelExampleWriter.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/example/ModelExampleWriter.java @@ -46,284 +46,303 @@ import java.util.stream.Stream; public class ModelExampleWriter { - private static final Logger LOGGER = new PluginLogger(Javagen.getPluginInstance(), ModelExampleWriter.class); + private static final Logger LOGGER = new PluginLogger(Javagen.getPluginInstance(), ModelExampleWriter.class); + + private final Set imports = new HashSet<>(); + + private final Consumer assertionWriter; + private final ExampleNodeModelInitializationVisitor modelInitializationVisitor = + new ExampleNodeModelInitializationVisitor(); + private final String modelInitializationCode; + + public ModelExampleWriter(ExampleNode exampleNode, String modelVariableName) { + this.imports.add("org.junit.jupiter.api.Assertions"); + + ExampleNodeAssertionVisitor assertionVisitor = new ExampleNodeAssertionVisitor(); + assertionVisitor.accept(exampleNode, modelVariableName); + imports.addAll(assertionVisitor.imports); + + this.assertionWriter = methodBlock -> { + assertionVisitor.assertions.forEach(methodBlock::line); + }; + + modelInitializationCode = modelInitializationVisitor.accept(exampleNode); + imports.addAll(modelInitializationVisitor.getImports()); + } + + public Set getImports() { + return imports; + } + + public Set getHelperFeatures() { + return modelInitializationVisitor.getHelperFeatures(); + } + + public void writeAssertion(JavaBlock methodBlock) { + assertionWriter.accept(methodBlock); + } + + public String getModelInitializationCode() { + return modelInitializationCode; + } + + public static void writeMapOfMethod(JavaClass classBlock) { + classBlock.lineComment("Use \"Map.of\" if available"); + classBlock.annotation("SuppressWarnings(\"unchecked\")"); + classBlock.method(JavaVisibility.Private, Collections.singletonList(JavaModifier.Static), " Map mapOf(Object... inputs)", methodBlock -> { + methodBlock.line("Map map = new HashMap<>();"); + methodBlock.line("for (int i = 0; i < inputs.length; i += 2) {"); + methodBlock.indent(() -> { + methodBlock.line("String key = (String) inputs[i];"); + methodBlock.line("T value = (T) inputs[i + 1];"); + methodBlock.line("map.put(key, value);"); + }); + methodBlock.line("}"); + methodBlock.line("return map;"); + }); + } + + public static class ExampleNodeAssertionVisitor { private final Set imports = new HashSet<>(); - private final Consumer assertionWriter; - private final ExampleNodeModelInitializationVisitor modelInitializationVisitor = - new ExampleNodeModelInitializationVisitor(); - private final String modelInitializationCode; + private final List assertions = new ArrayList<>(); - public ModelExampleWriter(ExampleNode exampleNode, String modelVariableName) { - this.imports.add("org.junit.jupiter.api.Assertions"); + private void addEqualsAssertion(String expected, String code) { + assertions.add(String.format("Assertions.assertEquals(%1$s, %2$s);", expected, code)); + } - ExampleNodeAssertionVisitor assertionVisitor = new ExampleNodeAssertionVisitor(); - assertionVisitor.accept(exampleNode, modelVariableName); - imports.addAll(assertionVisitor.imports); + public void accept(ExampleNode node, String getterCode) { + if (node instanceof LiteralNode) { + node.getClientType().addImportsTo(imports, false); - this.assertionWriter = methodBlock -> { - assertionVisitor.assertions.forEach(methodBlock::line); - }; + addEqualsAssertion( + node.getClientType().defaultValueExpression(((LiteralNode) node).getLiteralsValue()), + getterCode); + } else if (node instanceof ObjectNode) { + // additionalProperties + } else if (node instanceof ListNode) { + if (!node.getChildNodes().isEmpty()) { + node = node.getChildNodes().get(0); + getterCode += ".get(0)"; + accept(node, getterCode); + } + } else if (node instanceof MapNode) { + if (!node.getChildNodes().isEmpty()) { + String key = ((MapNode) node).getKeys().get(0); + node = node.getChildNodes().get(0); + getterCode += String.format(".get(%s)", ClassType.STRING.defaultValueExpression(key)); + accept(node, getterCode); + } + } else if (node instanceof ClientModelNode) { + ClientModelNode clientModelNode = ((ClientModelNode) node); - modelInitializationCode = modelInitializationVisitor.accept(exampleNode); - imports.addAll(modelInitializationVisitor.getImports()); + ClientModel model = clientModelNode.getClientModel(); + + imports.add(model.getFullName()); + + for (ExampleNode childNode : node.getChildNodes()) { + ModelProperty modelProperty = clientModelNode.getClientModelProperties().get(childNode); + String childGetterCode = getterCode + String.format(".%s()", modelProperty.getGetterName()); + accept(childNode, childGetterCode); + } + } } public Set getImports() { - return imports; + return imports; + } + + public List getAssertions() { + return assertions; + } + } + + public static class ExampleNodeModelInitializationVisitor { + + protected final Set imports = new HashSet<>(); + protected final Set helperFeatures = new HashSet<>(); + + /** + * Extension to write code for deserialize JSON String to Object. + * @param jsonStr the JSON String. + */ + protected String codeDeserializeJsonString(String jsonStr) { + imports.add(com.azure.core.util.serializer.JacksonAdapter.class.getName()); + imports.add(com.azure.core.util.serializer.SerializerEncoding.class.getName()); + + return String.format("JacksonAdapter.createDefaultSerializerAdapter().deserialize(%s, Object.class, SerializerEncoding.JSON)", + ClassType.STRING.defaultValueExpression(jsonStr)); + } + + public Set getImports() { + if (helperFeatures.contains(ExampleHelperFeature.ThrowsIOException)) { + imports.add(java.io.IOException.class.getName()); + } + return imports; } public Set getHelperFeatures() { - return modelInitializationVisitor.getHelperFeatures(); + return helperFeatures; } - public void writeAssertion(JavaBlock methodBlock) { - assertionWriter.accept(methodBlock); - } - - public String getModelInitializationCode() { - return modelInitializationCode; - } - - public static void writeMapOfMethod(JavaClass classBlock) { - classBlock.lineComment("Use \"Map.of\" if available"); - classBlock.annotation("SuppressWarnings(\"unchecked\")"); - classBlock.method(JavaVisibility.Private, Collections.singletonList(JavaModifier.Static), " Map mapOf(Object... inputs)", methodBlock -> { - methodBlock.line("Map map = new HashMap<>();"); - methodBlock.line("for (int i = 0; i < inputs.length; i += 2) {"); - methodBlock.indent(() -> { - methodBlock.line("String key = (String) inputs[i];"); - methodBlock.line("T value = (T) inputs[i + 1];"); - methodBlock.line("map.put(key, value);"); - }); - methodBlock.line("}"); - methodBlock.line("return map;"); - }); - } - - public static class ExampleNodeAssertionVisitor { - - private final Set imports = new HashSet<>(); - - private final List assertions = new ArrayList<>(); - - private void addEqualsAssertion(String expected, String code) { - assertions.add(String.format("Assertions.assertEquals(%1$s, %2$s);", expected, code)); + public String accept(ExampleNode node) { + if (node instanceof LiteralNode) { + if (node.getClientType() != ClassType.CONTEXT) { + node.getClientType().addImportsTo(imports, false); } - public void accept(ExampleNode node, String getterCode) { - if (node instanceof LiteralNode) { - node.getClientType().addImportsTo(imports, false); + if (node.getClientType() == ClassType.URL) { + helperFeatures.add(ExampleHelperFeature.ThrowsIOException); // MalformedURLException from URL ctor + } - addEqualsAssertion( - node.getClientType().defaultValueExpression(((LiteralNode) node).getLiteralsValue()), - getterCode); - } else if (node instanceof ObjectNode) { - // additionalProperties - } else if (node instanceof ListNode) { - if (!node.getChildNodes().isEmpty()) { - node = node.getChildNodes().get(0); - getterCode += ".get(0)"; - accept(node, getterCode); - } - } else if (node instanceof MapNode) { - if (!node.getChildNodes().isEmpty()) { - String key = ((MapNode) node).getKeys().get(0); - node = node.getChildNodes().get(0); - getterCode += String.format(".get(%s)", ClassType.STRING.defaultValueExpression(key)); - accept(node, getterCode); - } - } else if (node instanceof ClientModelNode) { - ClientModelNode clientModelNode = ((ClientModelNode) node); + String literalValue = ((LiteralNode) node).getLiteralsValue(); + if (literalValue == null) { + if (node.getClientType() instanceof PrimitiveType) { + return node.getClientType().defaultValueExpression(); + } else { + return "null"; + } + } - ClientModel model = clientModelNode.getClientModel(); + return node.getClientType().defaultValueExpression(literalValue); + } else if (node instanceof ObjectNode) { + IType simpleType = null; + if (node.getObjectValue() instanceof Integer) { + simpleType = PrimitiveType.INT; + } else if (node.getObjectValue() instanceof Long) { + simpleType = PrimitiveType.LONG; + } else if (node.getObjectValue() instanceof Float) { + simpleType = PrimitiveType.FLOAT; + } else if (node.getObjectValue() instanceof Double) { + simpleType = PrimitiveType.DOUBLE; + } else if (node.getObjectValue() instanceof Boolean) { + simpleType = PrimitiveType.BOOLEAN; + } else if (node.getObjectValue() instanceof String) { + simpleType = ClassType.STRING; + } - imports.add(model.getFullName()); + if (simpleType != null) { + return simpleType.defaultValueExpression(node.getObjectValue().toString()); + } else { + helperFeatures.add(ExampleHelperFeature.ThrowsIOException); - for (ExampleNode childNode : node.getChildNodes()) { - ModelProperty modelProperty = clientModelNode.getClientModelProperties().get(childNode); - String childGetterCode = getterCode + String.format(".%s()", modelProperty.getGetterName()); - accept(childNode, childGetterCode); - } + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + JsonWriter jsonWriter = JsonProviders.createWriter(outputStream)) { + jsonWriter.writeUntyped(node.getObjectValue()).flush(); + + return codeDeserializeJsonString(outputStream.toString(StandardCharsets.UTF_8)); + } catch (IOException e) { + LOGGER.error("Failed to write JSON {}", node.getObjectValue()); + throw new IllegalStateException(e); + } + } + } else if (node instanceof ListNode) { + imports.add(java.util.Arrays.class.getName()); + + StringBuilder builder = new StringBuilder(); + // Arrays.asList(...) + builder.append("Arrays.asList(") + .append(node.getChildNodes().stream().map(this::accept).collect(Collectors.joining(", "))) + .append(")"); + + return builder.toString(); + } else if (node instanceof MapNode) { + imports.add(java.util.Map.class.getName()); + imports.add(java.util.HashMap.class.getName()); + + helperFeatures.add(ExampleHelperFeature.MapOfMethod); + + List keys = ((MapNode) node).getKeys(); + + StringBuilder builder = new StringBuilder(); + // mapOf(...) + // similar to Map.of in Java 9 + builder.append("mapOf("); + for (int i = 0; i < keys.size(); ++i) { + if (i != 0) { + builder.append(", "); + } + String key = keys.get(i); + ExampleNode elementNode = node.getChildNodes().get(i); + builder.append(ClassType.STRING.defaultValueExpression(key)) + .append(", ") + .append(this.accept(elementNode)); + } + builder.append(")"); + + return builder.toString(); + } else if (node instanceof ClientModelNode) { + ClientModelNode clientModelNode = ((ClientModelNode) node); + + ClientModel model = clientModelNode.getClientModel(); + + imports.add(model.getFullName()); + + StringBuilder builder = new StringBuilder(); + if (JavaSettings.getInstance().isRequiredFieldsAsConstructorArgs()) { + List requiredParentProperties = ClientModelUtil.getRequiredWritableParentProperties(model); + List requiredProperties = model.getProperties().stream() + .filter(ClientModelProperty::isRequired) + .filter(property -> !property.isConstant() && !property.isReadOnly()) + .collect(Collectors.toList()); + + List properties = Stream.concat( + requiredParentProperties.stream(), requiredProperties.stream()) + .map(ModelProperty::ofClientModelProperty) + .collect(Collectors.toList()); + Map ctorPosition = new HashMap<>(); + for (int i = 0; i < properties.size(); ++i) { + ctorPosition.put(properties.get(i), i); + } + + List initAtCtors = new ArrayList<>(Collections.nCopies(properties.size(), null)); + List initAtSetters = new ArrayList<>(); + for (ExampleNode childNode : node.getChildNodes()) { + ModelProperty modelProperty = clientModelNode.getClientModelProperties().get(childNode); + if (ctorPosition.containsKey(modelProperty)) { + initAtCtors.set(ctorPosition.get(modelProperty), this.accept(childNode)); + } else { + // .setProperty(...) + initAtSetters.add(String.format(".%1$s(%2$s)", modelProperty.getSetterName(), this.accept(childNode))); } - } - - public Set getImports() { - return imports; - } - - public List getAssertions() { - return assertions; - } - } - - public static class ExampleNodeModelInitializationVisitor { - - protected final Set imports = new HashSet<>(); - protected final Set helperFeatures = new HashSet<>(); - - /** - * Extension to write code for deserialize JSON String to Object. - * @param jsonStr the JSON String. - */ - protected String codeDeserializeJsonString(String jsonStr) { - imports.add(com.azure.core.util.serializer.JacksonAdapter.class.getName()); - imports.add(com.azure.core.util.serializer.SerializerEncoding.class.getName()); - - return String.format("JacksonAdapter.createDefaultSerializerAdapter().deserialize(%s, Object.class, SerializerEncoding.JSON)", - ClassType.STRING.defaultValueExpression(jsonStr)); - } - - public Set getImports() { - if (helperFeatures.contains(ExampleHelperFeature.ThrowsIOException)) { - imports.add(java.io.IOException.class.getName()); + } + for (int i = 0; i < properties.size(); ++i) { + String ctorParameterValue = initAtCtors.get(i); + if (ctorParameterValue == null) { // not present, due to missing required property + if (properties.get(i).getClientType() instanceof PrimitiveType) { + initAtCtors.set(i, properties.get(i).getClientType().defaultValueExpression()); + } else { + initAtCtors.set(i, "null"); + } } - return imports; - } - - public Set getHelperFeatures() { - return helperFeatures; - } - - public String accept(ExampleNode node) { - if (node instanceof LiteralNode) { - if (node.getClientType() != ClassType.CONTEXT) { - node.getClientType().addImportsTo(imports, false); - } - - if (node.getClientType() == ClassType.URL) { - helperFeatures.add(ExampleHelperFeature.ThrowsIOException); // MalformedURLException from URL ctor - } - - return node.getClientType().defaultValueExpression(((LiteralNode) node).getLiteralsValue()); - } else if (node instanceof ObjectNode) { - IType simpleType = null; - if (node.getObjectValue() instanceof Integer) { - simpleType = PrimitiveType.INT; - } else if (node.getObjectValue() instanceof Long) { - simpleType = PrimitiveType.LONG; - } else if (node.getObjectValue() instanceof Float) { - simpleType = PrimitiveType.FLOAT; - } else if (node.getObjectValue() instanceof Double) { - simpleType = PrimitiveType.DOUBLE; - } else if (node.getObjectValue() instanceof Boolean) { - simpleType = PrimitiveType.BOOLEAN; - } else if (node.getObjectValue() instanceof String) { - simpleType = ClassType.STRING; - } - - if (simpleType != null) { - return simpleType.defaultValueExpression(node.getObjectValue().toString()); - } else { - helperFeatures.add(ExampleHelperFeature.ThrowsIOException); - - try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - JsonWriter jsonWriter = JsonProviders.createWriter(outputStream)) { - jsonWriter.writeUntyped(node.getObjectValue()).flush(); - - return codeDeserializeJsonString(outputStream.toString(StandardCharsets.UTF_8)); - } catch (IOException e) { - LOGGER.error("Failed to write JSON {}", node.getObjectValue()); - throw new IllegalStateException(e); - } - } - } else if (node instanceof ListNode) { - imports.add(java.util.Arrays.class.getName()); - - StringBuilder builder = new StringBuilder(); - // Arrays.asList(...) - builder.append("Arrays.asList(") - .append(node.getChildNodes().stream().map(this::accept).collect(Collectors.joining(", "))) - .append(")"); - - return builder.toString(); - } else if (node instanceof MapNode) { - imports.add(java.util.Map.class.getName()); - imports.add(java.util.HashMap.class.getName()); - - helperFeatures.add(ExampleHelperFeature.MapOfMethod); - - List keys = ((MapNode) node).getKeys(); - - StringBuilder builder = new StringBuilder(); - // mapOf(...) - // similar to Map.of in Java 9 - builder.append("mapOf("); - for (int i = 0; i < keys.size(); ++i) { - if (i != 0) { - builder.append(", "); - } - String key = keys.get(i); - ExampleNode elementNode = node.getChildNodes().get(i); - builder.append(ClassType.STRING.defaultValueExpression(key)) - .append(", ") - .append(this.accept(elementNode)); - } - builder.append(")"); - - return builder.toString(); - } else if (node instanceof ClientModelNode) { - ClientModelNode clientModelNode = ((ClientModelNode) node); - - ClientModel model = clientModelNode.getClientModel(); - - imports.add(model.getFullName()); - - StringBuilder builder = new StringBuilder(); - if (JavaSettings.getInstance().isRequiredFieldsAsConstructorArgs()) { - List requiredParentProperties = ClientModelUtil.getRequiredWritableParentProperties(model); - List requiredProperties = model.getProperties().stream() - .filter(ClientModelProperty::isRequired) - .filter(property -> !property.isConstant() && !property.isReadOnly()) - .collect(Collectors.toList()); - - List properties = Stream.concat( - requiredParentProperties.stream(), requiredProperties.stream()) - .map(ModelProperty::ofClientModelProperty) - .collect(Collectors.toList()); - Map ctorPosition = new HashMap<>(); - for (int i = 0; i < properties.size(); ++i) { - ctorPosition.put(properties.get(i), i); - } - - List initAtCtors = new ArrayList<>(Collections.nCopies(properties.size(), "")); - List initAtSetters = new ArrayList<>(); - for (ExampleNode childNode : node.getChildNodes()) { - ModelProperty modelProperty = clientModelNode.getClientModelProperties().get(childNode); - if (ctorPosition.containsKey(modelProperty)) { - initAtCtors.set(ctorPosition.get(modelProperty), this.accept(childNode)); - } else { - // .setProperty(...) - initAtSetters.add(String.format(".%1$s(%2$s)", modelProperty.getSetterName(), this.accept(childNode))); - } - } - // model constructor - builder.append("new ").append(model.getName()) - .append("(").append(String.join(", ", initAtCtors)).append(")"); - // setters - initAtSetters.forEach(builder::append); - } else { - // model with setters - builder.append("new ").append(model.getName()).append("()"); - for (ExampleNode childNode : node.getChildNodes()) { - ModelProperty modelProperty = clientModelNode.getClientModelProperties().get(childNode); - // .setProperty(...) - builder.append(".").append(modelProperty.getSetterName()) - .append("(").append(this.accept(childNode)).append(")"); - } - } - return builder.toString(); - } else if (node instanceof BinaryDataNode) { - this.imports.add(com.azure.core.util.BinaryData.class.getName()); - this.imports.add(java.nio.charset.StandardCharsets.class.getName()); - return binaryDataNodeExpression((BinaryDataNode) node); - } - return null; + } + // model constructor + builder.append("new ").append(model.getName()) + .append("(").append(String.join(", ", initAtCtors)).append(")"); + // setters + initAtSetters.forEach(builder::append); + } else { + // model with setters + builder.append("new ").append(model.getName()).append("()"); + for (ExampleNode childNode : node.getChildNodes()) { + ModelProperty modelProperty = clientModelNode.getClientModelProperties().get(childNode); + // .setProperty(...) + builder.append(".").append(modelProperty.getSetterName()) + .append("(").append(this.accept(childNode)).append(")"); + } } + return builder.toString(); + } else if (node instanceof BinaryDataNode) { + this.imports.add(com.azure.core.util.BinaryData.class.getName()); + this.imports.add(java.nio.charset.StandardCharsets.class.getName()); + return binaryDataNodeExpression((BinaryDataNode) node); + } + return null; } + } - private static String binaryDataNodeExpression(BinaryDataNode binaryDataNode) { - return String.format("BinaryData.fromBytes(\"%s\".getBytes(StandardCharsets.UTF_8))", TemplateUtil.escapeString(binaryDataNode.getExampleValue())); - } + private static String binaryDataNodeExpression(BinaryDataNode binaryDataNode) { + return String.format("BinaryData.fromBytes(\"%s\".getBytes(StandardCharsets.UTF_8))", TemplateUtil.escapeString(binaryDataNode.getExampleValue())); + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/ClientModelUtil.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/ClientModelUtil.java index 37f884d91..f39a76d7d 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/ClientModelUtil.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/ClientModelUtil.java @@ -52,720 +52,791 @@ import java.util.stream.Stream; */ public class ClientModelUtil { - public static final String MULTI_PART_FORM_DATA_HELPER_CLASS_NAME = "MultipartFormDataHelper"; - public static final String GENERIC_MULTI_PART_FORM_DATA_HELPER_CLASS_NAME = "GenericMultipartFormDataHelper"; + public static final String MULTI_PART_FORM_DATA_HELPER_CLASS_NAME = "MultipartFormDataHelper"; + public static final String GENERIC_MULTI_PART_FORM_DATA_HELPER_CLASS_NAME = "GenericMultipartFormDataHelper"; - private static final Pattern SPLIT_FLATTEN_PROPERTY_PATTERN = Pattern.compile("((? asyncClients, List syncClients) { + String packageName = getAsyncSyncClientPackageName(serviceClient); + boolean generateAsyncMethods = JavaSettings.getInstance().isGenerateAsyncMethods(); + boolean generateSyncMethods = JavaSettings.getInstance().isGenerateSyncMethods(); + + if (serviceClient.getProxy() != null) { + AsyncSyncClient.Builder builder = new AsyncSyncClient.Builder() + .packageName(packageName) + .serviceClient(serviceClient) + .crossLanguageDefinitionId(client.getCrossLanguageDefinitionId()); + + final List convenienceMethods = client.getOperationGroups().stream() + .filter(og -> CoreUtils.isNullOrEmpty(og.getLanguage().getJava().getName())) // no resource group + .findAny() + .map(og -> getConvenienceMethods(serviceClient::getClientMethods, og)) + .orElse(Collections.emptyList()); + builder.convenienceMethods(convenienceMethods); + + if (generateAsyncMethods) { + String asyncClassName = clientNameToAsyncClientName(serviceClient.getClientBaseName()); + asyncClients.add(builder.className(asyncClassName).build()); + } + + if (generateSyncMethods) { + String syncClassName = + serviceClient.getClientBaseName().endsWith("Client") + ? serviceClient.getClientBaseName() + : serviceClient.getClientBaseName() + "Client"; + syncClients.add(builder.className(syncClassName).build()); + } } - /** - * Prepare async/sync clients for service client. - * - * @param serviceClient the service client. - * @param asyncClients output, the async clients. - * @param syncClients output, the sync client. - */ - public static void getAsyncSyncClients(Client client, ServiceClient serviceClient, - List asyncClients, List syncClients) { - String packageName = getAsyncSyncClientPackageName(serviceClient); - boolean generateAsyncMethods = JavaSettings.getInstance().isGenerateAsyncMethods(); - boolean generateSyncMethods = JavaSettings.getInstance().isGenerateSyncMethods(); + final int count = serviceClient.getMethodGroupClients().size() + asyncClients.size(); + for (MethodGroupClient methodGroupClient : serviceClient.getMethodGroupClients()) { + AsyncSyncClient.Builder builder = new AsyncSyncClient.Builder() + .packageName(packageName) + .serviceClient(serviceClient) + .methodGroupClient(methodGroupClient); - if (serviceClient.getProxy() != null) { - AsyncSyncClient.Builder builder = new AsyncSyncClient.Builder() - .packageName(packageName) - .serviceClient(serviceClient) - .crossLanguageDefinitionId(client.getCrossLanguageDefinitionId()); + final List convenienceMethods = client.getOperationGroups().stream() + .filter(og -> methodGroupClient.getClassBaseName().equals(og.getLanguage().getJava().getName())) + .findAny() + .map(og -> getConvenienceMethods(methodGroupClient::getClientMethods, og)) + .orElse(Collections.emptyList()); + builder.convenienceMethods(convenienceMethods); - final List convenienceMethods = client.getOperationGroups().stream() - .filter(og -> CoreUtils.isNullOrEmpty(og.getLanguage().getJava().getName())) // no resource group - .findAny() - .map(og -> getConvenienceMethods(serviceClient::getClientMethods, og)) - .orElse(Collections.emptyList()); - builder.convenienceMethods(convenienceMethods); + if (count == 1) { + // if it is the only method group, use service client name as base. - if (generateAsyncMethods) { - String asyncClassName = clientNameToAsyncClientName(serviceClient.getClientBaseName()); - asyncClients.add(builder.className(asyncClassName).build()); - } - - if (generateSyncMethods) { - String syncClassName = - serviceClient.getClientBaseName().endsWith("Client") - ? serviceClient.getClientBaseName() - : serviceClient.getClientBaseName() + "Client"; - syncClients.add(builder.className(syncClassName).build()); - } + if (generateAsyncMethods) { + String asyncClassName = clientNameToAsyncClientName(serviceClient.getClientBaseName()); + asyncClients.add(builder.className(asyncClassName).build()); } - final int count = serviceClient.getMethodGroupClients().size() + asyncClients.size(); - for (MethodGroupClient methodGroupClient : serviceClient.getMethodGroupClients()) { - AsyncSyncClient.Builder builder = new AsyncSyncClient.Builder() - .packageName(packageName) - .serviceClient(serviceClient) - .methodGroupClient(methodGroupClient); - - final List convenienceMethods = client.getOperationGroups().stream() - .filter(og -> methodGroupClient.getClassBaseName().equals(og.getLanguage().getJava().getName())) - .findAny() - .map(og -> getConvenienceMethods(methodGroupClient::getClientMethods, og)) - .orElse(Collections.emptyList()); - builder.convenienceMethods(convenienceMethods); - - if (count == 1) { - // if it is the only method group, use service client name as base. - - if (generateAsyncMethods) { - String asyncClassName = clientNameToAsyncClientName(serviceClient.getClientBaseName()); - asyncClients.add(builder.className(asyncClassName).build()); - } - - if (generateSyncMethods) { - String syncClassName = - serviceClient.getClientBaseName().endsWith("Client") - ? serviceClient.getClientBaseName() - : serviceClient.getClientBaseName() + "Client"; - syncClients.add(builder.className(syncClassName).build()); - } - } else { - if (generateAsyncMethods) { - String asyncClassName = clientNameToAsyncClientName(methodGroupClient.getClassBaseName()); - asyncClients.add(builder.className(asyncClassName).build()); - } - - if (generateSyncMethods) { - String syncClassName = - methodGroupClient.getClassBaseName().endsWith("Client") - ? methodGroupClient.getClassBaseName() - : methodGroupClient.getClassBaseName() + "Client"; - syncClients.add(builder.className(syncClassName).build()); - } - } + if (generateSyncMethods) { + String syncClassName = + serviceClient.getClientBaseName().endsWith("Client") + ? serviceClient.getClientBaseName() + : serviceClient.getClientBaseName() + "Client"; + syncClients.add(builder.className(syncClassName).build()); } - } - - private static List getConvenienceMethods(Supplier> clientMethods, OperationGroup og) { - return og.getOperations().stream() - .filter(o -> o.getConvenienceApi() != null) - .flatMap(o -> { - List cMethods = Mappers.getClientMethodMapper().map(o, false) - .stream() - .filter(m -> m.getMethodVisibility() == JavaVisibility.Public) - .collect(Collectors.toList()); - if (!cMethods.isEmpty()) { - // sync stack generates additional proxy methods with name suffix "Sync" - String proxyMethodBaseName = cMethods.iterator().next().getProxyMethod().getBaseName(); - return clientMethods.get().stream() - .filter(m -> - proxyMethodBaseName.equals(m.getProxyMethod().getBaseName()) - && m.getMethodVisibility() == JavaVisibility.Public) - .map(m -> new ConvenienceMethod(m, cMethods)); - } else { - return Stream.empty(); - } - }).collect(Collectors.toList()); - } - - /** - * @param codeModel the code model - * @return the interface name of service client. - */ - public static String getClientInterfaceName(Client codeModel) { - JavaSettings settings = JavaSettings.getInstance(); - String serviceClientInterfaceName = (settings.getClientTypePrefix() == null ? "" : settings.getClientTypePrefix()) - + codeModel.getLanguage().getJava().getName(); - if (settings.isDataPlaneClient()) { - // mandate ending Client for LLC - if (!serviceClientInterfaceName.endsWith("Client")) { - String serviceName = settings.getServiceName(); - if (serviceName != null && codeModel instanceof CodeModel) { - serviceName = CodeNamer.removeSpaceCharacters(serviceName); - serviceClientInterfaceName = serviceName.endsWith("Client") ? serviceName : (serviceName + "Client"); - } else { - serviceClientInterfaceName += "Client"; - } - } + } else { + if (generateAsyncMethods) { + String asyncClassName = clientNameToAsyncClientName(methodGroupClient.getClassBaseName()); + asyncClients.add(builder.className(asyncClassName).build()); } - return serviceClientInterfaceName; - } - /** - * @param codeModel the code model - * @return the class name of service client implementation. - */ - public static String getClientImplementClassName(Client codeModel) { - String serviceClientInterfaceName = getClientInterfaceName(codeModel); - return getClientImplementClassName(serviceClientInterfaceName); - } - - /** - * @param serviceClientInterfaceName the interface name of service client - * @return the class name of service client implementation. - */ - public static String getClientImplementClassName(String serviceClientInterfaceName) { - JavaSettings settings = JavaSettings.getInstance(); - String serviceClientClassName = serviceClientInterfaceName; - if (settings.isGenerateClientAsImpl()) { - serviceClientClassName += "Impl"; + if (generateSyncMethods) { + String syncClassName = + methodGroupClient.getClassBaseName().endsWith("Client") + ? methodGroupClient.getClassBaseName() + : methodGroupClient.getClassBaseName() + "Client"; + syncClients.add(builder.className(syncClassName).build()); } - return serviceClientClassName; + } } + } - /** - * @param serviceClientInterfaceName the interface name of service client - * @return the class name of service version. - */ - public static String getServiceVersionClassName(String serviceClientInterfaceName) { - JavaSettings settings = JavaSettings.getInstance(); - String serviceName; - if (settings.getServiceName() == null) { - if (serviceClientInterfaceName.endsWith("Client")) { - // remove ending Client - serviceName = serviceClientInterfaceName.substring(0, serviceClientInterfaceName.length() - "Client".length()); - } else { - serviceName = serviceClientInterfaceName; - } + private static List getConvenienceMethods(Supplier> clientMethods, OperationGroup og) { + return og.getOperations().stream() + .filter(o -> o.getConvenienceApi() != null) + .flatMap(o -> { + List cMethods = Mappers.getClientMethodMapper().map(o, false) + .stream() + .filter(m -> m.getMethodVisibility() == JavaVisibility.Public) + .collect(Collectors.toList()); + if (!cMethods.isEmpty()) { + // sync stack generates additional proxy methods with name suffix "Sync" + String proxyMethodBaseName = cMethods.iterator().next().getProxyMethod().getBaseName(); + return clientMethods.get().stream() + .filter(m -> + proxyMethodBaseName.equals(m.getProxyMethod().getBaseName()) + && m.getMethodVisibility() == JavaVisibility.Public) + .map(m -> new ConvenienceMethod(m, cMethods)); } else { - serviceName = CodeNamer.removeSpaceCharacters(settings.getServiceName()); + return Stream.empty(); } - return serviceName + (serviceName.endsWith("Service") ? "Version" : "ServiceVersion"); - } + }).collect(Collectors.toList()); + } - /** - * Gets the suffix of the builder class. - *

- * The class name of the Builder is usually the service client interface name + builder suffix. - * - * @return the suffix of the builder class. - */ - public static String getBuilderSuffix() { - JavaSettings settings = JavaSettings.getInstance(); - StringBuilder builderSuffix = new StringBuilder(); - if (!settings.isFluent() - && settings.isGenerateClientAsImpl() - && !settings.isGenerateSyncAsyncClients() - && !settings.isDataPlaneClient()) { - builderSuffix.append("Impl"); - } - builderSuffix.append("Builder"); - return builderSuffix.toString(); - } - - public static String getServiceClientBuilderPackageName(ServiceClient serviceClient) { - JavaSettings settings = JavaSettings.getInstance(); - String builderPackage = serviceClient.getPackage(); - if (settings.isFluent()) { - builderPackage = settings.getPackage(settings.getImplementationSubpackage()); - } else if (settings.isGenerateSyncAsyncClients() || settings.isDataPlaneClient()) { - if (serviceClient.getBuilderPackageName() != null) { - builderPackage = serviceClient.getBuilderPackageName(); - } else { - builderPackage = settings.getPackage(); - } - } - return builderPackage; - } - - public static String getServiceClientPackageName(String serviceClientClassName) { - JavaSettings settings = JavaSettings.getInstance(); - String subpackage = settings.isGenerateClientAsImpl() ? settings.getImplementationSubpackage() : null; - if (settings.isFluent()) { - if (settings.isGenerateSyncAsyncClients() || settings.isGenerateClientInterfaces()) { - subpackage = settings.getImplementationSubpackage(); - } else { - subpackage = settings.getFluentSubpackage(); - } - } - if (settings.isCustomType(serviceClientClassName)) { - subpackage = settings.getCustomTypesSubpackage(); - } - return settings.getPackage(subpackage); - } - - public static String getAsyncSyncClientPackageName(ServiceClient serviceClient) { - JavaSettings settings = JavaSettings.getInstance(); - if (settings.isFluent()) { - return settings.getPackage(settings.getFluentSubpackage()); + /** + * @param codeModel the code model + * @return the interface name of service client. + */ + public static String getClientInterfaceName(Client codeModel) { + JavaSettings settings = JavaSettings.getInstance(); + String serviceClientInterfaceName = (settings.getClientTypePrefix() == null ? "" : settings.getClientTypePrefix()) + + codeModel.getLanguage().getJava().getName(); + if (settings.isDataPlaneClient()) { + // mandate ending Client for LLC + if (!serviceClientInterfaceName.endsWith("Client")) { + String serviceName = settings.getServiceName(); + if (serviceName != null && codeModel instanceof CodeModel) { + serviceName = CodeNamer.removeSpaceCharacters(serviceName); + serviceClientInterfaceName = serviceName.endsWith("Client") ? serviceName : (serviceName + "Client"); } else { - return getServiceClientBuilderPackageName(serviceClient); + serviceClientInterfaceName += "Client"; } + } } + return serviceClientInterfaceName; + } - public static String getServiceClientInterfacePackageName() { - JavaSettings settings = JavaSettings.getInstance(); - if (settings.isFluent()) { - return settings.getPackage(settings.getFluentSubpackage()); - } else { - return settings.getPackage(); + /** + * @param codeModel the code model + * @return the class name of service client implementation. + */ + public static String getClientImplementClassName(Client codeModel) { + String serviceClientInterfaceName = getClientInterfaceName(codeModel); + return getClientImplementClassName(serviceClientInterfaceName); + } + + /** + * @param serviceClientInterfaceName the interface name of service client + * @return the class name of service client implementation. + */ + public static String getClientImplementClassName(String serviceClientInterfaceName) { + JavaSettings settings = JavaSettings.getInstance(); + String serviceClientClassName = serviceClientInterfaceName; + if (settings.isGenerateClientAsImpl()) { + serviceClientClassName += "Impl"; + } + return serviceClientClassName; + } + + /** + * @param serviceClientInterfaceName the interface name of service client + * @return the class name of service version. + */ + public static String getServiceVersionClassName(String serviceClientInterfaceName) { + JavaSettings settings = JavaSettings.getInstance(); + String serviceName; + if (settings.getServiceName() == null) { + if (serviceClientInterfaceName.endsWith("Client")) { + // remove ending Client + serviceName = serviceClientInterfaceName.substring(0, serviceClientInterfaceName.length() - "Client".length()); + } else { + serviceName = serviceClientInterfaceName; + } + } else { + serviceName = CodeNamer.removeSpaceCharacters(settings.getServiceName()); + } + return serviceName + (serviceName.endsWith("Service") ? "Version" : "ServiceVersion"); + } + + /** + * Gets the suffix of the builder class. + *

+ * The class name of the Builder is usually the service client interface name + builder suffix. + * + * @return the suffix of the builder class. + */ + public static String getBuilderSuffix() { + JavaSettings settings = JavaSettings.getInstance(); + StringBuilder builderSuffix = new StringBuilder(); + if (!settings.isFluent() + && settings.isGenerateClientAsImpl() + && !settings.isGenerateSyncAsyncClients() + && !settings.isDataPlaneClient()) { + builderSuffix.append("Impl"); + } + builderSuffix.append("Builder"); + return builderSuffix.toString(); + } + + public static String getServiceClientBuilderPackageName(ServiceClient serviceClient) { + JavaSettings settings = JavaSettings.getInstance(); + String builderPackage = serviceClient.getPackage(); + if (settings.isFluent()) { + builderPackage = settings.getPackage(settings.getImplementationSubpackage()); + } else if (settings.isGenerateSyncAsyncClients() || settings.isDataPlaneClient()) { + if (serviceClient.getBuilderPackageName() != null) { + builderPackage = serviceClient.getBuilderPackageName(); + } else { + builderPackage = settings.getPackage(); + } + } + return builderPackage; + } + + public static String getServiceClientPackageName(String serviceClientClassName) { + JavaSettings settings = JavaSettings.getInstance(); + String subpackage = settings.isGenerateClientAsImpl() ? settings.getImplementationSubpackage() : null; + if (settings.isFluent()) { + if (settings.isGenerateSyncAsyncClients() || settings.isGenerateClientInterfaces()) { + subpackage = settings.getImplementationSubpackage(); + } else { + subpackage = settings.getFluentSubpackage(); + } + } + if (settings.isCustomType(serviceClientClassName)) { + subpackage = settings.getCustomTypesSubpackage(); + } + return settings.getPackage(subpackage); + } + + public static String getAsyncSyncClientPackageName(ServiceClient serviceClient) { + JavaSettings settings = JavaSettings.getInstance(); + if (settings.isFluent()) { + return settings.getPackage(settings.getFluentSubpackage()); + } else { + return getServiceClientBuilderPackageName(serviceClient); + } + } + + public static String getServiceClientInterfacePackageName() { + JavaSettings settings = JavaSettings.getInstance(); + if (settings.isFluent()) { + return settings.getPackage(settings.getFluentSubpackage()); + } else { + return settings.getPackage(); + } + } + + public static String getClientDefaultValueOrConstantValue(Parameter parameter) { + String clientDefaultValueOrConstantValue = parameter.getClientDefaultValue(); + if (clientDefaultValueOrConstantValue == null) { + if (parameter.getSchema() != null && parameter.getSchema() instanceof ConstantSchema) { + ConstantSchema constantSchema = (ConstantSchema) parameter.getSchema(); + if (constantSchema.getValue() != null) { + clientDefaultValueOrConstantValue = constantSchema.getValue().getValue().toString(); } + } + } + return clientDefaultValueOrConstantValue; + } + + private static String getFirstApiVersionFromOperation(CodeModel codeModel) { + return codeModel.getOperationGroups().stream() + .flatMap(og -> og.getOperations().stream()) + .filter(o -> o.getApiVersions() != null) + .flatMap(o -> o.getApiVersions().stream()) + .filter(Objects::nonNull) + .map(ApiVersion::getVersion) + .filter(Objects::nonNull) + .findFirst() + .orElse(null); + } + + public static List getApiVersions(CodeModel codeModel) { + List versions = codeModel.getClients().stream() + .filter(c -> !CoreUtils.isNullOrEmpty(c.getApiVersions())) + .map(c -> c.getApiVersions().stream().map(ApiVersion::getVersion).collect(Collectors.toList())) + .findFirst().orElse(null); + if (versions == null) { + String version = getFirstApiVersionFromOperation(codeModel); + if (version != null) { + versions = Collections.singletonList(version); + } else { + versions = Collections.emptyList(); + } + } + return versions; + } + + public static String getArtifactId() { + JavaSettings settings = JavaSettings.getInstance(); + String artifactId = settings.getArtifactId(); + if (settings.isDataPlaneClient() && CoreUtils.isNullOrEmpty(artifactId)) { + // convert package/namespace to artifact + artifactId = settings.getPackage().toLowerCase(Locale.ROOT) + .replace("com.", "") + .replace(".", "-"); + } + return artifactId; + } + + public static String clientNameToAsyncClientName(String clientName) { + if (clientName.endsWith("Client")) { + clientName = clientName.substring(0, clientName.length() - "Client".length()) + "AsyncClient"; + } else { + clientName += "AsyncClient"; + } + return clientName; + } + + /** + * Split and unescape the possible flattened serialized property name to its components. + * + * @param serializedName the serialized property name belongs to either model or property that has {@code @JsonFlatten} annotation. + * @return the components of the serialized property names + */ + public static List splitFlattenedSerializedName(String serializedName) { + if (serializedName == null) { + return Collections.emptyList(); } - public static String getClientDefaultValueOrConstantValue(Parameter parameter) { - String clientDefaultValueOrConstantValue = parameter.getClientDefaultValue(); - if (clientDefaultValueOrConstantValue == null) { - if (parameter.getSchema() != null && parameter.getSchema() instanceof ConstantSchema) { - ConstantSchema constantSchema = (ConstantSchema) parameter.getSchema(); - if (constantSchema.getValue() != null) { - clientDefaultValueOrConstantValue = constantSchema.getValue().getValue().toString(); - } - } + String[] values = SPLIT_FLATTEN_PROPERTY_PATTERN.split(serializedName); + for (int i = 0; i < values.length; ++i) { + values[i] = values[i].replace("\\\\.", "."); + } + return Arrays.asList(values); + } + + private static Function getClientModelFunction = name -> ClientModels.getInstance().getModel(name); + + /** + * Replace the default function of getting ClientModel by name. + *

+ * Used in Fluent for providing additional ClientModel that exists in azure-core-management, + * e.g. Resource, ManagementError + * + * @param function the function of getting ClientModel by name + */ + public static void setGetClientModelFunction(Function function) { + getClientModelFunction = function; + } + + /** + * Get ClientModel by name. + * + * @param name the name of the ClientModel (without package) + * @return the ClientModel instance. null if not found. + */ + public static ClientModel getClientModel(String name) { + return getClientModelFunction.apply(name); + } + + /** + * Check if the type is a ClientModel. + * + * @param type the type + * @return whether the type is a ClientModel. + */ + public static boolean isClientModel(IType type) { + if (type instanceof ClassType) { + ClassType classType = (ClassType) type; + return classType.getPackage().startsWith(JavaSettings.getInstance().getPackage()) + && getClientModel(classType.getName()) != null; + } else { + return false; + } + } + + /** + * Check if the type is an external model. + * + * @param type the type + * @return whether the type is an external model. + */ + public static boolean isExternalModel(IType type) { + if (type instanceof ClassType) { + ClassType classType = (ClassType) type; + ClientModel model = getClientModel(classType.getName()); + return model != null && model.getImplementationDetails() != null && model.getImplementationDetails().getUsages() != null + && model.getImplementationDetails().getUsages().contains(ImplementationDetails.Usage.EXTERNAL); + } else { + return false; + } + } + + /** + * Check if the type is an output only model. + *

+ * A model is considered output only if and only if the model's usages contain either + * {@link ImplementationDetails#isOutput()} or {@link ImplementationDetails#isException()} and do not contain + * {@link ImplementationDetails#isInput()}. + * + * @param model the client model. + * @return whether the type is an output only model. + */ + public static boolean isOutputOnly(ClientModel model) { + if (hasNoUsage(model)) { + return false; + } + ImplementationDetails details = model.getImplementationDetails(); + + return (details.isOutput() || details.isException()) && !details.isInput(); + } + + /** + * Check if the model is used in json-merge-patch operation + */ + public static boolean isJsonMergePatchModel(ClientModel model, JavaSettings settings) { + // JSON merge patch is only supported for stream style serialization. + return settings.isStreamStyleSerialization() + && model.getImplementationDetails() != null && model.getImplementationDetails().getUsages() != null + && model.getImplementationDetails().getUsages().contains(ImplementationDetails.Usage.JSON_MERGE_PATCH); + } + + /** + * Gets all parent properties. + * + * @param model The client model. + * @return Returns all properties that are defined by super types of the client model. + */ + public static List getParentProperties(ClientModel model) { + return getParentProperties(model, true); + } + + /** + * Gets all parent properties. + * + * @param model The client model. + * @param parentPropertiesFirst whether parent properties are in the front of the return list + * @return Returns all properties that are defined by super types of the client model. + */ + public static List getParentProperties(ClientModel model, boolean parentPropertiesFirst) { + String lastParentName = model.getName(); + ClientModel parentModel = getClientModel(model.getParentModelName()); + List parentProperties = new ArrayList<>(); + while (parentModel != null && !lastParentName.equals(parentModel.getName())) { + // Add the properties in inverse order as they be reverse at the end. + List parentProps = new ArrayList<>(parentModel.getProperties()); + for (int i = parentProps.size() - 1; i >= 0; i--) { + parentProperties.add(parentProps.get(i)); + } + + lastParentName = parentModel.getName(); + parentModel = getClientModel(parentModel.getParentModelName()); + } + if (parentPropertiesFirst) { + Collections.reverse(parentProperties); + } + return parentProperties; + } + + public static List getRequiredWritableParentProperties(ClientModel model) { + String lastParentName = model.getName(); + ClientModel parentModel = getClientModel(model.getParentModelName()); + List requiredParentProperties = new ArrayList<>(); + while (parentModel != null && !lastParentName.equals(parentModel.getName())) { + // Add the properties in inverse order as they be reverse at the end. + List ctorArgs = parentModel.getProperties().stream() + .filter(property -> property.isRequired() && !property.isConstant() && !property.isReadOnly()) + .collect(Collectors.toList()); + + for (int i = ctorArgs.size() - 1; i >= 0; i--) { + requiredParentProperties.add(ctorArgs.get(i)); + } + + lastParentName = parentModel.getName(); + parentModel = getClientModel(parentModel.getParentModelName()); + } + Collections.reverse(requiredParentProperties); + return requiredParentProperties; + } + + /** + * Gets all the properties that parent models define that are part of the constructor. + *

+ * This uses {@link ClientModelUtil#includePropertyInConstructor(ClientModelProperty, JavaSettings)} to determine + * which properties should be included in the constructor. + * + * @param model The client model. + * @param settings Autorest generation settings. + * @return All properties that are defined by super types of the client model that should be included in the + * constructor. + */ + public static List getParentConstructorProperties(ClientModel model, JavaSettings settings) { + String lastParentName = model.getName(); + ClientModel parentModel = getClientModel(model.getParentModelName()); + Set constructorProperties = new LinkedHashSet<>(); + while (parentModel != null && !lastParentName.equals(parentModel.getName())) { + // Add the properties in inverse order as they be reverse at the end. + List parentProperties = parentModel.getProperties(); + for (int i = parentProperties.size() - 1; i >= 0; i--) { + ClientModelProperty property = parentProperties.get(i); + if (includePropertyInConstructor(property, settings)) { + constructorProperties.add(property); } - return clientDefaultValueOrConstantValue; + } + + lastParentName = parentModel.getName(); + parentModel = getClientModel(parentModel.getParentModelName()); } - private static String getFirstApiVersionFromOperation(CodeModel codeModel) { - return codeModel.getOperationGroups().stream() - .flatMap(og -> og.getOperations().stream()) - .filter(o -> o.getApiVersions() != null) - .flatMap(o -> o.getApiVersions().stream()) - .filter(Objects::nonNull) - .map(ApiVersion::getVersion) - .filter(Objects::nonNull) - .findFirst() - .orElse(null); - } + List propertyList = new ArrayList<>(constructorProperties); + Collections.reverse(propertyList); + return propertyList; + } - public static List getApiVersions(CodeModel codeModel) { - List versions = codeModel.getClients().stream() - .filter(c -> !CoreUtils.isNullOrEmpty(c.getApiVersions())) - .map(c -> c.getApiVersions().stream().map(ApiVersion::getVersion).collect(Collectors.toList())) - .findFirst().orElse(null); - if (versions == null) { - String version = getFirstApiVersionFromOperation(codeModel); - if (version != null) { - versions = Collections.singletonList(version); - } else { - versions = Collections.emptyList(); - } - } - return versions; - } + /** + * Whether the property needs public setter. + * + * @param property The client model property, or a reference. + * @param settings Autorest generation settings. + * @return whether the property will have a setter method. + */ + public static boolean needsPublicSetter(ClientModelPropertyAccess property, JavaSettings settings) { + return !isReadOnlyOrInConstructor(property, settings) && !isFlattenedProperty(property); + } - public static String getArtifactId() { - JavaSettings settings = JavaSettings.getInstance(); - String artifactId = settings.getArtifactId(); - if (settings.isDataPlaneClient() && CoreUtils.isNullOrEmpty(artifactId)) { - // convert package/namespace to artifact - artifactId = settings.getPackage().toLowerCase(Locale.ROOT) - .replace("com.", "") - .replace(".", "-"); - } - return artifactId; - } + private static boolean isReadOnlyOrInConstructor(ClientModelPropertyAccess property, JavaSettings settings) { + return property.isReadOnly() || (settings.isRequiredFieldsAsConstructorArgs() && property.isRequired()); + } - public static String clientNameToAsyncClientName(String clientName) { - if (clientName.endsWith("Client")) { - clientName = clientName.substring(0, clientName.length() - "Client".length()) + "AsyncClient"; - } else { - clientName += "AsyncClient"; - } - return clientName; - } + private static boolean isFlattenedProperty(ClientModelPropertyAccess property) { + return (property instanceof ClientModelProperty) && ((ClientModelProperty) property).getClientFlatten(); + } - /** - * Split and unescape the possible flattened serialized property name to its components. - * - * @param serializedName the serialized property name belongs to either model or property that has {@code @JsonFlatten} annotation. - * @return the components of the serialized property names - */ - public static List splitFlattenedSerializedName(String serializedName) { - if (serializedName == null) { - return Collections.emptyList(); - } + /** + * Determines whether the {@link ClientModelProperty} should be included in the model's constructor. + *

+ * The {@code property} is included in the constructor if it is {@link ClientModelProperty#isRequired()}, + * {@link JavaSettings#isRequiredFieldsAsConstructorArgs()} is true, and either the property is not + * {@link ClientModelProperty#isReadOnly()}, is {@link ClientModelProperty#isPolymorphicDiscriminator()}, or + * {@link JavaSettings#isIncludeReadOnlyInConstructorArgs()} is true. + * + * @param property The {@link ClientModelProperty} + * @param settings The Autorest generation settings. + * @return Whether the {@code property} should be included in the model's constructor. + */ + public static boolean includePropertyInConstructor(ClientModelProperty property, JavaSettings settings) { + // First, the property must be required and the setting to include required fields as constructor args must be + // enabled. + boolean requiredAndIncluded = property.isRequired() && settings.isRequiredFieldsAsConstructorArgs(); - String[] values = SPLIT_FLATTEN_PROPERTY_PATTERN.split(serializedName); - for (int i = 0; i < values.length; ++i) { - values[i] = values[i].replace("\\\\.", "."); - } - return Arrays.asList(values); - } + // Then, one of the property not being read-only or the setting to include read-only properties in constructor + // args is enabled must be true. + boolean notReadOnlyOrIncludeReadOnly = !property.isReadOnly() || settings.isIncludeReadOnlyInConstructorArgs(); - private static Function getClientModelFunction = name -> ClientModels.getInstance().getModel(name); + // Polymorphic discriminators are a special case as they are their own concept within codegen but there can be + // cases where the same property is defined as the polymorphic discriminator and a property in the class. Only + // when the property defined in the class is required will the polymorphic discriminator be considered needed in + // the constructor. + boolean polymorphicDiscriminatorIsRequired = property.isPolymorphicDiscriminator() && property.isRequired(); - /** - * Replace the default function of getting ClientModel by name. - *

- * Used in Fluent for providing additional ClientModel that exists in azure-core-management, - * e.g. Resource, ManagementError - * - * @param function the function of getting ClientModel by name - */ - public static void setGetClientModelFunction(Function function) { - getClientModelFunction = function; - } + return requiredAndIncluded && (notReadOnlyOrIncludeReadOnly || polymorphicDiscriminatorIsRequired); + } - /** - * Get ClientModel by name. - * - * @param name the name of the ClientModel (without package) - * @return the ClientModel instance. null if not found. - */ - public static ClientModel getClientModel(String name) { - return getClientModelFunction.apply(name); - } - - /** - * Check if the type is a ClientModel. - * - * @param type the type - * @return whether the type is a ClientModel. - */ - public static boolean isClientModel(IType type) { - if (type instanceof ClassType) { - ClassType classType = (ClassType) type; - return classType.getPackage().startsWith(JavaSettings.getInstance().getPackage()) - && getClientModel(classType.getName()) != null; - } else { - return false; - } - } - - /** - * Check if the type is an external model. - * - * @param type the type - * @return whether the type is an external model. - */ - public static boolean isExternalModel(IType type) { - if (type instanceof ClassType) { - ClassType classType = (ClassType) type; - ClientModel model = getClientModel(classType.getName()); - return model != null && model.getImplementationDetails() != null && model.getImplementationDetails().getUsages() != null - && model.getImplementationDetails().getUsages().contains(ImplementationDetails.Usage.EXTERNAL); - } else { - return false; - } - } - - /** - * Check if the type is an output only model. - *

- * A model is considered output only if and only if the model's usages contain either - * {@link ImplementationDetails#isOutput()} or {@link ImplementationDetails#isException()} and do not contain - * {@link ImplementationDetails#isInput()}. - * - * @param model the client model. - * @return whether the type is an output only model. - */ - public static boolean isOutputOnly(ClientModel model) { - if (hasNoUsage(model)) { - return false; - } - ImplementationDetails details = model.getImplementationDetails(); - - return (details.isOutput() || details.isException()) && !details.isInput(); - } - - /** - * Check if the model is used in json-merge-patch operation - */ - public static boolean isJsonMergePatchModel(ClientModel model, JavaSettings settings) { - // JSON merge patch is only supported for stream style serialization. - return settings.isStreamStyleSerialization() - && model.getImplementationDetails() != null && model.getImplementationDetails().getUsages() != null - && model.getImplementationDetails().getUsages().contains(ImplementationDetails.Usage.JSON_MERGE_PATCH); - } - - /** - * Gets all parent properties. - * - * @param model The client model. - * @return Returns all properties that are defined by super types of the client model. - */ - public static List getParentProperties(ClientModel model) { - return getParentProperties(model, true); - } - - /** - * Gets all parent properties. - * - * @param model The client model. - * @param parentPropertiesFirst whether parent properties are in the front of the return list - * @return Returns all properties that are defined by super types of the client model. - */ - public static List getParentProperties(ClientModel model, boolean parentPropertiesFirst) { - String lastParentName = model.getName(); - ClientModel parentModel = getClientModel(model.getParentModelName()); - List parentProperties = new ArrayList<>(); - while (parentModel != null && !lastParentName.equals(parentModel.getName())) { - // Add the properties in inverse order as they be reverse at the end. - List parentProps = new ArrayList<>(parentModel.getProperties()); - for (int i = parentProps.size() - 1; i >= 0; i--) { - parentProperties.add(parentProps.get(i)); - } - - lastParentName = parentModel.getName(); - parentModel = getClientModel(parentModel.getParentModelName()); - } - if (parentPropertiesFirst) { - Collections.reverse(parentProperties); - } - return parentProperties; - } - - public static List getRequiredWritableParentProperties(ClientModel model) { - String lastParentName = model.getName(); - ClientModel parentModel = getClientModel(model.getParentModelName()); - List requiredParentProperties = new ArrayList<>(); - while (parentModel != null && !lastParentName.equals(parentModel.getName())) { - // Add the properties in inverse order as they be reverse at the end. - List ctorArgs = parentModel.getProperties().stream() - .filter(property -> property.isRequired() && !property.isConstant() && !property.isReadOnly()) - .collect(Collectors.toList()); - - for (int i = ctorArgs.size() - 1; i >= 0; i--) { - requiredParentProperties.add(ctorArgs.get(i)); - } - - lastParentName = parentModel.getName(); - parentModel = getClientModel(parentModel.getParentModelName()); - } - Collections.reverse(requiredParentProperties); - return requiredParentProperties; - } - - /** - * Gets all the properties that parent models define that are part of the constructor. - *

- * This uses {@link ClientModelUtil#includePropertyInConstructor(ClientModelProperty, JavaSettings)} to determine - * which properties should be included in the constructor. - * - * @param model The client model. - * @param settings Autorest generation settings. - * @return All properties that are defined by super types of the client model that should be included in the - * constructor. - */ - public static List getParentConstructorProperties(ClientModel model, JavaSettings settings) { - String lastParentName = model.getName(); - ClientModel parentModel = getClientModel(model.getParentModelName()); - Set constructorProperties = new LinkedHashSet<>(); - while (parentModel != null && !lastParentName.equals(parentModel.getName())) { - // Add the properties in inverse order as they be reverse at the end. - List parentProperties = parentModel.getProperties(); - for (int i = parentProperties.size() - 1; i >= 0; i--) { - ClientModelProperty property = parentProperties.get(i); - if (includePropertyInConstructor(property, settings)) { - constructorProperties.add(property); - } - } - - lastParentName = parentModel.getName(); - parentModel = getClientModel(parentModel.getParentModelName()); - } - - List propertyList = new ArrayList<>(constructorProperties); - Collections.reverse(propertyList); - return propertyList; - } - - /** - * Whether the property needs public setter. - * - * @param property The client model property, or a reference. - * @param settings Autorest generation settings. - * @return whether the property will have a setter method. - */ - public static boolean needsPublicSetter(ClientModelPropertyAccess property, JavaSettings settings) { - return !isReadOnlyOrInConstructor(property, settings) && !isFlattenedProperty(property); - } - - private static boolean isReadOnlyOrInConstructor(ClientModelPropertyAccess property, JavaSettings settings) { - return property.isReadOnly() || (settings.isRequiredFieldsAsConstructorArgs() && property.isRequired()); - } - - private static boolean isFlattenedProperty(ClientModelPropertyAccess property) { - return (property instanceof ClientModelProperty) && ((ClientModelProperty) property).getClientFlatten(); - } - - /** - * Determines whether the {@link ClientModelProperty} should be included in the model's constructor. - *

- * The {@code property} is included in the constructor if it is {@link ClientModelProperty#isRequired()}, - * {@link JavaSettings#isRequiredFieldsAsConstructorArgs()} is true, and either the property is not - * {@link ClientModelProperty#isReadOnly()}, is {@link ClientModelProperty#isPolymorphicDiscriminator()}, or - * {@link JavaSettings#isIncludeReadOnlyInConstructorArgs()} is true. - * - * @param property The {@link ClientModelProperty} - * @param settings The Autorest generation settings. - * @return Whether the {@code property} should be included in the model's constructor. - */ - public static boolean includePropertyInConstructor(ClientModelProperty property, JavaSettings settings) { - // First, the property must be required and the setting to include required fields as constructor args must be - // enabled. - boolean requiredAndIncluded = property.isRequired() && settings.isRequiredFieldsAsConstructorArgs(); - - // Then, one of the property not being read-only or the setting to include read-only properties in constructor - // args is enabled must be true. - boolean notReadOnlyOrIncludeReadOnly = !property.isReadOnly() || settings.isIncludeReadOnlyInConstructorArgs(); - - // Polymorphic discriminators are a special case as they are their own concept within codegen but there can be - // cases where the same property is defined as the polymorphic discriminator and a property in the class. Only - // when the property defined in the class is required will the polymorphic discriminator be considered needed in - // the constructor. - boolean polymorphicDiscriminatorIsRequired = property.isPolymorphicDiscriminator() && property.isRequired(); - - return requiredAndIncluded && (notReadOnlyOrIncludeReadOnly || polymorphicDiscriminatorIsRequired); - } - - /** - * Checks whether wire type and client type mismatch on this client model property. - * - * @param clientModelProperty the client model property. - * @param ignoreGenericType whether to ignore the mismatch, if both wire type and client type is generic type. - * For example, ignore the case of {@code List} vs {@code List}. - * @return whether wire type and client type mismatch. - */ - public static boolean isWireTypeMismatch(ClientModelProperty clientModelProperty, boolean ignoreGenericType) { - if (clientModelProperty.getClientType() == clientModelProperty.getWireType()) { - // same type - return false; - } else { - // type mismatch - if (ignoreGenericType - && clientModelProperty.getClientType() instanceof GenericType - && clientModelProperty.getWireType() instanceof GenericType) { - // at present, ignore generic type, as type erasure causes conflict of 2 constructors - return false; - } else { - return true; - } - } - } - - /** - * Gets a mapping of XML namespace to constant name for XML namespaces used in the model. - * - * @param model The model to get the XML namespaces from. - * @return A mapping of XML namespace to constant name. - */ - public static Map xmlNamespaceToConstantMapping(ClientModel model) { - Map xmlNamespaceConstantMap = new LinkedHashMap<>(); - ClientModel rootModel = getRootParent(model); - if (rootModel.getXmlNamespace() != null) { - xmlNamespaceConstantMap.put(rootModel.getXmlNamespace(), xmlNamespaceToConstant(rootModel.getXmlNamespace())); - } - - for (ClientModelProperty property : ClientModelUtil.getParentProperties(model)) { - if (property.getXmlNamespace() != null) { - xmlNamespaceConstantMap.put(property.getXmlNamespace(), - xmlNamespaceToConstant(property.getXmlNamespace())); - } - } - - for (ClientModelProperty property : model.getProperties()) { - if (property.getXmlNamespace() != null) { - xmlNamespaceConstantMap.put(property.getXmlNamespace(), - xmlNamespaceToConstant(property.getXmlNamespace())); - } - } - - return xmlNamespaceConstantMap; - } - - private static String xmlNamespaceToConstant(String xmlNamespace) { - URI uri = URI.create(xmlNamespace); - String host = CodeNamer.getEnumMemberName(uri.getHost()); - String path = uri.getPath(); - String[] segments = path.split("/"); - - // XML namespaces are URIs, use the host and the last two segments of the path as the constant. - if (segments.length >= 2) { - // More than two path segments, use HOST_SEGMENT[COUNT - 2]_SEGMENT[COUNT - 1] - return host + "_" + CodeNamer.getEnumMemberName(segments[segments.length - 2]) + "_" - + CodeNamer.getEnumMemberName(segments[segments.length - 1]); - } else if (segments.length == 1) { - // Only one path segment, use HOST_SEGMENT[0] - return host + "_" + CodeNamer.getEnumMemberName(segments[0]); - } else { - // No path segments, just use HOST - return host; - } - } - - /** - * Gets the root parent of the given model. - *

- * If the model isn't polymorphic or is the root parent the passed model will be returned. - * - * @param model The model to get the root parent of. - * @return The root parent of the given model, or the model itself if it's either not polymorphic or the root - * parent. - */ - public static ClientModel getRootParent(ClientModel model) { - if (!model.isPolymorphic()) { - return model; - } - - while (model.getParentModelName() != null) { - model = getClientModel(model.getParentModelName()); - } - - return model; - } - - public static Set getExternalPackageNamesUsedInClient(List models, CodeModel codeModel) { - // models - Set externalPackageNames = models == null ? new HashSet<>() : models.stream() - .filter(m -> m.getImplementationDetails() != null && m.getImplementationDetails().getUsages() != null - && m.getImplementationDetails().getUsages().contains(ImplementationDetails.Usage.EXTERNAL)) - .map(ClientModel::getPackage) - .collect(Collectors.toSet()); - - // LongRunningMetadata in methods - if (!CoreUtils.isNullOrEmpty(codeModel.getClients())) { - for (Client client : codeModel.getClients()) { - if (!CoreUtils.isNullOrEmpty(client.getOperationGroups())) { - for (OperationGroup og : client.getOperationGroups()) { - if (!CoreUtils.isNullOrEmpty(og.getOperations())) { - externalPackageNames.addAll(og.getOperations().stream() - .filter(o -> o.getLroMetadata() != null && o.getLroMetadata().getPollingStrategy() != null && o.getLroMetadata().getPollingStrategy().getLanguage() != null && o.getLroMetadata().getPollingStrategy().getLanguage().getJava() != null) - .map(o -> o.getLroMetadata().getPollingStrategy().getLanguage().getJava().getNamespace()) - .filter(Objects::nonNull) - .collect(Collectors.toSet())); - } - } - } - } - } - - return externalPackageNames; - } - - public static boolean requireOperationLocationPollingStrategy(CodeModel codeModel) { - if (!CoreUtils.isNullOrEmpty(codeModel.getClients())) { - for (Client client : codeModel.getClients()) { - if (!CoreUtils.isNullOrEmpty(client.getOperationGroups())) { - for (OperationGroup og : client.getOperationGroups()) { - if (!CoreUtils.isNullOrEmpty(og.getOperations())) { - for (Operation operation : og.getOperations()) { - if (operation.getLroMetadata() != null && operation.getLroMetadata().getPollingStrategy() != null) { - if (OPERATION_LOCATION_POLLING_STRATEGY.equals(operation.getLroMetadata().getPollingStrategy().getLanguage().getJava().getName())) { - return true; - } - } - } - } - } - } - } - } + /** + * Checks whether wire type and client type mismatch on this client model property. + * + * @param clientModelProperty the client model property. + * @param ignoreGenericType whether to ignore the mismatch, if both wire type and client type is generic type. + * For example, ignore the case of {@code List} vs {@code List}. + * @return whether wire type and client type mismatch. + */ + public static boolean isWireTypeMismatch(ClientModelProperty clientModelProperty, boolean ignoreGenericType) { + if (clientModelProperty.getClientType() == clientModelProperty.getWireType()) { + // same type + return false; + } else { + // type mismatch + if (ignoreGenericType + && clientModelProperty.getClientType() instanceof GenericType + && clientModelProperty.getWireType() instanceof GenericType) { + // at present, ignore generic type, as type erasure causes conflict of 2 constructors return false; + } else { + return true; + } + } + } + + /** + * Gets a mapping of XML namespace to constant name for XML namespaces used in the model. + * + * @param model The model to get the XML namespaces from. + * @return A mapping of XML namespace to constant name. + */ + public static Map xmlNamespaceToConstantMapping(ClientModel model) { + Map xmlNamespaceConstantMap = new LinkedHashMap<>(); + ClientModel rootModel = getRootParent(model); + if (rootModel.getXmlNamespace() != null) { + xmlNamespaceConstantMap.put(rootModel.getXmlNamespace(), xmlNamespaceToConstant(rootModel.getXmlNamespace())); } - public static boolean isMultipartModel(ClientModel model) { - return model.getSerializationFormats().contains(KnownMediaType.MULTIPART.value()); + for (ClientModelProperty property : ClientModelUtil.getParentProperties(model)) { + if (property.getXmlNamespace() != null) { + xmlNamespaceConstantMap.put(property.getXmlNamespace(), + xmlNamespaceToConstant(property.getXmlNamespace())); + } } - private static boolean hasNoUsage(ClientModel model) { - ImplementationDetails details = model.getImplementationDetails(); - return details == null || CoreUtils.isNullOrEmpty(details.getUsages()); + for (ClientModelProperty property : model.getProperties()) { + if (property.getXmlNamespace() != null) { + xmlNamespaceConstantMap.put(property.getXmlNamespace(), + xmlNamespaceToConstant(property.getXmlNamespace())); + } } + + return xmlNamespaceConstantMap; + } + + private static String xmlNamespaceToConstant(String xmlNamespace) { + URI uri = URI.create(xmlNamespace); + String host = CodeNamer.getEnumMemberName(uri.getHost()); + String path = uri.getPath(); + String[] segments = path.split("/"); + + // XML namespaces are URIs, use the host and the last two segments of the path as the constant. + if (segments.length >= 2) { + // More than two path segments, use HOST_SEGMENT[COUNT - 2]_SEGMENT[COUNT - 1] + return host + "_" + CodeNamer.getEnumMemberName(segments[segments.length - 2]) + "_" + + CodeNamer.getEnumMemberName(segments[segments.length - 1]); + } else if (segments.length == 1) { + // Only one path segment, use HOST_SEGMENT[0] + return host + "_" + CodeNamer.getEnumMemberName(segments[0]); + } else { + // No path segments, just use HOST + return host; + } + } + + /** + * Gets the root parent of the given model. + *

+ * If the model isn't polymorphic or is the root parent the passed model will be returned. + * + * @param model The model to get the root parent of. + * @return The root parent of the given model, or the model itself if it's either not polymorphic or the root + * parent. + */ + public static ClientModel getRootParent(ClientModel model) { + if (!model.isPolymorphic()) { + return model; + } + + while (model.getParentModelName() != null) { + model = getClientModel(model.getParentModelName()); + } + + return model; + } + + public static Set getExternalPackageNamesUsedInClient(List models, CodeModel codeModel) { + // models + Set externalPackageNames = models == null ? new HashSet<>() : models.stream() + .filter(m -> m.getImplementationDetails() != null && m.getImplementationDetails().getUsages() != null + && m.getImplementationDetails().getUsages().contains(ImplementationDetails.Usage.EXTERNAL)) + .map(ClientModel::getPackage) + .collect(Collectors.toSet()); + + // LongRunningMetadata in methods + if (!CoreUtils.isNullOrEmpty(codeModel.getClients())) { + for (Client client : codeModel.getClients()) { + if (!CoreUtils.isNullOrEmpty(client.getOperationGroups())) { + for (OperationGroup og : client.getOperationGroups()) { + if (!CoreUtils.isNullOrEmpty(og.getOperations())) { + externalPackageNames.addAll(og.getOperations().stream() + .filter(o -> o.getLroMetadata() != null && o.getLroMetadata().getPollingStrategy() != null && o.getLroMetadata().getPollingStrategy().getLanguage() != null && o.getLroMetadata().getPollingStrategy().getLanguage().getJava() != null) + .map(o -> o.getLroMetadata().getPollingStrategy().getLanguage().getJava().getNamespace()) + .filter(Objects::nonNull) + .collect(Collectors.toSet())); + } + } + } + } + } + + return externalPackageNames; + } + + public static boolean requireOperationLocationPollingStrategy(CodeModel codeModel) { + if (CoreUtils.isNullOrEmpty(codeModel.getClients())) { + return false; + } + + for (Client client : codeModel.getClients()) { + if (CoreUtils.isNullOrEmpty(client.getOperationGroups())) { + continue; + } + + for (OperationGroup og : client.getOperationGroups()) { + if (CoreUtils.isNullOrEmpty(og.getOperations())) { + continue; + } + + for (Operation operation : og.getOperations()) { + if (operation.getLroMetadata() != null && operation.getLroMetadata().getPollingStrategy() != null + && OPERATION_LOCATION_POLLING_STRATEGY.equals(operation.getLroMetadata().getPollingStrategy().getLanguage().getJava().getName())) { + return true; + } + } + } + } + + return false; + } + + /** + * Checks if the model defines the property. + * + * @param model The client model. + * @param property The client model property. + * @return Whether the model defines the property. + */ + public static boolean modelDefinesProperty(ClientModel model, ClientModelProperty property) { + // The model doesn't have a parent model, therefore it defines the property. + if (CoreUtils.isNullOrEmpty(model.getParentModelName())) { + return true; + } + + for (ClientModelProperty parentProperty : ClientModelUtil.getParentProperties(model)) { + if (Objects.equals(property.getSerializedName(), parentProperty.getSerializedName())) { + return false; + } + } + + return true; + } + + /** + * Gets the {@link ClientModel} that defines the given {@link ClientModelProperty}. + *

+ * This may return the passed {@link ClientModel} if the property is defined by the model. + * + * @param model The client model. + * @param property The client model property. + * @return The {@link ClientModel} that defines the given {@link ClientModelProperty}. + */ + public static ClientModel getDefiningModel(ClientModel model, ClientModelProperty property) { + ClientModel current = model; + while(current != null) { + if (ClientModelUtil.modelDefinesProperty(current, property)) { + return current; + } + current = ClientModelUtil.getClientModel(current.getParentModelName()); + } + throw new IllegalArgumentException("unable to find defining model for property: " + property); + } + + public static boolean readOnlyNotInCtor(ClientModel model, ClientModelProperty property, + JavaSettings settings) { + return // not required and in constructor + !(property.isRequired() && settings.isRequiredFieldsAsConstructorArgs()) + && ( + // must be read-only and not appear in constructor + (property.isReadOnly() && !settings.isIncludeReadOnlyInConstructorArgs()) + // immutable output model only has package-private setters, making its properties read-only + || isImmutableOutputModel(getDefiningModel(model, property), settings)); + } + + /** + * The model is immutable output if and only if the immutable output model setting is enabled and + * the usage of the model include output and does not include input. + * + * @param model the model to check + * @param settings JavaSettings instance + * @return whether the model is output-only immutable model + */ + public static boolean isImmutableOutputModel(ClientModel model, JavaSettings settings) { + return (settings.isOutputModelImmutable() && ClientModelUtil.isOutputOnly(model)); + } + + public static boolean isMultipartModel(ClientModel model) { + return model.getSerializationFormats().contains(KnownMediaType.MULTIPART.value()); + } + + private static boolean hasNoUsage(ClientModel model) { + ImplementationDetails details = model.getImplementationDetails(); + return details == null || CoreUtils.isNullOrEmpty(details.getUsages()); + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/ModelExampleUtil.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/ModelExampleUtil.java index e9c45ff82..c1e020615 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/ModelExampleUtil.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/ModelExampleUtil.java @@ -41,420 +41,420 @@ import java.util.stream.Collectors; public class ModelExampleUtil { - private static final Logger LOGGER = new PluginLogger(Javagen.getPluginInstance(), ModelExampleUtil.class); + private static final Logger LOGGER = new PluginLogger(Javagen.getPluginInstance(), ModelExampleUtil.class); - /** - * Parse the type (client model or others) with JSON object to tree of ExampleNode. - * - * @param type the client type, wire type is assumed to be same - * @param objectValue the JSON object - * @return the tree of ExampleNode - */ - public static ExampleNode parseNode(IType type, Object objectValue) { - return parseNode(type, type, objectValue); - } + /** + * Parse the type (client model or others) with JSON object to tree of ExampleNode. + * + * @param type the client type, wire type is assumed to be same + * @param objectValue the JSON object + * @return the tree of ExampleNode + */ + public static ExampleNode parseNode(IType type, Object objectValue) { + return parseNode(type, type, objectValue); + } - /** - * Parse the type (client model or others) with JSON object to tree of ExampleNode. - * - * @param type the client type - * @param wireType the wire type (the related but different type used in JSON, e.g. DateTimeRfc1123 for OffsetDateTime) - * @param objectValue the JSON object - * @return the tree of ExampleNode - */ - @SuppressWarnings("unchecked") - public static ExampleNode parseNode(IType type, IType wireType, Object objectValue) { - ExampleNode node; - if (type instanceof ListType) { - IType elementType = ((ListType) type).getElementType(); - if (objectValue instanceof List) { - ListNode listNode = new ListNode(elementType, objectValue); - node = listNode; + /** + * Parse the type (client model or others) with JSON object to tree of ExampleNode. + * + * @param type the client type + * @param wireType the wire type (the related but different type used in JSON, e.g. DateTimeRfc1123 for OffsetDateTime) + * @param objectValue the JSON object + * @return the tree of ExampleNode + */ + @SuppressWarnings("unchecked") + public static ExampleNode parseNode(IType type, IType wireType, Object objectValue) { + ExampleNode node; + if (type instanceof ListType) { + IType elementType = ((ListType) type).getElementType(); + if (objectValue instanceof List) { + ListNode listNode = new ListNode(elementType, objectValue); + node = listNode; - List elements = (List) objectValue; - for (Object childObjectValue : elements) { - ExampleNode childNode = parseNode(elementType, childObjectValue); - node.getChildNodes().add(childNode); - } + List elements = (List) objectValue; + for (Object childObjectValue : elements) { + ExampleNode childNode = parseNode(elementType, childObjectValue); + node.getChildNodes().add(childNode); + } + } else { + LOGGER.error("Example value is not List type: {}", objectValue); + node = new ListNode(elementType, null); + } + } else if (type instanceof MapType) { + IType elementType = ((MapType) type).getValueType(); + if (objectValue instanceof Map) { + MapNode mapNode = new MapNode(elementType, objectValue); + node = mapNode; + + Map dict = (Map) objectValue; + for (Map.Entry entry : dict.entrySet()) { + Object value = entry.getValue(); + + // redact possible credential + if (elementType == ClassType.STRING && entry.getValue() instanceof String) { + value = ModelTestCaseUtil.redactStringValue(Collections.singletonList(entry.getKey()), (String) value); + } + + ExampleNode childNode = parseNode(elementType, value); + node.getChildNodes().add(childNode); + mapNode.getKeys().add(entry.getKey()); + } + } else { + LOGGER.error("Example value is not Map type: {}", objectValue); + node = new MapNode(elementType, null); + } + } else if (type == ClassType.OBJECT) { + node = new ObjectNode(type, objectValue); + } else if (type == ClassType.BINARY_DATA && objectValue != null) { + node = new BinaryDataNode(type, objectValue); + } else if (type instanceof ClassType && objectValue instanceof Map) { + ClientModel model = ClientModelUtil.getClientModel(((ClassType) type).getName()); + if (model != null) { + if (model.isPolymorphic()) { + // polymorphic, need to get the correct subclass from discriminator + String serializedName = model.getPolymorphicDiscriminatorName(); + List jsonPropertyNames = Collections.singletonList(serializedName); + if (model.getNeedsFlatten()) { + jsonPropertyNames = ClientModelUtil.splitFlattenedSerializedName(serializedName); + } + + Object childObjectValue = getChildObjectValue(jsonPropertyNames, objectValue); + if (childObjectValue instanceof String) { + String discriminatorValue = (String) childObjectValue; + ClientModel derivedModel = getDerivedModel(model, discriminatorValue); + if (derivedModel != null) { + // use the subclass + type = derivedModel.getType(); + model = derivedModel; } else { - LOGGER.error("Example value is not List type: {}", objectValue); - node = new ListNode(elementType, null); + LOGGER.warn("Failed to find the subclass with discriminator value '{}'", discriminatorValue); } - } else if (type instanceof MapType) { - IType elementType = ((MapType) type).getValueType(); - if (objectValue instanceof Map) { - MapNode mapNode = new MapNode(elementType, objectValue); - node = mapNode; - - Map dict = (Map) objectValue; - for (Map.Entry entry : dict.entrySet()) { - Object value = entry.getValue(); - - // redact possible credential - if (elementType == ClassType.STRING && entry.getValue() instanceof String) { - value = ModelTestCaseUtil.redactStringValue(Collections.singletonList(entry.getKey()), (String) value); - } - - ExampleNode childNode = parseNode(elementType, value); - node.getChildNodes().add(childNode); - mapNode.getKeys().add(entry.getKey()); - } - } else { - LOGGER.error("Example value is not Map type: {}", objectValue); - node = new MapNode(elementType, null); - } - } else if (type == ClassType.OBJECT) { - node = new ObjectNode(type, objectValue); - } else if (type == ClassType.BINARY_DATA && objectValue != null) { - node = new BinaryDataNode(type, objectValue); - } else if (type instanceof ClassType && objectValue instanceof Map) { - ClientModel model = ClientModelUtil.getClientModel(((ClassType) type).getName()); - if (model != null) { - if (model.isPolymorphic()) { - // polymorphic, need to get the correct subclass from discriminator - String serializedName = model.getPolymorphicDiscriminatorName(); - List jsonPropertyNames = Collections.singletonList(serializedName); - if (model.getNeedsFlatten()) { - jsonPropertyNames = ClientModelUtil.splitFlattenedSerializedName(serializedName); - } - - Object childObjectValue = getChildObjectValue(jsonPropertyNames, objectValue); - if (childObjectValue instanceof String) { - String discriminatorValue = (String) childObjectValue; - ClientModel derivedModel = getDerivedModel(model, discriminatorValue); - if (derivedModel != null) { - // use the subclass - type = derivedModel.getType(); - model = derivedModel; - } else { - LOGGER.warn("Failed to find the subclass with discriminator value '{}'", discriminatorValue); - } - } else { - LOGGER.warn("Failed to find the sample value for discriminator property '{}'", serializedName); - } - } - - ClientModelNode clientModelNode = new ClientModelNode(type, objectValue).setClientModel(model); - node = clientModelNode; - - List modelProperties = getWritablePropertiesIncludeSuperclass(model); - for (ModelProperty modelProperty : modelProperties) { - List jsonPropertyNames = modelProperty.getSerializedNames(); - - Object childObjectValue = getChildObjectValue(jsonPropertyNames, objectValue); - if (childObjectValue != null) { - ExampleNode childNode = parseNode(modelProperty.getClientType(), modelProperty.getWireType(), childObjectValue); - node.getChildNodes().add(childNode); - clientModelNode.getClientModelProperties().put(childNode, modelProperty); - - // redact possible credential - if (childNode instanceof LiteralNode && childObjectValue instanceof String) { - LiteralNode literalChildNode = (LiteralNode) childNode; - if (literalChildNode.getClientType() == ClassType.STRING - && literalChildNode.getLiteralsValue() != null) { - literalChildNode.setLiteralsValue(ModelTestCaseUtil.redactStringValue(jsonPropertyNames, literalChildNode.getLiteralsValue())); - } - } - } - } - - // additional properties - ModelProperty additionalPropertiesProperty = getAdditionalPropertiesProperty(model); - if (additionalPropertiesProperty != null) { - // properties already defined in model - Set propertySerializedNames = modelProperties.stream() - .map(p -> p.getSerializedNames().iterator().next()) - .collect(Collectors.toSet()); - // the remaining properties in json - Map remainingValues = ((Map) objectValue).entrySet().stream() - .filter(e -> !propertySerializedNames.contains(e.getKey())) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - ExampleNode childNode = parseNode(additionalPropertiesProperty.getClientType(), additionalPropertiesProperty.getWireType(), remainingValues); - node.getChildNodes().add(childNode); - clientModelNode.getClientModelProperties().put(childNode, additionalPropertiesProperty); - } - } else { - // e.g. do not throw exception, use defaultValueExpression - node = defaultNode(type, wireType, objectValue); - } - } else if (objectValue == null) { - node = null; - } else { - node = defaultNode(type, wireType, objectValue); + } else { + LOGGER.warn("Failed to find the sample value for discriminator property '{}'", serializedName); + } } - return node; + + ClientModelNode clientModelNode = new ClientModelNode(type, objectValue).setClientModel(model); + node = clientModelNode; + + List modelProperties = getWritablePropertiesIncludeSuperclass(model); + for (ModelProperty modelProperty : modelProperties) { + List jsonPropertyNames = modelProperty.getSerializedNames(); + + Object childObjectValue = getChildObjectValue(jsonPropertyNames, objectValue); + if (childObjectValue != null) { + ExampleNode childNode = parseNode(modelProperty.getClientType(), modelProperty.getWireType(), childObjectValue); + node.getChildNodes().add(childNode); + clientModelNode.getClientModelProperties().put(childNode, modelProperty); + + // redact possible credential + if (childNode instanceof LiteralNode && childObjectValue instanceof String) { + LiteralNode literalChildNode = (LiteralNode) childNode; + if (literalChildNode.getClientType() == ClassType.STRING + && literalChildNode.getLiteralsValue() != null) { + literalChildNode.setLiteralsValue(ModelTestCaseUtil.redactStringValue(jsonPropertyNames, literalChildNode.getLiteralsValue())); + } + } + } + } + + // additional properties + ModelProperty additionalPropertiesProperty = getAdditionalPropertiesProperty(model); + if (additionalPropertiesProperty != null) { + // properties already defined in model + Set propertySerializedNames = modelProperties.stream() + .map(p -> p.getSerializedNames().iterator().next()) + .collect(Collectors.toSet()); + // the remaining properties in json + Map remainingValues = ((Map) objectValue).entrySet().stream() + .filter(e -> !propertySerializedNames.contains(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + ExampleNode childNode = parseNode(additionalPropertiesProperty.getClientType(), additionalPropertiesProperty.getWireType(), remainingValues); + node.getChildNodes().add(childNode); + clientModelNode.getClientModelProperties().put(childNode, additionalPropertiesProperty); + } + } else { + // e.g. do not throw exception, use defaultValueExpression + node = defaultNode(type, wireType, objectValue); + } + } else { + // If client type is unrecognized, or the objectValue is null, we return default node (LiteralNode) + // In case of null objectValue, instead of directly returning null node, we let downstream to decide how to deal with it + node = defaultNode(type, wireType, objectValue); + } + return node; + } + + /** + * Default String literal node. + * Generated example will be the type's defaultValueExpression. + * + * @param clientType the client type + * @param wireType the wire type + * @param exampleValue the example value + * @return string literal node + */ + private static ExampleNode defaultNode(IType clientType, IType wireType, Object exampleValue) { + ExampleNode node; + LiteralNode literalNode = new LiteralNode(clientType, exampleValue); + node = literalNode; + + if (exampleValue != null) { + String literalValue = convertLiteralToClientValue(wireType, exampleValue.toString()); + literalNode.setLiteralsValue(literalValue); + } + return node; + } + + /** + * Convert literal value in wire type, to literal value in client type + *

+ * date-time in RFC1123 to RFC3339 + * date-time in Unix epoch to RFC3339 + * bytes in base64URL to bytes in string + * + * @param wireType the wire type + * @param literalInWireType the literal value in wire type + * @return the literal value in client type + */ + public static String convertLiteralToClientValue(IType wireType, String literalInWireType) { + // see ClassType.convertToClientType and PrimitiveType.convertToClientType + String literalValue = literalInWireType; + if (wireType == ClassType.DATE_TIME_RFC_1123) { + literalValue = new DateTimeRfc1123(literalValue).getDateTime().toString(); + } else if (wireType == ClassType.BASE_64_URL) { + literalValue = new Base64Url(literalValue).toString(); + } else if (wireType == PrimitiveType.UNIX_TIME_LONG) { + literalValue = OffsetDateTime.from(Instant.ofEpochSecond(Long.parseLong(literalValue))).toString(); + } + return literalValue; + } + + @SuppressWarnings("unchecked") + public static Object getChildObjectValue(List jsonPropertyNames, Object objectValue) { + boolean found = true; + Object childObjectValue = objectValue; + // walk the sequence of serialized names + for (String name : jsonPropertyNames) { + if (name.isEmpty()) { + found = false; + break; + } + + if (childObjectValue instanceof Map) { + childObjectValue = ((Map) childObjectValue).get(name); + if (childObjectValue == null) { + found = false; + break; + } + } else { + found = false; + break; + } + } + return found ? childObjectValue : null; + } + + /** + * Parse method parameter (client model or others) to example node. + * @param example proxy method example + * @param methodParameter method parameter + * @return example node + */ + public static ExampleNode parseNodeFromParameter(ProxyMethodExample example, MethodParameter methodParameter) { + String serializedName = methodParameter.getSerializedName(); + if (serializedName == null && methodParameter.getProxyMethodParameter().getRequestParameterLocation() == RequestParameterLocation.BODY) { + serializedName = methodParameter.getProxyMethodParameter().getName(); } - /** - * Default String literal node. - * Generated example will be the type's defaultValueExpression. - * - * @param clientType the client type - * @param wireType the wire type - * @param exampleValue the example value - * @return string literal node - */ - private static ExampleNode defaultNode(IType clientType, IType wireType, Object exampleValue) { - ExampleNode node; - LiteralNode literalNode = new LiteralNode(clientType, exampleValue); - node = literalNode; + Object exampleValue = getParameterExampleValue(example, serializedName, methodParameter.getProxyMethodParameter().getRequestParameterLocation()); - if (exampleValue != null) { - String literalValue = convertLiteralToClientValue(wireType, exampleValue.toString()); - literalNode.setLiteralsValue(literalValue); + ExampleNode node; + if (exampleValue == null) { + if (ClassType.CONTEXT.equals(methodParameter.getClientMethodParameter().getClientType())) { + node = new LiteralNode(ClassType.CONTEXT, "").setLiteralsValue(""); + } else { + node = new LiteralNode(methodParameter.getClientMethodParameter().getClientType(), null); + } + } else { + node = parseNodeFromMethodParameter(methodParameter, exampleValue); + } + return node; + } + + /** + * Get the example value for the parameter. + * + * @param example proxy method example + * @param serializedName parameter serialized name + * @param requestParameterLocation parameter location + * @return the example value for the parameter, null if not found + */ + public static Object getParameterExampleValue(ProxyMethodExample example, String serializedName, RequestParameterLocation requestParameterLocation) { + + ProxyMethodExample.ParameterValue parameterValue = findParameter(example, serializedName); + + if (parameterValue == null && requestParameterLocation == RequestParameterLocation.BODY) { + // special handling for body, as it does not have serializedName + String paramSuffix = "Param"; + if (serializedName.endsWith(paramSuffix)) { + // hack, remove Param, as it likely added by codegen to avoid naming conflict + serializedName = serializedName.substring(0, serializedName.length() - paramSuffix.length()); + if (!serializedName.isEmpty()) { + parameterValue = findParameter(example, serializedName); } - return node; + } + + // fallback, "body" is commonly used in example JSON for request body + if (parameterValue == null && !"body".equalsIgnoreCase(serializedName)) { + serializedName = "body"; + parameterValue = findParameter(example, serializedName); + } } - /** - * Convert literal value in wire type, to literal value in client type - *

- * date-time in RFC1123 to RFC3339 - * date-time in Unix epoch to RFC3339 - * bytes in base64URL to bytes in string - * - * @param wireType the wire type - * @param literalInWireType the literal value in wire type - * @return the literal value in client type - */ - public static String convertLiteralToClientValue(IType wireType, String literalInWireType) { - // see ClassType.convertToClientType and PrimitiveType.convertToClientType - String literalValue = literalInWireType; - if (wireType == ClassType.DATE_TIME_RFC_1123) { - literalValue = new DateTimeRfc1123(literalValue).getDateTime().toString(); - } else if (wireType == ClassType.BASE_64_URL) { - literalValue = new Base64Url(literalValue).toString(); - } else if (wireType == PrimitiveType.UNIX_TIME_LONG) { - literalValue = OffsetDateTime.from(Instant.ofEpochSecond(Long.parseLong(literalValue))).toString(); - } - return literalValue; + Object exampleValue = parameterValue; + + if (parameterValue != null) { + exampleValue = requestParameterLocation == RequestParameterLocation.QUERY + ? parameterValue.getUnescapedQueryValue() + : parameterValue.getObjectValue(); } - @SuppressWarnings("unchecked") - public static Object getChildObjectValue(List jsonPropertyNames, Object objectValue) { - boolean found = true; - Object childObjectValue = objectValue; - // walk the sequence of serialized names - for (String name : jsonPropertyNames) { - if (name.isEmpty()) { - found = false; - break; - } + return exampleValue; + } - if (childObjectValue instanceof Map) { - childObjectValue = ((Map) childObjectValue).get(name); - if (childObjectValue == null) { - found = false; - break; - } - } else { - found = false; - break; - } - } - return found ? childObjectValue : null; + /** + * Find parameter example value from proxy method example by serialized parameter name. + * @param example proxy method example + * @param serializedName parameter serialized name + * @return example value for this parameter + */ + public static ProxyMethodExample.ParameterValue findParameter(ProxyMethodExample example, String serializedName) { + return example.getParameters().entrySet() + .stream().filter(p -> p.getKey().equalsIgnoreCase(serializedName)) + .map(Map.Entry::getValue) + .findFirst().orElse(null); + } + + private static ExampleNode parseNodeFromMethodParameter(MethodParameter methodParameter, Object objectValue) { + IType type = methodParameter.getClientMethodParameter().getClientType(); + IType wireType = methodParameter.getClientMethodParameter().getWireType(); + if (methodParameter.getProxyMethodParameter().getCollectionFormat() != null && type instanceof ListType && objectValue instanceof String) { + // handle parameter style + + IType elementType = ((ListType) type).getElementType(); + ListNode listNode = new ListNode(elementType, objectValue); + String value = (String) objectValue; + + CollectionFormat collectionFormat = methodParameter.getProxyMethodParameter().getCollectionFormat(); + String[] elements; + switch (collectionFormat) { + case CSV: + elements = value.split(",", -1); + break; + case SSV: + elements = value.split(" ", -1); + break; + case PIPES: + elements = value.split("\\|", -1); + break; + case TSV: + elements = value.split("\t", -1); + break; + default: + // TODO (weidxu): CollectionFormat.MULTI + elements = value.split(",", -1); + LOGGER.error("Parameter style '{}' is not supported, fallback to CSV", collectionFormat); + break; + } + for (String childObjectValue : elements) { + ExampleNode childNode = ModelExampleUtil.parseNode(elementType, childObjectValue); + listNode.getChildNodes().add(childNode); + } + return listNode; + } else { + return ModelExampleUtil.parseNode(type, wireType, objectValue); + } + } + + private static ModelProperty getAdditionalPropertiesProperty(ClientModel model) { + ModelProperty modelProperty = null; + ClientModelProperty property = model.getProperties().stream() + .filter(ClientModelProperty::isAdditionalProperties) + .findFirst().orElse(null); + if (property != null && property.getClientType() instanceof MapType) { + modelProperty = ModelProperty.ofClientModelProperty(property); + } + return modelProperty; + } + + private static List getWritablePropertiesIncludeSuperclass(ClientModel model) { + Map propertiesMap = new LinkedHashMap<>(); + List properties = new ArrayList<>(); + + List parentModels = new ArrayList<>(); + String parentModelName = model.getParentModelName(); + while (!CoreUtils.isNullOrEmpty(parentModelName)) { + ClientModel parentModel = ClientModelUtil.getClientModel(parentModelName); + if (parentModel != null) { + parentModels.add(parentModel); + } + parentModelName = parentModel == null ? null : parentModel.getParentModelName(); } - /** - * Parse method parameter (client model or others) to example node. - * @param example proxy method example - * @param methodParameter method parameter - * @return example node - */ - public static ExampleNode parseNodeFromParameter(ProxyMethodExample example, MethodParameter methodParameter) { - String serializedName = methodParameter.getSerializedName(); - if (serializedName == null && methodParameter.getProxyMethodParameter().getRequestParameterLocation() == RequestParameterLocation.BODY) { - serializedName = methodParameter.getProxyMethodParameter().getName(); - } + List> propertiesFromTypeAndParents = new ArrayList<>(); + propertiesFromTypeAndParents.add(new ArrayList<>()); + model.getAccessibleProperties().forEach(p -> { + ModelProperty modelProperty = ModelProperty.ofClientModelProperty(p); + if (propertiesMap.putIfAbsent(modelProperty.getName(), modelProperty) == null) { + propertiesFromTypeAndParents.get(propertiesFromTypeAndParents.size() - 1).add(modelProperty); + } + }); - Object exampleValue = getParameterExampleValue(example, serializedName, methodParameter.getProxyMethodParameter().getRequestParameterLocation()); + for (ClientModel parent : parentModels) { + propertiesFromTypeAndParents.add(new ArrayList<>()); - ExampleNode node; - if (exampleValue == null) { - if (ClassType.CONTEXT.equals(methodParameter.getClientMethodParameter().getClientType())) { - node = new LiteralNode(ClassType.CONTEXT, "").setLiteralsValue(""); - } else { - node = new LiteralNode(methodParameter.getClientMethodParameter().getClientType(), null); - } - } else { - node = parseNodeFromMethodParameter(methodParameter, exampleValue); + parent.getAccessibleProperties().forEach(p -> { + ModelProperty modelProperty = ModelProperty.ofClientModelProperty(p); + if (propertiesMap.putIfAbsent(modelProperty.getName(), modelProperty) == null) { + propertiesFromTypeAndParents.get(propertiesFromTypeAndParents.size() - 1).add(modelProperty); } - return node; + }); } - /** - * Get the example value for the parameter. - * - * @param example proxy method example - * @param serializedName parameter serialized name - * @param requestParameterLocation parameter location - * @return the example value for the parameter, null if not found - */ - public static Object getParameterExampleValue(ProxyMethodExample example, String serializedName, RequestParameterLocation requestParameterLocation) { - - ProxyMethodExample.ParameterValue parameterValue = findParameter(example, serializedName); - - if (parameterValue == null && requestParameterLocation == RequestParameterLocation.BODY) { - // special handling for body, as it does not have serializedName - String paramSuffix = "Param"; - if (serializedName.endsWith(paramSuffix)) { - // hack, remove Param, as it likely added by codegen to avoid naming conflict - serializedName = serializedName.substring(0, serializedName.length() - paramSuffix.length()); - if (!serializedName.isEmpty()) { - parameterValue = findParameter(example, serializedName); - } - } - - // fallback, "body" is commonly used in example JSON for request body - if (parameterValue == null && !"body".equalsIgnoreCase(serializedName)) { - serializedName = "body"; - parameterValue = findParameter(example, serializedName); - } - } - - Object exampleValue = parameterValue; - - if (parameterValue != null) { - exampleValue = requestParameterLocation == RequestParameterLocation.QUERY - ? parameterValue.getUnescapedQueryValue() - : parameterValue.getObjectValue(); - } - - return exampleValue; + Collections.reverse(propertiesFromTypeAndParents); + for (List properties1 : propertiesFromTypeAndParents) { + properties.addAll(properties1); } - /** - * Find parameter example value from proxy method example by serialized parameter name. - * @param example proxy method example - * @param serializedName parameter serialized name - * @return example value for this parameter - */ - public static ProxyMethodExample.ParameterValue findParameter(ProxyMethodExample example, String serializedName) { - return example.getParameters().entrySet() - .stream().filter(p -> p.getKey().equalsIgnoreCase(serializedName)) - .map(Map.Entry::getValue) - .findFirst().orElse(null); + return properties.stream() + .filter(p -> !p.isReadOnly() && !p.isConstant()) + .collect(Collectors.toList()); + } + + private static ClientModel getDerivedModel(ClientModel model, String discriminatorValue) { + if (discriminatorValue.equals(model.getSerializedName())) { + return model; } - private static ExampleNode parseNodeFromMethodParameter(MethodParameter methodParameter, Object objectValue) { - IType type = methodParameter.getClientMethodParameter().getClientType(); - IType wireType = methodParameter.getClientMethodParameter().getWireType(); - if (methodParameter.getProxyMethodParameter().getCollectionFormat() != null && type instanceof ListType && objectValue instanceof String) { - // handle parameter style - - IType elementType = ((ListType) type).getElementType(); - ListNode listNode = new ListNode(elementType, objectValue); - String value = (String) objectValue; - - CollectionFormat collectionFormat = methodParameter.getProxyMethodParameter().getCollectionFormat(); - String[] elements; - switch (collectionFormat) { - case CSV: - elements = value.split(",", -1); - break; - case SSV: - elements = value.split(" ", -1); - break; - case PIPES: - elements = value.split("\\|", -1); - break; - case TSV: - elements = value.split("\t", -1); - break; - default: - // TODO (weidxu): CollectionFormat.MULTI - elements = value.split(",", -1); - LOGGER.error("Parameter style '{}' is not supported, fallback to CSV", collectionFormat); - break; - } - for (String childObjectValue : elements) { - ExampleNode childNode = ModelExampleUtil.parseNode(elementType, childObjectValue); - listNode.getChildNodes().add(childNode); - } - return listNode; - } else { - return ModelExampleUtil.parseNode(type, wireType, objectValue); + // depth first search + if (model.getDerivedModels() != null) { + for (ClientModel childModel : model.getDerivedModels()) { + if (discriminatorValue.equalsIgnoreCase(childModel.getSerializedName())) { + // found + return childModel; + } else if (childModel.getDerivedModels() != null) { + // recursive + ClientModel childModel2 = getDerivedModel(childModel, discriminatorValue); + if (childModel2 != null) { + return childModel2; + } } + } } - private static ModelProperty getAdditionalPropertiesProperty(ClientModel model) { - ModelProperty modelProperty = null; - ClientModelProperty property = model.getProperties().stream() - .filter(ClientModelProperty::isAdditionalProperties) - .findFirst().orElse(null); - if (property != null && property.getClientType() instanceof MapType) { - modelProperty = ModelProperty.ofClientModelProperty(property); - } - return modelProperty; - } - - private static List getWritablePropertiesIncludeSuperclass(ClientModel model) { - Map propertiesMap = new LinkedHashMap<>(); - List properties = new ArrayList<>(); - - List parentModels = new ArrayList<>(); - String parentModelName = model.getParentModelName(); - while (!CoreUtils.isNullOrEmpty(parentModelName)) { - ClientModel parentModel = ClientModelUtil.getClientModel(parentModelName); - if (parentModel != null) { - parentModels.add(parentModel); - } - parentModelName = parentModel == null ? null : parentModel.getParentModelName(); - } - - List> propertiesFromTypeAndParents = new ArrayList<>(); - propertiesFromTypeAndParents.add(new ArrayList<>()); - model.getAccessibleProperties().forEach(p -> { - ModelProperty modelProperty = ModelProperty.ofClientModelProperty(p); - if (propertiesMap.putIfAbsent(modelProperty.getName(), modelProperty) == null) { - propertiesFromTypeAndParents.get(propertiesFromTypeAndParents.size() - 1).add(modelProperty); - } - }); - - for (ClientModel parent : parentModels) { - propertiesFromTypeAndParents.add(new ArrayList<>()); - - parent.getAccessibleProperties().forEach(p -> { - ModelProperty modelProperty = ModelProperty.ofClientModelProperty(p); - if (propertiesMap.putIfAbsent(modelProperty.getName(), modelProperty) == null) { - propertiesFromTypeAndParents.get(propertiesFromTypeAndParents.size() - 1).add(modelProperty); - } - }); - } - - Collections.reverse(propertiesFromTypeAndParents); - for (List properties1 : propertiesFromTypeAndParents) { - properties.addAll(properties1); - } - - return properties.stream() - .filter(p -> !p.isReadOnly() && !p.isConstant()) - .collect(Collectors.toList()); - } - - private static ClientModel getDerivedModel(ClientModel model, String discriminatorValue) { - if (discriminatorValue.equals(model.getSerializedName())) { - return model; - } - - // depth first search - if (model.getDerivedModels() != null) { - for (ClientModel childModel : model.getDerivedModels()) { - if (discriminatorValue.equalsIgnoreCase(childModel.getSerializedName())) { - // found - return childModel; - } else if (childModel.getDerivedModels() != null) { - // recursive - ClientModel childModel2 = getDerivedModel(childModel, discriminatorValue); - if (childModel2 != null) { - return childModel2; - } - } - } - } - - // not found - return null; - } + // not found + return null; + } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/resources/Changelog_protocol.txt b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/Changelog_protocol.txt new file mode 100644 index 000000000..65f9df7e1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/Changelog_protocol.txt @@ -0,0 +1,13 @@ +# Release History + +## {{artifact-version}} ({{date-utc}}) + +- Azure {{service-name}} client library for Java. {{service-description}} + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/resources/GenericMultipartFormDataHelper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/GenericMultipartFormDataHelper.java new file mode 100644 index 000000000..9ec8e8d49 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/GenericMultipartFormDataHelper.java @@ -0,0 +1,214 @@ +import io.clientcore.core.http.models.HttpHeaderName; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.util.binarydata.BinaryData; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.SequenceInputStream; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.UUID; + +// DO NOT modify this helper class + +public final class MultipartFormDataHelper { + /** + * Line separator for the multipart HTTP request. + */ + private static final String CRLF = "\r\n"; + + private static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + /** + * Value to be used as part of the divider for the multipart requests. + */ + private final String boundary; + + /** + * The actual part separator in the request. This is obtained by prepending "--" to the "boundary". + */ + private final String partSeparator; + + /** + * The marker for the ending of a multipart request. This is obtained by post-pending "--" to the "partSeparator". + */ + private final String endMarker; + + /** + * Charset used for encoding the multipart HTTP request. + */ + private final Charset encoderCharset = StandardCharsets.UTF_8; + + private InputStream requestDataStream = new ByteArrayInputStream(new byte[0]); + private long requestLength = 0; + + private RequestOptions requestOptions; + private BinaryData requestBody; + + /** + * Default constructor used in the code. The boundary is a random value. + * + * @param requestOptions the RequestOptions to update + */ + public MultipartFormDataHelper(RequestOptions requestOptions) { + this(requestOptions, UUID.randomUUID().toString().substring(0, 16)); + } + + private MultipartFormDataHelper(RequestOptions requestOptions, String boundary) { + this.requestOptions = requestOptions; + this.boundary = boundary; + this.partSeparator = "--" + boundary; + this.endMarker = this.partSeparator + "--"; + } + + /** + * Gets the multipart HTTP request body. + * + * @return the BinaryData of the multipart HTTP request body + */ + public BinaryData getRequestBody() { + return requestBody; + } + + // text/plain + /** + * Formats a text/plain field for a multipart HTTP request. + * + * @param fieldName the field name + * @param value the value of the text/plain field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeTextField(String fieldName, String value) { + if (value != null) { + String serialized = partSeparator + + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + + CRLF + CRLF + + value + + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + // application/json + /** + * Formats a application/json field for a multipart HTTP request. + * + * @param fieldName the field name + * @param jsonObject the object of the application/json field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeJsonField(String fieldName, Object jsonObject) { + if (jsonObject != null) { + String serialized = partSeparator + CRLF + + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + + CRLF + "Content-Type: application/json" + + CRLF + CRLF + BinaryData.fromObject(jsonObject) + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + /** + * Formats a file field for a multipart HTTP request. + * + * @param fieldName the field name + * @param file the BinaryData of the file + * @param contentType the content-type of the file + * @param filename the filename + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileField( + String fieldName, + BinaryData file, + String contentType, + String filename) { + if (file != null) { + if (contentType != null && !contentType.isEmpty()) { + contentType = APPLICATION_OCTET_STREAM; + } + writeFileField(fieldName, file, contentType, filename); + } + return this; + } + + /** + * Formats a file field (potentially multiple files) for a multipart HTTP request. + * + * @param fieldName the field name + * @param files the List of BinaryData of the files + * @param contentTypes the List of content-type of the files + * @param filenames the List of filenames + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileFields( + String fieldName, + List files, + List contentTypes, + List filenames) { + if (files != null) { + for (int i = 0; i < files.size(); ++i) { + BinaryData file = files.get(i); + String contentType = contentTypes.get(i); + if (contentType != null && !contentType.isEmpty()) { + contentType = APPLICATION_OCTET_STREAM; + } + String filename = filenames.get(i); + writeFileField(fieldName, file, contentType, filename); + } + } + return this; + } + + /** + * Ends the serialization of the multipart HTTP request. + * + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper end() { + byte[] data = endMarker.getBytes(encoderCharset); + appendBytes(data); + + requestBody = BinaryData.fromStream(requestDataStream, requestLength); + + requestOptions + .setHeader(HttpHeaderName.CONTENT_TYPE, "multipart/form-data; boundary=" + this.boundary) + .setHeader(HttpHeaderName.CONTENT_LENGTH, String.valueOf(requestLength)); + + return this; + } + + private void writeFileField(String fieldName, BinaryData file, String contentType, String filename) { + String contentDispositionFilename = ""; + if (filename != null && !filename.isEmpty()) { + contentDispositionFilename = "; filename=\"" + escapeName(filename) + "\""; + } + + // Multipart preamble + String fileFieldPreamble = partSeparator + + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + contentDispositionFilename + + CRLF + "Content-Type: " + contentType + CRLF + CRLF; + byte[] data = fileFieldPreamble.getBytes(encoderCharset); + appendBytes(data); + + // Writing the file into the request as a byte stream + requestLength += file.getLength(); + requestDataStream = new SequenceInputStream(requestDataStream, file.toStream()); + + // CRLF + data = CRLF.getBytes(encoderCharset); + appendBytes(data); + } + + private void appendBytes(byte[] bytes) { + requestLength += bytes.length; + requestDataStream = new SequenceInputStream(requestDataStream, new ByteArrayInputStream(bytes)); + } + + private static String escapeName(String name) { + return name.replace("\n", "%0A").replace("\r", "%0D").replace("\"", "%22"); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/resources/MultipartFormDataHelper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/MultipartFormDataHelper.java new file mode 100644 index 000000000..24b8dfbb2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/MultipartFormDataHelper.java @@ -0,0 +1,215 @@ +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.SequenceInputStream; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.UUID; + +// DO NOT modify this helper class + +public final class MultipartFormDataHelper { + /** + * Line separator for the multipart HTTP request. + */ + private static final String CRLF = "\r\n"; + + private static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + /** + * Value to be used as part of the divider for the multipart requests. + */ + private final String boundary; + + /** + * The actual part separator in the request. This is obtained by prepending "--" to the "boundary". + */ + private final String partSeparator; + + /** + * The marker for the ending of a multipart request. This is obtained by post-pending "--" to the "partSeparator". + */ + private final String endMarker; + + /** + * Charset used for encoding the multipart HTTP request. + */ + private final Charset encoderCharset = StandardCharsets.UTF_8; + + private InputStream requestDataStream = new ByteArrayInputStream(new byte[0]); + private long requestLength = 0; + + private RequestOptions requestOptions; + private BinaryData requestBody; + + /** + * Default constructor used in the code. The boundary is a random value. + * + * @param requestOptions the RequestOptions to update + */ + public MultipartFormDataHelper(RequestOptions requestOptions) { + this(requestOptions, UUID.randomUUID().toString().substring(0, 16)); + } + + private MultipartFormDataHelper(RequestOptions requestOptions, String boundary) { + this.requestOptions = requestOptions; + this.boundary = boundary; + this.partSeparator = "--" + boundary; + this.endMarker = this.partSeparator + "--"; + } + + /** + * Gets the multipart HTTP request body. + * + * @return the BinaryData of the multipart HTTP request body + */ + public BinaryData getRequestBody() { + return requestBody; + } + + // text/plain + /** + * Formats a text/plain field for a multipart HTTP request. + * + * @param fieldName the field name + * @param value the value of the text/plain field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeTextField(String fieldName, String value) { + if (value != null) { + String serialized = partSeparator + + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + + CRLF + CRLF + + value + + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + // application/json + /** + * Formats a application/json field for a multipart HTTP request. + * + * @param fieldName the field name + * @param jsonObject the object of the application/json field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeJsonField(String fieldName, Object jsonObject) { + if (jsonObject != null) { + String serialized = partSeparator + CRLF + + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + + CRLF + "Content-Type: application/json" + + CRLF + CRLF + BinaryData.fromObject(jsonObject) + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + /** + * Formats a file field for a multipart HTTP request. + * + * @param fieldName the field name + * @param file the BinaryData of the file + * @param contentType the content-type of the file + * @param filename the filename + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileField( + String fieldName, + BinaryData file, + String contentType, + String filename) { + if (file != null) { + if (CoreUtils.isNullOrEmpty(contentType)) { + contentType = APPLICATION_OCTET_STREAM; + } + writeFileField(fieldName, file, contentType, filename); + } + return this; + } + + /** + * Formats a file field (potentially multiple files) for a multipart HTTP request. + * + * @param fieldName the field name + * @param files the List of BinaryData of the files + * @param contentTypes the List of content-type of the files + * @param filenames the List of filenames + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileFields( + String fieldName, + List files, + List contentTypes, + List filenames) { + if (files != null) { + for (int i = 0; i < files.size(); ++i) { + BinaryData file = files.get(i); + String contentType = contentTypes.get(i); + if (CoreUtils.isNullOrEmpty(contentType)) { + contentType = APPLICATION_OCTET_STREAM; + } + String filename = filenames.get(i); + writeFileField(fieldName, file, contentType, filename); + } + } + return this; + } + + /** + * Ends the serialization of the multipart HTTP request. + * + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper end() { + byte[] data = endMarker.getBytes(encoderCharset); + appendBytes(data); + + requestBody = BinaryData.fromStream(requestDataStream, requestLength); + + requestOptions + .setHeader(HttpHeaderName.CONTENT_TYPE, "multipart/form-data; boundary=" + this.boundary) + .setHeader(HttpHeaderName.CONTENT_LENGTH, String.valueOf(requestLength)); + + return this; + } + + private void writeFileField(String fieldName, BinaryData file, String contentType, String filename) { + String contentDispositionFilename = ""; + if (!CoreUtils.isNullOrEmpty(filename)) { + contentDispositionFilename = "; filename=\"" + escapeName(filename) + "\""; + } + + // Multipart preamble + String fileFieldPreamble = partSeparator + + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + contentDispositionFilename + + CRLF + "Content-Type: " + contentType + CRLF + CRLF; + byte[] data = fileFieldPreamble.getBytes(encoderCharset); + appendBytes(data); + + // Writing the file into the request as a byte stream + requestLength += file.getLength(); + requestDataStream = new SequenceInputStream(requestDataStream, file.toStream()); + + // CRLF + data = CRLF.getBytes(encoderCharset); + appendBytes(data); + } + + private void appendBytes(byte[] bytes) { + requestLength += bytes.length; + requestDataStream = new SequenceInputStream(requestDataStream, new ByteArrayInputStream(bytes)); + } + + private static String escapeName(String name) { + return name.replace("\n", "%0A").replace("\r", "%0D").replace("\"", "%22"); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/resources/OperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/OperationLocationPollingStrategy.java new file mode 100644 index 000000000..a9128286c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/OperationLocationPollingStrategy.java @@ -0,0 +1,129 @@ +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.OperationResourcePollingStrategy; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.time.OffsetDateTime; + +// DO NOT modify this helper class + +/** + * Implements an operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class OperationLocationPollingStrategy extends OperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(OperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + final Mono> pollResponseMono = PollingUtils.deserializeResponse((BinaryData) response.getValue(), serializer, pollResponseType) + .onErrorResume(exception -> { + LOGGER.info("Failed to parse initial response."); + return Mono.empty(); + }) + .map(value -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, value, retryAfter)); + return pollResponseMono.switchIfEmpty( + Mono.fromSupplier(() -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, null, retryAfter))); + } else { + return Mono.error(new AzureException(String.format( + "Operation failed or cancelled with status code %d," + ", '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + } + + /** + * {@inheritDoc} + */ + @Override + public Mono getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + return Mono.error(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + return Mono.error(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + return PollingUtils.deserializeResponse(latestResponseBody, serializer, PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE) + .flatMap(value -> { + if (value.get(propertyName) != null) { + return BinaryData.fromObjectAsync(value.get(propertyName)) + .flatMap(result -> PollingUtils.deserializeResponse(result, serializer, resultType)); + } else { + return Mono.error(new AzureException("Cannot get final result")); + } + }) + .switchIfEmpty(Mono.error(new AzureException("Cannot get final result"))); + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/resources/PollingUtils.java b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/PollingUtils.java new file mode 100644 index 000000000..af023f25b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/PollingUtils.java @@ -0,0 +1,138 @@ +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.net.URI; +import java.net.URISyntaxException; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.temporal.ChronoUnit; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +// DO NOT modify this helper class + +final class PollingUtils { + + public static final TypeReference> POST_POLL_RESULT_TYPE_REFERENCE + = new TypeReference>() { }; + + public static final HttpHeaderName OPERATION_LOCATION_HEADER + = HttpHeaderName.fromString("Operation-Location"); + + public static final String HTTP_METHOD = "httpMethod"; + public static final String REQUEST_URL = "requestURL"; + public static final String POLL_RESPONSE_BODY = "pollResponseBody"; + + private static final String FORWARD_SLASH = "/"; + public static String getAbsolutePath(String path, String endpoint, ClientLogger logger) { + try { + URI uri = new URI(path); + if (!uri.isAbsolute()) { + if (CoreUtils.isNullOrEmpty(endpoint)) { + throw logger.logExceptionAsError(new IllegalArgumentException( + "Relative path requires endpoint to be non-null and non-empty to create an absolute path.")); + } + + if (endpoint.endsWith(FORWARD_SLASH) && path.startsWith(FORWARD_SLASH)) { + return endpoint + path.substring(1); + } else if (!endpoint.endsWith(FORWARD_SLASH) && !path.startsWith(FORWARD_SLASH)) { + return endpoint + FORWARD_SLASH + path; + } else { + return endpoint + path; + } + } + } catch (URISyntaxException ex) { + throw logger.logExceptionAsWarning(new IllegalArgumentException("'path' must be a valid URI.", ex)); + } + return path; + } + + public static T deserializeResponseSync(BinaryData binaryData, ObjectSerializer serializer, TypeReference typeReference) { + T value; + if (binaryData == null) { + value = null; + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = typeReference.getJavaClass().cast(binaryData.toReplayableBinaryData()); + } else { + value = binaryData.toObject(typeReference, serializer); + } + return value; + } + + @SuppressWarnings("unchecked") + public static Mono deserializeResponse(BinaryData binaryData, ObjectSerializer serializer, TypeReference typeReference) { + Mono value; + if (binaryData == null) { + value = Mono.empty(); + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = (Mono) binaryData.toReplayableBinaryDataAsync(); + } else { + value = binaryData.toObjectAsync(typeReference, serializer); + } + return value; + } + + private static final HttpHeaderName RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("retry-after-ms"); + private static final HttpHeaderName X_MS_RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("x-ms-retry-after-ms"); + public static Duration getRetryAfterFromHeaders(HttpHeaders headers, Supplier nowSupplier) { + // Found 'x-ms-retry-after-ms' header, use a Duration of milliseconds based on the value. + Duration retryDelay = tryGetRetryDelay(headers, X_MS_RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'retry-after-ms' header, use a Duration of milliseconds based on the value. + retryDelay = tryGetRetryDelay(headers, RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'Retry-After' header. First, attempt to resolve it as a Duration of seconds. If that fails, then + // attempt to resolve it as an HTTP date (RFC1123). + retryDelay = tryGetRetryDelay(headers, HttpHeaderName.RETRY_AFTER, + headerValue -> tryParseLongOrDateTime(headerValue, nowSupplier)); + + // Either the retry delay will have been found or it'll be null, null indicates no retry after. + return retryDelay; + } + private static Duration tryGetRetryDelay(HttpHeaders headers, HttpHeaderName headerName, + Function delayParser) { + String headerValue = headers.getValue(headerName); + + return CoreUtils.isNullOrEmpty(headerValue) ? null : delayParser.apply(headerValue); + } + private static Duration tryParseLongOrDateTime(String value, Supplier nowSupplier) { + long delaySeconds; + try { + OffsetDateTime retryAfter = new DateTimeRfc1123(value).getDateTime(); + + delaySeconds = nowSupplier.get().until(retryAfter, ChronoUnit.SECONDS); + } catch (DateTimeException ex) { + delaySeconds = tryParseLong(value); + } + + return (delaySeconds >= 0) ? Duration.ofSeconds(delaySeconds) : null; + } + private static long tryParseLong(String value) { + try { + return Long.parseLong(value); + } catch (NumberFormatException ex) { + return -1; + } + } + private static Duration tryGetDelayMillis(String value) { + long delayMillis = tryParseLong(value); + return (delayMillis >= 0) ? Duration.ofMillis(delayMillis) : null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/resources/Readme_protocol.txt b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/Readme_protocol.txt new file mode 100644 index 000000000..221b24aaf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/Readme_protocol.txt @@ -0,0 +1,80 @@ +# Azure {{service-name}} client library for Java + +Azure {{service-name}} client library for Java. + +{{service-description}} + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] +- [Product documentation][product_documentation] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;{{group-id}}:{{artifact-id}};current}) +```xml + + {{group-id}} + {{artifact-id}} + {{artifact-version}} + +``` +[//]: # ({x-version-update-end}) + +### Authentication + +[Azure Identity][azure_identity] package provides the default implementation for authenticating the client. + +## Key concepts + +## Examples + +```java {{package-name}}.readme +``` + +### Service API versions + +The client library targets the latest service API version by default. +The service client builder accepts an optional service API version parameter to specify which API version to communicate. + +#### Select a service API version + +You have the flexibility to explicitly select a supported service API version when initializing a service client via the service client builder. +This ensures that the client can communicate with services using the specified API version. + +When selecting an API version, it is important to verify that there are no breaking changes compared to the latest API version. +If there are significant differences, API calls may fail due to incompatibility. + +Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy. + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[product_documentation]: https://azure.microsoft.com/services/ +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity + +{{impression-pixel}} diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/resources/SyncOperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/SyncOperationLocationPollingStrategy.java new file mode 100644 index 000000000..129dec751 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/SyncOperationLocationPollingStrategy.java @@ -0,0 +1,124 @@ +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncOperationResourcePollingStrategy; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; + +import java.io.UncheckedIOException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Map; + +// DO NOT modify this helper class + +/** + * Implements a synchronous operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class SyncOperationLocationPollingStrategy extends SyncOperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(SyncOperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public PollResponse onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + T initialResponseType = null; + try { + initialResponseType = PollingUtils.deserializeResponseSync((BinaryData) response.getValue(), serializer, pollResponseType); + } catch (UncheckedIOException e) { + LOGGER.info("Failed to parse initial response."); + } + return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, initialResponseType, retryAfter); + } + + throw LOGGER.logExceptionAsError(new AzureException(String.format( + "Operation failed or cancelled with status code %d, '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + + /** + * {@inheritDoc} + */ + public U getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody = + BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + Map pollResult = + PollingUtils.deserializeResponseSync(latestResponseBody, serializer, PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE); + if (pollResult != null && pollResult.get(propertyName) != null) { + return PollingUtils.deserializeResponseSync(BinaryData.fromObject(pollResult.get(propertyName)), serializer, resultType); + } else { + throw LOGGER.logExceptionAsError(new AzureException("Cannot get final result")); + } + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/resources/data-plane.md b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/data-plane.md new file mode 100644 index 000000000..6d6faf609 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/data-plane.md @@ -0,0 +1,23 @@ +#### data-plane + +```yaml +azure-arm: false + +license-header: MICROSOFT_MIT_SMALL + +generate-client-interfaces: false +generate-client-as-impl: true +generate-sync-async-clients: true +generate-builder-per-client: true +sync-methods: all +enable-sync-stack: true +required-fields-as-ctor-args: true +enable-page-size: true +use-key-credential: true + +use-default-http-status-code-to-exception-type-mapping: true +polling: {} + +models-subpackage: implementation.models +client-logger: true +``` diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/resources/pom.xml b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/pom.xml new file mode 100644 index 000000000..b26df1144 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/pom.xml @@ -0,0 +1,80 @@ + + + + 4.0.0 + + com.azure + autorest-generated-client + 1.0.0-beta.1 + + Microsoft Azure client library + This package contains the generated client library. + https://github.com/Azure/azure-sdk-for-java + + + + azure-java-build-docs + ${site.url}/site/${project.artifactId} + + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + + com.azure + azure-json + 1.2.0 + + + com.azure + azure-xml + 1.1.0 + + + com.azure + azure-core + 1.51.0 + + + com.azure + azure-core-http-netty + 1.15.3 + + + + + com.azure + azure-core-test + 1.26.2 + test + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.7.1 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 11 + 11 + + + + + + diff --git a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 new file mode 100644 index 000000000..be67f2685 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 @@ -0,0 +1,190 @@ +# Use case: +# +# The purpose of this script is to compact the steps required to regenerate TypeSpec into a single script. +# +# If 'com.azure.autorest.customization' tests fails, re-install 'customization-base'. +# +# Before running this script the 'tsp' profile must be built, 'mvn install -P local,tsp'. +param ( + [int] $Parallelization = [Environment]::ProcessorCount +) + + +$ExitCode = 0 + +if ($Parallelization -lt 1) { + $Parallelization = 1 +} + +Write-Host "Parallelization: $Parallelization" + + +$generateScript = { + $tspFile = $_ + + $tspClientFile = $tspFile -replace 'main.tsp', 'client.tsp' + if (($tspClientFile -match 'client.tsp$') -and (Test-Path $tspClientFile)) { + $tspFile = $tspClientFile + } + + # With TypeSpec code generation being parallelized, we need to make sure that the output directory is unique + # for each test run. We do this by appending a random number to the output directory. + # Without this, we could have multiple runs trying to write to the same directory which introduces race conditions. + $tspOptions = "--option ""@typespec/http-client-java.emitter-output-dir={project-root}/tsp-output/$(Get-Random)""" + if ($tspFile -match "type[\\/]enum[\\/]extensible[\\/]") { + # override namespace for reserved keyword "enum" + $tspOptions += " --option ""@typespec/http-client-java.namespace=com.type.enums.extensible""" + } elseif ($tspFile -match "type[\\/]enum[\\/]fixed[\\/]") { + # override namespace for reserved keyword "enum" + $tspOptions += " --option ""@typespec/http-client-java.namespace=com.type.enums.fixed""" + } elseif ($tspFile -match "azure[\\/]example[\\/]basic[\\/]") { + # override examples-directory + $tspOptions += " --option ""@typespec/http-client-java.examples-directory={project-root}/http/azure/example/basic/examples""" + } elseif ($tspFile -match "resiliency[\\/]srv-driven[\\/]old\.tsp") { + # override namespace for "resiliency/srv-driven/old.tsp" (make it different to that from "main.tsp") + $tspOptions += " --option ""@typespec/http-client-java.namespace=com.resiliency.servicedriven.v1""" + # enable advanced versioning for resiliency test + $tspOptions += " --option ""@typespec/http-client-java.advanced-versioning=true""" + $tspOptions += " --option ""@typespec/http-client-java.api-version=all""" + } elseif ($tspFile -match "resiliency[\\/]srv-driven[\\/]main\.tsp") { + # enable advanced versioning for resiliency test + $tspOptions += " --option ""@typespec/http-client-java.advanced-versioning=true""" + $tspOptions += " --option ""@typespec/http-client-java.api-version=all""" + } elseif ($tspFile -match "azure[\\/]resource-manager[\\/].*[\\/]main\.tsp") { + # for mgmt, do not generate tests due to random mock values + $tspOptions += " --option ""@typespec/http-client-java.generate-tests=false""" + # also generate with group-etag-headers=false since mgmt doesn't support etag grouping yet + $tspOptions += " --option ""@typespec/http-client-java.group-etag-headers=false""" + } elseif ($tspFile -match "tsp[\\/]versioning.tsp") { + # test generating from specific api-version + $tspOptions += " --option ""@typespec/http-client-java.api-version=2022-09-01""" + # exclude preview from service versions + $tspOptions += " --option ""@typespec/http-client-java.service-version-exclude-preview=true""" + } elseif ($tspFile -match "arm.tsp") { + # for mgmt, do not generate tests due to random mock values + $tspOptions += " --option ""@typespec/http-client-java.generate-tests=false""" + # also don't generate with stream-style-serialization as azure-core-management hasn't migrated to azure-json yet + $tspOptions += " --option ""@typespec/http-client-java.stream-style-serialization=false""" + # also generate with group-etag-headers=false since mgmt doesn't support etag grouping yet + $tspOptions += " --option ""@typespec/http-client-java.group-etag-headers=false""" + # also test generating from specific api-version + $tspOptions += " --option ""@typespec/http-client-java.api-version=2023-11-01""" + # exclude preview from service versions + $tspOptions += " --option ""@typespec/http-client-java.service-version-exclude-preview=true""" + } elseif ($tspFile -match "arm-stream-style-serialization.tsp") { + $tspOptions += " --option ""@typespec/http-client-java.stream-style-serialization=true""" + # for mgmt, do not generate tests due to random mock values + $tspOptions += " --option ""@typespec/http-client-java.generate-tests=false""" + # also generate with group-etag-headers=false since mgmt doesn't support etag grouping yet + $tspOptions += " --option ""@typespec/http-client-java.group-etag-headers=false""" + } + + # Test customization for one of the TypeSpec definitions - naming.tsp + if ($tspFile -match "tsp[\\/]naming.tsp$") { + # Add the customization-class option for Java emitter + $tspOptions += " --option ""@typespec/http-client-java.customization-class=../../customization/src/main/java/CustomizationTest.java""" + } + + $tspTrace = "--trace import-resolution --trace projection --trace http-client-java" + $tspCommand = "npx tsp compile $tspFile $tspOptions $tspTrace" + + $timer = [Diagnostics.Stopwatch]::StartNew() + $generateOutput = Invoke-Expression $tspCommand + $timer.Stop() + + $global:ExitCode = $global:ExitCode -bor $LASTEXITCODE + + if ($LASTEXITCODE -ne 0) { + Write-Host " + ======================== + $tspCommand + ======================== + FAILED (Time elapsed: $($timer.ToString())) + $([String]::Join("`n", $generateOutput)) + " + } else { + Write-Host " + ======================== + $tspCommand + ======================== + SUCCEEDED (Time elapsed: $($timer.ToString())) + " + } + + if ($global:ExitCode -ne 0) { + exit $global:ExitCode + } +} + +Set-Location ../../ + +npm install +npm run build +npm pack + +Set-Location ./generator/http-client-generator-test + + +if (Test-Path node_modules) { + Remove-Item node_modules -Recurse -Force +} + +if (Test-Path package-lock.json) { + Remove-Item package-lock.json +} + +# delete output +if (Test-Path tsp-output) { + Remove-Item tsp-output -Recurse -Force +} +npm install + +New-Item -Path ./existingcode/src/main/java/com/cadl/ -ItemType Directory -Force | Out-Null + +if (Test-Path ./src/main/java/com/cadl/partialupdate) { + Copy-Item -Path ./src/main/java/com/cadl/partialupdate -Destination ./existingcode/src/main/java/com/cadl/partialupdate -Recurse -Force +} + +if (Test-Path ./src/main) { + Remove-Item ./src/main -Recurse -Force +} +if (Test-Path ./src/samples) { + Remove-Item ./src/samples -Recurse -Force +} +if (Test-Path ./tsp-output) { + Remove-Item ./tsp-output -Recurse -Force +} + +# run other local tests except partial update +$job = Get-Item ./tsp/* -Filter "*.tsp" -Exclude "*partialupdate*" | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob + +$job | Wait-Job -Timeout 600 +$job | Receive-Job + +# partial update test +npx tsp compile ./tsp/partialupdate.tsp --option="@typespec/http-client-java.emitter-output-dir={project-root}/existingcode" +Copy-Item -Path ./existingcode/src/main/java/com/cadl/partialupdate -Destination ./src/main/java/com/cadl/partialupdate -Recurse -Force +Remove-Item ./existingcode -Recurse -Force + +# run cadl ranch tests sources +Copy-Item -Path node_modules/@azure-tools/cadl-ranch-specs/http -Destination ./ -Recurse -Force +# remove xml tests, emitter has not supported xml model +Remove-Item ./http/payload/xml -Recurse -Force + +$job = (Get-ChildItem ./http -Include "main.tsp","old.tsp" -File -Recurse) | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob + +$job | Wait-Job -Timeout 1200 +$job | Receive-Job + +Remove-Item ./http -Recurse -Force + +Copy-Item -Path ./tsp-output/*/src -Destination ./ -Recurse -Force -Exclude @("ReadmeSamples.java", "module-info.java") + +Remove-Item ./tsp-output -Recurse -Force + +if (Test-Path ./src/main/resources/META-INF/client-structure-service_apiview_properties.json) { + # client structure is generated from multiple client.tsp files and the last one to execute overwrites + # the api view properties file. Because the tests run in parallel, the order is not guaranteed. This + # causes git diff check to fail as the checked in file is not the same as the generated one. + Remove-Item ./src/main/resources/META-INF/client-structure-service_apiview_properties.json -Force +} diff --git a/packages/http-client-java/generator/http-client-generator-test/customization/pom.xml b/packages/http-client-java/generator/http-client-generator-test/customization/pom.xml new file mode 100644 index 000000000..67869ce55 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/customization/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + + Microsoft Autorest TypeSpec Tests code customization + This package contains code for Microsoft Autorest TypeSpec Tests code customization + + com.microsoft.typespec + http-client-generator-customization-test + 1.0.0-beta.1 + jar + + + + com.microsoft.typespec + http-client-generator-core + 1.0.0-beta.1 + + + diff --git a/packages/http-client-java/generator/http-client-generator-test/customization/src/main/java/CustomizationTest.java b/packages/http-client-java/generator/http-client-generator-test/customization/src/main/java/CustomizationTest.java new file mode 100644 index 000000000..b383fbb2e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/customization/src/main/java/CustomizationTest.java @@ -0,0 +1,23 @@ +import com.microsoft.typespec.http.client.generator.core.customization.ClassCustomization; +import com.microsoft.typespec.http.client.generator.core.customization.Customization; +import com.microsoft.typespec.http.client.generator.core.customization.LibraryCustomization; +import com.microsoft.typespec.http.client.generator.core.customization.PackageCustomization; +import org.slf4j.Logger; + +import java.util.Arrays; + +/** + * This class contains the customization code to customize the AutoRest generated code for App Configuration. + */ +public class CustomizationTest extends Customization { + + @Override + public void customize(LibraryCustomization customization, Logger logger) { + logger.info("Customizing the NamingClient javadoc"); + PackageCustomization packageCustomization = customization.getPackage("com.cadl.naming"); + ClassCustomization classCustomization = packageCustomization.getClass("NamingClient"); + classCustomization.getMethod("postWithResponse") + .getJavadoc() + .setDescription("Protocol method for POST operation."); + } +} 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 new file mode 100644 index 000000000..212bebcfb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/package.json @@ -0,0 +1,29 @@ +{ + "name": "@typespec/http-client-java-tests", + "version": "0.1.0", + "type": "module", + "scripts": { + "format": "npm run -s prettier -- --write", + "check-format": "npm run prettier -- --check", + "prettier": "prettier --config ./.prettierrc.yaml **/*.tsp", + "testserver-run": "npx cadl-ranch serve ./node_modules/@azure-tools/cadl-ranch-specs/http --coverageFile ./cadl-ranch-coverage-java.json" + }, + "dependencies": { + "@azure-tools/cadl-ranch-specs": "0.35.2", + "@typespec/http-client-java": "file:/../../typespec-http-client-java-0.1.0.tgz", + "@typespec/http-client-java-tests": "file:" + }, + "overrides": { + "@typespec/compiler": "~0.59.0", + "@typespec/http": "~0.59.0", + "@typespec/rest": "~0.59.0", + "@typespec/versioning": "~0.59.0", + "@typespec/openapi": "~0.59.0", + "@typespec/xml": "~0.59.0", + "@azure-tools/typespec-azure-core": "~0.45.0", + "@azure-tools/typespec-client-generator-core": "~0.45.0", + "@azure-tools/typespec-azure-resource-manager": "~0.45.0", + "@azure-tools/typespec-autorest": "~0.45.0" + }, + "private": true +} diff --git a/packages/http-client-java/generator/http-client-generator-test/pom.xml b/packages/http-client-java/generator/http-client-generator-test/pom.xml new file mode 100644 index 000000000..0f93e2d19 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/pom.xml @@ -0,0 +1,97 @@ + + 4.0.0 + + com.microsoft.typespec + typespec-java-generator + 1.0.0-beta.1 + + + com.microsoft.typespec + http-client-generator-test + jar + + http-client-generator-test + http://maven.apache.org + + + UTF-8 + + + + + com.azure + azure-core + 1.51.0 + + + com.azure + azure-json + 1.2.0 + + + com.azure + azure-xml + 1.1.0 + + + com.azure + azure-core-test + 1.26.2 + test + + + com.azure + azure-identity + 1.13.2 + + + com.azure + azure-core-management + 1.15.2 + + + com.azure + azure-core-http-netty + 1.15.3 + test + + + org.junit.jupiter + junit-jupiter-api + 5.9.3 + test + + + io.projectreactor + reactor-test + 3.4.38 + + + org.mockito + mockito-core + 4.11.0 + test + + + + + net.bytebuddy + byte-buddy + 1.14.12 + test + + + net.bytebuddy + byte-buddy-agent + 1.14.12 + test + + + org.slf4j + slf4j-simple + 1.7.36 + test + + + diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/AccessClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/AccessClientBuilder.java new file mode 100644 index 000000000..3ce73c56e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/AccessClientBuilder.java @@ -0,0 +1,357 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access; + +import com._specs_.azure.clientgenerator.core.access.implementation.AccessClientImpl; +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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; + +/** + * A builder for creating a new instance of the AccessClient type. + */ +@ServiceClientBuilder( + serviceClients = { + PublicOperationClient.class, + InternalOperationClient.class, + SharedModelInOperationClient.class, + RelativeModelInOperationClient.class, + PublicOperationAsyncClient.class, + InternalOperationAsyncClient.class, + SharedModelInOperationAsyncClient.class, + RelativeModelInOperationAsyncClient.class }) +public final class AccessClientBuilder 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("_specs_-azure-clientgenerator-core-access.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the AccessClientBuilder. + */ + @Generated + public AccessClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AccessClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AccessClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AccessClientBuilder 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 AccessClientBuilder 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 AccessClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AccessClientBuilder 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 AccessClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AccessClientBuilder 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 AccessClientBuilder. + */ + @Generated + public AccessClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of AccessClientImpl with the provided parameters. + * + * @return an instance of AccessClientImpl. + */ + @Generated + private AccessClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + AccessClientImpl client + = new AccessClientImpl(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 PublicOperationAsyncClient class. + * + * @return an instance of PublicOperationAsyncClient. + */ + @Generated + public PublicOperationAsyncClient buildPublicOperationAsyncClient() { + return new PublicOperationAsyncClient(buildInnerClient().getPublicOperations()); + } + + /** + * Builds an instance of InternalOperationAsyncClient class. + * + * @return an instance of InternalOperationAsyncClient. + */ + @Generated + public InternalOperationAsyncClient buildInternalOperationAsyncClient() { + return new InternalOperationAsyncClient(buildInnerClient().getInternalOperations()); + } + + /** + * Builds an instance of SharedModelInOperationAsyncClient class. + * + * @return an instance of SharedModelInOperationAsyncClient. + */ + @Generated + public SharedModelInOperationAsyncClient buildSharedModelInOperationAsyncClient() { + return new SharedModelInOperationAsyncClient(buildInnerClient().getSharedModelInOperations()); + } + + /** + * Builds an instance of RelativeModelInOperationAsyncClient class. + * + * @return an instance of RelativeModelInOperationAsyncClient. + */ + @Generated + public RelativeModelInOperationAsyncClient buildRelativeModelInOperationAsyncClient() { + return new RelativeModelInOperationAsyncClient(buildInnerClient().getRelativeModelInOperations()); + } + + /** + * Builds an instance of PublicOperationClient class. + * + * @return an instance of PublicOperationClient. + */ + @Generated + public PublicOperationClient buildPublicOperationClient() { + return new PublicOperationClient(buildInnerClient().getPublicOperations()); + } + + /** + * Builds an instance of InternalOperationClient class. + * + * @return an instance of InternalOperationClient. + */ + @Generated + public InternalOperationClient buildInternalOperationClient() { + return new InternalOperationClient(buildInnerClient().getInternalOperations()); + } + + /** + * Builds an instance of SharedModelInOperationClient class. + * + * @return an instance of SharedModelInOperationClient. + */ + @Generated + public SharedModelInOperationClient buildSharedModelInOperationClient() { + return new SharedModelInOperationClient(buildInnerClient().getSharedModelInOperations()); + } + + /** + * Builds an instance of RelativeModelInOperationClient class. + * + * @return an instance of RelativeModelInOperationClient. + */ + @Generated + public RelativeModelInOperationClient buildRelativeModelInOperationClient() { + return new RelativeModelInOperationClient(buildInnerClient().getRelativeModelInOperations()); + } + + private static final ClientLogger LOGGER = new ClientLogger(AccessClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/InternalOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/InternalOperationAsyncClient.java new file mode 100644 index 000000000..1cadd70dd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/InternalOperationAsyncClient.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 com._specs_.azure.clientgenerator.core.access; + +import com._specs_.azure.clientgenerator.core.access.implementation.InternalOperationsImpl; +import com._specs_.azure.clientgenerator.core.access.implementation.models.InternalDecoratorModelInInternal; +import com._specs_.azure.clientgenerator.core.access.implementation.models.NoDecoratorModelInInternal; +import com._specs_.azure.clientgenerator.core.access.models.PublicDecoratorModelInInternal; +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 reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AccessClient type. + */ +@ServiceClient(builder = AccessClientBuilder.class, isAsync = true) +public final class InternalOperationAsyncClient { + @Generated + private final InternalOperationsImpl serviceClient; + + /** + * Initializes an instance of InternalOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + InternalOperationAsyncClient(InternalOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The noDecoratorInInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in an internal operation, should be generated but not exported along with {@link Response} on + * successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> noDecoratorInInternalWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.noDecoratorInInternalWithResponseAsync(name, requestOptions); + } + + /** + * The internalDecoratorInInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in an internal operation, should be generated but not exported along with {@link Response} on + * successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> internalDecoratorInInternalWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.internalDecoratorInInternalWithResponseAsync(name, requestOptions); + } + + /** + * The publicDecoratorInInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in an internal operation but with public decorator, should be generated and exported along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> publicDecoratorInInternalWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.publicDecoratorInInternalWithResponseAsync(name, requestOptions); + } + + /** + * The noDecoratorInInternal operation. + * + * @param name The name 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 used in an internal operation, should be generated but not exported on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono noDecoratorInInternal(String name) { + // Generated convenience method for noDecoratorInInternalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return noDecoratorInInternalWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(NoDecoratorModelInInternal.class)); + } + + /** + * The internalDecoratorInInternal operation. + * + * @param name The name 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 used in an internal operation, should be generated but not exported on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono internalDecoratorInInternal(String name) { + // Generated convenience method for internalDecoratorInInternalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return internalDecoratorInInternalWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(InternalDecoratorModelInInternal.class)); + } + + /** + * The publicDecoratorInInternal operation. + * + * @param name The name 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 used in an internal operation but with public decorator, should be generated and exported on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono publicDecoratorInInternal(String name) { + // Generated convenience method for publicDecoratorInInternalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return publicDecoratorInInternalWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PublicDecoratorModelInInternal.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/InternalOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/InternalOperationClient.java new file mode 100644 index 000000000..31dd4b867 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/InternalOperationClient.java @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access; + +import com._specs_.azure.clientgenerator.core.access.implementation.InternalOperationsImpl; +import com._specs_.azure.clientgenerator.core.access.implementation.models.InternalDecoratorModelInInternal; +import com._specs_.azure.clientgenerator.core.access.implementation.models.NoDecoratorModelInInternal; +import com._specs_.azure.clientgenerator.core.access.models.PublicDecoratorModelInInternal; +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; + +/** + * Initializes a new instance of the synchronous AccessClient type. + */ +@ServiceClient(builder = AccessClientBuilder.class) +public final class InternalOperationClient { + @Generated + private final InternalOperationsImpl serviceClient; + + /** + * Initializes an instance of InternalOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + InternalOperationClient(InternalOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The noDecoratorInInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in an internal operation, should be generated but not exported along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response noDecoratorInInternalWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.noDecoratorInInternalWithResponse(name, requestOptions); + } + + /** + * The internalDecoratorInInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in an internal operation, should be generated but not exported along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response internalDecoratorInInternalWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.internalDecoratorInInternalWithResponse(name, requestOptions); + } + + /** + * The publicDecoratorInInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in an internal operation but with public decorator, should be generated and exported along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response publicDecoratorInInternalWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.publicDecoratorInInternalWithResponse(name, requestOptions); + } + + /** + * The noDecoratorInInternal operation. + * + * @param name The name 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 used in an internal operation, should be generated but not exported. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + NoDecoratorModelInInternal noDecoratorInInternal(String name) { + // Generated convenience method for noDecoratorInInternalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return noDecoratorInInternalWithResponse(name, requestOptions).getValue() + .toObject(NoDecoratorModelInInternal.class); + } + + /** + * The internalDecoratorInInternal operation. + * + * @param name The name 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 used in an internal operation, should be generated but not exported. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + InternalDecoratorModelInInternal internalDecoratorInInternal(String name) { + // Generated convenience method for internalDecoratorInInternalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return internalDecoratorInInternalWithResponse(name, requestOptions).getValue() + .toObject(InternalDecoratorModelInInternal.class); + } + + /** + * The publicDecoratorInInternal operation. + * + * @param name The name 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 used in an internal operation but with public decorator, should be generated and exported. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + PublicDecoratorModelInInternal publicDecoratorInInternal(String name) { + // Generated convenience method for publicDecoratorInInternalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return publicDecoratorInInternalWithResponse(name, requestOptions).getValue() + .toObject(PublicDecoratorModelInInternal.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/PublicOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/PublicOperationAsyncClient.java new file mode 100644 index 000000000..78913337b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/PublicOperationAsyncClient.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access; + +import com._specs_.azure.clientgenerator.core.access.implementation.PublicOperationsImpl; +import com._specs_.azure.clientgenerator.core.access.models.NoDecoratorModelInPublic; +import com._specs_.azure.clientgenerator.core.access.models.PublicDecoratorModelInPublic; +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 reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AccessClient type. + */ +@ServiceClient(builder = AccessClientBuilder.class, isAsync = true) +public final class PublicOperationAsyncClient { + @Generated + private final PublicOperationsImpl serviceClient; + + /** + * Initializes an instance of PublicOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PublicOperationAsyncClient(PublicOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The noDecoratorInPublic operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in a public operation, should be generated and exported along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> noDecoratorInPublicWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.noDecoratorInPublicWithResponseAsync(name, requestOptions); + } + + /** + * The publicDecoratorInPublic operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in a public operation, should be generated and exported along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> publicDecoratorInPublicWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.publicDecoratorInPublicWithResponseAsync(name, requestOptions); + } + + /** + * The noDecoratorInPublic operation. + * + * @param name The name 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 used in a public operation, should be generated and exported on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono noDecoratorInPublic(String name) { + // Generated convenience method for noDecoratorInPublicWithResponse + RequestOptions requestOptions = new RequestOptions(); + return noDecoratorInPublicWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(NoDecoratorModelInPublic.class)); + } + + /** + * The publicDecoratorInPublic operation. + * + * @param name The name 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 used in a public operation, should be generated and exported on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono publicDecoratorInPublic(String name) { + // Generated convenience method for publicDecoratorInPublicWithResponse + RequestOptions requestOptions = new RequestOptions(); + return publicDecoratorInPublicWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PublicDecoratorModelInPublic.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/PublicOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/PublicOperationClient.java new file mode 100644 index 000000000..472adda67 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/PublicOperationClient.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access; + +import com._specs_.azure.clientgenerator.core.access.implementation.PublicOperationsImpl; +import com._specs_.azure.clientgenerator.core.access.models.NoDecoratorModelInPublic; +import com._specs_.azure.clientgenerator.core.access.models.PublicDecoratorModelInPublic; +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; + +/** + * Initializes a new instance of the synchronous AccessClient type. + */ +@ServiceClient(builder = AccessClientBuilder.class) +public final class PublicOperationClient { + @Generated + private final PublicOperationsImpl serviceClient; + + /** + * Initializes an instance of PublicOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PublicOperationClient(PublicOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The noDecoratorInPublic operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in a public operation, should be generated and exported along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response noDecoratorInPublicWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.noDecoratorInPublicWithResponse(name, requestOptions); + } + + /** + * The publicDecoratorInPublic operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in a public operation, should be generated and exported along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response publicDecoratorInPublicWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.publicDecoratorInPublicWithResponse(name, requestOptions); + } + + /** + * The noDecoratorInPublic operation. + * + * @param name The name 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 used in a public operation, should be generated and exported. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public NoDecoratorModelInPublic noDecoratorInPublic(String name) { + // Generated convenience method for noDecoratorInPublicWithResponse + RequestOptions requestOptions = new RequestOptions(); + return noDecoratorInPublicWithResponse(name, requestOptions).getValue() + .toObject(NoDecoratorModelInPublic.class); + } + + /** + * The publicDecoratorInPublic operation. + * + * @param name The name 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 used in a public operation, should be generated and exported. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PublicDecoratorModelInPublic publicDecoratorInPublic(String name) { + // Generated convenience method for publicDecoratorInPublicWithResponse + RequestOptions requestOptions = new RequestOptions(); + return publicDecoratorInPublicWithResponse(name, requestOptions).getValue() + .toObject(PublicDecoratorModelInPublic.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/RelativeModelInOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/RelativeModelInOperationAsyncClient.java new file mode 100644 index 000000000..42e2631c8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/RelativeModelInOperationAsyncClient.java @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access; + +import com._specs_.azure.clientgenerator.core.access.implementation.RelativeModelInOperationsImpl; +import com._specs_.azure.clientgenerator.core.access.implementation.models.AbstractModel; +import com._specs_.azure.clientgenerator.core.access.implementation.models.OuterModel; +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 reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AccessClient type. + */ +@ServiceClient(builder = AccessClientBuilder.class, isAsync = true) +public final class RelativeModelInOperationAsyncClient { + @Generated + private final RelativeModelInOperationsImpl serviceClient; + + /** + * Initializes an instance of RelativeModelInOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RelativeModelInOperationAsyncClient(RelativeModelInOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Expected query parameter: name=<any string> + * Expected response body: + * ```json + * { + * "name": <any string>, + * "inner": + * { + * "name": <any string> + * } + * } + * ```. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     inner (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name 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 used in internal operations, should be generated but not exported along with {@link Response} on + * successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> operationWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.operationWithResponseAsync(name, requestOptions); + } + + /** + * Expected query parameter: kind=<any string> + * Expected response body: + * ```json + * { + * "name": <any string>, + * "kind": "real" + * } + * ```. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param kind The kind 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 used in internal operations, should be generated but not exported along with {@link Response} on + * successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> discriminatorWithResponse(String kind, RequestOptions requestOptions) { + return this.serviceClient.discriminatorWithResponseAsync(kind, requestOptions); + } + + /** + * Expected query parameter: name=<any string> + * Expected response body: + * ```json + * { + * "name": <any string>, + * "inner": + * { + * "name": <any string> + * } + * } + * ```. + * + * @param name The name 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 used in internal operations, should be generated but not exported on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono operation(String name) { + // Generated convenience method for operationWithResponse + RequestOptions requestOptions = new RequestOptions(); + return operationWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(OuterModel.class)); + } + + /** + * Expected query parameter: kind=<any string> + * Expected response body: + * ```json + * { + * "name": <any string>, + * "kind": "real" + * } + * ```. + * + * @param kind The kind 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 used in internal operations, should be generated but not exported on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono discriminator(String kind) { + // Generated convenience method for discriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return discriminatorWithResponse(kind, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AbstractModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/RelativeModelInOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/RelativeModelInOperationClient.java new file mode 100644 index 000000000..f49e30819 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/RelativeModelInOperationClient.java @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access; + +import com._specs_.azure.clientgenerator.core.access.implementation.RelativeModelInOperationsImpl; +import com._specs_.azure.clientgenerator.core.access.implementation.models.AbstractModel; +import com._specs_.azure.clientgenerator.core.access.implementation.models.OuterModel; +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; + +/** + * Initializes a new instance of the synchronous AccessClient type. + */ +@ServiceClient(builder = AccessClientBuilder.class) +public final class RelativeModelInOperationClient { + @Generated + private final RelativeModelInOperationsImpl serviceClient; + + /** + * Initializes an instance of RelativeModelInOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RelativeModelInOperationClient(RelativeModelInOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Expected query parameter: name=<any string> + * Expected response body: + * ```json + * { + * "name": <any string>, + * "inner": + * { + * "name": <any string> + * } + * } + * ```. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     inner (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name 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 used in internal operations, should be generated but not exported along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response operationWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.operationWithResponse(name, requestOptions); + } + + /** + * Expected query parameter: kind=<any string> + * Expected response body: + * ```json + * { + * "name": <any string>, + * "kind": "real" + * } + * ```. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param kind The kind 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 used in internal operations, should be generated but not exported along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response discriminatorWithResponse(String kind, RequestOptions requestOptions) { + return this.serviceClient.discriminatorWithResponse(kind, requestOptions); + } + + /** + * Expected query parameter: name=<any string> + * Expected response body: + * ```json + * { + * "name": <any string>, + * "inner": + * { + * "name": <any string> + * } + * } + * ```. + * + * @param name The name 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 used in internal operations, should be generated but not exported. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + OuterModel operation(String name) { + // Generated convenience method for operationWithResponse + RequestOptions requestOptions = new RequestOptions(); + return operationWithResponse(name, requestOptions).getValue().toObject(OuterModel.class); + } + + /** + * Expected query parameter: kind=<any string> + * Expected response body: + * ```json + * { + * "name": <any string>, + * "kind": "real" + * } + * ```. + * + * @param kind The kind 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 used in internal operations, should be generated but not exported. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + AbstractModel discriminator(String kind) { + // Generated convenience method for discriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return discriminatorWithResponse(kind, requestOptions).getValue().toObject(AbstractModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/SharedModelInOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/SharedModelInOperationAsyncClient.java new file mode 100644 index 000000000..8b3caf31c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/SharedModelInOperationAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access; + +import com._specs_.azure.clientgenerator.core.access.implementation.SharedModelInOperationsImpl; +import com._specs_.azure.clientgenerator.core.access.models.SharedModel; +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 reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AccessClient type. + */ +@ServiceClient(builder = AccessClientBuilder.class, isAsync = true) +public final class SharedModelInOperationAsyncClient { + @Generated + private final SharedModelInOperationsImpl serviceClient; + + /** + * Initializes an instance of SharedModelInOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SharedModelInOperationAsyncClient(SharedModelInOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The publicMethod operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used by both public and internal operation along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> publicMethodWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.publicMethodWithResponseAsync(name, requestOptions); + } + + /** + * The internal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used by both public and internal operation along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> internalWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.internalWithResponseAsync(name, requestOptions); + } + + /** + * The publicMethod operation. + * + * @param name The name 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 used by both public and internal operation on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono publicMethod(String name) { + // Generated convenience method for publicMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return publicMethodWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SharedModel.class)); + } + + /** + * The internal operation. + * + * @param name The name 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 used by both public and internal operation on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono internal(String name) { + // Generated convenience method for internalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return internalWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SharedModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/SharedModelInOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/SharedModelInOperationClient.java new file mode 100644 index 000000000..dd99a503d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/SharedModelInOperationClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access; + +import com._specs_.azure.clientgenerator.core.access.implementation.SharedModelInOperationsImpl; +import com._specs_.azure.clientgenerator.core.access.models.SharedModel; +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; + +/** + * Initializes a new instance of the synchronous AccessClient type. + */ +@ServiceClient(builder = AccessClientBuilder.class) +public final class SharedModelInOperationClient { + @Generated + private final SharedModelInOperationsImpl serviceClient; + + /** + * Initializes an instance of SharedModelInOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SharedModelInOperationClient(SharedModelInOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The publicMethod operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used by both public and internal operation along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response publicMethodWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.publicMethodWithResponse(name, requestOptions); + } + + /** + * The internal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used by both public and internal operation along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response internalWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.internalWithResponse(name, requestOptions); + } + + /** + * The publicMethod operation. + * + * @param name The name 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 used by both public and internal operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SharedModel publicMethod(String name) { + // Generated convenience method for publicMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return publicMethodWithResponse(name, requestOptions).getValue().toObject(SharedModel.class); + } + + /** + * The internal operation. + * + * @param name The name 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 used by both public and internal operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + SharedModel internal(String name) { + // Generated convenience method for internalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return internalWithResponse(name, requestOptions).getValue().toObject(SharedModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/AccessClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/AccessClientImpl.java new file mode 100644 index 000000000..ae5fdc17a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/AccessClientImpl.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the AccessClient type. + */ +public final class AccessClientImpl { + /** + * 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; + } + + /** + * The PublicOperationsImpl object to access its operations. + */ + private final PublicOperationsImpl publicOperations; + + /** + * Gets the PublicOperationsImpl object to access its operations. + * + * @return the PublicOperationsImpl object. + */ + public PublicOperationsImpl getPublicOperations() { + return this.publicOperations; + } + + /** + * The InternalOperationsImpl object to access its operations. + */ + private final InternalOperationsImpl internalOperations; + + /** + * Gets the InternalOperationsImpl object to access its operations. + * + * @return the InternalOperationsImpl object. + */ + public InternalOperationsImpl getInternalOperations() { + return this.internalOperations; + } + + /** + * The SharedModelInOperationsImpl object to access its operations. + */ + private final SharedModelInOperationsImpl sharedModelInOperations; + + /** + * Gets the SharedModelInOperationsImpl object to access its operations. + * + * @return the SharedModelInOperationsImpl object. + */ + public SharedModelInOperationsImpl getSharedModelInOperations() { + return this.sharedModelInOperations; + } + + /** + * The RelativeModelInOperationsImpl object to access its operations. + */ + private final RelativeModelInOperationsImpl relativeModelInOperations; + + /** + * Gets the RelativeModelInOperationsImpl object to access its operations. + * + * @return the RelativeModelInOperationsImpl object. + */ + public RelativeModelInOperationsImpl getRelativeModelInOperations() { + return this.relativeModelInOperations; + } + + /** + * Initializes an instance of AccessClient client. + * + * @param endpoint Service host. + */ + public AccessClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of AccessClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public AccessClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of AccessClient 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 AccessClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.publicOperations = new PublicOperationsImpl(this); + this.internalOperations = new InternalOperationsImpl(this); + this.sharedModelInOperations = new SharedModelInOperationsImpl(this); + this.relativeModelInOperations = new RelativeModelInOperationsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/InternalOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/InternalOperationsImpl.java new file mode 100644 index 000000000..d1cec38a8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/InternalOperationsImpl.java @@ -0,0 +1,277 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +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.BinaryData; +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 InternalOperations. + */ +public final class InternalOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final InternalOperationsService service; + + /** + * The service client containing this operation class. + */ + private final AccessClientImpl client; + + /** + * Initializes an instance of InternalOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + InternalOperationsImpl(AccessClientImpl client) { + this.service = RestProxy.create(InternalOperationsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AccessClientInternalOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AccessClientInternal") + public interface InternalOperationsService { + @Get("/azure/client-generator-core/access/internalOperation/noDecoratorInInternal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> noDecoratorInInternal(@HostParam("endpoint") String endpoint, + @QueryParam("name") String name, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/azure/client-generator-core/access/internalOperation/noDecoratorInInternal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response noDecoratorInInternalSync(@HostParam("endpoint") String endpoint, + @QueryParam("name") String name, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/azure/client-generator-core/access/internalOperation/internalDecoratorInInternal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> internalDecoratorInInternal(@HostParam("endpoint") String endpoint, + @QueryParam("name") String name, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/azure/client-generator-core/access/internalOperation/internalDecoratorInInternal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response internalDecoratorInInternalSync(@HostParam("endpoint") String endpoint, + @QueryParam("name") String name, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/azure/client-generator-core/access/internalOperation/publicDecoratorInInternal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> publicDecoratorInInternal(@HostParam("endpoint") String endpoint, + @QueryParam("name") String name, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/azure/client-generator-core/access/internalOperation/publicDecoratorInInternal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response publicDecoratorInInternalSync(@HostParam("endpoint") String endpoint, + @QueryParam("name") String name, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * The noDecoratorInInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in an internal operation, should be generated but not exported along with {@link Response} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> noDecoratorInInternalWithResponseAsync(String name, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.noDecoratorInInternal(this.client.getEndpoint(), name, accept, requestOptions, context)); + } + + /** + * The noDecoratorInInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in an internal operation, should be generated but not exported along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response noDecoratorInInternalWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.noDecoratorInInternalSync(this.client.getEndpoint(), name, accept, requestOptions, Context.NONE); + } + + /** + * The internalDecoratorInInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in an internal operation, should be generated but not exported along with {@link Response} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> internalDecoratorInInternalWithResponseAsync(String name, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.internalDecoratorInInternal(this.client.getEndpoint(), name, + accept, requestOptions, context)); + } + + /** + * The internalDecoratorInInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in an internal operation, should be generated but not exported along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response internalDecoratorInInternalWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.internalDecoratorInInternalSync(this.client.getEndpoint(), name, accept, requestOptions, + Context.NONE); + } + + /** + * The publicDecoratorInInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in an internal operation but with public decorator, should be generated and exported along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> publicDecoratorInInternalWithResponseAsync(String name, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.publicDecoratorInInternal(this.client.getEndpoint(), name, + accept, requestOptions, context)); + } + + /** + * The publicDecoratorInInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in an internal operation but with public decorator, should be generated and exported along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response publicDecoratorInInternalWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.publicDecoratorInInternalSync(this.client.getEndpoint(), name, accept, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/PublicOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/PublicOperationsImpl.java new file mode 100644 index 000000000..e6aaefc24 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/PublicOperationsImpl.java @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +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.BinaryData; +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 PublicOperations. + */ +public final class PublicOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PublicOperationsService service; + + /** + * The service client containing this operation class. + */ + private final AccessClientImpl client; + + /** + * Initializes an instance of PublicOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PublicOperationsImpl(AccessClientImpl client) { + this.service + = RestProxy.create(PublicOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AccessClientPublicOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AccessClientPublicOp") + public interface PublicOperationsService { + @Get("/azure/client-generator-core/access/publicOperation/noDecoratorInPublic") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> noDecoratorInPublic(@HostParam("endpoint") String endpoint, + @QueryParam("name") String name, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/azure/client-generator-core/access/publicOperation/noDecoratorInPublic") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response noDecoratorInPublicSync(@HostParam("endpoint") String endpoint, + @QueryParam("name") String name, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/azure/client-generator-core/access/publicOperation/publicDecoratorInPublic") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> publicDecoratorInPublic(@HostParam("endpoint") String endpoint, + @QueryParam("name") String name, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/azure/client-generator-core/access/publicOperation/publicDecoratorInPublic") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response publicDecoratorInPublicSync(@HostParam("endpoint") String endpoint, + @QueryParam("name") String name, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * The noDecoratorInPublic operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in a public operation, should be generated and exported along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> noDecoratorInPublicWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.noDecoratorInPublic(this.client.getEndpoint(), name, accept, requestOptions, context)); + } + + /** + * The noDecoratorInPublic operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in a public operation, should be generated and exported along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response noDecoratorInPublicWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.noDecoratorInPublicSync(this.client.getEndpoint(), name, accept, requestOptions, Context.NONE); + } + + /** + * The publicDecoratorInPublic operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in a public operation, should be generated and exported along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> publicDecoratorInPublicWithResponseAsync(String name, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.publicDecoratorInPublic(this.client.getEndpoint(), name, accept, + requestOptions, context)); + } + + /** + * The publicDecoratorInPublic operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used in a public operation, should be generated and exported along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response publicDecoratorInPublicWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.publicDecoratorInPublicSync(this.client.getEndpoint(), name, accept, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/RelativeModelInOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/RelativeModelInOperationsImpl.java new file mode 100644 index 000000000..4f77f36c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/RelativeModelInOperationsImpl.java @@ -0,0 +1,240 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +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.BinaryData; +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 RelativeModelInOperations. + */ +public final class RelativeModelInOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RelativeModelInOperationsService service; + + /** + * The service client containing this operation class. + */ + private final AccessClientImpl client; + + /** + * Initializes an instance of RelativeModelInOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + RelativeModelInOperationsImpl(AccessClientImpl client) { + this.service = RestProxy.create(RelativeModelInOperationsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AccessClientRelativeModelInOperations to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AccessClientRelative") + public interface RelativeModelInOperationsService { + @Get("/azure/client-generator-core/access/relativeModelInOperation/operation") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> operation(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/access/relativeModelInOperation/operation") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response operationSync(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/access/relativeModelInOperation/discriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> discriminator(@HostParam("endpoint") String endpoint, + @QueryParam("kind") String kind, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/azure/client-generator-core/access/relativeModelInOperation/discriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response discriminatorSync(@HostParam("endpoint") String endpoint, @QueryParam("kind") String kind, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Expected query parameter: name=<any string> + * Expected response body: + * ```json + * { + * "name": <any string>, + * "inner": + * { + * "name": <any string> + * } + * } + * ```. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     inner (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name 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 used in internal operations, should be generated but not exported along with {@link Response} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> operationWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.operation(this.client.getEndpoint(), name, accept, requestOptions, context)); + } + + /** + * Expected query parameter: name=<any string> + * Expected response body: + * ```json + * { + * "name": <any string>, + * "inner": + * { + * "name": <any string> + * } + * } + * ```. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     inner (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name 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 used in internal operations, should be generated but not exported along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response operationWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.operationSync(this.client.getEndpoint(), name, accept, requestOptions, Context.NONE); + } + + /** + * Expected query parameter: kind=<any string> + * Expected response body: + * ```json + * { + * "name": <any string>, + * "kind": "real" + * } + * ```. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param kind The kind 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 used in internal operations, should be generated but not exported along with {@link Response} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> discriminatorWithResponseAsync(String kind, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.discriminator(this.client.getEndpoint(), kind, accept, requestOptions, context)); + } + + /** + * Expected query parameter: kind=<any string> + * Expected response body: + * ```json + * { + * "name": <any string>, + * "kind": "real" + * } + * ```. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param kind The kind 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 used in internal operations, should be generated but not exported along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response discriminatorWithResponse(String kind, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.discriminatorSync(this.client.getEndpoint(), kind, accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/SharedModelInOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/SharedModelInOperationsImpl.java new file mode 100644 index 000000000..62910d08d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/SharedModelInOperationsImpl.java @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +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.BinaryData; +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 SharedModelInOperations. + */ +public final class SharedModelInOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SharedModelInOperationsService service; + + /** + * The service client containing this operation class. + */ + private final AccessClientImpl client; + + /** + * Initializes an instance of SharedModelInOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SharedModelInOperationsImpl(AccessClientImpl client) { + this.service = RestProxy.create(SharedModelInOperationsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AccessClientSharedModelInOperations to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AccessClientSharedMo") + public interface SharedModelInOperationsService { + @Get("/azure/client-generator-core/access/sharedModelInOperation/public") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> publicMethod(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/access/sharedModelInOperation/public") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response publicMethodSync(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/access/sharedModelInOperation/internal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> internal(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/access/sharedModelInOperation/internal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response internalSync(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * The publicMethod operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used by both public and internal operation along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> publicMethodWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.publicMethod(this.client.getEndpoint(), name, accept, requestOptions, context)); + } + + /** + * The publicMethod operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used by both public and internal operation along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response publicMethodWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.publicMethodSync(this.client.getEndpoint(), name, accept, requestOptions, Context.NONE); + } + + /** + * The internal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used by both public and internal operation along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> internalWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.internal(this.client.getEndpoint(), name, accept, requestOptions, context)); + } + + /** + * The internal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 used by both public and internal operation along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response internalWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.internalSync(this.client.getEndpoint(), name, accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/AbstractModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/AbstractModel.java new file mode 100644 index 000000000..a1c9c9c75 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/AbstractModel.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.implementation.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; + +/** + * Used in internal operations, should be generated but not exported. + */ +@Immutable +public class AbstractModel implements JsonSerializable { + /* + * Discriminator property for AbstractModel. + */ + @Generated + String kind; + + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of AbstractModel class. + * + * @param name the name value to set. + */ + @Generated + protected AbstractModel(String name) { + this.name = name; + this.kind = "AbstractModel"; + } + + /** + * Get the kind property: Discriminator property for AbstractModel. + * + * @return the kind value. + */ + @Generated + public String getKind() { + return this.kind; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + void toJsonShared(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("kind", this.kind); + } + + /** + * Reads an instance of AbstractModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AbstractModel 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 AbstractModel. + */ + @Generated + public static AbstractModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("real".equals(discriminatorValue)) { + return RealModel.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static AbstractModel fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + AbstractModel deserializedAbstractModel = new AbstractModel(name); + deserializedAbstractModel.kind = kind; + + return deserializedAbstractModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/BaseModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/BaseModel.java new file mode 100644 index 000000000..a07093e2f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/BaseModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.implementation.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; + +/** + * Used in internal operations, should be generated but not exported. + */ +@Immutable +public class BaseModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of BaseModel class. + * + * @param name the name value to set. + */ + @Generated + protected BaseModel(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BaseModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BaseModel 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 BaseModel. + */ + @Generated + public static BaseModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new BaseModel(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/InnerModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/InnerModel.java new file mode 100644 index 000000000..f25467917 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/InnerModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.implementation.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; + +/** + * Used in internal operations, should be generated but not exported. + */ +@Immutable +public final class InnerModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of InnerModel class. + * + * @param name the name value to set. + */ + @Generated + private InnerModel(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerModel 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 InnerModel. + */ + @Generated + public static InnerModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new InnerModel(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/InternalDecoratorModelInInternal.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/InternalDecoratorModelInInternal.java new file mode 100644 index 000000000..ef5a20cd5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/InternalDecoratorModelInInternal.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.implementation.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; + +/** + * Used in an internal operation, should be generated but not exported. + */ +@Immutable +public final class InternalDecoratorModelInInternal implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of InternalDecoratorModelInInternal class. + * + * @param name the name value to set. + */ + @Generated + private InternalDecoratorModelInInternal(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InternalDecoratorModelInInternal from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InternalDecoratorModelInInternal 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 InternalDecoratorModelInInternal. + */ + @Generated + public static InternalDecoratorModelInInternal fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new InternalDecoratorModelInInternal(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/NoDecoratorModelInInternal.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/NoDecoratorModelInInternal.java new file mode 100644 index 000000000..9a68f77fa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/NoDecoratorModelInInternal.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.implementation.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; + +/** + * Used in an internal operation, should be generated but not exported. + */ +@Immutable +public final class NoDecoratorModelInInternal implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of NoDecoratorModelInInternal class. + * + * @param name the name value to set. + */ + @Generated + private NoDecoratorModelInInternal(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NoDecoratorModelInInternal from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NoDecoratorModelInInternal 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 NoDecoratorModelInInternal. + */ + @Generated + public static NoDecoratorModelInInternal fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new NoDecoratorModelInInternal(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/OuterModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/OuterModel.java new file mode 100644 index 000000000..3e81a845f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/OuterModel.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 com._specs_.azure.clientgenerator.core.access.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Used in internal operations, should be generated but not exported. + */ +@Immutable +public final class OuterModel extends BaseModel { + /* + * The inner property. + */ + @Generated + private final InnerModel inner; + + /** + * Creates an instance of OuterModel class. + * + * @param name the name value to set. + * @param inner the inner value to set. + */ + @Generated + private OuterModel(String name, InnerModel inner) { + super(name); + this.inner = inner; + } + + /** + * Get the inner property: The inner property. + * + * @return the inner value. + */ + @Generated + public InnerModel getInner() { + return this.inner; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeJsonField("inner", this.inner); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OuterModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OuterModel 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 OuterModel. + */ + @Generated + public static OuterModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + InnerModel inner = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("inner".equals(fieldName)) { + inner = InnerModel.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new OuterModel(name, inner); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/RealModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/RealModel.java new file mode 100644 index 000000000..891e6fa2b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/RealModel.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Used in internal operations, should be generated but not exported. + */ +@Immutable +public final class RealModel extends AbstractModel { + /** + * Creates an instance of RealModel class. + * + * @param name the name value to set. + */ + @Generated + private RealModel(String name) { + super(name); + this.kind = "real"; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RealModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RealModel 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 RealModel. + */ + @Generated + public static RealModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String kind = "real"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + RealModel deserializedRealModel = new RealModel(name); + deserializedRealModel.kind = kind; + + return deserializedRealModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/models/package-info.java new file mode 100644 index 000000000..1217a1672 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/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 Access. + * Test for internal decorator. + * + */ +package com._specs_.azure.clientgenerator.core.access.implementation.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/implementation/package-info.java new file mode 100644 index 000000000..6647b739f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/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 Access. + * Test for internal decorator. + * + */ +package com._specs_.azure.clientgenerator.core.access.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/NoDecoratorModelInPublic.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/NoDecoratorModelInPublic.java new file mode 100644 index 000000000..a9b58bb9f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/NoDecoratorModelInPublic.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.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; + +/** + * Used in a public operation, should be generated and exported. + */ +@Immutable +public final class NoDecoratorModelInPublic implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of NoDecoratorModelInPublic class. + * + * @param name the name value to set. + */ + @Generated + private NoDecoratorModelInPublic(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NoDecoratorModelInPublic from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NoDecoratorModelInPublic 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 NoDecoratorModelInPublic. + */ + @Generated + public static NoDecoratorModelInPublic fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new NoDecoratorModelInPublic(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/PublicDecoratorModelInInternal.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/PublicDecoratorModelInInternal.java new file mode 100644 index 000000000..89316a7b0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/PublicDecoratorModelInInternal.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.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; + +/** + * Used in an internal operation but with public decorator, should be generated and exported. + */ +@Immutable +public final class PublicDecoratorModelInInternal implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of PublicDecoratorModelInInternal class. + * + * @param name the name value to set. + */ + @Generated + private PublicDecoratorModelInInternal(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PublicDecoratorModelInInternal from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PublicDecoratorModelInInternal 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 PublicDecoratorModelInInternal. + */ + @Generated + public static PublicDecoratorModelInInternal fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new PublicDecoratorModelInInternal(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/PublicDecoratorModelInPublic.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/PublicDecoratorModelInPublic.java new file mode 100644 index 000000000..29ca90615 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/PublicDecoratorModelInPublic.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.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; + +/** + * Used in a public operation, should be generated and exported. + */ +@Immutable +public final class PublicDecoratorModelInPublic implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of PublicDecoratorModelInPublic class. + * + * @param name the name value to set. + */ + @Generated + private PublicDecoratorModelInPublic(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PublicDecoratorModelInPublic from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PublicDecoratorModelInPublic 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 PublicDecoratorModelInPublic. + */ + @Generated + public static PublicDecoratorModelInPublic fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new PublicDecoratorModelInPublic(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/SharedModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/SharedModel.java new file mode 100644 index 000000000..d44595619 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/SharedModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.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; + +/** + * Used by both public and internal operation. It should be generated and exported. + */ +@Immutable +public final class SharedModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of SharedModel class. + * + * @param name the name value to set. + */ + @Generated + private SharedModel(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SharedModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SharedModel 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 SharedModel. + */ + @Generated + public static SharedModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SharedModel(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/models/package-info.java new file mode 100644 index 000000000..d9fbdb89f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/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 Access. + * Test for internal decorator. + * + */ +package com._specs_.azure.clientgenerator.core.access.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/package-info.java new file mode 100644 index 000000000..e1e7d36b6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/access/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 Access. + * Test for internal decorator. + * + */ +package com._specs_.azure.clientgenerator.core.access; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageAsyncClient.java new file mode 100644 index 000000000..af440eded --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageAsyncClient.java @@ -0,0 +1,237 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.usage; + +import com._specs_.azure.clientgenerator.core.usage.implementation.ModelInOperationsImpl; +import com._specs_.azure.clientgenerator.core.usage.models.InputModel; +import com._specs_.azure.clientgenerator.core.usage.models.OutputModel; +import com._specs_.azure.clientgenerator.core.usage.models.RoundTripModel; +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 reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UsageClient type. + */ +@ServiceClient(builder = UsageClientBuilder.class, isAsync = true) +public final class UsageAsyncClient { + @Generated + private final ModelInOperationsImpl serviceClient; + + /** + * Initializes an instance of UsageAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UsageAsyncClient(ModelInOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Expected body parameter: + * ```json + * { + * "name": <any string> + * } + * ```. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> inputToInputOutputWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.inputToInputOutputWithResponseAsync(body, requestOptions); + } + + /** + * Expected response body: + * ```json + * { + * "name": <any string> + * } + * ```. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 usage override to roundtrip along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> outputToInputOutputWithResponse(RequestOptions requestOptions) { + return this.serviceClient.outputToInputOutputWithResponseAsync(requestOptions); + } + + /** + * "ResultModel" should be usage=output, as it is read-only and does not exist in request body. + * + * Expected body parameter: + * ```json + * { + * } + * ``` + * + * Expected response body: + * ```json + * { + * "result": { + * "name": <any string> + * } + * } + * ```. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     result (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     result (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> modelInReadOnlyPropertyWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.modelInReadOnlyPropertyWithResponseAsync(body, requestOptions); + } + + /** + * Expected body parameter: + * ```json + * { + * "name": <any string> + * } + * ```. + * + * @param body The body 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 inputToInputOutput(InputModel body) { + // Generated convenience method for inputToInputOutputWithResponse + RequestOptions requestOptions = new RequestOptions(); + return inputToInputOutputWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Expected response body: + * ```json + * { + * "name": <any string> + * } + * ```. + * + * @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 usage override to roundtrip on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono outputToInputOutput() { + // Generated convenience method for outputToInputOutputWithResponse + RequestOptions requestOptions = new RequestOptions(); + return outputToInputOutputWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(OutputModel.class)); + } + + /** + * "ResultModel" should be usage=output, as it is read-only and does not exist in request body. + * + * Expected body parameter: + * ```json + * { + * } + * ``` + * + * Expected response body: + * ```json + * { + * "result": { + * "name": <any string> + * } + * } + * ```. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono modelInReadOnlyProperty(RoundTripModel body) { + // Generated convenience method for modelInReadOnlyPropertyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return modelInReadOnlyPropertyWithResponse(BinaryData.fromObject(body), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(RoundTripModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageClient.java new file mode 100644 index 000000000..47b5fda03 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageClient.java @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.usage; + +import com._specs_.azure.clientgenerator.core.usage.implementation.ModelInOperationsImpl; +import com._specs_.azure.clientgenerator.core.usage.models.InputModel; +import com._specs_.azure.clientgenerator.core.usage.models.OutputModel; +import com._specs_.azure.clientgenerator.core.usage.models.RoundTripModel; +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; + +/** + * Initializes a new instance of the synchronous UsageClient type. + */ +@ServiceClient(builder = UsageClientBuilder.class) +public final class UsageClient { + @Generated + private final ModelInOperationsImpl serviceClient; + + /** + * Initializes an instance of UsageClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UsageClient(ModelInOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Expected body parameter: + * ```json + * { + * "name": <any string> + * } + * ```. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 inputToInputOutputWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.inputToInputOutputWithResponse(body, requestOptions); + } + + /** + * Expected response body: + * ```json + * { + * "name": <any string> + * } + * ```. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 usage override to roundtrip along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response outputToInputOutputWithResponse(RequestOptions requestOptions) { + return this.serviceClient.outputToInputOutputWithResponse(requestOptions); + } + + /** + * "ResultModel" should be usage=output, as it is read-only and does not exist in request body. + * + * Expected body parameter: + * ```json + * { + * } + * ``` + * + * Expected response body: + * ```json + * { + * "result": { + * "name": <any string> + * } + * } + * ```. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     result (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     result (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response modelInReadOnlyPropertyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.modelInReadOnlyPropertyWithResponse(body, requestOptions); + } + + /** + * Expected body parameter: + * ```json + * { + * "name": <any string> + * } + * ```. + * + * @param body The body 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 inputToInputOutput(InputModel body) { + // Generated convenience method for inputToInputOutputWithResponse + RequestOptions requestOptions = new RequestOptions(); + inputToInputOutputWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Expected response body: + * ```json + * { + * "name": <any string> + * } + * ```. + * + * @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 usage override to roundtrip. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public OutputModel outputToInputOutput() { + // Generated convenience method for outputToInputOutputWithResponse + RequestOptions requestOptions = new RequestOptions(); + return outputToInputOutputWithResponse(requestOptions).getValue().toObject(OutputModel.class); + } + + /** + * "ResultModel" should be usage=output, as it is read-only and does not exist in request body. + * + * Expected body parameter: + * ```json + * { + * } + * ``` + * + * Expected response body: + * ```json + * { + * "result": { + * "name": <any string> + * } + * } + * ```. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public RoundTripModel modelInReadOnlyProperty(RoundTripModel body) { + // Generated convenience method for modelInReadOnlyPropertyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return modelInReadOnlyPropertyWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(RoundTripModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageClientBuilder.java new file mode 100644 index 000000000..16d7b3ae9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/UsageClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.usage; + +import com._specs_.azure.clientgenerator.core.usage.implementation.UsageClientImpl; +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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; + +/** + * A builder for creating a new instance of the UsageClient type. + */ +@ServiceClientBuilder(serviceClients = { UsageClient.class, UsageAsyncClient.class }) +public final class UsageClientBuilder 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("_specs_-azure-clientgenerator-core-usage.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the UsageClientBuilder. + */ + @Generated + public UsageClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UsageClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UsageClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UsageClientBuilder 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 UsageClientBuilder 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 UsageClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UsageClientBuilder 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 UsageClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UsageClientBuilder 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 UsageClientBuilder. + */ + @Generated + public UsageClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of UsageClientImpl with the provided parameters. + * + * @return an instance of UsageClientImpl. + */ + @Generated + private UsageClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + UsageClientImpl client + = new UsageClientImpl(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 UsageAsyncClient class. + * + * @return an instance of UsageAsyncClient. + */ + @Generated + public UsageAsyncClient buildAsyncClient() { + return new UsageAsyncClient(buildInnerClient().getModelInOperations()); + } + + /** + * Builds an instance of UsageClient class. + * + * @return an instance of UsageClient. + */ + @Generated + public UsageClient buildClient() { + return new UsageClient(buildInnerClient().getModelInOperations()); + } + + private static final ClientLogger LOGGER = new ClientLogger(UsageClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/ModelInOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/ModelInOperationsImpl.java new file mode 100644 index 000000000..4c8f3a930 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/ModelInOperationsImpl.java @@ -0,0 +1,345 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.usage.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ModelInOperations. + */ +public final class ModelInOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelInOperationsService service; + + /** + * The service client containing this operation class. + */ + private final UsageClientImpl client; + + /** + * Initializes an instance of ModelInOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelInOperationsImpl(UsageClientImpl client) { + this.service + = RestProxy.create(ModelInOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for UsageClientModelInOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UsageClientModelInOp") + public interface ModelInOperationsService { + @Post("/azure/client-generator-core/usage/inputToInputOutput") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> inputToInputOutput(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/azure/client-generator-core/usage/inputToInputOutput") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response inputToInputOutputSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/usage/outputToInputOutput") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> outputToInputOutput(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/usage/outputToInputOutput") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response outputToInputOutputSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/azure/client-generator-core/usage/modelInReadOnlyProperty") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> modelInReadOnlyProperty(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/azure/client-generator-core/usage/modelInReadOnlyProperty") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response modelInReadOnlyPropertySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Expected body parameter: + * ```json + * { + * "name": <any string> + * } + * ```. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> inputToInputOutputWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.inputToInputOutput(this.client.getEndpoint(), contentType, body, + requestOptions, context)); + } + + /** + * Expected body parameter: + * ```json + * { + * "name": <any string> + * } + * ```. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 inputToInputOutputWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.inputToInputOutputSync(this.client.getEndpoint(), contentType, body, requestOptions, + Context.NONE); + } + + /** + * Expected response body: + * ```json + * { + * "name": <any string> + * } + * ```. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 usage override to roundtrip along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> outputToInputOutputWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.outputToInputOutput(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Expected response body: + * ```json + * { + * "name": <any string> + * } + * ```. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 usage override to roundtrip along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response outputToInputOutputWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.outputToInputOutputSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * "ResultModel" should be usage=output, as it is read-only and does not exist in request body. + * + * Expected body parameter: + * ```json + * { + * } + * ``` + * + * Expected response body: + * ```json + * { + * "result": { + * "name": <any string> + * } + * } + * ```. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     result (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     result (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> modelInReadOnlyPropertyWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.modelInReadOnlyProperty(this.client.getEndpoint(), contentType, + accept, body, requestOptions, context)); + } + + /** + * "ResultModel" should be usage=output, as it is read-only and does not exist in request body. + * + * Expected body parameter: + * ```json + * { + * } + * ``` + * + * Expected response body: + * ```json + * { + * "result": { + * "name": <any string> + * } + * } + * ```. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     result (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     result (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response modelInReadOnlyPropertyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.modelInReadOnlyPropertySync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/UsageClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/UsageClientImpl.java new file mode 100644 index 000000000..72ec8e251 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/UsageClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.usage.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the UsageClient type. + */ +public final class UsageClientImpl { + /** + * 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; + } + + /** + * The ModelInOperationsImpl object to access its operations. + */ + private final ModelInOperationsImpl modelInOperations; + + /** + * Gets the ModelInOperationsImpl object to access its operations. + * + * @return the ModelInOperationsImpl object. + */ + public ModelInOperationsImpl getModelInOperations() { + return this.modelInOperations; + } + + /** + * Initializes an instance of UsageClient client. + * + * @param endpoint Service host. + */ + public UsageClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of UsageClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public UsageClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of UsageClient 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 UsageClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.modelInOperations = new ModelInOperationsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/implementation/package-info.java new file mode 100644 index 000000000..35a5c6d88 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/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 Usage. + * Test for internal decorator. + * + */ +package com._specs_.azure.clientgenerator.core.usage.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/InputModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/InputModel.java new file mode 100644 index 000000000..ea68f203a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/InputModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.usage.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; + +/** + * Usage override to roundtrip. + */ +@Immutable +public final class InputModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of InputModel class. + * + * @param name the name value to set. + */ + @Generated + public InputModel(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InputModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InputModel 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 InputModel. + */ + @Generated + public static InputModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new InputModel(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/OrphanModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/OrphanModel.java new file mode 100644 index 000000000..ac76f02e2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/OrphanModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.usage.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; + +/** + * Not used anywhere, but access is override to public so still need to be generated and exported with serialization. + */ +@Immutable +public final class OrphanModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of OrphanModel class. + * + * @param name the name value to set. + */ + @Generated + public OrphanModel(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OrphanModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OrphanModel 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 OrphanModel. + */ + @Generated + public static OrphanModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new OrphanModel(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/OutputModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/OutputModel.java new file mode 100644 index 000000000..59a1123ca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/OutputModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.usage.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; + +/** + * Usage override to roundtrip. + */ +@Immutable +public final class OutputModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of OutputModel class. + * + * @param name the name value to set. + */ + @Generated + public OutputModel(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OutputModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OutputModel 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 OutputModel. + */ + @Generated + public static OutputModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new OutputModel(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/ResultModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/ResultModel.java new file mode 100644 index 000000000..18428fb28 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/ResultModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.usage.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; + +/** + * The ResultModel model. + */ +@Immutable +public final class ResultModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ResultModel class. + * + * @param name the name value to set. + */ + @Generated + private ResultModel(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResultModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResultModel 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 ResultModel. + */ + @Generated + public static ResultModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ResultModel(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/RoundTripModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/RoundTripModel.java new file mode 100644 index 000000000..7ff291f02 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/RoundTripModel.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.usage.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; + +/** + * The RoundTripModel model. + */ +@Immutable +public final class RoundTripModel implements JsonSerializable { + /* + * The result property. + */ + @Generated + private ResultModel result; + + /** + * Creates an instance of RoundTripModel class. + */ + @Generated + public RoundTripModel() { + } + + /** + * Get the result property: The result property. + * + * @return the result value. + */ + @Generated + public ResultModel getResult() { + return this.result; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RoundTripModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RoundTripModel 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 RoundTripModel. + */ + @Generated + public static RoundTripModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RoundTripModel deserializedRoundTripModel = new RoundTripModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("result".equals(fieldName)) { + deserializedRoundTripModel.result = ResultModel.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedRoundTripModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/models/package-info.java new file mode 100644 index 000000000..91cbf21e4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/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 Usage. + * Test for internal decorator. + * + */ +package com._specs_.azure.clientgenerator.core.usage.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/package-info.java new file mode 100644 index 000000000..87cbf5528 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/clientgenerator/core/usage/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 Usage. + * Test for internal decorator. + * + */ +package com._specs_.azure.clientgenerator.core.usage; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/BasicAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/BasicAsyncClient.java new file mode 100644 index 000000000..fb9519930 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/BasicAsyncClient.java @@ -0,0 +1,524 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.basic; + +import com._specs_.azure.core.basic.implementation.BasicClientImpl; +import com._specs_.azure.core.basic.implementation.JsonMergePatchHelper; +import com._specs_.azure.core.basic.models.User; +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.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +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 java.util.List; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BasicClient type. + */ +@ServiceClient(builder = BasicClientBuilder.class, isAsync = true) +public final class BasicAsyncClient { + @Generated + private final BasicClientImpl serviceClient; + + /** + * Initializes an instance of BasicAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BasicAsyncClient(BasicClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Adds a user or updates a user's fields. + * + * Creates or updates a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param resource The resource instance. + * @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 details about a user along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateWithResponse(int id, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateWithResponseAsync(id, resource, requestOptions); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param resource The resource instance. + * @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 details about a user along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrReplaceWithResponse(int id, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.createOrReplaceWithResponseAsync(id, resource, requestOptions); + } + + /** + * Gets a user. + * + * Gets a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @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 user. + * + * Gets a User along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(int id, RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(id, requestOptions); + } + + /** + * Lists all users. + * + * Lists all Users. + *

Query Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
orderbyList<String>NoExpressions that specify the order of returned + * results. Call {@link RequestOptions#addQueryParam} to add string to array.
filterStringNoFilter the result list using the given expression.
selectList<String>NoSelect the specified fields to be included in the + * response. Call {@link RequestOptions#addQueryParam} to add string to array.
expandList<String>NoExpand the indicated resources into the response. + * Call {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(RequestOptions requestOptions) { + return this.serviceClient.listAsync(requestOptions); + } + + /** + * Deletes a user. + * + * Deletes a User. + * + * @param id The user's id. + * @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> deleteWithResponse(int id, RequestOptions requestOptions) { + return this.serviceClient.deleteWithResponseAsync(id, requestOptions); + } + + /** + * Exports a user. + * + * Exports a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param format The format of the data. + * @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 details about a user along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> exportWithResponse(int id, String format, RequestOptions requestOptions) { + return this.serviceClient.exportWithResponseAsync(id, format, requestOptions); + } + + /** + * Adds a user or updates a user's fields. + * + * Creates or updates a User. + * + * @param id The user's id. + * @param resource The resource instance. + * @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 details about a user on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrUpdate(int id, User resource) { + // Generated convenience method for createOrUpdateWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getUserAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getUserAccessor().prepareModelForJsonMergePatch(resource, false); + return createOrUpdateWithResponse(id, resourceInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(User.class)); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + * + * @param id The user's id. + * @param resource The resource instance. + * @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 details about a user on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrReplace(int id, User resource) { + // Generated convenience method for createOrReplaceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createOrReplaceWithResponse(id, BinaryData.fromObject(resource), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(User.class)); + } + + /** + * Gets a user. + * + * Gets a User. + * + * @param id The user's id. + * @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 user. + * + * Gets a User on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get(int id) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(id, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(User.class)); + } + + /** + * Lists all users. + * + * Lists all Users. + * + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @param orderBy Expressions that specify the order of returned results. + * @param filter Filter the result list using the given expression. + * @param select Select the specified fields to be included in the response. + * @param expand Expand the indicated resources into the response. + * @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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(Integer top, Integer skip, List orderBy, String filter, List select, + List expand) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + if (orderBy != null) { + for (String paramItemValue : orderBy) { + if (paramItemValue != null) { + requestOptions.addQueryParam("orderby", paramItemValue, false); + } + } + } + if (filter != null) { + requestOptions.addQueryParam("filter", filter, false); + } + if (select != null) { + for (String paramItemValue : select) { + if (paramItemValue != null) { + requestOptions.addQueryParam("select", paramItemValue, false); + } + } + } + if (expand != null) { + for (String paramItemValue : expand) { + if (paramItemValue != null) { + requestOptions.addQueryParam("expand", paramItemValue, false); + } + } + } + PagedFlux pagedFluxResponse = list(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(User.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Lists all users. + * + * Lists all Users. + * + * @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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = list(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(User.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Deletes a user. + * + * Deletes a User. + * + * @param id The user's id. + * @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 delete(int id) { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteWithResponse(id, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Exports a user. + * + * Exports a User. + * + * @param id The user's id. + * @param format The format of the data. + * @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 details about a user on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono export(int id, String format) { + // Generated convenience method for exportWithResponse + RequestOptions requestOptions = new RequestOptions(); + return exportWithResponse(id, format, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(User.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/BasicClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/BasicClient.java new file mode 100644 index 000000000..5dec8c617 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/BasicClient.java @@ -0,0 +1,488 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.basic; + +import com._specs_.azure.core.basic.implementation.BasicClientImpl; +import com._specs_.azure.core.basic.implementation.JsonMergePatchHelper; +import com._specs_.azure.core.basic.models.User; +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.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import java.util.List; + +/** + * Initializes a new instance of the synchronous BasicClient type. + */ +@ServiceClient(builder = BasicClientBuilder.class) +public final class BasicClient { + @Generated + private final BasicClientImpl serviceClient; + + /** + * Initializes an instance of BasicClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BasicClient(BasicClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Adds a user or updates a user's fields. + * + * Creates or updates a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param resource The resource instance. + * @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 details about a user along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(int id, BinaryData resource, RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateWithResponse(id, resource, requestOptions); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param resource The resource instance. + * @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 details about a user along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrReplaceWithResponse(int id, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.createOrReplaceWithResponse(id, resource, requestOptions); + } + + /** + * Gets a user. + * + * Gets a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @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 user. + * + * Gets a User along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(int id, RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(id, requestOptions); + } + + /** + * Lists all users. + * + * Lists all Users. + *

Query Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
orderbyList<String>NoExpressions that specify the order of returned + * results. Call {@link RequestOptions#addQueryParam} to add string to array.
filterStringNoFilter the result list using the given expression.
selectList<String>NoSelect the specified fields to be included in the + * response. Call {@link RequestOptions#addQueryParam} to add string to array.
expandList<String>NoExpand the indicated resources into the response. + * Call {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + return this.serviceClient.list(requestOptions); + } + + /** + * Deletes a user. + * + * Deletes a User. + * + * @param id The user's id. + * @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 deleteWithResponse(int id, RequestOptions requestOptions) { + return this.serviceClient.deleteWithResponse(id, requestOptions); + } + + /** + * Exports a user. + * + * Exports a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param format The format of the data. + * @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 details about a user along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response exportWithResponse(int id, String format, RequestOptions requestOptions) { + return this.serviceClient.exportWithResponse(id, format, requestOptions); + } + + /** + * Adds a user or updates a user's fields. + * + * Creates or updates a User. + * + * @param id The user's id. + * @param resource The resource instance. + * @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 details about a user. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public User createOrUpdate(int id, User resource) { + // Generated convenience method for createOrUpdateWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getUserAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getUserAccessor().prepareModelForJsonMergePatch(resource, false); + return createOrUpdateWithResponse(id, resourceInBinaryData, requestOptions).getValue().toObject(User.class); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + * + * @param id The user's id. + * @param resource The resource instance. + * @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 details about a user. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public User createOrReplace(int id, User resource) { + // Generated convenience method for createOrReplaceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createOrReplaceWithResponse(id, BinaryData.fromObject(resource), requestOptions).getValue() + .toObject(User.class); + } + + /** + * Gets a user. + * + * Gets a User. + * + * @param id The user's id. + * @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 user. + * + * Gets a User. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public User get(int id) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(id, requestOptions).getValue().toObject(User.class); + } + + /** + * Lists all users. + * + * Lists all Users. + * + * @param top The number of result items to return. + * @param skip The number of result items to skip. + * @param orderBy Expressions that specify the order of returned results. + * @param filter Filter the result list using the given expression. + * @param select Select the specified fields to be included in the response. + * @param expand Expand the indicated resources into the response. + * @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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Integer top, Integer skip, List orderBy, String filter, List select, + List expand) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (top != null) { + requestOptions.addQueryParam("top", String.valueOf(top), false); + } + if (skip != null) { + requestOptions.addQueryParam("skip", String.valueOf(skip), false); + } + if (orderBy != null) { + for (String paramItemValue : orderBy) { + if (paramItemValue != null) { + requestOptions.addQueryParam("orderby", paramItemValue, false); + } + } + } + if (filter != null) { + requestOptions.addQueryParam("filter", filter, false); + } + if (select != null) { + for (String paramItemValue : select) { + if (paramItemValue != null) { + requestOptions.addQueryParam("select", paramItemValue, false); + } + } + } + if (expand != null) { + for (String paramItemValue : expand) { + if (paramItemValue != null) { + requestOptions.addQueryParam("expand", paramItemValue, false); + } + } + } + return serviceClient.list(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(User.class)); + } + + /** + * Lists all users. + * + * Lists all Users. + * + * @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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.list(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(User.class)); + } + + /** + * Deletes a user. + * + * Deletes a User. + * + * @param id The user's id. + * @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 delete(int id) { + // Generated convenience method for deleteWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteWithResponse(id, requestOptions).getValue(); + } + + /** + * Exports a user. + * + * Exports a User. + * + * @param id The user's id. + * @param format The format of the data. + * @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 details about a user. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public User export(int id, String format) { + // Generated convenience method for exportWithResponse + RequestOptions requestOptions = new RequestOptions(); + return exportWithResponse(id, format, requestOptions).getValue().toObject(User.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/BasicClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/BasicClientBuilder.java new file mode 100644 index 000000000..8afed75e1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/BasicClientBuilder.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.basic; + +import com._specs_.azure.core.basic.implementation.BasicClientImpl; +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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; + +/** + * A builder for creating a new instance of the BasicClient type. + */ +@ServiceClientBuilder(serviceClients = { BasicClient.class, BasicAsyncClient.class }) +public final class BasicClientBuilder 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("_specs_-azure-core-basic.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the BasicClientBuilder. + */ + @Generated + public BasicClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BasicClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BasicClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BasicClientBuilder 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 BasicClientBuilder 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 BasicClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BasicClientBuilder 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 BasicClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BasicClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private BasicServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the BasicClientBuilder. + */ + @Generated + public BasicClientBuilder serviceVersion(BasicServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 BasicClientBuilder. + */ + @Generated + public BasicClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of BasicClientImpl with the provided parameters. + * + * @return an instance of BasicClientImpl. + */ + @Generated + private BasicClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + BasicServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : BasicServiceVersion.getLatest(); + BasicClientImpl client = new BasicClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, localServiceVersion); + 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 BasicAsyncClient class. + * + * @return an instance of BasicAsyncClient. + */ + @Generated + public BasicAsyncClient buildAsyncClient() { + return new BasicAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of BasicClient class. + * + * @return an instance of BasicClient. + */ + @Generated + public BasicClient buildClient() { + return new BasicClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(BasicClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/BasicServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/BasicServiceVersion.java new file mode 100644 index 000000000..99d3232c4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/BasicServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.basic; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of BasicClient. + */ +public enum BasicServiceVersion implements ServiceVersion { + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + BasicServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link BasicServiceVersion}. + */ + public static BasicServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/implementation/BasicClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/implementation/BasicClientImpl.java new file mode 100644 index 000000000..20ae11448 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/implementation/BasicClientImpl.java @@ -0,0 +1,1067 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.basic.implementation; + +import com._specs_.azure.core.basic.BasicServiceVersion; +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +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.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.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.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.UrlBuilder; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the BasicClient type. + */ +public final class BasicClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BasicClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final BasicServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public BasicServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 BasicClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public BasicClientImpl(String endpoint, BasicServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of BasicClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public BasicClientImpl(HttpPipeline httpPipeline, String endpoint, BasicServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of BasicClient 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. + * @param serviceVersion Service version. + */ + public BasicClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + BasicServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(BasicClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for BasicClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BasicClient") + public interface BasicClientService { + @Patch("/azure/core/basic/users/{id}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + Context context); + + @Patch("/azure/core/basic/users/{id}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + Context context); + + @Put("/azure/core/basic/users/{id}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrReplace(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Put("/azure/core/basic/users/{id}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createOrReplaceSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Get("/azure/core/basic/users/{id}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/core/basic/users/{id}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/core/basic/users") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/core/basic/users") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Delete("/azure/core/basic/users/{id}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Delete("/azure/core/basic/users/{id}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("id") int id, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Post("/azure/core/basic/users/{id}:export") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> export(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, @QueryParam("format") String format, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/azure/core/basic/users/{id}:export") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response exportSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, @QueryParam("format") String format, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * Adds a user or updates a user's fields. + * + * Creates or updates a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param resource The resource instance. + * @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 details about a user along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateWithResponseAsync(int id, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createOrUpdate(this.getEndpoint(), + this.getServiceVersion().getVersion(), id, contentType, accept, resource, requestOptions, context)); + } + + /** + * Adds a user or updates a user's fields. + * + * Creates or updates a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param resource The resource instance. + * @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 details about a user along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(int id, BinaryData resource, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, contentType, + accept, resource, requestOptions, Context.NONE); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param resource The resource instance. + * @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 details about a user along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrReplaceWithResponseAsync(int id, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createOrReplace(this.getEndpoint(), + this.getServiceVersion().getVersion(), id, contentType, accept, resource, requestOptions, context)); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param resource The resource instance. + * @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 details about a user along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrReplaceWithResponse(int id, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrReplaceSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, contentType, + accept, resource, requestOptions, Context.NONE); + } + + /** + * Gets a user. + * + * Gets a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @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 user. + * + * Gets a User along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(int id, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.getEndpoint(), this.getServiceVersion().getVersion(), + id, accept, requestOptions, context)); + } + + /** + * Gets a user. + * + * Gets a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @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 user. + * + * Gets a User along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(int id, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, accept, requestOptions, + Context.NONE); + } + + /** + * Lists all users. + * + * Lists all Users. + *

Query Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
orderbyList<String>NoExpressions that specify the order of returned + * results. Call {@link RequestOptions#addQueryParam} to add string to array.
filterStringNoFilter the result list using the given expression.
selectList<String>NoSelect the specified fields to be included in the + * response. Call {@link RequestOptions#addQueryParam} to add string to array.
expandList<String>NoExpand the indicated resources into the response. + * Call {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (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 paged collection of User items along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, + requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Lists all users. + * + * Lists all Users. + *

Query Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
orderbyList<String>NoExpressions that specify the order of returned + * results. Call {@link RequestOptions#addQueryParam} to add string to array.
filterStringNoFilter the result list using the given expression.
selectList<String>NoSelect the specified fields to be included in the + * response. Call {@link RequestOptions#addQueryParam} to add string to array.
expandList<String>NoExpand the indicated resources into the response. + * Call {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePageAsync(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * Lists all users. + * + * Lists all Users. + *

Query Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
orderbyList<String>NoExpressions that specify the order of returned + * results. Call {@link RequestOptions#addQueryParam} to add string to array.
filterStringNoFilter the result list using the given expression.
selectList<String>NoSelect the specified fields to be included in the + * response. Call {@link RequestOptions#addQueryParam} to add string to array.
expandList<String>NoExpand the indicated resources into the response. + * Call {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (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 paged collection of User items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, + requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Lists all users. + * + * Lists all Users. + *

Query Parameters

+ * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
topIntegerNoThe number of result items to return.
skipIntegerNoThe number of result items to skip.
maxpagesizeIntegerNoThe maximum number of result items per page.
orderbyList<String>NoExpressions that specify the order of returned + * results. Call {@link RequestOptions#addQueryParam} to add string to array.
filterStringNoFilter the result list using the given expression.
selectList<String>NoSelect the specified fields to be included in the + * response. Call {@link RequestOptions#addQueryParam} to add string to array.
expandList<String>NoExpand the indicated resources into the response. + * Call {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePage(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * Deletes a user. + * + * Deletes a User. + * + * @param id The user's id. + * @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> deleteWithResponseAsync(int id, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.delete(this.getEndpoint(), this.getServiceVersion().getVersion(), + id, accept, requestOptions, context)); + } + + /** + * Deletes a user. + * + * Deletes a User. + * + * @param id The user's id. + * @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 deleteWithResponse(int id, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, accept, requestOptions, + Context.NONE); + } + + /** + * Exports a user. + * + * Exports a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param format The format of the data. + * @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 details about a user along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> exportWithResponseAsync(int id, String format, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.export(this.getEndpoint(), this.getServiceVersion().getVersion(), + id, format, accept, requestOptions, context)); + } + + /** + * Exports a user. + * + * Exports a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param format The format of the data. + * @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 details about a user along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response exportWithResponse(int id, String format, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.exportSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, format, accept, + requestOptions, Context.NONE); + } + + /** + * Lists all users. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of User items along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Lists all users. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional, Required on create)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Optional, Required on create)
+     *             detail: String (Optional, Required on create)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of User items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/implementation/JsonMergePatchHelper.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/implementation/JsonMergePatchHelper.java new file mode 100644 index 000000000..cf80bc669 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/implementation/JsonMergePatchHelper.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.basic.implementation; + +import com._specs_.azure.core.basic.models.User; +import com._specs_.azure.core.basic.models.UserOrder; + +/** + * This is the Helper class to enable json merge patch serialization for a model. + */ +public class JsonMergePatchHelper { + private static UserAccessor userAccessor; + + public interface UserAccessor { + User prepareModelForJsonMergePatch(User user, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(User user); + } + + public static void setUserAccessor(UserAccessor accessor) { + userAccessor = accessor; + } + + public static UserAccessor getUserAccessor() { + return userAccessor; + } + + private static UserOrderAccessor userOrderAccessor; + + public interface UserOrderAccessor { + UserOrder prepareModelForJsonMergePatch(UserOrder userOrder, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(UserOrder userOrder); + } + + public static void setUserOrderAccessor(UserOrderAccessor accessor) { + userOrderAccessor = accessor; + } + + public static UserOrderAccessor getUserOrderAccessor() { + return userOrderAccessor; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/implementation/package-info.java new file mode 100644 index 000000000..bf79845a6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/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 Basic. + * Illustrates bodies templated with Azure Core. + * + */ +package com._specs_.azure.core.basic.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/models/User.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/models/User.java new file mode 100644 index 000000000..799ba77cf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/models/User.java @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.basic.models; + +import com._specs_.azure.core.basic.implementation.JsonMergePatchHelper; +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; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Details about a user. + */ +@Fluent +public final class User implements JsonSerializable { + /* + * The user's id. + */ + @Generated + private int id; + + /* + * The user's name. + */ + @Generated + private String name; + + /* + * The user's order list + */ + @Generated + private List orders; + + /* + * The entity tag for this resource. + */ + @Generated + private String etag; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setUserAccessor(new JsonMergePatchHelper.UserAccessor() { + @Override + public User prepareModelForJsonMergePatch(User model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(User model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of User class. + */ + @Generated + public User() { + } + + /** + * Get the id property: The user's id. + * + * @return the id value. + */ + @Generated + public int getId() { + return this.id; + } + + /** + * Get the name property: The user's name. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The user's name. + *

Required when create the resource.

+ * + * @param name the name value to set. + * @return the User object itself. + */ + @Generated + public User setName(String name) { + this.name = name; + this.updatedProperties.add("name"); + return this; + } + + /** + * Get the orders property: The user's order list. + * + * @return the orders value. + */ + @Generated + public List getOrders() { + return this.orders; + } + + /** + * Set the orders property: The user's order list. + * + * @param orders the orders value to set. + * @return the User object itself. + */ + @Generated + public User setOrders(List orders) { + this.orders = orders; + this.updatedProperties.add("orders"); + return this; + } + + /** + * Get the etag property: The entity tag for this resource. + * + * @return the etag value. + */ + @Generated + public String getEtag() { + return this.etag; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeArrayField("orders", this.orders, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("name")) { + if (this.name == null) { + jsonWriter.writeNullField("name"); + } else { + jsonWriter.writeStringField("name", this.name); + } + } + if (updatedProperties.contains("orders")) { + if (this.orders == null) { + jsonWriter.writeNullField("orders"); + } else { + jsonWriter.writeArrayField("orders", this.orders, (writer, element) -> writer.writeJson(element)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of User from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of User 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 User. + */ + @Generated + public static User fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + User deserializedUser = new User(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedUser.id = reader.getInt(); + } else if ("etag".equals(fieldName)) { + deserializedUser.etag = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedUser.name = reader.getString(); + } else if ("orders".equals(fieldName)) { + List orders = reader.readArray(reader1 -> UserOrder.fromJson(reader1)); + deserializedUser.orders = orders; + } else { + reader.skipChildren(); + } + } + + return deserializedUser; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/models/UserOrder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/models/UserOrder.java new file mode 100644 index 000000000..bf810b013 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/models/UserOrder.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 com._specs_.azure.core.basic.models; + +import com._specs_.azure.core.basic.implementation.JsonMergePatchHelper; +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; +import java.util.HashSet; +import java.util.Set; + +/** + * UserOrder for testing list with expand. + */ +@Fluent +public final class UserOrder implements JsonSerializable { + /* + * The user's id. + */ + @Generated + private int id; + + /* + * The user's id. + */ + @Generated + private int userId; + + /* + * The user's order detail + */ + @Generated + private String detail; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setUserOrderAccessor(new JsonMergePatchHelper.UserOrderAccessor() { + @Override + public UserOrder prepareModelForJsonMergePatch(UserOrder model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(UserOrder model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of UserOrder class. + */ + @Generated + public UserOrder() { + } + + /** + * Get the id property: The user's id. + * + * @return the id value. + */ + @Generated + public int getId() { + return this.id; + } + + /** + * Get the userId property: The user's id. + * + * @return the userId value. + */ + @Generated + public int getUserId() { + return this.userId; + } + + /** + * Set the userId property: The user's id. + *

Required when create the resource.

+ * + * @param userId the userId value to set. + * @return the UserOrder object itself. + */ + @Generated + public UserOrder setUserId(int userId) { + this.userId = userId; + this.updatedProperties.add("userId"); + return this; + } + + /** + * Get the detail property: The user's order detail. + * + * @return the detail value. + */ + @Generated + public String getDetail() { + return this.detail; + } + + /** + * Set the detail property: The user's order detail. + *

Required when create the resource.

+ * + * @param detail the detail value to set. + * @return the UserOrder object itself. + */ + @Generated + public UserOrder setDetail(String detail) { + this.detail = detail; + this.updatedProperties.add("detail"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("userId", this.userId); + jsonWriter.writeStringField("detail", this.detail); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("userId")) { + jsonWriter.writeIntField("userId", this.userId); + } + if (updatedProperties.contains("detail")) { + if (this.detail == null) { + jsonWriter.writeNullField("detail"); + } else { + jsonWriter.writeStringField("detail", this.detail); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserOrder from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserOrder 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 UserOrder. + */ + @Generated + public static UserOrder fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UserOrder deserializedUserOrder = new UserOrder(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedUserOrder.id = reader.getInt(); + } else if ("userId".equals(fieldName)) { + deserializedUserOrder.userId = reader.getInt(); + } else if ("detail".equals(fieldName)) { + deserializedUserOrder.detail = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedUserOrder; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/models/package-info.java new file mode 100644 index 000000000..8eafa21f9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/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 Basic. + * Illustrates bodies templated with Azure Core. + * + */ +package com._specs_.azure.core.basic.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/package-info.java new file mode 100644 index 000000000..16ed05636 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/basic/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 Basic. + * Illustrates bodies templated with Azure Core. + * + */ +package com._specs_.azure.core.basic; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/RpcAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/RpcAsyncClient.java new file mode 100644 index 000000000..9db25d7e4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/RpcAsyncClient.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 com._specs_.azure.core.lro.rpc; + +import com._specs_.azure.core.lro.rpc.implementation.RpcClientImpl; +import com._specs_.azure.core.lro.rpc.models.GenerationOptions; +import com._specs_.azure.core.lro.rpc.models.GenerationResult; +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.util.BinaryData; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollOperationDetails; + +/** + * Initializes a new instance of the asynchronous RpcClient type. + */ +@ServiceClient(builder = RpcClientBuilder.class, isAsync = true) +public final class RpcAsyncClient { + @Generated + private final RpcClientImpl serviceClient; + + /** + * Initializes an instance of RpcAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RpcAsyncClient(RpcClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Generate data. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prompt: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLongRunningRpc(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.beginLongRunningRpcAsync(body, requestOptions); + } + + /** + * Generate data. + * + * @param body The body 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 the {@link PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLongRunningRpc(GenerationOptions body) { + // Generated convenience method for beginLongRunningRpcWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginLongRunningRpcWithModelAsync(BinaryData.fromObject(body), requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/RpcClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/RpcClient.java new file mode 100644 index 000000000..2170e6bc8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/RpcClient.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 com._specs_.azure.core.lro.rpc; + +import com._specs_.azure.core.lro.rpc.implementation.RpcClientImpl; +import com._specs_.azure.core.lro.rpc.models.GenerationOptions; +import com._specs_.azure.core.lro.rpc.models.GenerationResult; +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.util.BinaryData; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; + +/** + * Initializes a new instance of the synchronous RpcClient type. + */ +@ServiceClient(builder = RpcClientBuilder.class) +public final class RpcClient { + @Generated + private final RpcClientImpl serviceClient; + + /** + * Initializes an instance of RpcClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RpcClient(RpcClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Generate data. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prompt: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLongRunningRpc(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.beginLongRunningRpc(body, requestOptions); + } + + /** + * Generate data. + * + * @param body The body 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 the {@link SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLongRunningRpc(GenerationOptions body) { + // Generated convenience method for beginLongRunningRpcWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginLongRunningRpcWithModel(BinaryData.fromObject(body), requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/RpcClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/RpcClientBuilder.java new file mode 100644 index 000000000..7bb66a010 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/RpcClientBuilder.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.rpc; + +import com._specs_.azure.core.lro.rpc.implementation.RpcClientImpl; +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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; + +/** + * A builder for creating a new instance of the RpcClient type. + */ +@ServiceClientBuilder(serviceClients = { RpcClient.class, RpcAsyncClient.class }) +public final class RpcClientBuilder + 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("_specs_-azure-core-lro-rpc.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the RpcClientBuilder. + */ + @Generated + public RpcClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RpcClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RpcClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RpcClientBuilder 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 RpcClientBuilder 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 RpcClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RpcClientBuilder 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 RpcClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RpcClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private RpcServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the RpcClientBuilder. + */ + @Generated + public RpcClientBuilder serviceVersion(RpcServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 RpcClientBuilder. + */ + @Generated + public RpcClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of RpcClientImpl with the provided parameters. + * + * @return an instance of RpcClientImpl. + */ + @Generated + private RpcClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + RpcServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : RpcServiceVersion.getLatest(); + RpcClientImpl client = new RpcClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, localServiceVersion); + 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 RpcAsyncClient class. + * + * @return an instance of RpcAsyncClient. + */ + @Generated + public RpcAsyncClient buildAsyncClient() { + return new RpcAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of RpcClient class. + * + * @return an instance of RpcClient. + */ + @Generated + public RpcClient buildClient() { + return new RpcClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(RpcClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/RpcServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/RpcServiceVersion.java new file mode 100644 index 000000000..b66b71436 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/RpcServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.rpc; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of RpcClient. + */ +public enum RpcServiceVersion implements ServiceVersion { + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + RpcServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link RpcServiceVersion}. + */ + public static RpcServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/OperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/OperationLocationPollingStrategy.java new file mode 100644 index 000000000..4d4c1998e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/OperationLocationPollingStrategy.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.rpc.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.OperationResourcePollingStrategy; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.time.OffsetDateTime; + +// DO NOT modify this helper class + +/** + * Implements an operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class OperationLocationPollingStrategy extends OperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(OperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + final Mono> pollResponseMono + = PollingUtils.deserializeResponse((BinaryData) response.getValue(), serializer, pollResponseType) + .onErrorResume(exception -> { + LOGGER.info("Failed to parse initial response."); + return Mono.empty(); + }) + .map(value -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, value, retryAfter)); + return pollResponseMono.switchIfEmpty( + Mono.fromSupplier(() -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, null, retryAfter))); + } else { + return Mono + .error( + new AzureException(String.format( + "Operation failed or cancelled with status code %d," + + ", '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + } + + /** + * {@inheritDoc} + */ + @Override + public Mono getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + return Mono.error(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + return Mono.error(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + return PollingUtils + .deserializeResponse(latestResponseBody, serializer, PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE) + .flatMap(value -> { + if (value.get(propertyName) != null) { + return BinaryData.fromObjectAsync(value.get(propertyName)) + .flatMap(result -> PollingUtils.deserializeResponse(result, serializer, resultType)); + } else { + return Mono.error(new AzureException("Cannot get final result")); + } + }) + .switchIfEmpty(Mono.error(new AzureException("Cannot get final result"))); + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/PollingUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/PollingUtils.java new file mode 100644 index 000000000..e7f20f6c4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/PollingUtils.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.rpc.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.net.URI; +import java.net.URISyntaxException; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.temporal.ChronoUnit; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +// DO NOT modify this helper class + +final class PollingUtils { + + public static final TypeReference> POST_POLL_RESULT_TYPE_REFERENCE + = new TypeReference>() { + }; + + public static final HttpHeaderName OPERATION_LOCATION_HEADER = HttpHeaderName.fromString("Operation-Location"); + + public static final String HTTP_METHOD = "httpMethod"; + public static final String REQUEST_URL = "requestURL"; + public static final String POLL_RESPONSE_BODY = "pollResponseBody"; + + private static final String FORWARD_SLASH = "/"; + + public static String getAbsolutePath(String path, String endpoint, ClientLogger logger) { + try { + URI uri = new URI(path); + if (!uri.isAbsolute()) { + if (CoreUtils.isNullOrEmpty(endpoint)) { + throw logger.logExceptionAsError(new IllegalArgumentException( + "Relative path requires endpoint to be non-null and non-empty to create an absolute path.")); + } + + if (endpoint.endsWith(FORWARD_SLASH) && path.startsWith(FORWARD_SLASH)) { + return endpoint + path.substring(1); + } else if (!endpoint.endsWith(FORWARD_SLASH) && !path.startsWith(FORWARD_SLASH)) { + return endpoint + FORWARD_SLASH + path; + } else { + return endpoint + path; + } + } + } catch (URISyntaxException ex) { + throw logger.logExceptionAsWarning(new IllegalArgumentException("'path' must be a valid URI.", ex)); + } + return path; + } + + public static T deserializeResponseSync(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + T value; + if (binaryData == null) { + value = null; + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = typeReference.getJavaClass().cast(binaryData.toReplayableBinaryData()); + } else { + value = binaryData.toObject(typeReference, serializer); + } + return value; + } + + @SuppressWarnings("unchecked") + public static Mono deserializeResponse(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + Mono value; + if (binaryData == null) { + value = Mono.empty(); + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = (Mono) binaryData.toReplayableBinaryDataAsync(); + } else { + value = binaryData.toObjectAsync(typeReference, serializer); + } + return value; + } + + private static final HttpHeaderName RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("retry-after-ms"); + private static final HttpHeaderName X_MS_RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("x-ms-retry-after-ms"); + + public static Duration getRetryAfterFromHeaders(HttpHeaders headers, Supplier nowSupplier) { + // Found 'x-ms-retry-after-ms' header, use a Duration of milliseconds based on the value. + Duration retryDelay = tryGetRetryDelay(headers, X_MS_RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'retry-after-ms' header, use a Duration of milliseconds based on the value. + retryDelay = tryGetRetryDelay(headers, RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'Retry-After' header. First, attempt to resolve it as a Duration of seconds. If that fails, then + // attempt to resolve it as an HTTP date (RFC1123). + retryDelay = tryGetRetryDelay(headers, HttpHeaderName.RETRY_AFTER, + headerValue -> tryParseLongOrDateTime(headerValue, nowSupplier)); + + // Either the retry delay will have been found or it'll be null, null indicates no retry after. + return retryDelay; + } + + private static Duration tryGetRetryDelay(HttpHeaders headers, HttpHeaderName headerName, + Function delayParser) { + String headerValue = headers.getValue(headerName); + + return CoreUtils.isNullOrEmpty(headerValue) ? null : delayParser.apply(headerValue); + } + + private static Duration tryParseLongOrDateTime(String value, Supplier nowSupplier) { + long delaySeconds; + try { + OffsetDateTime retryAfter = new DateTimeRfc1123(value).getDateTime(); + + delaySeconds = nowSupplier.get().until(retryAfter, ChronoUnit.SECONDS); + } catch (DateTimeException ex) { + delaySeconds = tryParseLong(value); + } + + return (delaySeconds >= 0) ? Duration.ofSeconds(delaySeconds) : null; + } + + private static long tryParseLong(String value) { + try { + return Long.parseLong(value); + } catch (NumberFormatException ex) { + return -1; + } + } + + private static Duration tryGetDelayMillis(String value) { + long delayMillis = tryParseLong(value); + return (delayMillis >= 0) ? Duration.ofMillis(delayMillis) : null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/RpcClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/RpcClientImpl.java new file mode 100644 index 000000000..c8f5a1184 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/RpcClientImpl.java @@ -0,0 +1,485 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.rpc.implementation; + +import com._specs_.azure.core.lro.rpc.RpcServiceVersion; +import com._specs_.azure.core.lro.rpc.models.GenerationResult; +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.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.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.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.TypeReference; +import java.time.Duration; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the RpcClient type. + */ +public final class RpcClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RpcClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final RpcServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public RpcServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 RpcClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public RpcClientImpl(String endpoint, RpcServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of RpcClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public RpcClientImpl(HttpPipeline httpPipeline, String endpoint, RpcServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of RpcClient 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. + * @param serviceVersion Service version. + */ + public RpcClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + RpcServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(RpcClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for RpcClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "RpcClient") + public interface RpcClientService { + @Post("/azure/core/lro/rpc/generations:submit") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> longRunningRpc(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/azure/core/lro/rpc/generations:submit") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response longRunningRpcSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Generate data. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prompt: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 provides status details for long running operations along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> longRunningRpcWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.longRunningRpc(this.getEndpoint(), + this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); + } + + /** + * Generate data. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prompt: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 provides status details for long running operations along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response longRunningRpcWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.longRunningRpcSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, + accept, body, requestOptions, Context.NONE); + } + + /** + * Generate data. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prompt: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 PollerFlux} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLongRunningRpcAsync(BinaryData body, RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.longRunningRpcWithResponseAsync(body, requestOptions), + new com._specs_.azure.core.lro.rpc.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Generate data. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prompt: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 SyncPoller} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLongRunningRpc(BinaryData body, RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.longRunningRpcWithResponse(body, requestOptions), + new com._specs_.azure.core.lro.rpc.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Generate data. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prompt: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 PollerFlux} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLongRunningRpcWithModelAsync(BinaryData body, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.longRunningRpcWithResponseAsync(body, requestOptions), + new com._specs_.azure.core.lro.rpc.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), + TypeReference.createInstance(GenerationResult.class)); + } + + /** + * Generate data. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prompt: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 SyncPoller} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLongRunningRpcWithModel(BinaryData body, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.longRunningRpcWithResponse(body, requestOptions), + new com._specs_.azure.core.lro.rpc.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), + TypeReference.createInstance(GenerationResult.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/SyncOperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/SyncOperationLocationPollingStrategy.java new file mode 100644 index 000000000..79c3f0566 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/SyncOperationLocationPollingStrategy.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.rpc.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncOperationResourcePollingStrategy; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; + +import java.io.UncheckedIOException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Map; + +// DO NOT modify this helper class + +/** + * Implements a synchronous operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class SyncOperationLocationPollingStrategy extends SyncOperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(SyncOperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public PollResponse onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + T initialResponseType = null; + try { + initialResponseType = PollingUtils.deserializeResponseSync((BinaryData) response.getValue(), serializer, + pollResponseType); + } catch (UncheckedIOException e) { + LOGGER.info("Failed to parse initial response."); + } + return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, initialResponseType, retryAfter); + } + + throw LOGGER.logExceptionAsError(new AzureException( + String.format("Operation failed or cancelled with status code %d, '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + + /** + * {@inheritDoc} + */ + public U getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + Map pollResult = PollingUtils.deserializeResponseSync(latestResponseBody, serializer, + PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE); + if (pollResult != null && pollResult.get(propertyName) != null) { + return PollingUtils.deserializeResponseSync(BinaryData.fromObject(pollResult.get(propertyName)), + serializer, resultType); + } else { + throw LOGGER.logExceptionAsError(new AzureException("Cannot get final result")); + } + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/implementation/package-info.java new file mode 100644 index 000000000..8fad41622 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/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 Rpc. + * Illustrates bodies templated with Azure Core with long-running RPC operation. + * + */ +package com._specs_.azure.core.lro.rpc.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/GenerationOptions.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/GenerationOptions.java new file mode 100644 index 000000000..ff3ba790a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/GenerationOptions.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.rpc.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; + +/** + * Options for the generation. + */ +@Immutable +public final class GenerationOptions implements JsonSerializable { + /* + * Prompt. + */ + @Generated + private final String prompt; + + /** + * Creates an instance of GenerationOptions class. + * + * @param prompt the prompt value to set. + */ + @Generated + public GenerationOptions(String prompt) { + this.prompt = prompt; + } + + /** + * Get the prompt property: Prompt. + * + * @return the prompt value. + */ + @Generated + public String getPrompt() { + return this.prompt; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prompt", this.prompt); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GenerationOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GenerationOptions 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 GenerationOptions. + */ + @Generated + public static GenerationOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prompt = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prompt".equals(fieldName)) { + prompt = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new GenerationOptions(prompt); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/GenerationResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/GenerationResult.java new file mode 100644 index 000000000..f2c3f4252 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/GenerationResult.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.rpc.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; + +/** + * Result of the generation. + */ +@Immutable +public final class GenerationResult implements JsonSerializable { + /* + * The data. + */ + @Generated + private final String data; + + /** + * Creates an instance of GenerationResult class. + * + * @param data the data value to set. + */ + @Generated + private GenerationResult(String data) { + this.data = data; + } + + /** + * Get the data property: The data. + * + * @return the data value. + */ + @Generated + public String getData() { + return this.data; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("data", this.data); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GenerationResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GenerationResult 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 GenerationResult. + */ + @Generated + public static GenerationResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String data = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("data".equals(fieldName)) { + data = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new GenerationResult(data); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/models/package-info.java new file mode 100644 index 000000000..76b811e72 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/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 Rpc. + * Illustrates bodies templated with Azure Core with long-running RPC operation. + * + */ +package com._specs_.azure.core.lro.rpc.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/package-info.java new file mode 100644 index 000000000..662e037c8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/rpc/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 Rpc. + * Illustrates bodies templated with Azure Core with long-running RPC operation. + * + */ +package com._specs_.azure.core.lro.rpc; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/StandardAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/StandardAsyncClient.java new file mode 100644 index 000000000..7f473f849 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/StandardAsyncClient.java @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard; + +import com._specs_.azure.core.lro.standard.implementation.StandardClientImpl; +import com._specs_.azure.core.lro.standard.models.ExportedUser; +import com._specs_.azure.core.lro.standard.models.User; +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.util.BinaryData; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollOperationDetails; + +/** + * Initializes a new instance of the asynchronous StandardClient type. + */ +@ServiceClient(builder = StandardClientBuilder.class, isAsync = true) +public final class StandardAsyncClient { + @Generated + private final StandardClientImpl serviceClient; + + /** + * Initializes an instance of StandardAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StandardAsyncClient(StandardClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + * @param name The name of user. + * @param resource The resource instance. + * @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 PollerFlux} for polling of details about a user. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateOrReplace(String name, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.beginCreateOrReplaceAsync(name, resource, requestOptions); + } + + /** + * Deletes a user. + * + * Deletes a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @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 PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginDelete(String name, RequestOptions requestOptions) { + return this.serviceClient.beginDeleteAsync(name, requestOptions); + } + + /** + * Exports a user. + * + * Exports a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @param format The format of the data. + * @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 PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginExport(String name, String format, RequestOptions requestOptions) { + return this.serviceClient.beginExportAsync(name, format, requestOptions); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + * + * @param name The name of user. + * @param resource The resource instance. + * @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 the {@link PollerFlux} for polling of details about a user. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateOrReplace(String name, User resource) { + // Generated convenience method for beginCreateOrReplaceWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginCreateOrReplaceWithModelAsync(name, BinaryData.fromObject(resource), requestOptions); + } + + /** + * Deletes a user. + * + * Deletes a User. + * + * @param name The name of user. + * @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 the {@link PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginDelete(String name) { + // Generated convenience method for beginDeleteWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginDeleteWithModelAsync(name, requestOptions); + } + + /** + * Exports a user. + * + * Exports a User. + * + * @param name The name of user. + * @param format The format of the data. + * @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 the {@link PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginExport(String name, String format) { + // Generated convenience method for beginExportWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginExportWithModelAsync(name, format, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/StandardClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/StandardClient.java new file mode 100644 index 000000000..8895dc668 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/StandardClient.java @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard; + +import com._specs_.azure.core.lro.standard.implementation.StandardClientImpl; +import com._specs_.azure.core.lro.standard.models.ExportedUser; +import com._specs_.azure.core.lro.standard.models.User; +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.util.BinaryData; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; + +/** + * Initializes a new instance of the synchronous StandardClient type. + */ +@ServiceClient(builder = StandardClientBuilder.class) +public final class StandardClient { + @Generated + private final StandardClientImpl serviceClient; + + /** + * Initializes an instance of StandardClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StandardClient(StandardClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + * @param name The name of user. + * @param resource The resource instance. + * @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 SyncPoller} for polling of details about a user. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateOrReplace(String name, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.beginCreateOrReplace(name, resource, requestOptions); + } + + /** + * Deletes a user. + * + * Deletes a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @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 SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginDelete(String name, RequestOptions requestOptions) { + return this.serviceClient.beginDelete(name, requestOptions); + } + + /** + * Exports a user. + * + * Exports a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @param format The format of the data. + * @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 SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginExport(String name, String format, RequestOptions requestOptions) { + return this.serviceClient.beginExport(name, format, requestOptions); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + * + * @param name The name of user. + * @param resource The resource instance. + * @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 the {@link SyncPoller} for polling of details about a user. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateOrReplace(String name, User resource) { + // Generated convenience method for beginCreateOrReplaceWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginCreateOrReplaceWithModel(name, BinaryData.fromObject(resource), requestOptions); + } + + /** + * Deletes a user. + * + * Deletes a User. + * + * @param name The name of user. + * @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 the {@link SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginDelete(String name) { + // Generated convenience method for beginDeleteWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginDeleteWithModel(name, requestOptions); + } + + /** + * Exports a user. + * + * Exports a User. + * + * @param name The name of user. + * @param format The format of the data. + * @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 the {@link SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginExport(String name, String format) { + // Generated convenience method for beginExportWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginExportWithModel(name, format, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/StandardClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/StandardClientBuilder.java new file mode 100644 index 000000000..82da25b87 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/StandardClientBuilder.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard; + +import com._specs_.azure.core.lro.standard.implementation.StandardClientImpl; +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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; + +/** + * A builder for creating a new instance of the StandardClient type. + */ +@ServiceClientBuilder(serviceClients = { StandardClient.class, StandardAsyncClient.class }) +public final class StandardClientBuilder 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("_specs_-azure-core-lro-standard.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the StandardClientBuilder. + */ + @Generated + public StandardClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public StandardClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public StandardClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public StandardClientBuilder 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 StandardClientBuilder 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 StandardClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public StandardClientBuilder 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 StandardClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public StandardClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private StandardServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the StandardClientBuilder. + */ + @Generated + public StandardClientBuilder serviceVersion(StandardServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 StandardClientBuilder. + */ + @Generated + public StandardClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of StandardClientImpl with the provided parameters. + * + * @return an instance of StandardClientImpl. + */ + @Generated + private StandardClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + StandardServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : StandardServiceVersion.getLatest(); + StandardClientImpl client = new StandardClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, localServiceVersion); + 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 StandardAsyncClient class. + * + * @return an instance of StandardAsyncClient. + */ + @Generated + public StandardAsyncClient buildAsyncClient() { + return new StandardAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of StandardClient class. + * + * @return an instance of StandardClient. + */ + @Generated + public StandardClient buildClient() { + return new StandardClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(StandardClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/StandardServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/StandardServiceVersion.java new file mode 100644 index 000000000..7d3908e6e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/StandardServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of StandardClient. + */ +public enum StandardServiceVersion implements ServiceVersion { + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + StandardServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link StandardServiceVersion}. + */ + public static StandardServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/OperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/OperationLocationPollingStrategy.java new file mode 100644 index 000000000..e2adbc829 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/OperationLocationPollingStrategy.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.OperationResourcePollingStrategy; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.time.OffsetDateTime; + +// DO NOT modify this helper class + +/** + * Implements an operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class OperationLocationPollingStrategy extends OperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(OperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + final Mono> pollResponseMono + = PollingUtils.deserializeResponse((BinaryData) response.getValue(), serializer, pollResponseType) + .onErrorResume(exception -> { + LOGGER.info("Failed to parse initial response."); + return Mono.empty(); + }) + .map(value -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, value, retryAfter)); + return pollResponseMono.switchIfEmpty( + Mono.fromSupplier(() -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, null, retryAfter))); + } else { + return Mono + .error( + new AzureException(String.format( + "Operation failed or cancelled with status code %d," + + ", '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + } + + /** + * {@inheritDoc} + */ + @Override + public Mono getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + return Mono.error(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + return Mono.error(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + return PollingUtils + .deserializeResponse(latestResponseBody, serializer, PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE) + .flatMap(value -> { + if (value.get(propertyName) != null) { + return BinaryData.fromObjectAsync(value.get(propertyName)) + .flatMap(result -> PollingUtils.deserializeResponse(result, serializer, resultType)); + } else { + return Mono.error(new AzureException("Cannot get final result")); + } + }) + .switchIfEmpty(Mono.error(new AzureException("Cannot get final result"))); + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/PollingUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/PollingUtils.java new file mode 100644 index 000000000..072dd02f1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/PollingUtils.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.net.URI; +import java.net.URISyntaxException; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.temporal.ChronoUnit; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +// DO NOT modify this helper class + +final class PollingUtils { + + public static final TypeReference> POST_POLL_RESULT_TYPE_REFERENCE + = new TypeReference>() { + }; + + public static final HttpHeaderName OPERATION_LOCATION_HEADER = HttpHeaderName.fromString("Operation-Location"); + + public static final String HTTP_METHOD = "httpMethod"; + public static final String REQUEST_URL = "requestURL"; + public static final String POLL_RESPONSE_BODY = "pollResponseBody"; + + private static final String FORWARD_SLASH = "/"; + + public static String getAbsolutePath(String path, String endpoint, ClientLogger logger) { + try { + URI uri = new URI(path); + if (!uri.isAbsolute()) { + if (CoreUtils.isNullOrEmpty(endpoint)) { + throw logger.logExceptionAsError(new IllegalArgumentException( + "Relative path requires endpoint to be non-null and non-empty to create an absolute path.")); + } + + if (endpoint.endsWith(FORWARD_SLASH) && path.startsWith(FORWARD_SLASH)) { + return endpoint + path.substring(1); + } else if (!endpoint.endsWith(FORWARD_SLASH) && !path.startsWith(FORWARD_SLASH)) { + return endpoint + FORWARD_SLASH + path; + } else { + return endpoint + path; + } + } + } catch (URISyntaxException ex) { + throw logger.logExceptionAsWarning(new IllegalArgumentException("'path' must be a valid URI.", ex)); + } + return path; + } + + public static T deserializeResponseSync(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + T value; + if (binaryData == null) { + value = null; + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = typeReference.getJavaClass().cast(binaryData.toReplayableBinaryData()); + } else { + value = binaryData.toObject(typeReference, serializer); + } + return value; + } + + @SuppressWarnings("unchecked") + public static Mono deserializeResponse(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + Mono value; + if (binaryData == null) { + value = Mono.empty(); + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = (Mono) binaryData.toReplayableBinaryDataAsync(); + } else { + value = binaryData.toObjectAsync(typeReference, serializer); + } + return value; + } + + private static final HttpHeaderName RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("retry-after-ms"); + private static final HttpHeaderName X_MS_RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("x-ms-retry-after-ms"); + + public static Duration getRetryAfterFromHeaders(HttpHeaders headers, Supplier nowSupplier) { + // Found 'x-ms-retry-after-ms' header, use a Duration of milliseconds based on the value. + Duration retryDelay = tryGetRetryDelay(headers, X_MS_RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'retry-after-ms' header, use a Duration of milliseconds based on the value. + retryDelay = tryGetRetryDelay(headers, RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'Retry-After' header. First, attempt to resolve it as a Duration of seconds. If that fails, then + // attempt to resolve it as an HTTP date (RFC1123). + retryDelay = tryGetRetryDelay(headers, HttpHeaderName.RETRY_AFTER, + headerValue -> tryParseLongOrDateTime(headerValue, nowSupplier)); + + // Either the retry delay will have been found or it'll be null, null indicates no retry after. + return retryDelay; + } + + private static Duration tryGetRetryDelay(HttpHeaders headers, HttpHeaderName headerName, + Function delayParser) { + String headerValue = headers.getValue(headerName); + + return CoreUtils.isNullOrEmpty(headerValue) ? null : delayParser.apply(headerValue); + } + + private static Duration tryParseLongOrDateTime(String value, Supplier nowSupplier) { + long delaySeconds; + try { + OffsetDateTime retryAfter = new DateTimeRfc1123(value).getDateTime(); + + delaySeconds = nowSupplier.get().until(retryAfter, ChronoUnit.SECONDS); + } catch (DateTimeException ex) { + delaySeconds = tryParseLong(value); + } + + return (delaySeconds >= 0) ? Duration.ofSeconds(delaySeconds) : null; + } + + private static long tryParseLong(String value) { + try { + return Long.parseLong(value); + } catch (NumberFormatException ex) { + return -1; + } + } + + private static Duration tryGetDelayMillis(String value) { + long delayMillis = tryParseLong(value); + return (delayMillis >= 0) ? Duration.ofMillis(delayMillis) : null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/StandardClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/StandardClientImpl.java new file mode 100644 index 000000000..f7e54a273 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/StandardClientImpl.java @@ -0,0 +1,1011 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard.implementation; + +import com._specs_.azure.core.lro.standard.StandardServiceVersion; +import com._specs_.azure.core.lro.standard.models.ExportedUser; +import com._specs_.azure.core.lro.standard.models.User; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +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.PathParam; +import com.azure.core.annotation.Post; +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.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.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.TypeReference; +import java.time.Duration; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the StandardClient type. + */ +public final class StandardClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StandardClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final StandardServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public StandardServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 StandardClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public StandardClientImpl(String endpoint, StandardServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of StandardClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public StandardClientImpl(HttpPipeline httpPipeline, String endpoint, StandardServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of StandardClient 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. + * @param serviceVersion Service version. + */ + public StandardClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + StandardServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(StandardClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for StandardClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "StandardClient") + public interface StandardClientService { + @Put("/azure/core/lro/standard/users/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrReplace(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Put("/azure/core/lro/standard/users/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createOrReplaceSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Delete("/azure/core/lro/standard/users/{name}") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/azure/core/lro/standard/users/{name}") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/azure/core/lro/standard/users/{name}:export") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> export(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @QueryParam("format") String format, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Post("/azure/core/lro/standard/users/{name}:export") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response exportSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @QueryParam("format") String format, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + * @param name The name of user. + * @param resource The resource instance. + * @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 details about a user along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrReplaceWithResponseAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createOrReplace(this.getEndpoint(), + this.getServiceVersion().getVersion(), name, contentType, accept, resource, requestOptions, context)); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + * @param name The name of user. + * @param resource The resource instance. + * @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 details about a user along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrReplaceWithResponse(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrReplaceSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, contentType, + accept, resource, requestOptions, Context.NONE); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + * @param name The name of user. + * @param resource The resource instance. + * @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 PollerFlux} for polling of details about a user. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateOrReplaceAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.createOrReplaceWithResponseAsync(name, resource, requestOptions), + new com._specs_.azure.core.lro.standard.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + * @param name The name of user. + * @param resource The resource instance. + * @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 SyncPoller} for polling of details about a user. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateOrReplace(String name, BinaryData resource, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.createOrReplaceWithResponse(name, resource, requestOptions), + new com._specs_.azure.core.lro.standard.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + * @param name The name of user. + * @param resource The resource instance. + * @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 PollerFlux} for polling of details about a user. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateOrReplaceWithModelAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.createOrReplaceWithResponseAsync(name, resource, requestOptions), + new com._specs_.azure.core.lro.standard.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(User.class)); + } + + /** + * Adds a user or replaces a user's fields. + * + * Creates or replaces a User. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     role: String (Required)
+     * }
+     * }
+ * + * @param name The name of user. + * @param resource The resource instance. + * @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 SyncPoller} for polling of details about a user. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateOrReplaceWithModel(String name, BinaryData resource, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.createOrReplaceWithResponse(name, resource, requestOptions), + new com._specs_.azure.core.lro.standard.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(User.class)); + } + + /** + * Deletes a user. + * + * Deletes a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @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 provides status details for long running operations along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.delete(this.getEndpoint(), this.getServiceVersion().getVersion(), + name, accept, requestOptions, context)); + } + + /** + * Deletes a user. + * + * Deletes a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @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 provides status details for long running operations along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response deleteWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, accept, + requestOptions, Context.NONE); + } + + /** + * Deletes a user. + * + * Deletes a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @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 PollerFlux} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginDeleteAsync(String name, RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.deleteWithResponseAsync(name, requestOptions), + new com._specs_.azure.core.lro.standard.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(Void.class)); + } + + /** + * Deletes a user. + * + * Deletes a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @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 SyncPoller} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginDelete(String name, RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.deleteWithResponse(name, requestOptions), + new com._specs_.azure.core.lro.standard.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(Void.class)); + } + + /** + * Deletes a user. + * + * Deletes a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @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 PollerFlux} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginDeleteWithModelAsync(String name, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.deleteWithResponseAsync(name, requestOptions), + new com._specs_.azure.core.lro.standard.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(Void.class)); + } + + /** + * Deletes a user. + * + * Deletes a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @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 SyncPoller} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginDeleteWithModel(String name, RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.deleteWithResponse(name, requestOptions), + new com._specs_.azure.core.lro.standard.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(Void.class)); + } + + /** + * Exports a user. + * + * Exports a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @param format The format of the data. + * @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 provides status details for long running operations along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> exportWithResponseAsync(String name, String format, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.export(this.getEndpoint(), this.getServiceVersion().getVersion(), + name, format, accept, requestOptions, context)); + } + + /** + * Exports a user. + * + * Exports a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @param format The format of the data. + * @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 provides status details for long running operations along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response exportWithResponse(String name, String format, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.exportSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, format, accept, + requestOptions, Context.NONE); + } + + /** + * Exports a user. + * + * Exports a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @param format The format of the data. + * @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 PollerFlux} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginExportAsync(String name, String format, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.exportWithResponseAsync(name, format, requestOptions), + new com._specs_.azure.core.lro.standard.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Exports a user. + * + * Exports a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @param format The format of the data. + * @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 SyncPoller} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginExport(String name, String format, RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.exportWithResponse(name, format, requestOptions), + new com._specs_.azure.core.lro.standard.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Exports a user. + * + * Exports a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @param format The format of the data. + * @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 PollerFlux} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginExportWithModelAsync(String name, String format, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.exportWithResponseAsync(name, format, requestOptions), + new com._specs_.azure.core.lro.standard.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(ExportedUser.class)); + } + + /** + * Exports a user. + * + * Exports a User. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name of user. + * @param format The format of the data. + * @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 SyncPoller} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginExportWithModel(String name, String format, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.exportWithResponse(name, format, requestOptions), + new com._specs_.azure.core.lro.standard.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(ExportedUser.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/SyncOperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/SyncOperationLocationPollingStrategy.java new file mode 100644 index 000000000..ecebf01ab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/SyncOperationLocationPollingStrategy.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncOperationResourcePollingStrategy; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; + +import java.io.UncheckedIOException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Map; + +// DO NOT modify this helper class + +/** + * Implements a synchronous operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class SyncOperationLocationPollingStrategy extends SyncOperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(SyncOperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public PollResponse onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + T initialResponseType = null; + try { + initialResponseType = PollingUtils.deserializeResponseSync((BinaryData) response.getValue(), serializer, + pollResponseType); + } catch (UncheckedIOException e) { + LOGGER.info("Failed to parse initial response."); + } + return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, initialResponseType, retryAfter); + } + + throw LOGGER.logExceptionAsError(new AzureException( + String.format("Operation failed or cancelled with status code %d, '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + + /** + * {@inheritDoc} + */ + public U getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + Map pollResult = PollingUtils.deserializeResponseSync(latestResponseBody, serializer, + PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE); + if (pollResult != null && pollResult.get(propertyName) != null) { + return PollingUtils.deserializeResponseSync(BinaryData.fromObject(pollResult.get(propertyName)), + serializer, resultType); + } else { + throw LOGGER.logExceptionAsError(new AzureException("Cannot get final result")); + } + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/implementation/package-info.java new file mode 100644 index 000000000..b847bc40f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/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 Standard. + * Illustrates bodies templated with Azure Core with long-running operation. + * + */ +package com._specs_.azure.core.lro.standard.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/ExportedUser.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/ExportedUser.java new file mode 100644 index 000000000..d348d2550 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/ExportedUser.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard.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; + +/** + * The exported user data. + */ +@Immutable +public final class ExportedUser implements JsonSerializable { + /* + * The name of user. + */ + @Generated + private final String name; + + /* + * The exported URI. + */ + @Generated + private final String resourceUri; + + /** + * Creates an instance of ExportedUser class. + * + * @param name the name value to set. + * @param resourceUri the resourceUri value to set. + */ + @Generated + private ExportedUser(String name, String resourceUri) { + this.name = name; + this.resourceUri = resourceUri; + } + + /** + * Get the name property: The name of user. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the resourceUri property: The exported URI. + * + * @return the resourceUri value. + */ + @Generated + public String getResourceUri() { + return this.resourceUri; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("resourceUri", this.resourceUri); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExportedUser from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExportedUser 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 ExportedUser. + */ + @Generated + public static ExportedUser fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String resourceUri = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("resourceUri".equals(fieldName)) { + resourceUri = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ExportedUser(name, resourceUri); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/User.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/User.java new file mode 100644 index 000000000..d94a9d19c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/User.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard.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; + +/** + * Details about a user. + */ +@Immutable +public final class User implements JsonSerializable { + /* + * The name of user. + */ + @Generated + private String name; + + /* + * The role of user + */ + @Generated + private final String role; + + /** + * Creates an instance of User class. + * + * @param role the role value to set. + */ + @Generated + public User(String role) { + this.role = role; + } + + /** + * Get the name property: The name of user. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the role property: The role of user. + * + * @return the role value. + */ + @Generated + public String getRole() { + return this.role; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("role", this.role); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of User from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of User 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 User. + */ + @Generated + public static User fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String role = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("role".equals(fieldName)) { + role = reader.getString(); + } else { + reader.skipChildren(); + } + } + User deserializedUser = new User(role); + deserializedUser.name = name; + + return deserializedUser; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/models/package-info.java new file mode 100644 index 000000000..a9cc1baaa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/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 Standard. + * Illustrates bodies templated with Azure Core with long-running operation. + * + */ +package com._specs_.azure.core.lro.standard.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/package-info.java new file mode 100644 index 000000000..427a75ac1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/lro/standard/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 Standard. + * Illustrates bodies templated with Azure Core with long-running operation. + * + */ +package com._specs_.azure.core.lro.standard; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/ModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/ModelAsyncClient.java new file mode 100644 index 000000000..1f518dac0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/ModelAsyncClient.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 com._specs_.azure.core.model; + +import com._specs_.azure.core.model.implementation.AzureCoreEmbeddingVectorsImpl; +import com._specs_.azure.core.model.models.AzureEmbeddingModel; +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 com.azure.core.util.serializer.TypeReference; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ModelClient type. + */ +@ServiceClient(builder = ModelClientBuilder.class, isAsync = true) +public final class ModelAsyncClient { + @Generated + private final AzureCoreEmbeddingVectorsImpl serviceClient; + + /** + * Initializes an instance of ModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelAsyncClient(AzureCoreEmbeddingVectorsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get an embedding vector. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     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 an embedding vector along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * put an embedding vector. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body _. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * post a model which has an embeddingVector property. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body _. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postWithResponseAsync(body, requestOptions); + } + + /** + * get an embedding vector. + * + * @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 an embedding vector on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_INTEGER)); + } + + /** + * put an embedding vector. + * + * @param body _. + * @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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * post a model which has an embeddingVector property. + * + * @param body _. + * @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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono post(AzureEmbeddingModel body) { + // Generated convenience method for postWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AzureEmbeddingModel.class)); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_INTEGER = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/ModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/ModelClient.java new file mode 100644 index 000000000..170aadb44 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/ModelClient.java @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model; + +import com._specs_.azure.core.model.implementation.AzureCoreEmbeddingVectorsImpl; +import com._specs_.azure.core.model.models.AzureEmbeddingModel; +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.serializer.TypeReference; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ModelClient type. + */ +@ServiceClient(builder = ModelClientBuilder.class) +public final class ModelClient { + @Generated + private final AzureCoreEmbeddingVectorsImpl serviceClient; + + /** + * Initializes an instance of ModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelClient(AzureCoreEmbeddingVectorsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get an embedding vector. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     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 an embedding vector along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * put an embedding vector. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body _. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * post a model which has an embeddingVector property. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body _. + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postWithResponse(body, requestOptions); + } + + /** + * get an embedding vector. + * + * @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 an embedding vector. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_INTEGER); + } + + /** + * put an embedding vector. + * + * @param body _. + * @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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * post a model which has an embeddingVector property. + * + * @param body _. + * @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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AzureEmbeddingModel post(AzureEmbeddingModel body) { + // Generated convenience method for postWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(AzureEmbeddingModel.class); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_INTEGER = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/ModelClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/ModelClientBuilder.java new file mode 100644 index 000000000..50e42f831 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/ModelClientBuilder.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model; + +import com._specs_.azure.core.model.implementation.ModelClientImpl; +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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; + +/** + * A builder for creating a new instance of the ModelClient type. + */ +@ServiceClientBuilder(serviceClients = { ModelClient.class, ModelAsyncClient.class }) +public final class ModelClientBuilder 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("_specs_-azure-core-model.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ModelClientBuilder. + */ + @Generated + public ModelClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder 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 ModelClientBuilder 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 ModelClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder 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 ModelClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private ModelServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the ModelClientBuilder. + */ + @Generated + public ModelClientBuilder serviceVersion(ModelServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 ModelClientBuilder. + */ + @Generated + public ModelClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ModelClientImpl with the provided parameters. + * + * @return an instance of ModelClientImpl. + */ + @Generated + private ModelClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ModelServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ModelServiceVersion.getLatest(); + ModelClientImpl client = new ModelClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, localServiceVersion); + 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 ModelAsyncClient class. + * + * @return an instance of ModelAsyncClient. + */ + @Generated + public ModelAsyncClient buildAsyncClient() { + return new ModelAsyncClient(buildInnerClient().getAzureCoreEmbeddingVectors()); + } + + /** + * Builds an instance of ModelClient class. + * + * @return an instance of ModelClient. + */ + @Generated + public ModelClient buildClient() { + return new ModelClient(buildInnerClient().getAzureCoreEmbeddingVectors()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ModelClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/ModelServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/ModelServiceVersion.java new file mode 100644 index 000000000..a8bb4574d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/ModelServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of ModelClient. + */ +public enum ModelServiceVersion implements ServiceVersion { + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + ModelServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link ModelServiceVersion}. + */ + public static ModelServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/implementation/AzureCoreEmbeddingVectorsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/implementation/AzureCoreEmbeddingVectorsImpl.java new file mode 100644 index 000000000..ae6979705 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/implementation/AzureCoreEmbeddingVectorsImpl.java @@ -0,0 +1,300 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model.implementation; + +import com._specs_.azure.core.model.ModelServiceVersion; +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.Put; +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.BinaryData; +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 AzureCoreEmbeddingVectors. + */ +public final class AzureCoreEmbeddingVectorsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final AzureCoreEmbeddingVectorsService service; + + /** + * The service client containing this operation class. + */ + private final ModelClientImpl client; + + /** + * Initializes an instance of AzureCoreEmbeddingVectorsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + AzureCoreEmbeddingVectorsImpl(ModelClientImpl client) { + this.service = RestProxy.create(AzureCoreEmbeddingVectorsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ModelServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for ModelClientAzureCoreEmbeddingVectors to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ModelClientAzureCore") + public interface AzureCoreEmbeddingVectorsService { + @Get("/azure/core/model/embeddingVector") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/core/model/embeddingVector") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/azure/core/model/embeddingVector") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/azure/core/model/embeddingVector") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/azure/core/model/embeddingVector") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> post(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/azure/core/model/embeddingVector") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response postSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * get an embedding vector. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     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 an embedding vector along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * get an embedding vector. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     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 an embedding vector along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * put an embedding vector. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body _. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * put an embedding vector. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body _. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * post a model which has an embeddingVector property. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body _. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.post(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); + } + + /** + * post a model which has an embeddingVector property. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     embedding (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body _. + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.postSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/implementation/ModelClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/implementation/ModelClientImpl.java new file mode 100644 index 000000000..5ea0743ef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/implementation/ModelClientImpl.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model.implementation; + +import com._specs_.azure.core.model.ModelServiceVersion; +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the ModelClient type. + */ +public final class ModelClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final ModelServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ModelServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * The AzureCoreEmbeddingVectorsImpl object to access its operations. + */ + private final AzureCoreEmbeddingVectorsImpl azureCoreEmbeddingVectors; + + /** + * Gets the AzureCoreEmbeddingVectorsImpl object to access its operations. + * + * @return the AzureCoreEmbeddingVectorsImpl object. + */ + public AzureCoreEmbeddingVectorsImpl getAzureCoreEmbeddingVectors() { + return this.azureCoreEmbeddingVectors; + } + + /** + * Initializes an instance of ModelClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public ModelClientImpl(String endpoint, ModelServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of ModelClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public ModelClientImpl(HttpPipeline httpPipeline, String endpoint, ModelServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of ModelClient 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. + * @param serviceVersion Service version. + */ + public ModelClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + ModelServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.azureCoreEmbeddingVectors = new AzureCoreEmbeddingVectorsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/implementation/package-info.java new file mode 100644 index 000000000..038f11270 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Model. + * + */ +package com._specs_.azure.core.model.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/models/AzureEmbeddingModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/models/AzureEmbeddingModel.java new file mode 100644 index 000000000..25cac4f4f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/models/AzureEmbeddingModel.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model.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; +import java.util.List; + +/** + * The AzureEmbeddingModel model. + */ +@Immutable +public final class AzureEmbeddingModel implements JsonSerializable { + /* + * The embedding property. + */ + @Generated + private final List embedding; + + /** + * Creates an instance of AzureEmbeddingModel class. + * + * @param embedding the embedding value to set. + */ + @Generated + public AzureEmbeddingModel(List embedding) { + this.embedding = embedding; + } + + /** + * Get the embedding property: The embedding property. + * + * @return the embedding value. + */ + @Generated + public List getEmbedding() { + return this.embedding; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("embedding", this.embedding, (writer, element) -> writer.writeInt(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureEmbeddingModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureEmbeddingModel 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 AzureEmbeddingModel. + */ + @Generated + public static AzureEmbeddingModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List embedding = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("embedding".equals(fieldName)) { + embedding = reader.readArray(reader1 -> reader1.getInt()); + } else { + reader.skipChildren(); + } + } + return new AzureEmbeddingModel(embedding); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/models/package-info.java new file mode 100644 index 000000000..3f230c882 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Model. + * + */ +package com._specs_.azure.core.model.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/package-info.java new file mode 100644 index 000000000..a828f7154 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/model/package-info.java @@ -0,0 +1,10 @@ +// 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 Model. + * + */ +package com._specs_.azure.core.model; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/PageAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/PageAsyncClient.java new file mode 100644 index 000000000..7934db454 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/PageAsyncClient.java @@ -0,0 +1,285 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page; + +import com._specs_.azure.core.page.implementation.PageClientImpl; +import com._specs_.azure.core.page.models.ListItemInputBody; +import com._specs_.azure.core.page.models.ListItemInputExtensibleEnum; +import com._specs_.azure.core.page.models.User; +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.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; + +/** + * Initializes a new instance of the asynchronous PageClient type. + */ +@ServiceClient(builder = PageClientBuilder.class, isAsync = true) +public final class PageAsyncClient { + @Generated + private final PageClientImpl serviceClient; + + /** + * Initializes an instance of PageAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PageAsyncClient(PageClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List with Azure.Core.Page<>. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithPage(RequestOptions requestOptions) { + return this.serviceClient.listWithPageAsync(requestOptions); + } + + /** + * List with extensible enum parameter Azure.Core.Page<>. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
anotherStringNoAnother query parameter. Allowed values: "First", + * "Second".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     inputName: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param bodyInput The body of the input. + * @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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithParameters(BinaryData bodyInput, RequestOptions requestOptions) { + return this.serviceClient.listWithParametersAsync(bodyInput, requestOptions); + } + + /** + * List with custom page model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (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 the paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithCustomPageModel(RequestOptions requestOptions) { + return this.serviceClient.listWithCustomPageModelAsync(requestOptions); + } + + /** + * List with Azure.Core.Page<>. + * + * @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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithPage() { + // Generated convenience method for listWithPage + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listWithPage(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(User.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List with extensible enum parameter Azure.Core.Page<>. + * + * @param bodyInput The body of the input. + * @param another Another query 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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithParameters(ListItemInputBody bodyInput, ListItemInputExtensibleEnum another) { + // Generated convenience method for listWithParameters + RequestOptions requestOptions = new RequestOptions(); + if (another != null) { + requestOptions.addQueryParam("another", another.toString(), false); + } + PagedFlux pagedFluxResponse = listWithParameters(BinaryData.fromObject(bodyInput), requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(User.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List with extensible enum parameter Azure.Core.Page<>. + * + * @param bodyInput The body of the input. + * @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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithParameters(ListItemInputBody bodyInput) { + // Generated convenience method for listWithParameters + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listWithParameters(BinaryData.fromObject(bodyInput), requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(User.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List with custom page model. + * + * @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 the paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithCustomPageModel() { + // Generated convenience method for listWithCustomPageModel + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listWithCustomPageModel(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(User.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/PageClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/PageClient.java new file mode 100644 index 000000000..8c3d8c4fc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/PageClient.java @@ -0,0 +1,236 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page; + +import com._specs_.azure.core.page.implementation.PageClientImpl; +import com._specs_.azure.core.page.models.ListItemInputBody; +import com._specs_.azure.core.page.models.ListItemInputExtensibleEnum; +import com._specs_.azure.core.page.models.User; +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.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; + +/** + * Initializes a new instance of the synchronous PageClient type. + */ +@ServiceClient(builder = PageClientBuilder.class) +public final class PageClient { + @Generated + private final PageClientImpl serviceClient; + + /** + * Initializes an instance of PageClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PageClient(PageClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List with Azure.Core.Page<>. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithPage(RequestOptions requestOptions) { + return this.serviceClient.listWithPage(requestOptions); + } + + /** + * List with extensible enum parameter Azure.Core.Page<>. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
anotherStringNoAnother query parameter. Allowed values: "First", + * "Second".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     inputName: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param bodyInput The body of the input. + * @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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithParameters(BinaryData bodyInput, RequestOptions requestOptions) { + return this.serviceClient.listWithParameters(bodyInput, requestOptions); + } + + /** + * List with custom page model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (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 the paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithCustomPageModel(RequestOptions requestOptions) { + return this.serviceClient.listWithCustomPageModel(requestOptions); + } + + /** + * List with Azure.Core.Page<>. + * + * @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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithPage() { + // Generated convenience method for listWithPage + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listWithPage(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(User.class)); + } + + /** + * List with extensible enum parameter Azure.Core.Page<>. + * + * @param bodyInput The body of the input. + * @param another Another query 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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithParameters(ListItemInputBody bodyInput, ListItemInputExtensibleEnum another) { + // Generated convenience method for listWithParameters + RequestOptions requestOptions = new RequestOptions(); + if (another != null) { + requestOptions.addQueryParam("another", another.toString(), false); + } + return serviceClient.listWithParameters(BinaryData.fromObject(bodyInput), requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(User.class)); + } + + /** + * List with extensible enum parameter Azure.Core.Page<>. + * + * @param bodyInput The body of the input. + * @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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithParameters(ListItemInputBody bodyInput) { + // Generated convenience method for listWithParameters + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listWithParameters(BinaryData.fromObject(bodyInput), requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(User.class)); + } + + /** + * List with custom page model. + * + * @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 the paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithCustomPageModel() { + // Generated convenience method for listWithCustomPageModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listWithCustomPageModel(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(User.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/PageClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/PageClientBuilder.java new file mode 100644 index 000000000..80b9dd8ce --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/PageClientBuilder.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page; + +import com._specs_.azure.core.page.implementation.PageClientImpl; +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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; + +/** + * A builder for creating a new instance of the PageClient type. + */ +@ServiceClientBuilder( + serviceClients = { + PageClient.class, + TwoModelsAsPageItemClient.class, + PageAsyncClient.class, + TwoModelsAsPageItemAsyncClient.class }) +public final class PageClientBuilder + 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("_specs_-azure-core-page.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the PageClientBuilder. + */ + @Generated + public PageClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PageClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PageClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PageClientBuilder 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 PageClientBuilder 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 PageClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PageClientBuilder 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 PageClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PageClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private PageServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the PageClientBuilder. + */ + @Generated + public PageClientBuilder serviceVersion(PageServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 PageClientBuilder. + */ + @Generated + public PageClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of PageClientImpl with the provided parameters. + * + * @return an instance of PageClientImpl. + */ + @Generated + private PageClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + PageServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : PageServiceVersion.getLatest(); + PageClientImpl client = new PageClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, localServiceVersion); + 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 PageAsyncClient class. + * + * @return an instance of PageAsyncClient. + */ + @Generated + public PageAsyncClient buildAsyncClient() { + return new PageAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of TwoModelsAsPageItemAsyncClient class. + * + * @return an instance of TwoModelsAsPageItemAsyncClient. + */ + @Generated + public TwoModelsAsPageItemAsyncClient buildTwoModelsAsPageItemAsyncClient() { + return new TwoModelsAsPageItemAsyncClient(buildInnerClient().getTwoModelsAsPageItems()); + } + + /** + * Builds an instance of PageClient class. + * + * @return an instance of PageClient. + */ + @Generated + public PageClient buildClient() { + return new PageClient(buildInnerClient()); + } + + /** + * Builds an instance of TwoModelsAsPageItemClient class. + * + * @return an instance of TwoModelsAsPageItemClient. + */ + @Generated + public TwoModelsAsPageItemClient buildTwoModelsAsPageItemClient() { + return new TwoModelsAsPageItemClient(buildInnerClient().getTwoModelsAsPageItems()); + } + + private static final ClientLogger LOGGER = new ClientLogger(PageClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/PageServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/PageServiceVersion.java new file mode 100644 index 000000000..6467cd5f9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/PageServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of PageClient. + */ +public enum PageServiceVersion implements ServiceVersion { + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + PageServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link PageServiceVersion}. + */ + public static PageServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/TwoModelsAsPageItemAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/TwoModelsAsPageItemAsyncClient.java new file mode 100644 index 000000000..7fd06e6fb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/TwoModelsAsPageItemAsyncClient.java @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page; + +import com._specs_.azure.core.page.implementation.TwoModelsAsPageItemsImpl; +import com._specs_.azure.core.page.models.FirstItem; +import com._specs_.azure.core.page.models.SecondItem; +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.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; + +/** + * Initializes a new instance of the asynchronous PageClient type. + */ +@ServiceClient(builder = PageClientBuilder.class, isAsync = true) +public final class TwoModelsAsPageItemAsyncClient { + @Generated + private final TwoModelsAsPageItemsImpl serviceClient; + + /** + * Initializes an instance of TwoModelsAsPageItemAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + TwoModelsAsPageItemAsyncClient(TwoModelsAsPageItemsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * FirstItem. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: 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 paged collection of FirstItem items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listFirstItem(RequestOptions requestOptions) { + return this.serviceClient.listFirstItemAsync(requestOptions); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * SecondItem. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 paged collection of SecondItem items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listSecondItem(RequestOptions requestOptions) { + return this.serviceClient.listSecondItemAsync(requestOptions); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * FirstItem. + * + * @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 paged collection of FirstItem items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listFirstItem() { + // Generated convenience method for listFirstItem + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listFirstItem(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(FirstItem.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * SecondItem. + * + * @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 paged collection of SecondItem items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listSecondItem() { + // Generated convenience method for listSecondItem + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listSecondItem(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(SecondItem.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/TwoModelsAsPageItemClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/TwoModelsAsPageItemClient.java new file mode 100644 index 000000000..865846757 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/TwoModelsAsPageItemClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page; + +import com._specs_.azure.core.page.implementation.TwoModelsAsPageItemsImpl; +import com._specs_.azure.core.page.models.FirstItem; +import com._specs_.azure.core.page.models.SecondItem; +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.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; + +/** + * Initializes a new instance of the synchronous PageClient type. + */ +@ServiceClient(builder = PageClientBuilder.class) +public final class TwoModelsAsPageItemClient { + @Generated + private final TwoModelsAsPageItemsImpl serviceClient; + + /** + * Initializes an instance of TwoModelsAsPageItemClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + TwoModelsAsPageItemClient(TwoModelsAsPageItemsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * FirstItem. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: 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 paged collection of FirstItem items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listFirstItem(RequestOptions requestOptions) { + return this.serviceClient.listFirstItem(requestOptions); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * SecondItem. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 paged collection of SecondItem items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listSecondItem(RequestOptions requestOptions) { + return this.serviceClient.listSecondItem(requestOptions); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * FirstItem. + * + * @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 paged collection of FirstItem items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listFirstItem() { + // Generated convenience method for listFirstItem + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listFirstItem(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(FirstItem.class)); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * SecondItem. + * + * @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 paged collection of SecondItem items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listSecondItem() { + // Generated convenience method for listSecondItem + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listSecondItem(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(SecondItem.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/implementation/PageClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/implementation/PageClientImpl.java new file mode 100644 index 000000000..63bf4c0cc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/implementation/PageClientImpl.java @@ -0,0 +1,1036 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page.implementation; + +import com._specs_.azure.core.page.PageServiceVersion; +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +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.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.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.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 java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the PageClient type. + */ +public final class PageClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PageClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final PageServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public PageServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * The TwoModelsAsPageItemsImpl object to access its operations. + */ + private final TwoModelsAsPageItemsImpl twoModelsAsPageItems; + + /** + * Gets the TwoModelsAsPageItemsImpl object to access its operations. + * + * @return the TwoModelsAsPageItemsImpl object. + */ + public TwoModelsAsPageItemsImpl getTwoModelsAsPageItems() { + return this.twoModelsAsPageItems; + } + + /** + * Initializes an instance of PageClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public PageClientImpl(String endpoint, PageServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of PageClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public PageClientImpl(HttpPipeline httpPipeline, String endpoint, PageServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of PageClient 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. + * @param serviceVersion Service version. + */ + public PageClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + PageServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.twoModelsAsPageItems = new TwoModelsAsPageItemsImpl(this); + this.service = RestProxy.create(PageClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for PageClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PageClient") + public interface PageClientService { + @Get("/azure/core/page/page") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listWithPage(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/core/page/page") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listWithPageSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/core/page/parameters") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listWithParameters(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData bodyInput, RequestOptions requestOptions, Context context); + + @Get("/azure/core/page/parameters") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listWithParametersSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData bodyInput, RequestOptions requestOptions, Context context); + + @Get("/azure/core/page/custom-page") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listWithCustomPageModel(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/core/page/custom-page") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listWithCustomPageModelSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listWithPageNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listWithPageNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listWithParametersNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listWithParametersNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listWithCustomPageModelNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listWithCustomPageModelNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * List with Azure.Core.Page<>. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (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 paged collection of User items along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listWithPageSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listWithPage(this.getEndpoint(), this.getServiceVersion().getVersion(), + accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List with Azure.Core.Page<>. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithPageAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listWithPageSinglePageAsync(requestOptions), + nextLink -> listWithPageNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * List with Azure.Core.Page<>. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (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 paged collection of User items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listWithPageSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listWithPageSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List with Azure.Core.Page<>. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithPage(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listWithPageSinglePage(requestOptions), + nextLink -> listWithPageNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * List with extensible enum parameter Azure.Core.Page<>. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
anotherStringNoAnother query parameter. Allowed values: "First", + * "Second".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     inputName: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param bodyInput The body of the input. + * @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 paged collection of User items along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listWithParametersSinglePageAsync(BinaryData bodyInput, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listWithParameters(this.getEndpoint(), + this.getServiceVersion().getVersion(), accept, bodyInput, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List with extensible enum parameter Azure.Core.Page<>. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
anotherStringNoAnother query parameter. Allowed values: "First", + * "Second".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     inputName: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param bodyInput The body of the input. + * @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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithParametersAsync(BinaryData bodyInput, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listWithParametersSinglePageAsync(bodyInput, requestOptions), + nextLink -> listWithParametersNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * List with extensible enum parameter Azure.Core.Page<>. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
anotherStringNoAnother query parameter. Allowed values: "First", + * "Second".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     inputName: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param bodyInput The body of the input. + * @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 paged collection of User items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listWithParametersSinglePage(BinaryData bodyInput, + RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listWithParametersSync(this.getEndpoint(), + this.getServiceVersion().getVersion(), accept, bodyInput, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List with extensible enum parameter Azure.Core.Page<>. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
anotherStringNoAnother query parameter. Allowed values: "First", + * "Second".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     inputName: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param bodyInput The body of the input. + * @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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithParameters(BinaryData bodyInput, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listWithParametersSinglePage(bodyInput, requestOptions), + nextLink -> listWithParametersNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * List with custom page model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (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 the response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listWithCustomPageModelSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listWithCustomPageModel(this.getEndpoint(), + this.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "items"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List with custom page model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (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 the paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithCustomPageModelAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listWithCustomPageModelSinglePageAsync(requestOptions), + nextLink -> listWithCustomPageModelNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * List with custom page model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (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 the response body along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listWithCustomPageModelSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listWithCustomPageModelSync(this.getEndpoint(), + this.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "items"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List with custom page model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (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 the paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithCustomPageModel(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listWithCustomPageModelSinglePage(requestOptions), + nextLink -> listWithCustomPageModelNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * List with Azure.Core.Page<>. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of User items along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listWithPageNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listWithPageNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List with Azure.Core.Page<>. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of User items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listWithPageNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listWithPageNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List with extensible enum parameter Azure.Core.Page<>. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of User items along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listWithParametersNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.listWithParametersNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List with extensible enum parameter Azure.Core.Page<>. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of User items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listWithParametersNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listWithParametersNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List with custom page model. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listWithCustomPageModelNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listWithCustomPageModelNext(nextLink, this.getEndpoint(), accept, + requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "items"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List with custom page model. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     *     orders (Optional): [
+     *          (Optional){
+     *             id: int (Required)
+     *             userId: int (Required)
+     *             detail: String (Required)
+     *         }
+     *     ]
+     *     etag: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 response body along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listWithCustomPageModelNextSinglePage(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listWithCustomPageModelNextSync(nextLink, this.getEndpoint(), accept, + requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "items"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/implementation/TwoModelsAsPageItemsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/implementation/TwoModelsAsPageItemsImpl.java new file mode 100644 index 000000000..239ad7013 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/implementation/TwoModelsAsPageItemsImpl.java @@ -0,0 +1,522 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page.implementation; + +import com._specs_.azure.core.page.PageServiceVersion; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +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.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.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 java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in TwoModelsAsPageItems. + */ +public final class TwoModelsAsPageItemsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final TwoModelsAsPageItemsService service; + + /** + * The service client containing this operation class. + */ + private final PageClientImpl client; + + /** + * Initializes an instance of TwoModelsAsPageItemsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + TwoModelsAsPageItemsImpl(PageClientImpl client) { + this.service = RestProxy.create(TwoModelsAsPageItemsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public PageServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for PageClientTwoModelsAsPageItems to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PageClientTwoModelsA") + public interface TwoModelsAsPageItemsService { + @Get("/azure/core/page/first-item") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listFirstItem(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/core/page/first-item") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listFirstItemSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/core/page/second-item") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listSecondItem(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/core/page/second-item") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listSecondItemSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listFirstItemNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listFirstItemNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listSecondItemNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listSecondItemNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * FirstItem. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: 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 paged collection of FirstItem items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listFirstItemSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listFirstItem(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * FirstItem. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: 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 paged collection of FirstItem items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listFirstItemAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listFirstItemSinglePageAsync(requestOptions), + nextLink -> listFirstItemNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * FirstItem. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: 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 paged collection of FirstItem items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listFirstItemSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listFirstItemSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * FirstItem. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: 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 paged collection of FirstItem items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listFirstItem(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listFirstItemSinglePage(requestOptions), + nextLink -> listFirstItemNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * SecondItem. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 paged collection of SecondItem items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSecondItemSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listSecondItem(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * SecondItem. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 paged collection of SecondItem items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listSecondItemAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listSecondItemSinglePageAsync(requestOptions), + nextLink -> listSecondItemNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * SecondItem. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 paged collection of SecondItem items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSecondItemSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listSecondItemSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * SecondItem. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 paged collection of SecondItem items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listSecondItem(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listSecondItemSinglePage(requestOptions), + nextLink -> listSecondItemNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * FirstItem. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of FirstItem items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listFirstItemNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.listFirstItemNext(nextLink, this.client.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * FirstItem. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of FirstItem items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listFirstItemNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listFirstItemNextSync(nextLink, this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * SecondItem. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of SecondItem items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSecondItemNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.listSecondItemNext(nextLink, this.client.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Two operations with two different page item types should be successfully generated. Should generate model for + * SecondItem. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of SecondItem items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSecondItemNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listSecondItemNextSync(nextLink, this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/implementation/package-info.java new file mode 100644 index 000000000..bbc401e32 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/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 Page. + * Illustrates bodies templated with Azure Core with paging support. + * + */ +package com._specs_.azure.core.page.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/FirstItem.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/FirstItem.java new file mode 100644 index 000000000..8b3a2f0a0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/FirstItem.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page.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; + +/** + * First item. + */ +@Immutable +public final class FirstItem implements JsonSerializable { + /* + * The id of the item. + */ + @Generated + private int id; + + /** + * Creates an instance of FirstItem class. + */ + @Generated + private FirstItem() { + } + + /** + * Get the id property: The id of the item. + * + * @return the id value. + */ + @Generated + public int getId() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FirstItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FirstItem 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 FirstItem. + */ + @Generated + public static FirstItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FirstItem deserializedFirstItem = new FirstItem(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedFirstItem.id = reader.getInt(); + } else { + reader.skipChildren(); + } + } + + return deserializedFirstItem; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/ListItemInputBody.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/ListItemInputBody.java new file mode 100644 index 000000000..45a377955 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/ListItemInputBody.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page.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; + +/** + * The body of the input. + */ +@Immutable +public final class ListItemInputBody implements JsonSerializable { + /* + * The name of the input. + */ + @Generated + private final String inputName; + + /** + * Creates an instance of ListItemInputBody class. + * + * @param inputName the inputName value to set. + */ + @Generated + public ListItemInputBody(String inputName) { + this.inputName = inputName; + } + + /** + * Get the inputName property: The name of the input. + * + * @return the inputName value. + */ + @Generated + public String getInputName() { + return this.inputName; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("inputName", this.inputName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ListItemInputBody from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ListItemInputBody 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 ListItemInputBody. + */ + @Generated + public static ListItemInputBody fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String inputName = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("inputName".equals(fieldName)) { + inputName = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ListItemInputBody(inputName); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/ListItemInputExtensibleEnum.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/ListItemInputExtensibleEnum.java new file mode 100644 index 000000000..740e1316b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/ListItemInputExtensibleEnum.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 com._specs_.azure.core.page.models; + +/** + * An extensible enum input parameter. + */ +public enum ListItemInputExtensibleEnum { + /** + * The first enum value. + */ + FIRST("First"), + + /** + * The second enum value. + */ + SECOND("Second"); + + /** + * The actual serialized value for a ListItemInputExtensibleEnum instance. + */ + private final String value; + + ListItemInputExtensibleEnum(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ListItemInputExtensibleEnum instance. + * + * @param value the serialized value to parse. + * @return the parsed ListItemInputExtensibleEnum object, or null if unable to parse. + */ + public static ListItemInputExtensibleEnum fromString(String value) { + if (value == null) { + return null; + } + ListItemInputExtensibleEnum[] items = ListItemInputExtensibleEnum.values(); + for (ListItemInputExtensibleEnum item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/SecondItem.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/SecondItem.java new file mode 100644 index 000000000..28e91adea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/SecondItem.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page.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; + +/** + * Second item. + */ +@Immutable +public final class SecondItem implements JsonSerializable { + /* + * The name of the item. + */ + @Generated + private String name; + + /** + * Creates an instance of SecondItem class. + */ + @Generated + private SecondItem() { + } + + /** + * Get the name property: The name of the item. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SecondItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SecondItem 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 SecondItem. + */ + @Generated + public static SecondItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SecondItem deserializedSecondItem = new SecondItem(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedSecondItem.name = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSecondItem; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/User.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/User.java new file mode 100644 index 000000000..4e26e26d4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/User.java @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page.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; +import java.util.List; + +/** + * Details about a user. + */ +@Immutable +public final class User implements JsonSerializable { + /* + * The user's id. + */ + @Generated + private int id; + + /* + * The user's name. + */ + @Generated + private final String name; + + /* + * The user's order list + */ + @Generated + private List orders; + + /* + * The entity tag for this resource. + */ + @Generated + private String etag; + + /** + * Creates an instance of User class. + * + * @param name the name value to set. + */ + @Generated + private User(String name) { + this.name = name; + } + + /** + * Get the id property: The user's id. + * + * @return the id value. + */ + @Generated + public int getId() { + return this.id; + } + + /** + * Get the name property: The user's name. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the orders property: The user's order list. + * + * @return the orders value. + */ + @Generated + public List getOrders() { + return this.orders; + } + + /** + * Get the etag property: The entity tag for this resource. + * + * @return the etag value. + */ + @Generated + public String getEtag() { + return this.etag; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeArrayField("orders", this.orders, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of User from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of User 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 User. + */ + @Generated + public static User fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int id = 0; + String name = null; + String etag = null; + List orders = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getInt(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("etag".equals(fieldName)) { + etag = reader.getString(); + } else if ("orders".equals(fieldName)) { + orders = reader.readArray(reader1 -> UserOrder.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + User deserializedUser = new User(name); + deserializedUser.id = id; + deserializedUser.etag = etag; + deserializedUser.orders = orders; + + return deserializedUser; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/UserOrder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/UserOrder.java new file mode 100644 index 000000000..abfde11dc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/UserOrder.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page.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; + +/** + * UserOrder for testing list with expand. + */ +@Immutable +public final class UserOrder implements JsonSerializable { + /* + * The user's id. + */ + @Generated + private int id; + + /* + * The user's id. + */ + @Generated + private final int userId; + + /* + * The user's order detail + */ + @Generated + private final String detail; + + /** + * Creates an instance of UserOrder class. + * + * @param userId the userId value to set. + * @param detail the detail value to set. + */ + @Generated + private UserOrder(int userId, String detail) { + this.userId = userId; + this.detail = detail; + } + + /** + * Get the id property: The user's id. + * + * @return the id value. + */ + @Generated + public int getId() { + return this.id; + } + + /** + * Get the userId property: The user's id. + * + * @return the userId value. + */ + @Generated + public int getUserId() { + return this.userId; + } + + /** + * Get the detail property: The user's order detail. + * + * @return the detail value. + */ + @Generated + public String getDetail() { + return this.detail; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("userId", this.userId); + jsonWriter.writeStringField("detail", this.detail); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserOrder from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserOrder 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 UserOrder. + */ + @Generated + public static UserOrder fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int id = 0; + int userId = 0; + String detail = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getInt(); + } else if ("userId".equals(fieldName)) { + userId = reader.getInt(); + } else if ("detail".equals(fieldName)) { + detail = reader.getString(); + } else { + reader.skipChildren(); + } + } + UserOrder deserializedUserOrder = new UserOrder(userId, detail); + deserializedUserOrder.id = id; + + return deserializedUserOrder; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/models/package-info.java new file mode 100644 index 000000000..3e6091912 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/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 Page. + * Illustrates bodies templated with Azure Core with paging support. + * + */ +package com._specs_.azure.core.page.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/package-info.java new file mode 100644 index 000000000..8f73b11cf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/page/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 Page. + * Illustrates bodies templated with Azure Core with paging support. + * + */ +package com._specs_.azure.core.page; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/ScalarAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/ScalarAsyncClient.java new file mode 100644 index 000000000..a7cb562f8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/ScalarAsyncClient.java @@ -0,0 +1,249 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.scalar; + +import com._specs_.azure.core.scalar.implementation.AzureLocationScalarsImpl; +import com._specs_.azure.core.scalar.models.AzureLocationModel; +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 reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class, isAsync = true) +public final class ScalarAsyncClient { + @Generated + private final AzureLocationScalarsImpl serviceClient; + + /** + * Initializes an instance of ScalarAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ScalarAsyncClient(AzureLocationScalarsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get azureLocation value. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 azureLocation value along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * put azureLocation value. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param body _. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * post a model which has azureLocation property. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     location: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     location: String (Required)
+     * }
+     * }
+ * + * @param body _. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postWithResponseAsync(body, requestOptions); + } + + /** + * azureLocation value header. + * + * @param region _. + * @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> headerMethodWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.headerMethodWithResponseAsync(region, requestOptions); + } + + /** + * azureLocation value query. + * + * @param region _. + * @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> queryWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.queryWithResponseAsync(region, requestOptions); + } + + /** + * get azureLocation value. + * + * @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 azureLocation value on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * put azureLocation value. + * + * @param body _. + * @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 put(String body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * post a model which has azureLocation property. + * + * @param body _. + * @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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono post(AzureLocationModel body) { + // Generated convenience method for postWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AzureLocationModel.class)); + } + + /** + * azureLocation value header. + * + * @param region _. + * @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 headerMethod(String region) { + // Generated convenience method for headerMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return headerMethodWithResponse(region, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * azureLocation value query. + * + * @param region _. + * @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 query(String region) { + // Generated convenience method for queryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return queryWithResponse(region, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/ScalarClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/ScalarClient.java new file mode 100644 index 000000000..593f5fd1e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/ScalarClient.java @@ -0,0 +1,243 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.scalar; + +import com._specs_.azure.core.scalar.implementation.AzureLocationScalarsImpl; +import com._specs_.azure.core.scalar.models.AzureLocationModel; +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; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class ScalarClient { + @Generated + private final AzureLocationScalarsImpl serviceClient; + + /** + * Initializes an instance of ScalarClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ScalarClient(AzureLocationScalarsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get azureLocation value. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 azureLocation value along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * put azureLocation value. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param body _. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * post a model which has azureLocation property. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     location: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     location: String (Required)
+     * }
+     * }
+ * + * @param body _. + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postWithResponse(body, requestOptions); + } + + /** + * azureLocation value header. + * + * @param region _. + * @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 headerMethodWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.headerMethodWithResponse(region, requestOptions); + } + + /** + * azureLocation value query. + * + * @param region _. + * @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 queryWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.queryWithResponse(region, requestOptions); + } + + /** + * get azureLocation value. + * + * @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 azureLocation value. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(String.class); + } + + /** + * put azureLocation value. + * + * @param body _. + * @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 put(String body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * post a model which has azureLocation property. + * + * @param body _. + * @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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AzureLocationModel post(AzureLocationModel body) { + // Generated convenience method for postWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(AzureLocationModel.class); + } + + /** + * azureLocation value header. + * + * @param region _. + * @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 headerMethod(String region) { + // Generated convenience method for headerMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + headerMethodWithResponse(region, requestOptions).getValue(); + } + + /** + * azureLocation value query. + * + * @param region _. + * @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 query(String region) { + // Generated convenience method for queryWithResponse + RequestOptions requestOptions = new RequestOptions(); + queryWithResponse(region, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/ScalarClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/ScalarClientBuilder.java new file mode 100644 index 000000000..e6b649b44 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/ScalarClientBuilder.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.scalar; + +import com._specs_.azure.core.scalar.implementation.ScalarClientImpl; +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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; + +/** + * A builder for creating a new instance of the ScalarClient type. + */ +@ServiceClientBuilder(serviceClients = { ScalarClient.class, ScalarAsyncClient.class }) +public final class ScalarClientBuilder 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("_specs_-azure-core-scalar.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ScalarClientBuilder. + */ + @Generated + public ScalarClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ScalarClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ScalarClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ScalarClientBuilder 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 ScalarClientBuilder 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 ScalarClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ScalarClientBuilder 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 ScalarClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ScalarClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private ScalarServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the ScalarClientBuilder. + */ + @Generated + public ScalarClientBuilder serviceVersion(ScalarServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 ScalarClientBuilder. + */ + @Generated + public ScalarClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ScalarClientImpl with the provided parameters. + * + * @return an instance of ScalarClientImpl. + */ + @Generated + private ScalarClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ScalarServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ScalarServiceVersion.getLatest(); + ScalarClientImpl client = new ScalarClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, localServiceVersion); + 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 ScalarAsyncClient class. + * + * @return an instance of ScalarAsyncClient. + */ + @Generated + public ScalarAsyncClient buildAsyncClient() { + return new ScalarAsyncClient(buildInnerClient().getAzureLocationScalars()); + } + + /** + * Builds an instance of ScalarClient class. + * + * @return an instance of ScalarClient. + */ + @Generated + public ScalarClient buildClient() { + return new ScalarClient(buildInnerClient().getAzureLocationScalars()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ScalarClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/ScalarServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/ScalarServiceVersion.java new file mode 100644 index 000000000..097b4768c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/ScalarServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.scalar; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of ScalarClient. + */ +public enum ScalarServiceVersion implements ServiceVersion { + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + ScalarServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link ScalarServiceVersion}. + */ + public static ScalarServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/implementation/AzureLocationScalarsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/implementation/AzureLocationScalarsImpl.java new file mode 100644 index 000000000..ad6f9f9f6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/implementation/AzureLocationScalarsImpl.java @@ -0,0 +1,387 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.scalar.implementation; + +import com._specs_.azure.core.scalar.ScalarServiceVersion; +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +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.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.BinaryData; +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 AzureLocationScalars. + */ +public final class AzureLocationScalarsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final AzureLocationScalarsService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of AzureLocationScalarsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + AzureLocationScalarsImpl(ScalarClientImpl client) { + this.service = RestProxy.create(AzureLocationScalarsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ScalarServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for ScalarClientAzureLocationScalars to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ScalarClientAzureLoc") + public interface AzureLocationScalarsService { + @Get("/azure/core/scalar/azureLocation") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/core/scalar/azureLocation") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/azure/core/scalar/azureLocation") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/azure/core/scalar/azureLocation") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/azure/core/scalar/azureLocation") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> post(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/azure/core/scalar/azureLocation") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response postSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/azure/core/scalar/azureLocation/header") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> headerMethod(@HostParam("endpoint") String endpoint, @HeaderParam("region") String region, + RequestOptions requestOptions, Context context); + + @Post("/azure/core/scalar/azureLocation/header") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response headerMethodSync(@HostParam("endpoint") String endpoint, @HeaderParam("region") String region, + RequestOptions requestOptions, Context context); + + @Post("/azure/core/scalar/azureLocation/query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> query(@HostParam("endpoint") String endpoint, @QueryParam("region") String region, + RequestOptions requestOptions, Context context); + + @Post("/azure/core/scalar/azureLocation/query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response querySync(@HostParam("endpoint") String endpoint, @QueryParam("region") String region, + RequestOptions requestOptions, Context context); + } + + /** + * get azureLocation value. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 azureLocation value along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * get azureLocation value. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 azureLocation value along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * put azureLocation value. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param body _. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * put azureLocation value. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param body _. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * post a model which has azureLocation property. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     location: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     location: String (Required)
+     * }
+     * }
+ * + * @param body _. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.post(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); + } + + /** + * post a model which has azureLocation property. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     location: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     location: String (Required)
+     * }
+     * }
+ * + * @param body _. + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.postSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); + } + + /** + * azureLocation value header. + * + * @param region _. + * @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> headerMethodWithResponseAsync(String region, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.headerMethod(this.client.getEndpoint(), region, requestOptions, context)); + } + + /** + * azureLocation value header. + * + * @param region _. + * @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 headerMethodWithResponse(String region, RequestOptions requestOptions) { + return service.headerMethodSync(this.client.getEndpoint(), region, requestOptions, Context.NONE); + } + + /** + * azureLocation value query. + * + * @param region _. + * @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> queryWithResponseAsync(String region, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.query(this.client.getEndpoint(), region, requestOptions, context)); + } + + /** + * azureLocation value query. + * + * @param region _. + * @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 queryWithResponse(String region, RequestOptions requestOptions) { + return service.querySync(this.client.getEndpoint(), region, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/implementation/ScalarClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/implementation/ScalarClientImpl.java new file mode 100644 index 000000000..8571d3943 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/implementation/ScalarClientImpl.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.scalar.implementation; + +import com._specs_.azure.core.scalar.ScalarServiceVersion; +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the ScalarClient type. + */ +public final class ScalarClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final ScalarServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ScalarServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * The AzureLocationScalarsImpl object to access its operations. + */ + private final AzureLocationScalarsImpl azureLocationScalars; + + /** + * Gets the AzureLocationScalarsImpl object to access its operations. + * + * @return the AzureLocationScalarsImpl object. + */ + public AzureLocationScalarsImpl getAzureLocationScalars() { + return this.azureLocationScalars; + } + + /** + * Initializes an instance of ScalarClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public ScalarClientImpl(String endpoint, ScalarServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of ScalarClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public ScalarClientImpl(HttpPipeline httpPipeline, String endpoint, ScalarServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of ScalarClient 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. + * @param serviceVersion Service version. + */ + public ScalarClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + ScalarServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.azureLocationScalars = new AzureLocationScalarsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/implementation/package-info.java new file mode 100644 index 000000000..f9b10861e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Scalar. + * + */ +package com._specs_.azure.core.scalar.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/models/AzureLocationModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/models/AzureLocationModel.java new file mode 100644 index 000000000..f05793328 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/models/AzureLocationModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.scalar.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; + +/** + * The AzureLocationModel model. + */ +@Immutable +public final class AzureLocationModel implements JsonSerializable { + /* + * The location property. + */ + @Generated + private final String location; + + /** + * Creates an instance of AzureLocationModel class. + * + * @param location the location value to set. + */ + @Generated + public AzureLocationModel(String location) { + this.location = location; + } + + /** + * Get the location property: The location property. + * + * @return the location value. + */ + @Generated + public String getLocation() { + return this.location; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", this.location); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureLocationModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureLocationModel 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 AzureLocationModel. + */ + @Generated + public static AzureLocationModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String location = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("location".equals(fieldName)) { + location = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new AzureLocationModel(location); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/models/package-info.java new file mode 100644 index 000000000..13abc89b5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Scalar. + * + */ +package com._specs_.azure.core.scalar.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/package-info.java new file mode 100644 index 000000000..3f943f42f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/scalar/package-info.java @@ -0,0 +1,10 @@ +// 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 Scalar. + * + */ +package com._specs_.azure.core.scalar; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/TraitsAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/TraitsAsyncClient.java new file mode 100644 index 000000000..68f22bd50 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/TraitsAsyncClient.java @@ -0,0 +1,215 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.traits; + +import com._specs_.azure.core.traits.implementation.TraitsClientImpl; +import com._specs_.azure.core.traits.models.User; +import com._specs_.azure.core.traits.models.UserActionParam; +import com._specs_.azure.core.traits.models.UserActionResponse; +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.HttpHeaderName; +import com.azure.core.http.RequestConditions; +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.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous TraitsClient type. + */ +@ServiceClient(builder = TraitsClientBuilder.class, isAsync = true) +public final class TraitsAsyncClient { + @Generated + private final TraitsClientImpl serviceClient; + + /** + * Initializes an instance of TraitsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + TraitsAsyncClient(TraitsClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get a resource, sending and receiving headers. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional)
+     * }
+     * }
+ * + * @param id The user's id. + * @param foo header in request. + * @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 resource, sending and receiving headers along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> smokeTestWithResponse(int id, String foo, RequestOptions requestOptions) { + return this.serviceClient.smokeTestWithResponseAsync(id, foo, requestOptions); + } + + /** + * Test for repeatable requests. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     userActionValue: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     userActionResult: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param body The body 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 user action response along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> repeatableActionWithResponse(int id, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.repeatableActionWithResponseAsync(id, body, requestOptions); + } + + /** + * Get a resource, sending and receiving headers. + * + * @param id The user's id. + * @param foo header in request. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @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 resource, sending and receiving headers on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono smokeTest(int id, String foo, RequestConditions requestConditions) { + // Generated convenience method for smokeTestWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return smokeTestWithResponse(id, foo, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(User.class)); + } + + /** + * Get a resource, sending and receiving headers. + * + * @param id The user's id. + * @param foo header in request. + * @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 resource, sending and receiving headers on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono smokeTest(int id, String foo) { + // Generated convenience method for smokeTestWithResponse + RequestOptions requestOptions = new RequestOptions(); + return smokeTestWithResponse(id, foo, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(User.class)); + } + + /** + * Test for repeatable requests. + * + * @param id The user's id. + * @param body The body 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 user action response on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono repeatableAction(int id, UserActionParam body) { + // Generated convenience method for repeatableActionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return repeatableActionWithResponse(id, BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UserActionResponse.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/TraitsClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/TraitsClient.java new file mode 100644 index 000000000..ef9927aaf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/TraitsClient.java @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.traits; + +import com._specs_.azure.core.traits.implementation.TraitsClientImpl; +import com._specs_.azure.core.traits.models.User; +import com._specs_.azure.core.traits.models.UserActionParam; +import com._specs_.azure.core.traits.models.UserActionResponse; +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.HttpHeaderName; +import com.azure.core.http.RequestConditions; +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.DateTimeRfc1123; +import java.time.OffsetDateTime; + +/** + * Initializes a new instance of the synchronous TraitsClient type. + */ +@ServiceClient(builder = TraitsClientBuilder.class) +public final class TraitsClient { + @Generated + private final TraitsClientImpl serviceClient; + + /** + * Initializes an instance of TraitsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + TraitsClient(TraitsClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get a resource, sending and receiving headers. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional)
+     * }
+     * }
+ * + * @param id The user's id. + * @param foo header in request. + * @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 resource, sending and receiving headers along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response smokeTestWithResponse(int id, String foo, RequestOptions requestOptions) { + return this.serviceClient.smokeTestWithResponse(id, foo, requestOptions); + } + + /** + * Test for repeatable requests. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     userActionValue: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     userActionResult: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param body The body 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 user action response along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response repeatableActionWithResponse(int id, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.repeatableActionWithResponse(id, body, requestOptions); + } + + /** + * Get a resource, sending and receiving headers. + * + * @param id The user's id. + * @param foo header in request. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @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 resource, sending and receiving headers. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public User smokeTest(int id, String foo, RequestConditions requestConditions) { + // Generated convenience method for smokeTestWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return smokeTestWithResponse(id, foo, requestOptions).getValue().toObject(User.class); + } + + /** + * Get a resource, sending and receiving headers. + * + * @param id The user's id. + * @param foo header in request. + * @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 resource, sending and receiving headers. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public User smokeTest(int id, String foo) { + // Generated convenience method for smokeTestWithResponse + RequestOptions requestOptions = new RequestOptions(); + return smokeTestWithResponse(id, foo, requestOptions).getValue().toObject(User.class); + } + + /** + * Test for repeatable requests. + * + * @param id The user's id. + * @param body The body 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 user action response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UserActionResponse repeatableAction(int id, UserActionParam body) { + // Generated convenience method for repeatableActionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return repeatableActionWithResponse(id, BinaryData.fromObject(body), requestOptions).getValue() + .toObject(UserActionResponse.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/TraitsClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/TraitsClientBuilder.java new file mode 100644 index 000000000..fd180f21e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/TraitsClientBuilder.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.traits; + +import com._specs_.azure.core.traits.implementation.TraitsClientImpl; +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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; + +/** + * A builder for creating a new instance of the TraitsClient type. + */ +@ServiceClientBuilder(serviceClients = { TraitsClient.class, TraitsAsyncClient.class }) +public final class TraitsClientBuilder 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("_specs_-azure-core-traits.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the TraitsClientBuilder. + */ + @Generated + public TraitsClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TraitsClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TraitsClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TraitsClientBuilder 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 TraitsClientBuilder 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 TraitsClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TraitsClientBuilder 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 TraitsClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TraitsClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private TraitsServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the TraitsClientBuilder. + */ + @Generated + public TraitsClientBuilder serviceVersion(TraitsServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 TraitsClientBuilder. + */ + @Generated + public TraitsClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of TraitsClientImpl with the provided parameters. + * + * @return an instance of TraitsClientImpl. + */ + @Generated + private TraitsClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + TraitsServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : TraitsServiceVersion.getLatest(); + TraitsClientImpl client = new TraitsClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, localServiceVersion); + 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 TraitsAsyncClient class. + * + * @return an instance of TraitsAsyncClient. + */ + @Generated + public TraitsAsyncClient buildAsyncClient() { + return new TraitsAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of TraitsClient class. + * + * @return an instance of TraitsClient. + */ + @Generated + public TraitsClient buildClient() { + return new TraitsClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(TraitsClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/TraitsServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/TraitsServiceVersion.java new file mode 100644 index 000000000..87a22352c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/TraitsServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.traits; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of TraitsClient. + */ +public enum TraitsServiceVersion implements ServiceVersion { + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + TraitsServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link TraitsServiceVersion}. + */ + public static TraitsServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/implementation/TraitsClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/implementation/TraitsClientImpl.java new file mode 100644 index 000000000..fe021b1fc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/implementation/TraitsClientImpl.java @@ -0,0 +1,395 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.traits.implementation; + +import com._specs_.azure.core.traits.TraitsServiceVersion; +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +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.HttpHeaderName; +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.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the TraitsClient type. + */ +public final class TraitsClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final TraitsClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final TraitsServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public TraitsServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 TraitsClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public TraitsClientImpl(String endpoint, TraitsServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of TraitsClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public TraitsClientImpl(HttpPipeline httpPipeline, String endpoint, TraitsServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of TraitsClient 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. + * @param serviceVersion Service version. + */ + public TraitsClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + TraitsServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(TraitsClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for TraitsClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "TraitsClient") + public interface TraitsClientService { + @Get("/azure/core/traits/user/{id}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> smokeTest(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, @HeaderParam("foo") String foo, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/azure/core/traits/user/{id}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response smokeTestSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, @HeaderParam("foo") String foo, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/azure/core/traits/user/{id}:repeatableAction") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> repeatableAction(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/azure/core/traits/user/{id}:repeatableAction") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response repeatableActionSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") int id, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get a resource, sending and receiving headers. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional)
+     * }
+     * }
+ * + * @param id The user's id. + * @param foo header in request. + * @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 resource, sending and receiving headers along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> smokeTestWithResponseAsync(int id, String foo, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.smokeTest(this.getEndpoint(), + this.getServiceVersion().getVersion(), id, foo, accept, requestOptions, context)); + } + + /** + * Get a resource, sending and receiving headers. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Optional)
+     * }
+     * }
+ * + * @param id The user's id. + * @param foo header in request. + * @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 resource, sending and receiving headers along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response smokeTestWithResponse(int id, String foo, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.smokeTestSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, foo, accept, + requestOptions, Context.NONE); + } + + /** + * Test for repeatable requests. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     userActionValue: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     userActionResult: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param body The body 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 user action response along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> repeatableActionWithResponseAsync(int id, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-request-id"), CoreUtils.randomUuid().toString()); + } + }); + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-first-sent")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-first-sent"), + DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); + } + }); + return FluxUtil.withContext(context -> service.repeatableAction(this.getEndpoint(), + this.getServiceVersion().getVersion(), id, contentType, accept, body, requestOptionsLocal, context)); + } + + /** + * Test for repeatable requests. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     userActionValue: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     userActionResult: String (Required)
+     * }
+     * }
+ * + * @param id The user's id. + * @param body The body 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 user action response along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response repeatableActionWithResponse(int id, BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-request-id"), CoreUtils.randomUuid().toString()); + } + }); + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-first-sent")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-first-sent"), + DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); + } + }); + return service.repeatableActionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, contentType, + accept, body, requestOptionsLocal, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/implementation/package-info.java new file mode 100644 index 000000000..ba7d07ab0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/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 Traits. + * Illustrates Azure Core operation customizations by traits. + * + */ +package com._specs_.azure.core.traits.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/User.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/User.java new file mode 100644 index 000000000..562f7f44a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/User.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.traits.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; + +/** + * Sample Model. + */ +@Immutable +public final class User implements JsonSerializable { + /* + * The user's id. + */ + @Generated + private int id; + + /* + * The user's name. + */ + @Generated + private String name; + + /** + * Creates an instance of User class. + */ + @Generated + private User() { + } + + /** + * Get the id property: The user's id. + * + * @return the id value. + */ + @Generated + public int getId() { + return this.id; + } + + /** + * Get the name property: The user's name. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of User from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of User 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 User. + */ + @Generated + public static User fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + User deserializedUser = new User(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedUser.id = reader.getInt(); + } else if ("name".equals(fieldName)) { + deserializedUser.name = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedUser; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/UserActionParam.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/UserActionParam.java new file mode 100644 index 000000000..b7772c28d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/UserActionParam.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.traits.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; + +/** + * User action param. + */ +@Immutable +public final class UserActionParam implements JsonSerializable { + /* + * User action value. + */ + @Generated + private final String userActionValue; + + /** + * Creates an instance of UserActionParam class. + * + * @param userActionValue the userActionValue value to set. + */ + @Generated + public UserActionParam(String userActionValue) { + this.userActionValue = userActionValue; + } + + /** + * Get the userActionValue property: User action value. + * + * @return the userActionValue value. + */ + @Generated + public String getUserActionValue() { + return this.userActionValue; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("userActionValue", this.userActionValue); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserActionParam from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserActionParam 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 UserActionParam. + */ + @Generated + public static UserActionParam fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String userActionValue = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("userActionValue".equals(fieldName)) { + userActionValue = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new UserActionParam(userActionValue); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/UserActionResponse.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/UserActionResponse.java new file mode 100644 index 000000000..7852ae4bc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/UserActionResponse.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.traits.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; + +/** + * User action response. + */ +@Immutable +public final class UserActionResponse implements JsonSerializable { + /* + * User action result. + */ + @Generated + private final String userActionResult; + + /** + * Creates an instance of UserActionResponse class. + * + * @param userActionResult the userActionResult value to set. + */ + @Generated + private UserActionResponse(String userActionResult) { + this.userActionResult = userActionResult; + } + + /** + * Get the userActionResult property: User action result. + * + * @return the userActionResult value. + */ + @Generated + public String getUserActionResult() { + return this.userActionResult; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("userActionResult", this.userActionResult); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserActionResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserActionResponse 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 UserActionResponse. + */ + @Generated + public static UserActionResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String userActionResult = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("userActionResult".equals(fieldName)) { + userActionResult = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new UserActionResponse(userActionResult); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/models/package-info.java new file mode 100644 index 000000000..168cad162 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/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 Traits. + * Illustrates Azure Core operation customizations by traits. + * + */ +package com._specs_.azure.core.traits.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/package-info.java new file mode 100644 index 000000000..ed865539b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/core/traits/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 Traits. + * Illustrates Azure Core operation customizations by traits. + * + */ +package com._specs_.azure.core.traits; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/AzureExampleAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/AzureExampleAsyncClient.java new file mode 100644 index 000000000..6f1a775f5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/AzureExampleAsyncClient.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 com._specs_.azure.example.basic; + +import com._specs_.azure.example.basic.implementation.AzureExampleClientImpl; +import com._specs_.azure.example.basic.models.ActionRequest; +import com._specs_.azure.example.basic.models.ActionResponse; +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 reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AzureExampleClient type. + */ +@ServiceClient(builder = AzureExampleClientBuilder.class, isAsync = true) +public final class AzureExampleAsyncClient { + @Generated + private final AzureExampleClientImpl serviceClient; + + /** + * Initializes an instance of AzureExampleAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + AzureExampleAsyncClient(AzureExampleClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The basicAction operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     stringProperty: String (Required)
+     *     modelProperty (Optional): {
+     *         int32Property: Integer (Optional)
+     *         float32Property: Double (Optional)
+     *         enumProperty: String(EnumValue1) (Optional)
+     *     }
+     *     arrayProperty (Optional): [
+     *         String (Optional)
+     *     ]
+     *     recordProperty (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     stringProperty: String (Required)
+     *     modelProperty (Optional): {
+     *         int32Property: Integer (Optional)
+     *         float32Property: Double (Optional)
+     *         enumProperty: String(EnumValue1) (Optional)
+     *     }
+     *     arrayProperty (Optional): [
+     *         String (Optional)
+     *     ]
+     *     recordProperty (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param queryParam The queryParam parameter. + * @param headerParam The headerParam parameter. + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> basicActionWithResponse(String queryParam, String headerParam, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.basicActionWithResponseAsync(queryParam, headerParam, body, requestOptions); + } + + /** + * The basicAction operation. + * + * @param queryParam The queryParam parameter. + * @param headerParam The headerParam parameter. + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono basicAction(String queryParam, String headerParam, ActionRequest body) { + // Generated convenience method for basicActionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return basicActionWithResponse(queryParam, headerParam, BinaryData.fromObject(body), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ActionResponse.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/AzureExampleClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/AzureExampleClient.java new file mode 100644 index 000000000..5c99a1830 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/AzureExampleClient.java @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.example.basic; + +import com._specs_.azure.example.basic.implementation.AzureExampleClientImpl; +import com._specs_.azure.example.basic.models.ActionRequest; +import com._specs_.azure.example.basic.models.ActionResponse; +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; + +/** + * Initializes a new instance of the synchronous AzureExampleClient type. + */ +@ServiceClient(builder = AzureExampleClientBuilder.class) +public final class AzureExampleClient { + @Generated + private final AzureExampleClientImpl serviceClient; + + /** + * Initializes an instance of AzureExampleClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + AzureExampleClient(AzureExampleClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The basicAction operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     stringProperty: String (Required)
+     *     modelProperty (Optional): {
+     *         int32Property: Integer (Optional)
+     *         float32Property: Double (Optional)
+     *         enumProperty: String(EnumValue1) (Optional)
+     *     }
+     *     arrayProperty (Optional): [
+     *         String (Optional)
+     *     ]
+     *     recordProperty (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     stringProperty: String (Required)
+     *     modelProperty (Optional): {
+     *         int32Property: Integer (Optional)
+     *         float32Property: Double (Optional)
+     *         enumProperty: String(EnumValue1) (Optional)
+     *     }
+     *     arrayProperty (Optional): [
+     *         String (Optional)
+     *     ]
+     *     recordProperty (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param queryParam The queryParam parameter. + * @param headerParam The headerParam parameter. + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response basicActionWithResponse(String queryParam, String headerParam, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.basicActionWithResponse(queryParam, headerParam, body, requestOptions); + } + + /** + * The basicAction operation. + * + * @param queryParam The queryParam parameter. + * @param headerParam The headerParam parameter. + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ActionResponse basicAction(String queryParam, String headerParam, ActionRequest body) { + // Generated convenience method for basicActionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return basicActionWithResponse(queryParam, headerParam, BinaryData.fromObject(body), requestOptions).getValue() + .toObject(ActionResponse.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/AzureExampleClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/AzureExampleClientBuilder.java new file mode 100644 index 000000000..1222fc74f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/AzureExampleClientBuilder.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.example.basic; + +import com._specs_.azure.example.basic.implementation.AzureExampleClientImpl; +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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; + +/** + * A builder for creating a new instance of the AzureExampleClient type. + */ +@ServiceClientBuilder(serviceClients = { AzureExampleClient.class, AzureExampleAsyncClient.class }) +public final class AzureExampleClientBuilder 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("_specs_-azure-example-basic.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the AzureExampleClientBuilder. + */ + @Generated + public AzureExampleClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AzureExampleClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AzureExampleClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AzureExampleClientBuilder 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 AzureExampleClientBuilder 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 AzureExampleClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AzureExampleClientBuilder 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 AzureExampleClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AzureExampleClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private BasicServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the AzureExampleClientBuilder. + */ + @Generated + public AzureExampleClientBuilder serviceVersion(BasicServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 AzureExampleClientBuilder. + */ + @Generated + public AzureExampleClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of AzureExampleClientImpl with the provided parameters. + * + * @return an instance of AzureExampleClientImpl. + */ + @Generated + private AzureExampleClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + BasicServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : BasicServiceVersion.getLatest(); + AzureExampleClientImpl client = new AzureExampleClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, localServiceVersion); + 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 AzureExampleAsyncClient class. + * + * @return an instance of AzureExampleAsyncClient. + */ + @Generated + public AzureExampleAsyncClient buildAsyncClient() { + return new AzureExampleAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of AzureExampleClient class. + * + * @return an instance of AzureExampleClient. + */ + @Generated + public AzureExampleClient buildClient() { + return new AzureExampleClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(AzureExampleClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/BasicServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/BasicServiceVersion.java new file mode 100644 index 000000000..2e7f5eac2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/BasicServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.example.basic; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of BasicClient. + */ +public enum BasicServiceVersion implements ServiceVersion { + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + BasicServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link BasicServiceVersion}. + */ + public static BasicServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/implementation/AzureExampleClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/implementation/AzureExampleClientImpl.java new file mode 100644 index 000000000..fa748ec0a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/implementation/AzureExampleClientImpl.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 com._specs_.azure.example.basic.implementation; + +import com._specs_.azure.example.basic.BasicServiceVersion; +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.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.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 AzureExampleClient type. + */ +public final class AzureExampleClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final AzureExampleClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final BasicServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public BasicServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 AzureExampleClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public AzureExampleClientImpl(String endpoint, BasicServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of AzureExampleClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public AzureExampleClientImpl(HttpPipeline httpPipeline, String endpoint, BasicServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of AzureExampleClient 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. + * @param serviceVersion Service version. + */ + public AzureExampleClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + BasicServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service + = RestProxy.create(AzureExampleClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for AzureExampleClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AzureExampleClient") + public interface AzureExampleClientService { + @Post("/azure/example/basic/basic") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> basicAction(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @QueryParam("query-param") String queryParam, + @HeaderParam("header-param") String headerParam, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/azure/example/basic/basic") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response basicActionSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @QueryParam("query-param") String queryParam, + @HeaderParam("header-param") String headerParam, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The basicAction operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     stringProperty: String (Required)
+     *     modelProperty (Optional): {
+     *         int32Property: Integer (Optional)
+     *         float32Property: Double (Optional)
+     *         enumProperty: String(EnumValue1) (Optional)
+     *     }
+     *     arrayProperty (Optional): [
+     *         String (Optional)
+     *     ]
+     *     recordProperty (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     stringProperty: String (Required)
+     *     modelProperty (Optional): {
+     *         int32Property: Integer (Optional)
+     *         float32Property: Double (Optional)
+     *         enumProperty: String(EnumValue1) (Optional)
+     *     }
+     *     arrayProperty (Optional): [
+     *         String (Optional)
+     *     ]
+     *     recordProperty (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param queryParam The queryParam parameter. + * @param headerParam The headerParam parameter. + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> basicActionWithResponseAsync(String queryParam, String headerParam, + BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.basicAction(this.getEndpoint(), this.getServiceVersion().getVersion(), + queryParam, headerParam, contentType, accept, body, requestOptions, context)); + } + + /** + * The basicAction operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     stringProperty: String (Required)
+     *     modelProperty (Optional): {
+     *         int32Property: Integer (Optional)
+     *         float32Property: Double (Optional)
+     *         enumProperty: String(EnumValue1) (Optional)
+     *     }
+     *     arrayProperty (Optional): [
+     *         String (Optional)
+     *     ]
+     *     recordProperty (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     stringProperty: String (Required)
+     *     modelProperty (Optional): {
+     *         int32Property: Integer (Optional)
+     *         float32Property: Double (Optional)
+     *         enumProperty: String(EnumValue1) (Optional)
+     *     }
+     *     arrayProperty (Optional): [
+     *         String (Optional)
+     *     ]
+     *     recordProperty (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param queryParam The queryParam parameter. + * @param headerParam The headerParam parameter. + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response basicActionWithResponse(String queryParam, String headerParam, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.basicActionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), queryParam, + headerParam, contentType, accept, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/implementation/package-info.java new file mode 100644 index 000000000..b64dfd13c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/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 Basic. + * Test for loading JSON example and generating sample code. + * + */ +package com._specs_.azure.example.basic.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/ActionRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/ActionRequest.java new file mode 100644 index 000000000..fbcd06f55 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/ActionRequest.java @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.example.basic.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; +import java.util.List; +import java.util.Map; + +/** + * The ActionRequest model. + */ +@Fluent +public final class ActionRequest implements JsonSerializable { + /* + * The stringProperty property. + */ + @Generated + private final String stringProperty; + + /* + * The modelProperty property. + */ + @Generated + private Model modelProperty; + + /* + * The arrayProperty property. + */ + @Generated + private List arrayProperty; + + /* + * The recordProperty property. + */ + @Generated + private Map recordProperty; + + /** + * Creates an instance of ActionRequest class. + * + * @param stringProperty the stringProperty value to set. + */ + @Generated + public ActionRequest(String stringProperty) { + this.stringProperty = stringProperty; + } + + /** + * Get the stringProperty property: The stringProperty property. + * + * @return the stringProperty value. + */ + @Generated + public String getStringProperty() { + return this.stringProperty; + } + + /** + * Get the modelProperty property: The modelProperty property. + * + * @return the modelProperty value. + */ + @Generated + public Model getModelProperty() { + return this.modelProperty; + } + + /** + * Set the modelProperty property: The modelProperty property. + * + * @param modelProperty the modelProperty value to set. + * @return the ActionRequest object itself. + */ + @Generated + public ActionRequest setModelProperty(Model modelProperty) { + this.modelProperty = modelProperty; + return this; + } + + /** + * Get the arrayProperty property: The arrayProperty property. + * + * @return the arrayProperty value. + */ + @Generated + public List getArrayProperty() { + return this.arrayProperty; + } + + /** + * Set the arrayProperty property: The arrayProperty property. + * + * @param arrayProperty the arrayProperty value to set. + * @return the ActionRequest object itself. + */ + @Generated + public ActionRequest setArrayProperty(List arrayProperty) { + this.arrayProperty = arrayProperty; + return this; + } + + /** + * Get the recordProperty property: The recordProperty property. + * + * @return the recordProperty value. + */ + @Generated + public Map getRecordProperty() { + return this.recordProperty; + } + + /** + * Set the recordProperty property: The recordProperty property. + * + * @param recordProperty the recordProperty value to set. + * @return the ActionRequest object itself. + */ + @Generated + public ActionRequest setRecordProperty(Map recordProperty) { + this.recordProperty = recordProperty; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("stringProperty", this.stringProperty); + jsonWriter.writeJsonField("modelProperty", this.modelProperty); + jsonWriter.writeArrayField("arrayProperty", this.arrayProperty, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeMapField("recordProperty", this.recordProperty, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ActionRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ActionRequest 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 ActionRequest. + */ + @Generated + public static ActionRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String stringProperty = null; + Model modelProperty = null; + List arrayProperty = null; + Map recordProperty = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("stringProperty".equals(fieldName)) { + stringProperty = reader.getString(); + } else if ("modelProperty".equals(fieldName)) { + modelProperty = Model.fromJson(reader); + } else if ("arrayProperty".equals(fieldName)) { + arrayProperty = reader.readArray(reader1 -> reader1.getString()); + } else if ("recordProperty".equals(fieldName)) { + recordProperty = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + ActionRequest deserializedActionRequest = new ActionRequest(stringProperty); + deserializedActionRequest.modelProperty = modelProperty; + deserializedActionRequest.arrayProperty = arrayProperty; + deserializedActionRequest.recordProperty = recordProperty; + + return deserializedActionRequest; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/ActionResponse.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/ActionResponse.java new file mode 100644 index 000000000..fa2397a80 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/ActionResponse.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.example.basic.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; +import java.util.List; +import java.util.Map; + +/** + * The ActionResponse model. + */ +@Immutable +public final class ActionResponse implements JsonSerializable { + /* + * The stringProperty property. + */ + @Generated + private final String stringProperty; + + /* + * The modelProperty property. + */ + @Generated + private Model modelProperty; + + /* + * The arrayProperty property. + */ + @Generated + private List arrayProperty; + + /* + * The recordProperty property. + */ + @Generated + private Map recordProperty; + + /** + * Creates an instance of ActionResponse class. + * + * @param stringProperty the stringProperty value to set. + */ + @Generated + private ActionResponse(String stringProperty) { + this.stringProperty = stringProperty; + } + + /** + * Get the stringProperty property: The stringProperty property. + * + * @return the stringProperty value. + */ + @Generated + public String getStringProperty() { + return this.stringProperty; + } + + /** + * Get the modelProperty property: The modelProperty property. + * + * @return the modelProperty value. + */ + @Generated + public Model getModelProperty() { + return this.modelProperty; + } + + /** + * Get the arrayProperty property: The arrayProperty property. + * + * @return the arrayProperty value. + */ + @Generated + public List getArrayProperty() { + return this.arrayProperty; + } + + /** + * Get the recordProperty property: The recordProperty property. + * + * @return the recordProperty value. + */ + @Generated + public Map getRecordProperty() { + return this.recordProperty; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("stringProperty", this.stringProperty); + jsonWriter.writeJsonField("modelProperty", this.modelProperty); + jsonWriter.writeArrayField("arrayProperty", this.arrayProperty, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeMapField("recordProperty", this.recordProperty, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ActionResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ActionResponse 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 ActionResponse. + */ + @Generated + public static ActionResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String stringProperty = null; + Model modelProperty = null; + List arrayProperty = null; + Map recordProperty = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("stringProperty".equals(fieldName)) { + stringProperty = reader.getString(); + } else if ("modelProperty".equals(fieldName)) { + modelProperty = Model.fromJson(reader); + } else if ("arrayProperty".equals(fieldName)) { + arrayProperty = reader.readArray(reader1 -> reader1.getString()); + } else if ("recordProperty".equals(fieldName)) { + recordProperty = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + ActionResponse deserializedActionResponse = new ActionResponse(stringProperty); + deserializedActionResponse.modelProperty = modelProperty; + deserializedActionResponse.arrayProperty = arrayProperty; + deserializedActionResponse.recordProperty = recordProperty; + + return deserializedActionResponse; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/Enum.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/Enum.java new file mode 100644 index 000000000..ac150f5a5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/Enum.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.example.basic.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for Enum. + */ +public final class Enum extends ExpandableStringEnum { + /** + * Static value EnumValue1 for Enum. + */ + @Generated + public static final Enum ENUM_VALUE1 = fromString("EnumValue1"); + + /** + * Creates a new instance of Enum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public Enum() { + } + + /** + * Creates or finds a Enum from its string representation. + * + * @param name a name to look for. + * @return the corresponding Enum. + */ + @Generated + public static Enum fromString(String name) { + return fromString(name, Enum.class); + } + + /** + * Gets known Enum values. + * + * @return known Enum values. + */ + @Generated + public static Collection values() { + return values(Enum.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/Model.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/Model.java new file mode 100644 index 000000000..9ab5634f1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/Model.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 com._specs_.azure.example.basic.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 Model model. + */ +@Fluent +public final class Model implements JsonSerializable { + /* + * The int32Property property. + */ + @Generated + private Integer int32Property; + + /* + * The float32Property property. + */ + @Generated + private Double float32Property; + + /* + * The enumProperty property. + */ + @Generated + private Enum enumProperty; + + /** + * Creates an instance of Model class. + */ + @Generated + public Model() { + } + + /** + * Get the int32Property property: The int32Property property. + * + * @return the int32Property value. + */ + @Generated + public Integer getInt32Property() { + return this.int32Property; + } + + /** + * Set the int32Property property: The int32Property property. + * + * @param int32Property the int32Property value to set. + * @return the Model object itself. + */ + @Generated + public Model setInt32Property(Integer int32Property) { + this.int32Property = int32Property; + return this; + } + + /** + * Get the float32Property property: The float32Property property. + * + * @return the float32Property value. + */ + @Generated + public Double getFloat32Property() { + return this.float32Property; + } + + /** + * Set the float32Property property: The float32Property property. + * + * @param float32Property the float32Property value to set. + * @return the Model object itself. + */ + @Generated + public Model setFloat32Property(Double float32Property) { + this.float32Property = float32Property; + return this; + } + + /** + * Get the enumProperty property: The enumProperty property. + * + * @return the enumProperty value. + */ + @Generated + public Enum getEnumProperty() { + return this.enumProperty; + } + + /** + * Set the enumProperty property: The enumProperty property. + * + * @param enumProperty the enumProperty value to set. + * @return the Model object itself. + */ + @Generated + public Model setEnumProperty(Enum enumProperty) { + this.enumProperty = enumProperty; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("int32Property", this.int32Property); + jsonWriter.writeNumberField("float32Property", this.float32Property); + jsonWriter.writeStringField("enumProperty", this.enumProperty == null ? null : this.enumProperty.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Model from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Model 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 Model. + */ + @Generated + public static Model fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Model deserializedModel = new Model(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("int32Property".equals(fieldName)) { + deserializedModel.int32Property = reader.getNullable(JsonReader::getInt); + } else if ("float32Property".equals(fieldName)) { + deserializedModel.float32Property = reader.getNullable(JsonReader::getDouble); + } else if ("enumProperty".equals(fieldName)) { + deserializedModel.enumProperty = Enum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/models/package-info.java new file mode 100644 index 000000000..ef71b259a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/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 Basic. + * Test for loading JSON example and generating sample code. + * + */ +package com._specs_.azure.example.basic.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/package-info.java new file mode 100644 index 000000000..d7ada6ffe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/_specs_/azure/example/basic/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 Basic. + * Test for loading JSON example and generating sample code. + * + */ +package com._specs_.azure.example.basic; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/ApiKeyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/ApiKeyAsyncClient.java new file mode 100644 index 000000000..7dd91d33f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/ApiKeyAsyncClient.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 com.authentication.apikey; + +import com.authentication.apikey.implementation.ApiKeyClientImpl; +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 reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ApiKeyClient type. + */ +@ServiceClient(builder = ApiKeyClientBuilder.class, isAsync = true) +public final class ApiKeyAsyncClient { + @Generated + private final ApiKeyClientImpl serviceClient; + + /** + * Initializes an instance of ApiKeyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ApiKeyAsyncClient(ApiKeyClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check whether client is authenticated. + * + * @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> validWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validWithResponseAsync(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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> invalidWithResponse(RequestOptions requestOptions) { + return this.serviceClient.invalidWithResponseAsync(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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 valid() { + // Generated convenience method for validWithResponse + RequestOptions requestOptions = new RequestOptions(); + return validWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Check whether client is authenticated. + * + * @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 invalid() { + // Generated convenience method for invalidWithResponse + RequestOptions requestOptions = new RequestOptions(); + return invalidWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/ApiKeyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/ApiKeyClient.java new file mode 100644 index 000000000..936994325 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/ApiKeyClient.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.apikey; + +import com.authentication.apikey.implementation.ApiKeyClientImpl; +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; + +/** + * Initializes a new instance of the synchronous ApiKeyClient type. + */ +@ServiceClient(builder = ApiKeyClientBuilder.class) +public final class ApiKeyClient { + @Generated + private final ApiKeyClientImpl serviceClient; + + /** + * Initializes an instance of ApiKeyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ApiKeyClient(ApiKeyClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check whether client is authenticated. + * + * @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 validWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validWithResponse(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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 invalidWithResponse(RequestOptions requestOptions) { + return this.serviceClient.invalidWithResponse(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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 valid() { + // Generated convenience method for validWithResponse + RequestOptions requestOptions = new RequestOptions(); + validWithResponse(requestOptions).getValue(); + } + + /** + * Check whether client is authenticated. + * + * @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 invalid() { + // Generated convenience method for invalidWithResponse + RequestOptions requestOptions = new RequestOptions(); + invalidWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/ApiKeyClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/ApiKeyClientBuilder.java new file mode 100644 index 000000000..12c654d41 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/ApiKeyClientBuilder.java @@ -0,0 +1,310 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.apikey; + +import com.authentication.apikey.implementation.ApiKeyClientImpl; +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.client.traits.KeyCredentialTrait; +import com.azure.core.credential.KeyCredential; +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.KeyCredentialPolicy; +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; + +/** + * A builder for creating a new instance of the ApiKeyClient type. + */ +@ServiceClientBuilder(serviceClients = { ApiKeyClient.class, ApiKeyAsyncClient.class }) +public final class ApiKeyClientBuilder + implements HttpTrait, ConfigurationTrait, + KeyCredentialTrait, 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("authentication-apikey.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ApiKeyClientBuilder. + */ + @Generated + public ApiKeyClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ApiKeyClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ApiKeyClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ApiKeyClientBuilder 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 ApiKeyClientBuilder 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 ApiKeyClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ApiKeyClientBuilder 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 ApiKeyClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The KeyCredential used for authentication. + */ + @Generated + private KeyCredential keyCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ApiKeyClientBuilder credential(KeyCredential keyCredential) { + this.keyCredential = keyCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ApiKeyClientBuilder 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 ApiKeyClientBuilder. + */ + @Generated + public ApiKeyClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ApiKeyClientImpl with the provided parameters. + * + * @return an instance of ApiKeyClientImpl. + */ + @Generated + private ApiKeyClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ApiKeyClientImpl client + = new ApiKeyClientImpl(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()); + if (keyCredential != null) { + policies.add(new KeyCredentialPolicy("x-ms-api-key", keyCredential)); + } + 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 ApiKeyAsyncClient class. + * + * @return an instance of ApiKeyAsyncClient. + */ + @Generated + public ApiKeyAsyncClient buildAsyncClient() { + return new ApiKeyAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ApiKeyClient class. + * + * @return an instance of ApiKeyClient. + */ + @Generated + public ApiKeyClient buildClient() { + return new ApiKeyClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ApiKeyClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/implementation/ApiKeyClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/implementation/ApiKeyClientImpl.java new file mode 100644 index 000000000..57f30be3a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/implementation/ApiKeyClientImpl.java @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.apikey.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.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 ApiKeyClient type. + */ +public final class ApiKeyClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ApiKeyClientService 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 ApiKeyClient client. + * + * @param endpoint Service host. + */ + public ApiKeyClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ApiKeyClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ApiKeyClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ApiKeyClient 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 ApiKeyClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(ApiKeyClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for ApiKeyClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ApiKeyClient") + public interface ApiKeyClientService { + @Get("/authentication/api-key/valid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> valid(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/authentication/api-key/valid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response validSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/authentication/api-key/invalid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> invalid(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/authentication/api-key/invalid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response invalidSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * Check whether client is authenticated. + * + * @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> validWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.valid(this.getEndpoint(), requestOptions, context)); + } + + /** + * Check whether client is authenticated. + * + * @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 validWithResponse(RequestOptions requestOptions) { + return service.validSync(this.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * Check whether client is authenticated. + * + * @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> invalidWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.invalid(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Check whether client is authenticated. + * + * @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 invalidWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.invalidSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/implementation/package-info.java new file mode 100644 index 000000000..f828b078d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/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 ApiKey. + * Illustrates clients generated with ApiKey authentication. + * + */ +package com.authentication.apikey.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/package-info.java new file mode 100644 index 000000000..07cdb2edd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/apikey/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 ApiKey. + * Illustrates clients generated with ApiKey authentication. + * + */ +package com.authentication.apikey; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/CustomAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/CustomAsyncClient.java new file mode 100644 index 000000000..ed606ef32 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/CustomAsyncClient.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 com.authentication.http.custom; + +import com.authentication.http.custom.implementation.CustomClientImpl; +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 reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous CustomClient type. + */ +@ServiceClient(builder = CustomClientBuilder.class, isAsync = true) +public final class CustomAsyncClient { + @Generated + private final CustomClientImpl serviceClient; + + /** + * Initializes an instance of CustomAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CustomAsyncClient(CustomClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check whether client is authenticated. + * + * @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> validWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validWithResponseAsync(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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> invalidWithResponse(RequestOptions requestOptions) { + return this.serviceClient.invalidWithResponseAsync(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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 valid() { + // Generated convenience method for validWithResponse + RequestOptions requestOptions = new RequestOptions(); + return validWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Check whether client is authenticated. + * + * @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 invalid() { + // Generated convenience method for invalidWithResponse + RequestOptions requestOptions = new RequestOptions(); + return invalidWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/CustomClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/CustomClient.java new file mode 100644 index 000000000..cc3ebbf18 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/CustomClient.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.http.custom; + +import com.authentication.http.custom.implementation.CustomClientImpl; +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; + +/** + * Initializes a new instance of the synchronous CustomClient type. + */ +@ServiceClient(builder = CustomClientBuilder.class) +public final class CustomClient { + @Generated + private final CustomClientImpl serviceClient; + + /** + * Initializes an instance of CustomClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CustomClient(CustomClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check whether client is authenticated. + * + * @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 validWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validWithResponse(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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 invalidWithResponse(RequestOptions requestOptions) { + return this.serviceClient.invalidWithResponse(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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 valid() { + // Generated convenience method for validWithResponse + RequestOptions requestOptions = new RequestOptions(); + validWithResponse(requestOptions).getValue(); + } + + /** + * Check whether client is authenticated. + * + * @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 invalid() { + // Generated convenience method for invalidWithResponse + RequestOptions requestOptions = new RequestOptions(); + invalidWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/CustomClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/CustomClientBuilder.java new file mode 100644 index 000000000..2242889e3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/CustomClientBuilder.java @@ -0,0 +1,311 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.http.custom; + +import com.authentication.http.custom.implementation.CustomClientImpl; +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.client.traits.KeyCredentialTrait; +import com.azure.core.credential.KeyCredential; +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.KeyCredentialPolicy; +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; + +/** + * A builder for creating a new instance of the CustomClient type. + */ +@ServiceClientBuilder(serviceClients = { CustomClient.class, CustomAsyncClient.class }) +public final class CustomClientBuilder + implements HttpTrait, ConfigurationTrait, + KeyCredentialTrait, 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("authentication-http-custom.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the CustomClientBuilder. + */ + @Generated + public CustomClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public CustomClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public CustomClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public CustomClientBuilder 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 CustomClientBuilder 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 CustomClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public CustomClientBuilder 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 CustomClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The KeyCredential used for authentication. + */ + @Generated + private KeyCredential keyCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public CustomClientBuilder credential(KeyCredential keyCredential) { + this.keyCredential = keyCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public CustomClientBuilder 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 CustomClientBuilder. + */ + @Generated + public CustomClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of CustomClientImpl with the provided parameters. + * + * @return an instance of CustomClientImpl. + */ + @Generated + private CustomClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + CustomClientImpl client + = new CustomClientImpl(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()); + if (keyCredential != null) { + policies.add(new KeyCredentialPolicy("authorization", keyCredential, "SharedAccessKey")); + } + 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 CustomAsyncClient class. + * + * @return an instance of CustomAsyncClient. + */ + @Generated + public CustomAsyncClient buildAsyncClient() { + return new CustomAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of CustomClient class. + * + * @return an instance of CustomClient. + */ + @Generated + public CustomClient buildClient() { + return new CustomClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(CustomClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/implementation/CustomClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/implementation/CustomClientImpl.java new file mode 100644 index 000000000..f61eee8d7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/implementation/CustomClientImpl.java @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.http.custom.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.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 CustomClient type. + */ +public final class CustomClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CustomClientService 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 CustomClient client. + * + * @param endpoint Service host. + */ + public CustomClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of CustomClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public CustomClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of CustomClient 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 CustomClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(CustomClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for CustomClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CustomClient") + public interface CustomClientService { + @Get("/authentication/http/custom/valid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> valid(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/authentication/http/custom/valid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response validSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/authentication/http/custom/invalid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> invalid(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/authentication/http/custom/invalid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response invalidSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * Check whether client is authenticated. + * + * @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> validWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.valid(this.getEndpoint(), requestOptions, context)); + } + + /** + * Check whether client is authenticated. + * + * @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 validWithResponse(RequestOptions requestOptions) { + return service.validSync(this.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * Check whether client is authenticated. + * + * @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> invalidWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.invalid(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Check whether client is authenticated. + * + * @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 invalidWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.invalidSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/implementation/package-info.java new file mode 100644 index 000000000..e45d50d1c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/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 Custom. + * Illustrates clients generated with generic HTTP auth. + * + */ +package com.authentication.http.custom.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/package-info.java new file mode 100644 index 000000000..d0241d161 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/http/custom/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 Custom. + * Illustrates clients generated with generic HTTP auth. + * + */ +package com.authentication.http.custom; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/OAuth2AsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/OAuth2AsyncClient.java new file mode 100644 index 000000000..4c71d9f55 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/OAuth2AsyncClient.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 com.authentication.oauth2; + +import com.authentication.oauth2.implementation.OAuth2ClientImpl; +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 reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OAuth2Client type. + */ +@ServiceClient(builder = OAuth2ClientBuilder.class, isAsync = true) +public final class OAuth2AsyncClient { + @Generated + private final OAuth2ClientImpl serviceClient; + + /** + * Initializes an instance of OAuth2AsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + OAuth2AsyncClient(OAuth2ClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check whether client is authenticated. + * + * @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> validWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validWithResponseAsync(requestOptions); + } + + /** + * Check whether client is authenticated. Will return an invalid bearer error. + * + * @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> invalidWithResponse(RequestOptions requestOptions) { + return this.serviceClient.invalidWithResponseAsync(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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 valid() { + // Generated convenience method for validWithResponse + RequestOptions requestOptions = new RequestOptions(); + return validWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Check whether client is authenticated. Will return an invalid bearer error. + * + * @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 invalid() { + // Generated convenience method for invalidWithResponse + RequestOptions requestOptions = new RequestOptions(); + return invalidWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/OAuth2Client.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/OAuth2Client.java new file mode 100644 index 000000000..29b59cc2c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/OAuth2Client.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.oauth2; + +import com.authentication.oauth2.implementation.OAuth2ClientImpl; +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; + +/** + * Initializes a new instance of the synchronous OAuth2Client type. + */ +@ServiceClient(builder = OAuth2ClientBuilder.class) +public final class OAuth2Client { + @Generated + private final OAuth2ClientImpl serviceClient; + + /** + * Initializes an instance of OAuth2Client class. + * + * @param serviceClient the service client implementation. + */ + @Generated + OAuth2Client(OAuth2ClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check whether client is authenticated. + * + * @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 validWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validWithResponse(requestOptions); + } + + /** + * Check whether client is authenticated. Will return an invalid bearer error. + * + * @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 invalidWithResponse(RequestOptions requestOptions) { + return this.serviceClient.invalidWithResponse(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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 valid() { + // Generated convenience method for validWithResponse + RequestOptions requestOptions = new RequestOptions(); + validWithResponse(requestOptions).getValue(); + } + + /** + * Check whether client is authenticated. Will return an invalid bearer error. + * + * @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 invalid() { + // Generated convenience method for invalidWithResponse + RequestOptions requestOptions = new RequestOptions(); + invalidWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/OAuth2ClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/OAuth2ClientBuilder.java new file mode 100644 index 000000000..4c713e4cf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/OAuth2ClientBuilder.java @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.oauth2; + +import com.authentication.oauth2.implementation.OAuth2ClientImpl; +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.client.traits.TokenCredentialTrait; +import com.azure.core.credential.TokenCredential; +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.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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; + +/** + * A builder for creating a new instance of the OAuth2Client type. + */ +@ServiceClientBuilder(serviceClients = { OAuth2Client.class, OAuth2AsyncClient.class }) +public final class OAuth2ClientBuilder + implements HttpTrait, ConfigurationTrait, + TokenCredentialTrait, EndpointTrait { + @Generated + private static final String SDK_NAME = "name"; + + @Generated + private static final String SDK_VERSION = "version"; + + @Generated + private static final String[] DEFAULT_SCOPES = new String[] { "https://security.microsoft.com/.default" }; + + @Generated + private static final Map PROPERTIES = CoreUtils.getProperties("authentication-oauth2.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the OAuth2ClientBuilder. + */ + @Generated + public OAuth2ClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OAuth2ClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OAuth2ClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OAuth2ClientBuilder 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 OAuth2ClientBuilder 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 OAuth2ClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OAuth2ClientBuilder 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 OAuth2ClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated + private TokenCredential tokenCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OAuth2ClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OAuth2ClientBuilder 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 OAuth2ClientBuilder. + */ + @Generated + public OAuth2ClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of OAuth2ClientImpl with the provided parameters. + * + * @return an instance of OAuth2ClientImpl. + */ + @Generated + private OAuth2ClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + OAuth2ClientImpl client + = new OAuth2ClientImpl(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()); + if (tokenCredential != null) { + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } + 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 OAuth2AsyncClient class. + * + * @return an instance of OAuth2AsyncClient. + */ + @Generated + public OAuth2AsyncClient buildAsyncClient() { + return new OAuth2AsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of OAuth2Client class. + * + * @return an instance of OAuth2Client. + */ + @Generated + public OAuth2Client buildClient() { + return new OAuth2Client(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(OAuth2ClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/implementation/OAuth2ClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/implementation/OAuth2ClientImpl.java new file mode 100644 index 000000000..a603f8e20 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/implementation/OAuth2ClientImpl.java @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.oauth2.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.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 OAuth2Client type. + */ +public final class OAuth2ClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final OAuth2ClientService 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 OAuth2Client client. + * + * @param endpoint Service host. + */ + public OAuth2ClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of OAuth2Client client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public OAuth2ClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of OAuth2Client 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 OAuth2ClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(OAuth2ClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for OAuth2Client to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OAuth2Client") + public interface OAuth2ClientService { + @Get("/authentication/oauth2/valid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> valid(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/authentication/oauth2/valid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response validSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/authentication/oauth2/invalid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> invalid(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/authentication/oauth2/invalid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response invalidSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * Check whether client is authenticated. + * + * @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> validWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.valid(this.getEndpoint(), requestOptions, context)); + } + + /** + * Check whether client is authenticated. + * + * @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 validWithResponse(RequestOptions requestOptions) { + return service.validSync(this.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * Check whether client is authenticated. Will return an invalid bearer error. + * + * @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> invalidWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.invalid(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Check whether client is authenticated. Will return an invalid bearer error. + * + * @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 invalidWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.invalidSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/implementation/package-info.java new file mode 100644 index 000000000..a09f5bc72 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/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 OAuth2. + * Illustrates clients generated with OAuth2 authentication. + * + */ +package com.authentication.oauth2.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/package-info.java new file mode 100644 index 000000000..209e26d0c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/oauth2/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 OAuth2. + * Illustrates clients generated with OAuth2 authentication. + * + */ +package com.authentication.oauth2; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/UnionAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/UnionAsyncClient.java new file mode 100644 index 000000000..e5e2ab1bf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/UnionAsyncClient.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 com.authentication.union; + +import com.authentication.union.implementation.UnionClientImpl; +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 reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class, isAsync = true) +public final class UnionAsyncClient { + @Generated + private final UnionClientImpl serviceClient; + + /** + * Initializes an instance of UnionAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionAsyncClient(UnionClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check whether client is authenticated. + * + * @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> validKeyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validKeyWithResponseAsync(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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> validTokenWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validTokenWithResponseAsync(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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 validKey() { + // Generated convenience method for validKeyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return validKeyWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Check whether client is authenticated. + * + * @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 validToken() { + // Generated convenience method for validTokenWithResponse + RequestOptions requestOptions = new RequestOptions(); + return validTokenWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/UnionClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/UnionClient.java new file mode 100644 index 000000000..6951a3e44 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/UnionClient.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.union; + +import com.authentication.union.implementation.UnionClientImpl; +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; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class UnionClient { + @Generated + private final UnionClientImpl serviceClient; + + /** + * Initializes an instance of UnionClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionClient(UnionClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check whether client is authenticated. + * + * @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 validKeyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validKeyWithResponse(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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 validTokenWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validTokenWithResponse(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @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 validKey() { + // Generated convenience method for validKeyWithResponse + RequestOptions requestOptions = new RequestOptions(); + validKeyWithResponse(requestOptions).getValue(); + } + + /** + * Check whether client is authenticated. + * + * @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 validToken() { + // Generated convenience method for validTokenWithResponse + RequestOptions requestOptions = new RequestOptions(); + validTokenWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/UnionClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/UnionClientBuilder.java new file mode 100644 index 000000000..30aa7abda --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/UnionClientBuilder.java @@ -0,0 +1,335 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.union; + +import com.authentication.union.implementation.UnionClientImpl; +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.client.traits.KeyCredentialTrait; +import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.credential.KeyCredential; +import com.azure.core.credential.TokenCredential; +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.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.KeyCredentialPolicy; +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; + +/** + * A builder for creating a new instance of the UnionClient type. + */ +@ServiceClientBuilder(serviceClients = { UnionClient.class, UnionAsyncClient.class }) +public final class UnionClientBuilder implements HttpTrait, ConfigurationTrait, + TokenCredentialTrait, KeyCredentialTrait, + EndpointTrait { + @Generated + private static final String SDK_NAME = "name"; + + @Generated + private static final String SDK_VERSION = "version"; + + @Generated + private static final String[] DEFAULT_SCOPES = new String[] { "https://security.microsoft.com/.default" }; + + @Generated + private static final Map PROPERTIES = CoreUtils.getProperties("authentication-union.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the UnionClientBuilder. + */ + @Generated + public UnionClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder 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 UnionClientBuilder 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 UnionClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder 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 UnionClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated + private TokenCredential tokenCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The KeyCredential used for authentication. + */ + @Generated + private KeyCredential keyCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder credential(KeyCredential keyCredential) { + this.keyCredential = keyCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder 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 UnionClientBuilder. + */ + @Generated + public UnionClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of UnionClientImpl with the provided parameters. + * + * @return an instance of UnionClientImpl. + */ + @Generated + private UnionClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + UnionClientImpl client + = new UnionClientImpl(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()); + if (keyCredential != null) { + policies.add(new KeyCredentialPolicy("x-ms-api-key", keyCredential)); + } + if (tokenCredential != null) { + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } + 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 UnionAsyncClient class. + * + * @return an instance of UnionAsyncClient. + */ + @Generated + public UnionAsyncClient buildAsyncClient() { + return new UnionAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of UnionClient class. + * + * @return an instance of UnionClient. + */ + @Generated + public UnionClient buildClient() { + return new UnionClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(UnionClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/implementation/UnionClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/implementation/UnionClientImpl.java new file mode 100644 index 000000000..c09b8c5c1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/implementation/UnionClientImpl.java @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.union.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.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.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 UnionClient type. + */ +public final class UnionClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionClientService 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 UnionClient client. + * + * @param endpoint Service host. + */ + public UnionClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of UnionClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public UnionClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of UnionClient 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 UnionClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(UnionClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for UnionClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UnionClient") + public interface UnionClientService { + @Get("/authentication/union/validkey") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> validKey(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/authentication/union/validkey") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response validKeySync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/authentication/union/validtoken") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> validToken(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/authentication/union/validtoken") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response validTokenSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + } + + /** + * Check whether client is authenticated. + * + * @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> validKeyWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.validKey(this.getEndpoint(), requestOptions, context)); + } + + /** + * Check whether client is authenticated. + * + * @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 validKeyWithResponse(RequestOptions requestOptions) { + return service.validKeySync(this.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * Check whether client is authenticated. + * + * @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> validTokenWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.validToken(this.getEndpoint(), requestOptions, context)); + } + + /** + * Check whether client is authenticated. + * + * @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 validTokenWithResponse(RequestOptions requestOptions) { + return service.validTokenSync(this.getEndpoint(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/implementation/package-info.java new file mode 100644 index 000000000..cdc7d79df --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/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 Union. + * Illustrates clients generated with ApiKey and OAuth2 authentication. + * + */ +package com.authentication.union.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/package-info.java new file mode 100644 index 000000000..aa5b51e98 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/authentication/union/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 Union. + * Illustrates clients generated with ApiKey and OAuth2 authentication. + * + */ +package com.authentication.union; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/ManagedIdentityManager.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/ManagedIdentityManager.java new file mode 100644 index 000000000..50104d3a5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/ManagedIdentityManager.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpPipeline; +import com.azure.core.management.profile.AzureProfile; +import com.azure.resourcemanager.models.commontypes.managedidentity.fluent.ManagedIdentityClient; +import com.azure.resourcemanager.models.commontypes.managedidentity.implementation.ManagedIdentityClientBuilder; +import com.azure.resourcemanager.models.commontypes.managedidentity.implementation.ManagedIdentityTrackedResourcesImpl; +import com.azure.resourcemanager.models.commontypes.managedidentity.models.ManagedIdentityTrackedResources; +import java.time.Duration; +import java.util.Objects; + +/** + * Entry point to ManagedIdentityManager. + * Arm Managed Identity Provider management API. + */ +public final class ManagedIdentityManager { + private ManagedIdentityTrackedResources managedIdentityTrackedResources; + + private final ManagedIdentityClient clientObject; + + private ManagedIdentityManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new ManagedIdentityClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of ManagedIdentity service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ManagedIdentity service API instance. + */ + public static ManagedIdentityManager 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 ManagedIdentity service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the ManagedIdentity service API instance. + */ + public static ManagedIdentityManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new ManagedIdentityManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create ManagedIdentityManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new ManagedIdentityManager.Configurable(); + } + + /** + * Gets the resource collection API of ManagedIdentityTrackedResources. It manages ManagedIdentityTrackedResource. + * + * @return Resource collection API of ManagedIdentityTrackedResources. + */ + public ManagedIdentityTrackedResources managedIdentityTrackedResources() { + if (this.managedIdentityTrackedResources == null) { + this.managedIdentityTrackedResources + = new ManagedIdentityTrackedResourcesImpl(clientObject.getManagedIdentityTrackedResources(), this); + } + return managedIdentityTrackedResources; + } + + /** + * Gets wrapped service client ManagedIdentityClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client ManagedIdentityClient. + */ + public ManagedIdentityClient serviceClient() { + return this.clientObject; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/ManagedIdentityClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/ManagedIdentityClient.java new file mode 100644 index 000000000..f0a5e6ccd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/ManagedIdentityClient.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 com.azure.resourcemanager.models.commontypes.managedidentity.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for ManagedIdentityClient class. + */ +public interface ManagedIdentityClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * 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 ManagedIdentityTrackedResourcesClient object to access its operations. + * + * @return the ManagedIdentityTrackedResourcesClient object. + */ + ManagedIdentityTrackedResourcesClient getManagedIdentityTrackedResources(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/ManagedIdentityTrackedResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/ManagedIdentityTrackedResourcesClient.java new file mode 100644 index 000000000..208c9fc22 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/ManagedIdentityTrackedResourcesClient.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 com.azure.resourcemanager.models.commontypes.managedidentity.fluent; + +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; +import com.azure.resourcemanager.models.commontypes.managedidentity.fluent.models.ManagedIdentityTrackedResourceInner; + +/** + * An instance of this class provides access to all the operations defined in ManagedIdentityTrackedResourcesClient. + */ +public interface ManagedIdentityTrackedResourcesClient { + /** + * Get a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 ManagedIdentityTrackedResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, + String managedIdentityTrackedResourceName, Context context); + + /** + * Get a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 ManagedIdentityTrackedResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagedIdentityTrackedResourceInner getByResourceGroup(String resourceGroupName, + String managedIdentityTrackedResourceName); + + /** + * Create a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 createWithSystemAssignedWithResponse(String resourceGroupName, + String managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceInner resource, Context context); + + /** + * Create a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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) + ManagedIdentityTrackedResourceInner createWithSystemAssigned(String resourceGroupName, + String managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceInner resource); + + /** + * Update a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithUserAssignedAndSystemAssignedWithResponse( + String resourceGroupName, String managedIdentityTrackedResourceName, + ManagedIdentityTrackedResourceInner properties, Context context); + + /** + * Update a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagedIdentityTrackedResourceInner updateWithUserAssignedAndSystemAssigned(String resourceGroupName, + String managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceInner properties); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/models/ManagedIdentityTrackedResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/models/ManagedIdentityTrackedResourceInner.java new file mode 100644 index 000000000..386af48cc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/models/ManagedIdentityTrackedResourceInner.java @@ -0,0 +1,234 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.models.commontypes.managedidentity.models.ManagedIdentityTrackedResourceProperties; +import com.azure.resourcemanager.models.commontypes.managedidentity.models.ManagedServiceIdentity; +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 ManagedIdentityTrackedResourceInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private ManagedIdentityTrackedResourceProperties properties; + + /* + * The managed service identities assigned to this resource. + */ + private ManagedServiceIdentity identity; + + /* + * 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 ManagedIdentityTrackedResourceInner class. + */ + public ManagedIdentityTrackedResourceInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public ManagedIdentityTrackedResourceProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the ManagedIdentityTrackedResourceInner object itself. + */ + public ManagedIdentityTrackedResourceInner withProperties(ManagedIdentityTrackedResourceProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The managed service identities assigned to this resource. + * + * @param identity the identity value to set. + * @return the ManagedIdentityTrackedResourceInner object itself. + */ + public ManagedIdentityTrackedResourceInner withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + 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 ManagedIdentityTrackedResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ManagedIdentityTrackedResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + if (identity() != null) { + identity().validate(); + } + if (location() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property location in model ManagedIdentityTrackedResourceInner")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ManagedIdentityTrackedResourceInner.class); + + /** + * {@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); + jsonWriter.writeJsonField("identity", this.identity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagedIdentityTrackedResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagedIdentityTrackedResourceInner 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 ManagedIdentityTrackedResourceInner. + */ + public static ManagedIdentityTrackedResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagedIdentityTrackedResourceInner deserializedManagedIdentityTrackedResourceInner + = new ManagedIdentityTrackedResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedManagedIdentityTrackedResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedManagedIdentityTrackedResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedManagedIdentityTrackedResourceInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedManagedIdentityTrackedResourceInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedManagedIdentityTrackedResourceInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedManagedIdentityTrackedResourceInner.properties + = ManagedIdentityTrackedResourceProperties.fromJson(reader); + } else if ("identity".equals(fieldName)) { + deserializedManagedIdentityTrackedResourceInner.identity = ManagedServiceIdentity.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedManagedIdentityTrackedResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedManagedIdentityTrackedResourceInner; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/models/package-info.java new file mode 100644 index 000000000..7cb562268 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/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 ManagedIdentity. + * Arm Managed Identity Provider management API. + */ +package com.azure.resourcemanager.models.commontypes.managedidentity.fluent.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/fluent/package-info.java new file mode 100644 index 000000000..56076e0ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/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 ManagedIdentity. + * Arm Managed Identity Provider management API. + */ +package com.azure.resourcemanager.models.commontypes.managedidentity.fluent; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientBuilder.java new file mode 100644 index 000000000..ded7cbf3a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity.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 ManagedIdentityClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { ManagedIdentityClientImpl.class }) +public final class ManagedIdentityClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the ManagedIdentityClientBuilder. + */ + public ManagedIdentityClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the ManagedIdentityClientBuilder. + */ + public ManagedIdentityClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the ManagedIdentityClientBuilder. + */ + public ManagedIdentityClientBuilder 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 ManagedIdentityClientBuilder. + */ + public ManagedIdentityClientBuilder 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 ManagedIdentityClientBuilder. + */ + public ManagedIdentityClientBuilder 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 ManagedIdentityClientBuilder. + */ + public ManagedIdentityClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of ManagedIdentityClientImpl with the provided parameters. + * + * @return an instance of ManagedIdentityClientImpl. + */ + public ManagedIdentityClientImpl 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(); + ManagedIdentityClientImpl client = new ManagedIdentityClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientImpl.java new file mode 100644 index 000000000..c5518ec17 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityClientImpl.java @@ -0,0 +1,245 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity.implementation; + +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.polling.PollerFactory; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.resourcemanager.models.commontypes.managedidentity.fluent.ManagedIdentityClient; +import com.azure.resourcemanager.models.commontypes.managedidentity.fluent.ManagedIdentityTrackedResourcesClient; +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 ManagedIdentityClientImpl type. + */ +@ServiceClient(builder = ManagedIdentityClientBuilder.class) +public final class ManagedIdentityClientImpl implements ManagedIdentityClient { + /** + * 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 ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * 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 ManagedIdentityTrackedResourcesClient object to access its operations. + */ + private final ManagedIdentityTrackedResourcesClient managedIdentityTrackedResources; + + /** + * Gets the ManagedIdentityTrackedResourcesClient object to access its operations. + * + * @return the ManagedIdentityTrackedResourcesClient object. + */ + public ManagedIdentityTrackedResourcesClient getManagedIdentityTrackedResources() { + return this.managedIdentityTrackedResources; + } + + /** + * Initializes an instance of ManagedIdentityClient 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. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + ManagedIdentityClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.apiVersion = "2023-12-01-preview"; + this.managedIdentityTrackedResources = new ManagedIdentityTrackedResourcesClientImpl(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 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) { + } + + 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)); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourceImpl.java new file mode 100644 index 000000000..b37b5e949 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourceImpl.java @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.models.commontypes.managedidentity.fluent.models.ManagedIdentityTrackedResourceInner; +import com.azure.resourcemanager.models.commontypes.managedidentity.models.ManagedIdentityTrackedResource; +import com.azure.resourcemanager.models.commontypes.managedidentity.models.ManagedIdentityTrackedResourceProperties; +import com.azure.resourcemanager.models.commontypes.managedidentity.models.ManagedServiceIdentity; +import java.util.Collections; +import java.util.Map; + +public final class ManagedIdentityTrackedResourceImpl implements ManagedIdentityTrackedResource, + ManagedIdentityTrackedResource.Definition, ManagedIdentityTrackedResource.Update { + private ManagedIdentityTrackedResourceInner innerObject; + + private final com.azure.resourcemanager.models.commontypes.managedidentity.ManagedIdentityManager 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 ManagedIdentityTrackedResourceProperties properties() { + return this.innerModel().properties(); + } + + public ManagedServiceIdentity identity() { + return this.innerModel().identity(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public ManagedIdentityTrackedResourceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.models.commontypes.managedidentity.ManagedIdentityManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String managedIdentityTrackedResourceName; + + public ManagedIdentityTrackedResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public ManagedIdentityTrackedResource create() { + this.innerObject = serviceManager.serviceClient() + .getManagedIdentityTrackedResources() + .createWithSystemAssignedWithResponse(resourceGroupName, managedIdentityTrackedResourceName, + this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public ManagedIdentityTrackedResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getManagedIdentityTrackedResources() + .createWithSystemAssignedWithResponse(resourceGroupName, managedIdentityTrackedResourceName, + this.innerModel(), context) + .getValue(); + return this; + } + + ManagedIdentityTrackedResourceImpl(String name, + com.azure.resourcemanager.models.commontypes.managedidentity.ManagedIdentityManager serviceManager) { + this.innerObject = new ManagedIdentityTrackedResourceInner(); + this.serviceManager = serviceManager; + this.managedIdentityTrackedResourceName = name; + } + + public ManagedIdentityTrackedResourceImpl update() { + return this; + } + + public ManagedIdentityTrackedResource apply() { + this.innerObject = serviceManager.serviceClient() + .getManagedIdentityTrackedResources() + .updateWithUserAssignedAndSystemAssignedWithResponse(resourceGroupName, managedIdentityTrackedResourceName, + this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public ManagedIdentityTrackedResource apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getManagedIdentityTrackedResources() + .updateWithUserAssignedAndSystemAssignedWithResponse(resourceGroupName, managedIdentityTrackedResourceName, + this.innerModel(), context) + .getValue(); + return this; + } + + ManagedIdentityTrackedResourceImpl(ManagedIdentityTrackedResourceInner innerObject, + com.azure.resourcemanager.models.commontypes.managedidentity.ManagedIdentityManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.managedIdentityTrackedResourceName + = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "managedIdentityTrackedResources"); + } + + public ManagedIdentityTrackedResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getManagedIdentityTrackedResources() + .getByResourceGroupWithResponse(resourceGroupName, managedIdentityTrackedResourceName, Context.NONE) + .getValue(); + return this; + } + + public ManagedIdentityTrackedResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getManagedIdentityTrackedResources() + .getByResourceGroupWithResponse(resourceGroupName, managedIdentityTrackedResourceName, context) + .getValue(); + return this; + } + + public ManagedIdentityTrackedResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public ManagedIdentityTrackedResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public ManagedIdentityTrackedResourceImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public ManagedIdentityTrackedResourceImpl withProperties(ManagedIdentityTrackedResourceProperties properties) { + this.innerModel().withProperties(properties); + return this; + } + + public ManagedIdentityTrackedResourceImpl withIdentity(ManagedServiceIdentity identity) { + this.innerModel().withIdentity(identity); + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourcesClientImpl.java new file mode 100644 index 000000000..bd271c409 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourcesClientImpl.java @@ -0,0 +1,521 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity.implementation; + +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.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.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 com.azure.resourcemanager.models.commontypes.managedidentity.fluent.ManagedIdentityTrackedResourcesClient; +import com.azure.resourcemanager.models.commontypes.managedidentity.fluent.models.ManagedIdentityTrackedResourceInner; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ManagedIdentityTrackedResourcesClient. + */ +public final class ManagedIdentityTrackedResourcesClientImpl implements ManagedIdentityTrackedResourcesClient { + /** + * The proxy service used to perform REST calls. + */ + private final ManagedIdentityTrackedResourcesService service; + + /** + * The service client containing this operation class. + */ + private final ManagedIdentityClientImpl client; + + /** + * Initializes an instance of ManagedIdentityTrackedResourcesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ManagedIdentityTrackedResourcesClientImpl(ManagedIdentityClientImpl client) { + this.service = RestProxy.create(ManagedIdentityTrackedResourcesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ManagedIdentityClientManagedIdentityTrackedResources to be used by + * the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ManagedIdentityClien") + public interface ManagedIdentityTrackedResourcesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}") + @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("managedIdentityTrackedResourceName") String managedIdentityTrackedResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createWithSystemAssigned( + @HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("managedIdentityTrackedResourceName") String managedIdentityTrackedResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ManagedIdentityTrackedResourceInner resource, Context context); + + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> updateWithUserAssignedAndSystemAssigned( + @HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("managedIdentityTrackedResourceName") String managedIdentityTrackedResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ManagedIdentityTrackedResourceInner properties, Context context); + } + + /** + * Get a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 ManagedIdentityTrackedResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + getByResourceGroupWithResponseAsync(String resourceGroupName, String managedIdentityTrackedResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (managedIdentityTrackedResourceName == null) { + return Mono.error(new IllegalArgumentException( + "Parameter managedIdentityTrackedResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, managedIdentityTrackedResourceName, accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 ManagedIdentityTrackedResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String managedIdentityTrackedResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (managedIdentityTrackedResourceName == null) { + return Mono.error(new IllegalArgumentException( + "Parameter managedIdentityTrackedResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, managedIdentityTrackedResourceName, accept, context); + } + + /** + * Get a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 ManagedIdentityTrackedResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, + String managedIdentityTrackedResourceName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, managedIdentityTrackedResourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 ManagedIdentityTrackedResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, + String managedIdentityTrackedResourceName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, managedIdentityTrackedResourceName, context) + .block(); + } + + /** + * Get a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 ManagedIdentityTrackedResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagedIdentityTrackedResourceInner getByResourceGroup(String resourceGroupName, + String managedIdentityTrackedResourceName) { + return getByResourceGroupWithResponse(resourceGroupName, managedIdentityTrackedResourceName, Context.NONE) + .getValue(); + } + + /** + * Create a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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> createWithSystemAssignedWithResponseAsync( + String resourceGroupName, String managedIdentityTrackedResourceName, + ManagedIdentityTrackedResourceInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (managedIdentityTrackedResourceName == null) { + return Mono.error(new IllegalArgumentException( + "Parameter managedIdentityTrackedResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createWithSystemAssigned(this.client.getEndpoint(), + this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, + managedIdentityTrackedResourceName, contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createWithSystemAssignedWithResponseAsync( + String resourceGroupName, String managedIdentityTrackedResourceName, + ManagedIdentityTrackedResourceInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (managedIdentityTrackedResourceName == null) { + return Mono.error(new IllegalArgumentException( + "Parameter managedIdentityTrackedResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createWithSystemAssigned(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, managedIdentityTrackedResourceName, contentType, accept, + resource, context); + } + + /** + * Create a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 createWithSystemAssignedAsync(String resourceGroupName, + String managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceInner resource) { + return createWithSystemAssignedWithResponseAsync(resourceGroupName, managedIdentityTrackedResourceName, + resource).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 createWithSystemAssignedWithResponse(String resourceGroupName, + String managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceInner resource, Context context) { + return createWithSystemAssignedWithResponseAsync(resourceGroupName, managedIdentityTrackedResourceName, + resource, context).block(); + } + + /** + * Create a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 ManagedIdentityTrackedResourceInner createWithSystemAssigned(String resourceGroupName, + String managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceInner resource) { + return createWithSystemAssignedWithResponse(resourceGroupName, managedIdentityTrackedResourceName, resource, + Context.NONE).getValue(); + } + + /** + * Update a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName arm resource name for path. + * @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 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> + updateWithUserAssignedAndSystemAssignedWithResponseAsync(String resourceGroupName, + String managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceInner properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (managedIdentityTrackedResourceName == null) { + return Mono.error(new IllegalArgumentException( + "Parameter managedIdentityTrackedResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.updateWithUserAssignedAndSystemAssigned(this.client.getEndpoint(), + this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, + managedIdentityTrackedResourceName, contentType, accept, properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName arm resource name for path. + * @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 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> + updateWithUserAssignedAndSystemAssignedWithResponseAsync(String resourceGroupName, + String managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceInner properties, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (managedIdentityTrackedResourceName == null) { + return Mono.error(new IllegalArgumentException( + "Parameter managedIdentityTrackedResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.updateWithUserAssignedAndSystemAssigned(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, managedIdentityTrackedResourceName, contentType, accept, + properties, context); + } + + /** + * Update a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName arm resource name for path. + * @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 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 updateWithUserAssignedAndSystemAssignedAsync( + String resourceGroupName, String managedIdentityTrackedResourceName, + ManagedIdentityTrackedResourceInner properties) { + return updateWithUserAssignedAndSystemAssignedWithResponseAsync(resourceGroupName, + managedIdentityTrackedResourceName, properties).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Update a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName arm resource name for path. + * @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 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 updateWithUserAssignedAndSystemAssignedWithResponse( + String resourceGroupName, String managedIdentityTrackedResourceName, + ManagedIdentityTrackedResourceInner properties, Context context) { + return updateWithUserAssignedAndSystemAssignedWithResponseAsync(resourceGroupName, + managedIdentityTrackedResourceName, properties, context).block(); + } + + /** + * Update a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagedIdentityTrackedResourceInner updateWithUserAssignedAndSystemAssigned(String resourceGroupName, + String managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceInner properties) { + return updateWithUserAssignedAndSystemAssignedWithResponse(resourceGroupName, + managedIdentityTrackedResourceName, properties, Context.NONE).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourcesImpl.java new file mode 100644 index 000000000..e364375b7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ManagedIdentityTrackedResourcesImpl.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity.implementation; + +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; +import com.azure.resourcemanager.models.commontypes.managedidentity.fluent.ManagedIdentityTrackedResourcesClient; +import com.azure.resourcemanager.models.commontypes.managedidentity.fluent.models.ManagedIdentityTrackedResourceInner; +import com.azure.resourcemanager.models.commontypes.managedidentity.models.ManagedIdentityTrackedResource; +import com.azure.resourcemanager.models.commontypes.managedidentity.models.ManagedIdentityTrackedResources; + +public final class ManagedIdentityTrackedResourcesImpl implements ManagedIdentityTrackedResources { + private static final ClientLogger LOGGER = new ClientLogger(ManagedIdentityTrackedResourcesImpl.class); + + private final ManagedIdentityTrackedResourcesClient innerClient; + + private final com.azure.resourcemanager.models.commontypes.managedidentity.ManagedIdentityManager serviceManager; + + public ManagedIdentityTrackedResourcesImpl(ManagedIdentityTrackedResourcesClient innerClient, + com.azure.resourcemanager.models.commontypes.managedidentity.ManagedIdentityManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, + String managedIdentityTrackedResourceName, Context context) { + Response inner = this.serviceClient() + .getByResourceGroupWithResponse(resourceGroupName, managedIdentityTrackedResourceName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new ManagedIdentityTrackedResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public ManagedIdentityTrackedResource getByResourceGroup(String resourceGroupName, + String managedIdentityTrackedResourceName) { + ManagedIdentityTrackedResourceInner inner + = this.serviceClient().getByResourceGroup(resourceGroupName, managedIdentityTrackedResourceName); + if (inner != null) { + return new ManagedIdentityTrackedResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public ManagedIdentityTrackedResource 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 managedIdentityTrackedResourceName + = ResourceManagerUtils.getValueFromIdByName(id, "managedIdentityTrackedResources"); + if (managedIdentityTrackedResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format( + "The resource ID '%s' is not valid. Missing path segment 'managedIdentityTrackedResources'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, managedIdentityTrackedResourceName, 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 managedIdentityTrackedResourceName + = ResourceManagerUtils.getValueFromIdByName(id, "managedIdentityTrackedResources"); + if (managedIdentityTrackedResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format( + "The resource ID '%s' is not valid. Missing path segment 'managedIdentityTrackedResources'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, managedIdentityTrackedResourceName, context); + } + + private ManagedIdentityTrackedResourcesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.models.commontypes.managedidentity.ManagedIdentityManager manager() { + return this.serviceManager; + } + + public ManagedIdentityTrackedResourceImpl define(String name) { + return new ManagedIdentityTrackedResourceImpl(name, this.manager()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ResourceManagerUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ResourceManagerUtils.java new file mode 100644 index 000000000..e4ebaf5af --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/ResourceManagerUtils.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity.implementation; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + + } + +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/implementation/package-info.java new file mode 100644 index 000000000..fd1120064 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/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 ManagedIdentity. + * Arm Managed Identity Provider management API. + */ +package com.azure.resourcemanager.models.commontypes.managedidentity.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedIdentityTrackedResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedIdentityTrackedResource.java new file mode 100644 index 000000000..7eae76828 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedIdentityTrackedResource.java @@ -0,0 +1,301 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.models.commontypes.managedidentity.fluent.models.ManagedIdentityTrackedResourceInner; +import java.util.Map; + +/** + * An immutable client-side representation of ManagedIdentityTrackedResource. + */ +public interface ManagedIdentityTrackedResource { + /** + * 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. + */ + ManagedIdentityTrackedResourceProperties properties(); + + /** + * Gets the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + ManagedServiceIdentity identity(); + + /** + * 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 name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner + * com.azure.resourcemanager.models.commontypes.managedidentity.fluent.models.ManagedIdentityTrackedResourceInner + * object. + * + * @return the inner object. + */ + ManagedIdentityTrackedResourceInner innerModel(); + + /** + * The entirety of the ManagedIdentityTrackedResource definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The ManagedIdentityTrackedResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the ManagedIdentityTrackedResource definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the ManagedIdentityTrackedResource 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 ManagedIdentityTrackedResource 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 ManagedIdentityTrackedResource 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, DefinitionStages.WithIdentity { + /** + * Executes the create request. + * + * @return the created resource. + */ + ManagedIdentityTrackedResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + ManagedIdentityTrackedResource create(Context context); + } + + /** + * The stage of the ManagedIdentityTrackedResource 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 ManagedIdentityTrackedResource 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(ManagedIdentityTrackedResourceProperties properties); + } + + /** + * The stage of the ManagedIdentityTrackedResource definition allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: The managed service identities assigned to this resource.. + * + * @param identity The managed service identities assigned to this resource. + * @return the next definition stage. + */ + WithCreate withIdentity(ManagedServiceIdentity identity); + } + } + + /** + * Begins update for the ManagedIdentityTrackedResource resource. + * + * @return the stage of resource update. + */ + ManagedIdentityTrackedResource.Update update(); + + /** + * The template for ManagedIdentityTrackedResource update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithProperties, UpdateStages.WithIdentity { + /** + * Executes the update request. + * + * @return the updated resource. + */ + ManagedIdentityTrackedResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + ManagedIdentityTrackedResource apply(Context context); + } + + /** + * The ManagedIdentityTrackedResource update stages. + */ + interface UpdateStages { + /** + * The stage of the ManagedIdentityTrackedResource update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the ManagedIdentityTrackedResource update 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. + */ + Update withProperties(ManagedIdentityTrackedResourceProperties properties); + } + + /** + * The stage of the ManagedIdentityTrackedResource update allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: The managed service identities assigned to this resource.. + * + * @param identity The managed service identities assigned to this resource. + * @return the next definition stage. + */ + Update withIdentity(ManagedServiceIdentity identity); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + ManagedIdentityTrackedResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + ManagedIdentityTrackedResource refresh(Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedIdentityTrackedResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedIdentityTrackedResourceProperties.java new file mode 100644 index 000000000..acad3bd5e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedIdentityTrackedResourceProperties.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity.models; + +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; + +/** + * Managed Identity Arm Resource Properties. + */ +@Immutable +public final class ManagedIdentityTrackedResourceProperties + implements JsonSerializable { + /* + * The status of the last operation. + */ + private String provisioningState; + + /** + * Creates an instance of ManagedIdentityTrackedResourceProperties class. + */ + public ManagedIdentityTrackedResourceProperties() { + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public String provisioningState() { + return this.provisioningState; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagedIdentityTrackedResourceProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagedIdentityTrackedResourceProperties 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 ManagedIdentityTrackedResourceProperties. + */ + public static ManagedIdentityTrackedResourceProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagedIdentityTrackedResourceProperties deserializedManagedIdentityTrackedResourceProperties + = new ManagedIdentityTrackedResourceProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedManagedIdentityTrackedResourceProperties.provisioningState = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedManagedIdentityTrackedResourceProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedIdentityTrackedResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedIdentityTrackedResources.java new file mode 100644 index 000000000..47029516e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedIdentityTrackedResources.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 com.azure.resourcemanager.models.commontypes.managedidentity.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of ManagedIdentityTrackedResources. + */ +public interface ManagedIdentityTrackedResources { + /** + * Get a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 ManagedIdentityTrackedResource along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, + String managedIdentityTrackedResourceName, Context context); + + /** + * Get a ManagedIdentityTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param managedIdentityTrackedResourceName 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 ManagedIdentityTrackedResource. + */ + ManagedIdentityTrackedResource getByResourceGroup(String resourceGroupName, + String managedIdentityTrackedResourceName); + + /** + * Get a ManagedIdentityTrackedResource. + * + * @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 ManagedIdentityTrackedResource along with {@link Response}. + */ + ManagedIdentityTrackedResource getById(String id); + + /** + * Get a ManagedIdentityTrackedResource. + * + * @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 ManagedIdentityTrackedResource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new ManagedIdentityTrackedResource resource. + * + * @param name resource name. + * @return the first stage of the new ManagedIdentityTrackedResource definition. + */ + ManagedIdentityTrackedResource.DefinitionStages.Blank define(String name); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedServiceIdentity.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedServiceIdentity.java new file mode 100644 index 000000000..b04ee8119 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedServiceIdentity.java @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +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.Map; + +/** + * Managed service identity (system assigned and/or user assigned identities). + */ +@Fluent +public final class ManagedServiceIdentity implements JsonSerializable { + /* + * The service principal ID of the system assigned identity. This property will only be provided for a system + * assigned identity. + */ + private String principalId; + + /* + * The tenant ID of the system assigned identity. This property will only be provided for a system assigned + * identity. + */ + private String tenantId; + + /* + * The type of managed identity assigned to this resource. + */ + private ManagedServiceIdentityType type; + + /* + * The identities assigned to this resource by the user. + */ + private Map userAssignedIdentities; + + /** + * Creates an instance of ManagedServiceIdentity class. + */ + public ManagedServiceIdentity() { + } + + /** + * Get the principalId property: The service principal ID of the system assigned identity. This property will only + * be provided for a system assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The tenant ID of the system assigned identity. This property will only be provided for + * a system assigned identity. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Get the type property: The type of managed identity assigned to this resource. + * + * @return the type value. + */ + public ManagedServiceIdentityType type() { + return this.type; + } + + /** + * Set the type property: The type of managed identity assigned to this resource. + * + * @param type the type value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withType(ManagedServiceIdentityType type) { + this.type = type; + return this; + } + + /** + * Get the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (type() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property type in model ManagedServiceIdentity")); + } + if (userAssignedIdentities() != null) { + userAssignedIdentities().values().forEach(e -> { + if (e != null) { + e.validate(); + } + }); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ManagedServiceIdentity.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeMapField("userAssignedIdentities", this.userAssignedIdentities, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagedServiceIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagedServiceIdentity 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 ManagedServiceIdentity. + */ + public static ManagedServiceIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagedServiceIdentity deserializedManagedServiceIdentity = new ManagedServiceIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedManagedServiceIdentity.type = ManagedServiceIdentityType.fromString(reader.getString()); + } else if ("principalId".equals(fieldName)) { + deserializedManagedServiceIdentity.principalId = reader.getString(); + } else if ("tenantId".equals(fieldName)) { + deserializedManagedServiceIdentity.tenantId = reader.getString(); + } else if ("userAssignedIdentities".equals(fieldName)) { + Map userAssignedIdentities + = reader.readMap(reader1 -> UserAssignedIdentity.fromJson(reader1)); + deserializedManagedServiceIdentity.userAssignedIdentities = userAssignedIdentities; + } else { + reader.skipChildren(); + } + } + + return deserializedManagedServiceIdentity; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedServiceIdentityType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedServiceIdentityType.java new file mode 100644 index 000000000..a677cdcc5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/ManagedServiceIdentityType.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + */ +public final class ManagedServiceIdentityType extends ExpandableStringEnum { + /** + * Static value None for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType NONE = fromString("None"); + + /** + * Static value SystemAssigned for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); + + /** + * Static value UserAssigned for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType USER_ASSIGNED = fromString("UserAssigned"); + + /** + * Static value SystemAssigned,UserAssigned for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED_USER_ASSIGNED + = fromString("SystemAssigned,UserAssigned"); + + /** + * Creates a new instance of ManagedServiceIdentityType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ManagedServiceIdentityType() { + } + + /** + * Creates or finds a ManagedServiceIdentityType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ManagedServiceIdentityType. + */ + public static ManagedServiceIdentityType fromString(String name) { + return fromString(name, ManagedServiceIdentityType.class); + } + + /** + * Gets known ManagedServiceIdentityType values. + * + * @return known ManagedServiceIdentityType values. + */ + public static Collection values() { + return values(ManagedServiceIdentityType.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/UserAssignedIdentity.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/UserAssignedIdentity.java new file mode 100644 index 000000000..5a60a19ba --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/UserAssignedIdentity.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.commontypes.managedidentity.models; + +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; + +/** + * User assigned identity properties. + */ +@Immutable +public final class UserAssignedIdentity implements JsonSerializable { + /* + * The principal ID of the assigned identity. + */ + private String principalId; + + /* + * The client ID of the assigned identity. + */ + private String clientId; + + /** + * Creates an instance of UserAssignedIdentity class. + */ + public UserAssignedIdentity() { + } + + /** + * Get the principalId property: The principal ID of the assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the clientId property: The client ID of the assigned identity. + * + * @return the clientId value. + */ + public String clientId() { + return this.clientId; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserAssignedIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserAssignedIdentity 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 UserAssignedIdentity. + */ + public static UserAssignedIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UserAssignedIdentity deserializedUserAssignedIdentity = new UserAssignedIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("principalId".equals(fieldName)) { + deserializedUserAssignedIdentity.principalId = reader.getString(); + } else if ("clientId".equals(fieldName)) { + deserializedUserAssignedIdentity.clientId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedUserAssignedIdentity; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/models/package-info.java new file mode 100644 index 000000000..e4c8af4f3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/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 ManagedIdentity. + * Arm Managed Identity Provider management API. + */ +package com.azure.resourcemanager.models.commontypes.managedidentity.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/package-info.java new file mode 100644 index 000000000..af8e915ac --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/commontypes/managedidentity/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 ManagedIdentity. + * Arm Managed Identity Provider management API. + */ +package com.azure.resourcemanager.models.commontypes.managedidentity; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/ResourcesManager.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/ResourcesManager.java new file mode 100644 index 000000000..48ba17233 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/ResourcesManager.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpPipeline; +import com.azure.core.management.profile.AzureProfile; +import com.azure.resourcemanager.models.resources.fluent.ResourcesClient; +import com.azure.resourcemanager.models.resources.implementation.NestedProxyResourcesImpl; +import com.azure.resourcemanager.models.resources.implementation.ResourcesClientBuilder; +import com.azure.resourcemanager.models.resources.implementation.TopLevelTrackedResourcesImpl; +import com.azure.resourcemanager.models.resources.models.NestedProxyResources; +import com.azure.resourcemanager.models.resources.models.TopLevelTrackedResources; +import java.time.Duration; +import java.util.Objects; + +/** + * Entry point to ResourcesManager. + * Arm Resource Provider management API. + */ +public final class ResourcesManager { + private TopLevelTrackedResources topLevelTrackedResources; + + private NestedProxyResources nestedProxyResources; + + private final ResourcesClient clientObject; + + private ResourcesManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new ResourcesClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Resources service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Resources service API instance. + */ + public static ResourcesManager 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 Resources service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the Resources service API instance. + */ + public static ResourcesManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new ResourcesManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create ResourcesManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new ResourcesManager.Configurable(); + } + + /** + * Gets the resource collection API of TopLevelTrackedResources. It manages TopLevelTrackedResource. + * + * @return Resource collection API of TopLevelTrackedResources. + */ + public TopLevelTrackedResources topLevelTrackedResources() { + if (this.topLevelTrackedResources == null) { + this.topLevelTrackedResources + = new TopLevelTrackedResourcesImpl(clientObject.getTopLevelTrackedResources(), this); + } + return topLevelTrackedResources; + } + + /** + * Gets the resource collection API of NestedProxyResources. It manages NestedProxyResource. + * + * @return Resource collection API of NestedProxyResources. + */ + public NestedProxyResources nestedProxyResources() { + if (this.nestedProxyResources == null) { + this.nestedProxyResources = new NestedProxyResourcesImpl(clientObject.getNestedProxyResources(), this); + } + return nestedProxyResources; + } + + /** + * Gets wrapped service client ResourcesClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client ResourcesClient. + */ + public ResourcesClient serviceClient() { + return this.clientObject; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/NestedProxyResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/NestedProxyResourcesClient.java new file mode 100644 index 000000000..a363155ee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/NestedProxyResourcesClient.java @@ -0,0 +1,273 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.fluent; + +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; +import com.azure.resourcemanager.models.resources.fluent.models.NestedProxyResourceInner; + +/** + * An instance of this class provides access to all the operations defined in NestedProxyResourcesClient. + */ +public interface NestedProxyResourcesClient { + /** + * Get a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 NestedProxyResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, Context context); + + /** + * Get a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 NestedProxyResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + NestedProxyResourceInner get(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName); + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, NestedProxyResourceInner> beginCreateOrReplace( + String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + NestedProxyResourceInner resource); + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, NestedProxyResourceInner> beginCreateOrReplace( + String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + NestedProxyResourceInner resource, Context context); + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + NestedProxyResourceInner createOrReplace(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, NestedProxyResourceInner resource); + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + NestedProxyResourceInner createOrReplace(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, NestedProxyResourceInner resource, Context context); + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 the {@link SyncPoller} for polling of nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, NestedProxyResourceInner> beginUpdate(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName, NestedProxyResourceInner properties); + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 the {@link SyncPoller} for polling of nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, NestedProxyResourceInner> beginUpdate(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName, NestedProxyResourceInner properties, + Context context); + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + NestedProxyResourceInner update(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, NestedProxyResourceInner properties); + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + NestedProxyResourceInner update(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, NestedProxyResourceInner properties, Context context); + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName); + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, Context context); + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName); + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + Context context); + + /** + * List NestedProxyResource resources by TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the response of a NestedProxyResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByTopLevelTrackedResource(String resourceGroupName, + String topLevelTrackedResourceName); + + /** + * List NestedProxyResource resources by TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the response of a NestedProxyResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByTopLevelTrackedResource(String resourceGroupName, + String topLevelTrackedResourceName, Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/ResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/ResourcesClient.java new file mode 100644 index 000000000..eef0d1812 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/ResourcesClient.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for ResourcesClient class. + */ +public interface ResourcesClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * 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 TopLevelTrackedResourcesClient object to access its operations. + * + * @return the TopLevelTrackedResourcesClient object. + */ + TopLevelTrackedResourcesClient getTopLevelTrackedResources(); + + /** + * Gets the NestedProxyResourcesClient object to access its operations. + * + * @return the NestedProxyResourcesClient object. + */ + NestedProxyResourcesClient getNestedProxyResources(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/TopLevelTrackedResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/TopLevelTrackedResourcesClient.java new file mode 100644 index 000000000..4a7a5a584 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/TopLevelTrackedResourcesClient.java @@ -0,0 +1,281 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.fluent; + +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; +import com.azure.resourcemanager.models.resources.fluent.models.TopLevelTrackedResourceInner; + +/** + * An instance of this class provides access to all the operations defined in TopLevelTrackedResourcesClient. + */ +public interface TopLevelTrackedResourcesClient { + /** + * Get a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 TopLevelTrackedResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelTrackedResourceName, Context context); + + /** + * Get a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 TopLevelTrackedResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelTrackedResourceInner getByResourceGroup(String resourceGroupName, String topLevelTrackedResourceName); + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelTrackedResourceInner> beginCreateOrReplace( + String resourceGroupName, String topLevelTrackedResourceName, TopLevelTrackedResourceInner resource); + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelTrackedResourceInner> beginCreateOrReplace( + String resourceGroupName, String topLevelTrackedResourceName, TopLevelTrackedResourceInner resource, + Context context); + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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) + TopLevelTrackedResourceInner createOrReplace(String resourceGroupName, String topLevelTrackedResourceName, + TopLevelTrackedResourceInner resource); + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelTrackedResourceInner createOrReplace(String resourceGroupName, String topLevelTrackedResourceName, + TopLevelTrackedResourceInner resource, Context context); + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelTrackedResourceInner> beginUpdate( + String resourceGroupName, String topLevelTrackedResourceName, TopLevelTrackedResourceInner properties); + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelTrackedResourceInner> beginUpdate( + String resourceGroupName, String topLevelTrackedResourceName, TopLevelTrackedResourceInner properties, + Context context); + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelTrackedResourceInner update(String resourceGroupName, String topLevelTrackedResourceName, + TopLevelTrackedResourceInner properties); + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelTrackedResourceInner update(String resourceGroupName, String topLevelTrackedResourceName, + TopLevelTrackedResourceInner properties, Context context); + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelTrackedResourceName); + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelTrackedResourceName, + Context context); + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String topLevelTrackedResourceName); + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String topLevelTrackedResourceName, Context context); + + /** + * List TopLevelTrackedResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelTrackedResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List TopLevelTrackedResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelTrackedResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * List TopLevelTrackedResource resources by subscription ID. + * + * @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 TopLevelTrackedResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List TopLevelTrackedResource resources by subscription 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 TopLevelTrackedResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/models/NestedProxyResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/models/NestedProxyResourceInner.java new file mode 100644 index 000000000..8f9cd7416 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/models/NestedProxyResourceInner.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.fluent.models; + +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 com.azure.resourcemanager.models.resources.models.NestedProxyResourceProperties; +import java.io.IOException; + +/** + * Nested child of Top Level Tracked Resource. + */ +@Fluent +public final class NestedProxyResourceInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private NestedProxyResourceProperties 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 NestedProxyResourceInner class. + */ + public NestedProxyResourceInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public NestedProxyResourceProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the NestedProxyResourceInner object itself. + */ + public NestedProxyResourceInner withProperties(NestedProxyResourceProperties 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; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NestedProxyResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NestedProxyResourceInner 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 NestedProxyResourceInner. + */ + public static NestedProxyResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + NestedProxyResourceInner deserializedNestedProxyResourceInner = new NestedProxyResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedNestedProxyResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedNestedProxyResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedNestedProxyResourceInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedNestedProxyResourceInner.properties = NestedProxyResourceProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedNestedProxyResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedNestedProxyResourceInner; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/models/TopLevelTrackedResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/models/TopLevelTrackedResourceInner.java new file mode 100644 index 000000000..af9aad549 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/models/TopLevelTrackedResourceInner.java @@ -0,0 +1,201 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.models.resources.models.TopLevelTrackedResourceProperties; +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 TopLevelTrackedResourceInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private TopLevelTrackedResourceProperties 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 TopLevelTrackedResourceInner class. + */ + public TopLevelTrackedResourceInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public TopLevelTrackedResourceProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the TopLevelTrackedResourceInner object itself. + */ + public TopLevelTrackedResourceInner withProperties(TopLevelTrackedResourceProperties 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 TopLevelTrackedResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopLevelTrackedResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + if (location() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property location in model TopLevelTrackedResourceInner")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(TopLevelTrackedResourceInner.class); + + /** + * {@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 TopLevelTrackedResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TopLevelTrackedResourceInner 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 TopLevelTrackedResourceInner. + */ + public static TopLevelTrackedResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TopLevelTrackedResourceInner deserializedTopLevelTrackedResourceInner = new TopLevelTrackedResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedTopLevelTrackedResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedTopLevelTrackedResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedTopLevelTrackedResourceInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedTopLevelTrackedResourceInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedTopLevelTrackedResourceInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedTopLevelTrackedResourceInner.properties + = TopLevelTrackedResourceProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedTopLevelTrackedResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedTopLevelTrackedResourceInner; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/models/package-info.java new file mode 100644 index 000000000..86b8f5b6a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/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 Resources. + * Arm Resource Provider management API. + */ +package com.azure.resourcemanager.models.resources.fluent.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/fluent/package-info.java new file mode 100644 index 000000000..492a2d30c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/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 Resources. + * Arm Resource Provider management API. + */ +package com.azure.resourcemanager.models.resources.fluent; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourceImpl.java new file mode 100644 index 000000000..8b09cccfd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourceImpl.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.models.resources.fluent.models.NestedProxyResourceInner; +import com.azure.resourcemanager.models.resources.models.NestedProxyResource; +import com.azure.resourcemanager.models.resources.models.NestedProxyResourceProperties; + +public final class NestedProxyResourceImpl + implements NestedProxyResource, NestedProxyResource.Definition, NestedProxyResource.Update { + private NestedProxyResourceInner innerObject; + + private final com.azure.resourcemanager.models.resources.ResourcesManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public NestedProxyResourceProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public NestedProxyResourceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.models.resources.ResourcesManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String topLevelTrackedResourceName; + + private String nextedProxyResourceName; + + public NestedProxyResourceImpl withExistingTopLevelTrackedResource(String resourceGroupName, + String topLevelTrackedResourceName) { + this.resourceGroupName = resourceGroupName; + this.topLevelTrackedResourceName = topLevelTrackedResourceName; + return this; + } + + public NestedProxyResource create() { + this.innerObject = serviceManager.serviceClient() + .getNestedProxyResources() + .createOrReplace(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, this.innerModel(), + Context.NONE); + return this; + } + + public NestedProxyResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getNestedProxyResources() + .createOrReplace(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, this.innerModel(), + context); + return this; + } + + NestedProxyResourceImpl(String name, com.azure.resourcemanager.models.resources.ResourcesManager serviceManager) { + this.innerObject = new NestedProxyResourceInner(); + this.serviceManager = serviceManager; + this.nextedProxyResourceName = name; + } + + public NestedProxyResourceImpl update() { + return this; + } + + public NestedProxyResource apply() { + this.innerObject = serviceManager.serviceClient() + .getNestedProxyResources() + .update(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, this.innerModel(), + Context.NONE); + return this; + } + + public NestedProxyResource apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getNestedProxyResources() + .update(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, this.innerModel(), + context); + return this; + } + + NestedProxyResourceImpl(NestedProxyResourceInner innerObject, + com.azure.resourcemanager.models.resources.ResourcesManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.topLevelTrackedResourceName + = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "topLevelTrackedResources"); + this.nextedProxyResourceName + = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "nestedProxyResources"); + } + + public NestedProxyResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getNestedProxyResources() + .getWithResponse(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, Context.NONE) + .getValue(); + return this; + } + + public NestedProxyResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getNestedProxyResources() + .getWithResponse(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, context) + .getValue(); + return this; + } + + public NestedProxyResourceImpl withProperties(NestedProxyResourceProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourcesClientImpl.java new file mode 100644 index 000000000..2ec2e1afe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourcesClientImpl.java @@ -0,0 +1,1259 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.implementation; + +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.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.models.resources.fluent.NestedProxyResourcesClient; +import com.azure.resourcemanager.models.resources.fluent.models.NestedProxyResourceInner; +import com.azure.resourcemanager.models.resources.implementation.models.NestedProxyResourceListResult; +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 NestedProxyResourcesClient. + */ +public final class NestedProxyResourcesClientImpl implements NestedProxyResourcesClient { + /** + * The proxy service used to perform REST calls. + */ + private final NestedProxyResourcesService service; + + /** + * The service client containing this operation class. + */ + private final ResourcesClientImpl client; + + /** + * Initializes an instance of NestedProxyResourcesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NestedProxyResourcesClientImpl(ResourcesClientImpl client) { + this.service = RestProxy.create(NestedProxyResourcesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ResourcesClientNestedProxyResources to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ResourcesClientNeste") + public interface NestedProxyResourcesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelTrackedResourceName") String topLevelTrackedResourceName, + @PathParam("nextedProxyResourceName") String nextedProxyResourceName, @HeaderParam("Accept") String accept, + Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}") + @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("topLevelTrackedResourceName") String topLevelTrackedResourceName, + @PathParam("nextedProxyResourceName") String nextedProxyResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") NestedProxyResourceInner resource, Context context); + + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelTrackedResourceName") String topLevelTrackedResourceName, + @PathParam("nextedProxyResourceName") String nextedProxyResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") NestedProxyResourceInner properties, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelTrackedResourceName") String topLevelTrackedResourceName, + @PathParam("nextedProxyResourceName") String nextedProxyResourceName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByTopLevelTrackedResource( + @HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelTrackedResourceName") String topLevelTrackedResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByTopLevelTrackedResourceNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 NestedProxyResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + if (nextedProxyResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter nextedProxyResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, + nextedProxyResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 NestedProxyResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + if (nextedProxyResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter nextedProxyResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, accept, context); + } + + /** + * Get a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 NestedProxyResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName) { + return getWithResponseAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 NestedProxyResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName, Context context) { + return getWithResponseAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, context) + .block(); + } + + /** + * Get a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 NestedProxyResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public NestedProxyResourceInner get(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName) { + return getWithResponse(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, Context.NONE) + .getValue(); + } + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrReplaceWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName, NestedProxyResourceInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + if (nextedProxyResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter nextedProxyResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + 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, topLevelTrackedResourceName, + nextedProxyResourceName, contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrReplaceWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName, NestedProxyResourceInner resource, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + if (nextedProxyResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter nextedProxyResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrReplace(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, + contentType, accept, resource, context); + } + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, NestedProxyResourceInner> beginCreateOrReplaceAsync( + String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + NestedProxyResourceInner resource) { + Mono>> mono = createOrReplaceWithResponseAsync(resourceGroupName, + topLevelTrackedResourceName, nextedProxyResourceName, resource); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), NestedProxyResourceInner.class, NestedProxyResourceInner.class, + this.client.getContext()); + } + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 PollerFlux} for polling of nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, NestedProxyResourceInner> beginCreateOrReplaceAsync( + String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + NestedProxyResourceInner resource, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = createOrReplaceWithResponseAsync(resourceGroupName, + topLevelTrackedResourceName, nextedProxyResourceName, resource, context); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), NestedProxyResourceInner.class, NestedProxyResourceInner.class, context); + } + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, NestedProxyResourceInner> beginCreateOrReplace( + String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + NestedProxyResourceInner resource) { + return this + .beginCreateOrReplaceAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, + resource) + .getSyncPoller(); + } + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, NestedProxyResourceInner> beginCreateOrReplace( + String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + NestedProxyResourceInner resource, Context context) { + return this + .beginCreateOrReplaceAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, + resource, context) + .getSyncPoller(); + } + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrReplaceAsync(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName, NestedProxyResourceInner resource) { + return beginCreateOrReplaceAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, + resource).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrReplaceAsync(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName, NestedProxyResourceInner resource, + Context context) { + return beginCreateOrReplaceAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, + resource, context).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public NestedProxyResourceInner createOrReplace(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, NestedProxyResourceInner resource) { + return createOrReplaceAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, resource) + .block(); + } + + /** + * Create a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public NestedProxyResourceInner createOrReplace(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, NestedProxyResourceInner resource, Context context) { + return createOrReplaceAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, resource, + context).block(); + } + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName, NestedProxyResourceInner properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + if (nextedProxyResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter nextedProxyResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, + nextedProxyResourceName, contentType, accept, properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName, NestedProxyResourceInner properties, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + if (nextedProxyResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter nextedProxyResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, contentType, accept, properties, + context); + } + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 the {@link PollerFlux} for polling of nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, NestedProxyResourceInner> beginUpdateAsync( + String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + NestedProxyResourceInner properties) { + Mono>> mono = updateWithResponseAsync(resourceGroupName, topLevelTrackedResourceName, + nextedProxyResourceName, properties); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), NestedProxyResourceInner.class, NestedProxyResourceInner.class, + this.client.getContext()); + } + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 the {@link PollerFlux} for polling of nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, NestedProxyResourceInner> beginUpdateAsync( + String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + NestedProxyResourceInner properties, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = updateWithResponseAsync(resourceGroupName, topLevelTrackedResourceName, + nextedProxyResourceName, properties, context); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), NestedProxyResourceInner.class, NestedProxyResourceInner.class, context); + } + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 the {@link SyncPoller} for polling of nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, NestedProxyResourceInner> beginUpdate( + String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + NestedProxyResourceInner properties) { + return this + .beginUpdateAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, properties) + .getSyncPoller(); + } + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 the {@link SyncPoller} for polling of nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, NestedProxyResourceInner> beginUpdate( + String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + NestedProxyResourceInner properties, Context context) { + return this + .beginUpdateAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, properties, + context) + .getSyncPoller(); + } + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, NestedProxyResourceInner properties) { + return beginUpdateAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, properties) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, NestedProxyResourceInner properties, Context context) { + return beginUpdateAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, properties, + context).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public NestedProxyResourceInner update(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, NestedProxyResourceInner properties) { + return updateAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, properties).block(); + } + + /** + * Update a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 nested child of Top Level Tracked Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public NestedProxyResourceInner update(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, NestedProxyResourceInner properties, Context context) { + return updateAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, properties, context) + .block(); + } + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + if (nextedProxyResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter nextedProxyResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, + nextedProxyResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + if (nextedProxyResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter nextedProxyResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, accept, context); + } + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName) { + Mono>> mono + = deleteWithResponseAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, + String topLevelTrackedResourceName, String nextedProxyResourceName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = deleteWithResponseAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + context); + } + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName) { + return this.beginDeleteAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName) + .getSyncPoller(); + } + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, Context context) { + return this.beginDeleteAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, context) + .getSyncPoller(); + } + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName) { + return beginDeleteAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, Context context) { + return beginDeleteAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName) { + deleteAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName).block(); + } + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + Context context) { + deleteAsync(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, context).block(); + } + + /** + * List NestedProxyResource resources by TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the response of a NestedProxyResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByTopLevelTrackedResourceSinglePageAsync(String resourceGroupName, String topLevelTrackedResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByTopLevelTrackedResource(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, 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 NestedProxyResource resources by TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the response of a NestedProxyResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByTopLevelTrackedResourceSinglePageAsync( + String resourceGroupName, String topLevelTrackedResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByTopLevelTrackedResource(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List NestedProxyResource resources by TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the response of a NestedProxyResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByTopLevelTrackedResourceAsync(String resourceGroupName, + String topLevelTrackedResourceName) { + return new PagedFlux<>( + () -> listByTopLevelTrackedResourceSinglePageAsync(resourceGroupName, topLevelTrackedResourceName), + nextLink -> listByTopLevelTrackedResourceNextSinglePageAsync(nextLink)); + } + + /** + * List NestedProxyResource resources by TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the response of a NestedProxyResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByTopLevelTrackedResourceAsync(String resourceGroupName, + String topLevelTrackedResourceName, Context context) { + return new PagedFlux<>( + () -> listByTopLevelTrackedResourceSinglePageAsync(resourceGroupName, topLevelTrackedResourceName, context), + nextLink -> listByTopLevelTrackedResourceNextSinglePageAsync(nextLink, context)); + } + + /** + * List NestedProxyResource resources by TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the response of a NestedProxyResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByTopLevelTrackedResource(String resourceGroupName, + String topLevelTrackedResourceName) { + return new PagedIterable<>(listByTopLevelTrackedResourceAsync(resourceGroupName, topLevelTrackedResourceName)); + } + + /** + * List NestedProxyResource resources by TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the response of a NestedProxyResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByTopLevelTrackedResource(String resourceGroupName, + String topLevelTrackedResourceName, Context context) { + return new PagedIterable<>( + listByTopLevelTrackedResourceAsync(resourceGroupName, topLevelTrackedResourceName, context)); + } + + /** + * List NestedProxyResource resources by TopLevelTrackedResource + * + * 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 NestedProxyResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByTopLevelTrackedResourceNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.listByTopLevelTrackedResourceNext(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())); + } + + /** + * List NestedProxyResource resources by TopLevelTrackedResource + * + * 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 NestedProxyResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByTopLevelTrackedResourceNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByTopLevelTrackedResourceNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> 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/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourcesImpl.java new file mode 100644 index 000000000..a4e6bff88 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/NestedProxyResourcesImpl.java @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.implementation; + +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; +import com.azure.resourcemanager.models.resources.fluent.NestedProxyResourcesClient; +import com.azure.resourcemanager.models.resources.fluent.models.NestedProxyResourceInner; +import com.azure.resourcemanager.models.resources.models.NestedProxyResource; +import com.azure.resourcemanager.models.resources.models.NestedProxyResources; + +public final class NestedProxyResourcesImpl implements NestedProxyResources { + private static final ClientLogger LOGGER = new ClientLogger(NestedProxyResourcesImpl.class); + + private final NestedProxyResourcesClient innerClient; + + private final com.azure.resourcemanager.models.resources.ResourcesManager serviceManager; + + public NestedProxyResourcesImpl(NestedProxyResourcesClient innerClient, + com.azure.resourcemanager.models.resources.ResourcesManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, Context context) { + Response inner = this.serviceClient() + .getWithResponse(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new NestedProxyResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public NestedProxyResource get(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName) { + NestedProxyResourceInner inner + = this.serviceClient().get(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName); + if (inner != null) { + return new NestedProxyResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public void delete(String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName) { + this.serviceClient().delete(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName); + } + + public void delete(String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + Context context) { + this.serviceClient().delete(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, context); + } + + public PagedIterable listByTopLevelTrackedResource(String resourceGroupName, + String topLevelTrackedResourceName) { + PagedIterable inner + = this.serviceClient().listByTopLevelTrackedResource(resourceGroupName, topLevelTrackedResourceName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new NestedProxyResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByTopLevelTrackedResource(String resourceGroupName, + String topLevelTrackedResourceName, Context context) { + PagedIterable inner = this.serviceClient() + .listByTopLevelTrackedResource(resourceGroupName, topLevelTrackedResourceName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new NestedProxyResourceImpl(inner1, this.manager())); + } + + public NestedProxyResource 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 topLevelTrackedResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelTrackedResources"); + if (topLevelTrackedResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'topLevelTrackedResources'.", id))); + } + String nextedProxyResourceName = ResourceManagerUtils.getValueFromIdByName(id, "nestedProxyResources"); + if (nextedProxyResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'nestedProxyResources'.", id))); + } + return this + .getWithResponse(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, 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 topLevelTrackedResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelTrackedResources"); + if (topLevelTrackedResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'topLevelTrackedResources'.", id))); + } + String nextedProxyResourceName = ResourceManagerUtils.getValueFromIdByName(id, "nestedProxyResources"); + if (nextedProxyResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'nestedProxyResources'.", id))); + } + return this.getWithResponse(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, context); + } + + public void deleteById(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 topLevelTrackedResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelTrackedResources"); + if (topLevelTrackedResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'topLevelTrackedResources'.", id))); + } + String nextedProxyResourceName = ResourceManagerUtils.getValueFromIdByName(id, "nestedProxyResources"); + if (nextedProxyResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'nestedProxyResources'.", id))); + } + this.delete(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, Context.NONE); + } + + public void deleteByIdWithResponse(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 topLevelTrackedResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelTrackedResources"); + if (topLevelTrackedResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'topLevelTrackedResources'.", id))); + } + String nextedProxyResourceName = ResourceManagerUtils.getValueFromIdByName(id, "nestedProxyResources"); + if (nextedProxyResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'nestedProxyResources'.", id))); + } + this.delete(resourceGroupName, topLevelTrackedResourceName, nextedProxyResourceName, context); + } + + private NestedProxyResourcesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.models.resources.ResourcesManager manager() { + return this.serviceManager; + } + + public NestedProxyResourceImpl define(String name) { + return new NestedProxyResourceImpl(name, this.manager()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourceManagerUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourceManagerUtils.java new file mode 100644 index 000000000..3029fbe5a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourceManagerUtils.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.implementation; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + + } + +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientBuilder.java new file mode 100644 index 000000000..0e78a1b9e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.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 ResourcesClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { ResourcesClientImpl.class }) +public final class ResourcesClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the ResourcesClientBuilder. + */ + public ResourcesClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the ResourcesClientBuilder. + */ + public ResourcesClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the ResourcesClientBuilder. + */ + public ResourcesClientBuilder 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 ResourcesClientBuilder. + */ + public ResourcesClientBuilder 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 ResourcesClientBuilder. + */ + public ResourcesClientBuilder 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 ResourcesClientBuilder. + */ + public ResourcesClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of ResourcesClientImpl with the provided parameters. + * + * @return an instance of ResourcesClientImpl. + */ + public ResourcesClientImpl 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(); + ResourcesClientImpl client = new ResourcesClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientImpl.java new file mode 100644 index 000000000..e3863a01f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/ResourcesClientImpl.java @@ -0,0 +1,261 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.implementation; + +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.polling.PollerFactory; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.resourcemanager.models.resources.fluent.NestedProxyResourcesClient; +import com.azure.resourcemanager.models.resources.fluent.ResourcesClient; +import com.azure.resourcemanager.models.resources.fluent.TopLevelTrackedResourcesClient; +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 ResourcesClientImpl type. + */ +@ServiceClient(builder = ResourcesClientBuilder.class) +public final class ResourcesClientImpl implements ResourcesClient { + /** + * 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 ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * 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 TopLevelTrackedResourcesClient object to access its operations. + */ + private final TopLevelTrackedResourcesClient topLevelTrackedResources; + + /** + * Gets the TopLevelTrackedResourcesClient object to access its operations. + * + * @return the TopLevelTrackedResourcesClient object. + */ + public TopLevelTrackedResourcesClient getTopLevelTrackedResources() { + return this.topLevelTrackedResources; + } + + /** + * The NestedProxyResourcesClient object to access its operations. + */ + private final NestedProxyResourcesClient nestedProxyResources; + + /** + * Gets the NestedProxyResourcesClient object to access its operations. + * + * @return the NestedProxyResourcesClient object. + */ + public NestedProxyResourcesClient getNestedProxyResources() { + return this.nestedProxyResources; + } + + /** + * Initializes an instance of ResourcesClient 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. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + ResourcesClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, Duration defaultPollInterval, + AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.apiVersion = "2023-12-01-preview"; + this.topLevelTrackedResources = new TopLevelTrackedResourcesClientImpl(this); + this.nestedProxyResources = new NestedProxyResourcesClientImpl(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 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) { + } + + 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)); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourceImpl.java new file mode 100644 index 000000000..58e476a13 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourceImpl.java @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.models.resources.fluent.models.TopLevelTrackedResourceInner; +import com.azure.resourcemanager.models.resources.models.TopLevelTrackedResource; +import com.azure.resourcemanager.models.resources.models.TopLevelTrackedResourceProperties; +import java.util.Collections; +import java.util.Map; + +public final class TopLevelTrackedResourceImpl + implements TopLevelTrackedResource, TopLevelTrackedResource.Definition, TopLevelTrackedResource.Update { + private TopLevelTrackedResourceInner innerObject; + + private final com.azure.resourcemanager.models.resources.ResourcesManager 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 TopLevelTrackedResourceProperties 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 String resourceGroupName() { + return resourceGroupName; + } + + public TopLevelTrackedResourceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.models.resources.ResourcesManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String topLevelTrackedResourceName; + + public TopLevelTrackedResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public TopLevelTrackedResource create() { + this.innerObject = serviceManager.serviceClient() + .getTopLevelTrackedResources() + .createOrReplace(resourceGroupName, topLevelTrackedResourceName, this.innerModel(), Context.NONE); + return this; + } + + public TopLevelTrackedResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTopLevelTrackedResources() + .createOrReplace(resourceGroupName, topLevelTrackedResourceName, this.innerModel(), context); + return this; + } + + TopLevelTrackedResourceImpl(String name, + com.azure.resourcemanager.models.resources.ResourcesManager serviceManager) { + this.innerObject = new TopLevelTrackedResourceInner(); + this.serviceManager = serviceManager; + this.topLevelTrackedResourceName = name; + } + + public TopLevelTrackedResourceImpl update() { + return this; + } + + public TopLevelTrackedResource apply() { + this.innerObject = serviceManager.serviceClient() + .getTopLevelTrackedResources() + .update(resourceGroupName, topLevelTrackedResourceName, this.innerModel(), Context.NONE); + return this; + } + + public TopLevelTrackedResource apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTopLevelTrackedResources() + .update(resourceGroupName, topLevelTrackedResourceName, this.innerModel(), context); + return this; + } + + TopLevelTrackedResourceImpl(TopLevelTrackedResourceInner innerObject, + com.azure.resourcemanager.models.resources.ResourcesManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.topLevelTrackedResourceName + = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "topLevelTrackedResources"); + } + + public TopLevelTrackedResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getTopLevelTrackedResources() + .getByResourceGroupWithResponse(resourceGroupName, topLevelTrackedResourceName, Context.NONE) + .getValue(); + return this; + } + + public TopLevelTrackedResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTopLevelTrackedResources() + .getByResourceGroupWithResponse(resourceGroupName, topLevelTrackedResourceName, context) + .getValue(); + return this; + } + + public TopLevelTrackedResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public TopLevelTrackedResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public TopLevelTrackedResourceImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public TopLevelTrackedResourceImpl withProperties(TopLevelTrackedResourceProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourcesClientImpl.java new file mode 100644 index 000000000..8846a0e31 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourcesClientImpl.java @@ -0,0 +1,1339 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.implementation; + +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.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.models.resources.fluent.TopLevelTrackedResourcesClient; +import com.azure.resourcemanager.models.resources.fluent.models.TopLevelTrackedResourceInner; +import com.azure.resourcemanager.models.resources.implementation.models.TopLevelTrackedResourceListResult; +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 TopLevelTrackedResourcesClient. + */ +public final class TopLevelTrackedResourcesClientImpl implements TopLevelTrackedResourcesClient { + /** + * The proxy service used to perform REST calls. + */ + private final TopLevelTrackedResourcesService service; + + /** + * The service client containing this operation class. + */ + private final ResourcesClientImpl client; + + /** + * Initializes an instance of TopLevelTrackedResourcesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + TopLevelTrackedResourcesClientImpl(ResourcesClientImpl client) { + this.service = RestProxy.create(TopLevelTrackedResourcesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ResourcesClientTopLevelTrackedResources to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ResourcesClientTopLe") + public interface TopLevelTrackedResourcesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}") + @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("topLevelTrackedResourceName") String topLevelTrackedResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}") + @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("topLevelTrackedResourceName") String topLevelTrackedResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") TopLevelTrackedResourceInner resource, Context context); + + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelTrackedResourceName") String topLevelTrackedResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") TopLevelTrackedResourceInner properties, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelTrackedResourceName") String topLevelTrackedResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroupNext( + @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) + Mono> listBySubscriptionNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 TopLevelTrackedResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 TopLevelTrackedResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, accept, context); + } + + /** + * Get a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 TopLevelTrackedResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, + String topLevelTrackedResourceName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, topLevelTrackedResourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 TopLevelTrackedResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelTrackedResourceName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, topLevelTrackedResourceName, context).block(); + } + + /** + * Get a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 TopLevelTrackedResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelTrackedResourceInner getByResourceGroup(String resourceGroupName, + String topLevelTrackedResourceName) { + return getByResourceGroupWithResponse(resourceGroupName, topLevelTrackedResourceName, Context.NONE).getValue(); + } + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 topLevelTrackedResourceName, TopLevelTrackedResourceInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + 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, topLevelTrackedResourceName, contentType, accept, + resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrReplaceWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName, TopLevelTrackedResourceInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrReplace(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, contentType, accept, + resource, context); + } + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TopLevelTrackedResourceInner> + beginCreateOrReplaceAsync(String resourceGroupName, String topLevelTrackedResourceName, + TopLevelTrackedResourceInner resource) { + Mono>> mono + = createOrReplaceWithResponseAsync(resourceGroupName, topLevelTrackedResourceName, resource); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), TopLevelTrackedResourceInner.class, TopLevelTrackedResourceInner.class, + this.client.getContext()); + } + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TopLevelTrackedResourceInner> + beginCreateOrReplaceAsync(String resourceGroupName, String topLevelTrackedResourceName, + TopLevelTrackedResourceInner resource, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = createOrReplaceWithResponseAsync(resourceGroupName, topLevelTrackedResourceName, resource, context); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), TopLevelTrackedResourceInner.class, TopLevelTrackedResourceInner.class, + context); + } + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelTrackedResourceInner> beginCreateOrReplace( + String resourceGroupName, String topLevelTrackedResourceName, TopLevelTrackedResourceInner resource) { + return this.beginCreateOrReplaceAsync(resourceGroupName, topLevelTrackedResourceName, resource).getSyncPoller(); + } + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelTrackedResourceInner> beginCreateOrReplace( + String resourceGroupName, String topLevelTrackedResourceName, TopLevelTrackedResourceInner resource, + Context context) { + return this.beginCreateOrReplaceAsync(resourceGroupName, topLevelTrackedResourceName, resource, context) + .getSyncPoller(); + } + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 topLevelTrackedResourceName, TopLevelTrackedResourceInner resource) { + return beginCreateOrReplaceAsync(resourceGroupName, topLevelTrackedResourceName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrReplaceAsync(String resourceGroupName, + String topLevelTrackedResourceName, TopLevelTrackedResourceInner resource, Context context) { + return beginCreateOrReplaceAsync(resourceGroupName, topLevelTrackedResourceName, resource, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 TopLevelTrackedResourceInner createOrReplace(String resourceGroupName, String topLevelTrackedResourceName, + TopLevelTrackedResourceInner resource) { + return createOrReplaceAsync(resourceGroupName, topLevelTrackedResourceName, resource).block(); + } + + /** + * Create a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelTrackedResourceInner createOrReplace(String resourceGroupName, String topLevelTrackedResourceName, + TopLevelTrackedResourceInner resource, Context context) { + return createOrReplaceAsync(resourceGroupName, topLevelTrackedResourceName, resource, context).block(); + } + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 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>> updateWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName, TopLevelTrackedResourceInner properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, contentType, accept, + properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 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>> updateWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName, TopLevelTrackedResourceInner properties, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelTrackedResourceName, contentType, accept, properties, context); + } + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TopLevelTrackedResourceInner> beginUpdateAsync( + String resourceGroupName, String topLevelTrackedResourceName, TopLevelTrackedResourceInner properties) { + Mono>> mono + = updateWithResponseAsync(resourceGroupName, topLevelTrackedResourceName, properties); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), TopLevelTrackedResourceInner.class, TopLevelTrackedResourceInner.class, + this.client.getContext()); + } + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TopLevelTrackedResourceInner> beginUpdateAsync( + String resourceGroupName, String topLevelTrackedResourceName, TopLevelTrackedResourceInner properties, + Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = updateWithResponseAsync(resourceGroupName, topLevelTrackedResourceName, properties, context); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), TopLevelTrackedResourceInner.class, TopLevelTrackedResourceInner.class, + context); + } + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelTrackedResourceInner> beginUpdate( + String resourceGroupName, String topLevelTrackedResourceName, TopLevelTrackedResourceInner properties) { + return this.beginUpdateAsync(resourceGroupName, topLevelTrackedResourceName, properties).getSyncPoller(); + } + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelTrackedResourceInner> beginUpdate( + String resourceGroupName, String topLevelTrackedResourceName, TopLevelTrackedResourceInner properties, + Context context) { + return this.beginUpdateAsync(resourceGroupName, topLevelTrackedResourceName, properties, context) + .getSyncPoller(); + } + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 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 updateAsync(String resourceGroupName, String topLevelTrackedResourceName, + TopLevelTrackedResourceInner properties) { + return beginUpdateAsync(resourceGroupName, topLevelTrackedResourceName, properties).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 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 updateAsync(String resourceGroupName, String topLevelTrackedResourceName, + TopLevelTrackedResourceInner properties, Context context) { + return beginUpdateAsync(resourceGroupName, topLevelTrackedResourceName, properties, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelTrackedResourceInner update(String resourceGroupName, String topLevelTrackedResourceName, + TopLevelTrackedResourceInner properties) { + return updateAsync(resourceGroupName, topLevelTrackedResourceName, properties).block(); + } + + /** + * Update a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelTrackedResourceInner update(String resourceGroupName, String topLevelTrackedResourceName, + TopLevelTrackedResourceInner properties, Context context) { + return updateAsync(resourceGroupName, topLevelTrackedResourceName, properties, context).block(); + } + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelTrackedResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, + String topLevelTrackedResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelTrackedResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelTrackedResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelTrackedResourceName, accept, context); + } + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, + String topLevelTrackedResourceName) { + Mono>> mono = deleteWithResponseAsync(resourceGroupName, topLevelTrackedResourceName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, + String topLevelTrackedResourceName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = deleteWithResponseAsync(resourceGroupName, topLevelTrackedResourceName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + context); + } + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, + String topLevelTrackedResourceName) { + return this.beginDeleteAsync(resourceGroupName, topLevelTrackedResourceName).getSyncPoller(); + } + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelTrackedResourceName, + Context context) { + return this.beginDeleteAsync(resourceGroupName, topLevelTrackedResourceName, context).getSyncPoller(); + } + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String topLevelTrackedResourceName) { + return beginDeleteAsync(resourceGroupName, topLevelTrackedResourceName).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String topLevelTrackedResourceName, Context context) { + return beginDeleteAsync(resourceGroupName, topLevelTrackedResourceName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String topLevelTrackedResourceName) { + deleteAsync(resourceGroupName, topLevelTrackedResourceName).block(); + } + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String topLevelTrackedResourceName, Context context) { + deleteAsync(resourceGroupName, topLevelTrackedResourceName, context).block(); + } + + /** + * List TopLevelTrackedResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelTrackedResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByResourceGroupSinglePageAsync(String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, 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 TopLevelTrackedResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelTrackedResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByResourceGroupSinglePageAsync(String resourceGroupName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List TopLevelTrackedResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelTrackedResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * List TopLevelTrackedResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelTrackedResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, + Context context) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * List TopLevelTrackedResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelTrackedResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * List TopLevelTrackedResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelTrackedResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * List TopLevelTrackedResource resources by subscription ID. + * + * @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 TopLevelTrackedResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), 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 TopLevelTrackedResource resources by subscription 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 TopLevelTrackedResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), accept, + context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List TopLevelTrackedResource resources by subscription ID. + * + * @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 TopLevelTrackedResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * List TopLevelTrackedResource resources by subscription 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 TopLevelTrackedResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * List TopLevelTrackedResource resources by subscription ID. + * + * @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 TopLevelTrackedResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List TopLevelTrackedResource resources by subscription 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 TopLevelTrackedResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * List TopLevelTrackedResource resources by resource group + * + * 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 TopLevelTrackedResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByResourceGroupNext(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())); + } + + /** + * List TopLevelTrackedResource resources by resource group + * + * 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 TopLevelTrackedResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List TopLevelTrackedResource resources by subscription ID + * + * 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 TopLevelTrackedResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listBySubscriptionNext(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())); + } + + /** + * List TopLevelTrackedResource resources by subscription ID + * + * 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 TopLevelTrackedResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> 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/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourcesImpl.java new file mode 100644 index 000000000..da4e26f30 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/TopLevelTrackedResourcesImpl.java @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.implementation; + +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; +import com.azure.resourcemanager.models.resources.fluent.TopLevelTrackedResourcesClient; +import com.azure.resourcemanager.models.resources.fluent.models.TopLevelTrackedResourceInner; +import com.azure.resourcemanager.models.resources.models.TopLevelTrackedResource; +import com.azure.resourcemanager.models.resources.models.TopLevelTrackedResources; + +public final class TopLevelTrackedResourcesImpl implements TopLevelTrackedResources { + private static final ClientLogger LOGGER = new ClientLogger(TopLevelTrackedResourcesImpl.class); + + private final TopLevelTrackedResourcesClient innerClient; + + private final com.azure.resourcemanager.models.resources.ResourcesManager serviceManager; + + public TopLevelTrackedResourcesImpl(TopLevelTrackedResourcesClient innerClient, + com.azure.resourcemanager.models.resources.ResourcesManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelTrackedResourceName, Context context) { + Response inner = this.serviceClient() + .getByResourceGroupWithResponse(resourceGroupName, topLevelTrackedResourceName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new TopLevelTrackedResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public TopLevelTrackedResource getByResourceGroup(String resourceGroupName, String topLevelTrackedResourceName) { + TopLevelTrackedResourceInner inner + = this.serviceClient().getByResourceGroup(resourceGroupName, topLevelTrackedResourceName); + if (inner != null) { + return new TopLevelTrackedResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String topLevelTrackedResourceName) { + this.serviceClient().delete(resourceGroupName, topLevelTrackedResourceName); + } + + public void delete(String resourceGroupName, String topLevelTrackedResourceName, Context context) { + this.serviceClient().delete(resourceGroupName, topLevelTrackedResourceName, context); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelTrackedResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner + = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelTrackedResourceImpl(inner1, this.manager())); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelTrackedResourceImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelTrackedResourceImpl(inner1, this.manager())); + } + + public TopLevelTrackedResource 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 topLevelTrackedResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelTrackedResources"); + if (topLevelTrackedResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'topLevelTrackedResources'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, topLevelTrackedResourceName, 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 topLevelTrackedResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelTrackedResources"); + if (topLevelTrackedResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'topLevelTrackedResources'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, topLevelTrackedResourceName, context); + } + + public void deleteById(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 topLevelTrackedResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelTrackedResources"); + if (topLevelTrackedResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'topLevelTrackedResources'.", id))); + } + this.delete(resourceGroupName, topLevelTrackedResourceName, Context.NONE); + } + + public void deleteByIdWithResponse(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 topLevelTrackedResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelTrackedResources"); + if (topLevelTrackedResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'topLevelTrackedResources'.", id))); + } + this.delete(resourceGroupName, topLevelTrackedResourceName, context); + } + + private TopLevelTrackedResourcesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.models.resources.ResourcesManager manager() { + return this.serviceManager; + } + + public TopLevelTrackedResourceImpl define(String name) { + return new TopLevelTrackedResourceImpl(name, this.manager()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/models/NestedProxyResourceListResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/models/NestedProxyResourceListResult.java new file mode 100644 index 000000000..aeaa5f02a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/models/NestedProxyResourceListResult.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.models.resources.fluent.models.NestedProxyResourceInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a NestedProxyResource list operation. + */ +@Immutable +public final class NestedProxyResourceListResult implements JsonSerializable { + /* + * The NestedProxyResource items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of NestedProxyResourceListResult class. + */ + private NestedProxyResourceListResult() { + } + + /** + * Get the value property: The NestedProxyResource 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; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property value in model NestedProxyResourceListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(NestedProxyResourceListResult.class); + + /** + * {@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 NestedProxyResourceListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NestedProxyResourceListResult 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 NestedProxyResourceListResult. + */ + public static NestedProxyResourceListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + NestedProxyResourceListResult deserializedNestedProxyResourceListResult + = new NestedProxyResourceListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> NestedProxyResourceInner.fromJson(reader1)); + deserializedNestedProxyResourceListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedNestedProxyResourceListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedNestedProxyResourceListResult; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/models/TopLevelTrackedResourceListResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/models/TopLevelTrackedResourceListResult.java new file mode 100644 index 000000000..6d724dd99 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/models/TopLevelTrackedResourceListResult.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.models.resources.fluent.models.TopLevelTrackedResourceInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a TopLevelTrackedResource list operation. + */ +@Immutable +public final class TopLevelTrackedResourceListResult implements JsonSerializable { + /* + * The TopLevelTrackedResource items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of TopLevelTrackedResourceListResult class. + */ + private TopLevelTrackedResourceListResult() { + } + + /** + * Get the value property: The TopLevelTrackedResource 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; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property value in model TopLevelTrackedResourceListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(TopLevelTrackedResourceListResult.class); + + /** + * {@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 TopLevelTrackedResourceListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TopLevelTrackedResourceListResult 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 TopLevelTrackedResourceListResult. + */ + public static TopLevelTrackedResourceListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TopLevelTrackedResourceListResult deserializedTopLevelTrackedResourceListResult + = new TopLevelTrackedResourceListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> TopLevelTrackedResourceInner.fromJson(reader1)); + deserializedTopLevelTrackedResourceListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedTopLevelTrackedResourceListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedTopLevelTrackedResourceListResult; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/implementation/package-info.java new file mode 100644 index 000000000..f3180da15 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/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 Resources. + * Arm Resource Provider management API. + */ +package com.azure.resourcemanager.models.resources.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/NestedProxyResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/NestedProxyResource.java new file mode 100644 index 000000000..b83c6f9d0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/NestedProxyResource.java @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.models.resources.fluent.models.NestedProxyResourceInner; + +/** + * An immutable client-side representation of NestedProxyResource. + */ +public interface NestedProxyResource { + /** + * 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. + */ + NestedProxyResourceProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.models.resources.fluent.models.NestedProxyResourceInner object. + * + * @return the inner object. + */ + NestedProxyResourceInner innerModel(); + + /** + * The entirety of the NestedProxyResource definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The NestedProxyResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the NestedProxyResource definition. + */ + interface Blank extends WithParentResource { + } + + /** + * The stage of the NestedProxyResource definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies resourceGroupName, topLevelTrackedResourceName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @return the next definition stage. + */ + WithCreate withExistingTopLevelTrackedResource(String resourceGroupName, + String topLevelTrackedResourceName); + } + + /** + * The stage of the NestedProxyResource 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.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + NestedProxyResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + NestedProxyResource create(Context context); + } + + /** + * The stage of the NestedProxyResource 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(NestedProxyResourceProperties properties); + } + } + + /** + * Begins update for the NestedProxyResource resource. + * + * @return the stage of resource update. + */ + NestedProxyResource.Update update(); + + /** + * The template for NestedProxyResource update. + */ + interface Update extends UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + NestedProxyResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + NestedProxyResource apply(Context context); + } + + /** + * The NestedProxyResource update stages. + */ + interface UpdateStages { + /** + * The stage of the NestedProxyResource update 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. + */ + Update withProperties(NestedProxyResourceProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + NestedProxyResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + NestedProxyResource refresh(Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/NestedProxyResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/NestedProxyResourceProperties.java new file mode 100644 index 000000000..e6c1fff68 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/NestedProxyResourceProperties.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.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; + +/** + * Nested Proxy Resource Properties. + */ +@Fluent +public final class NestedProxyResourceProperties implements JsonSerializable { + /* + * Provisioning State of the nested child Resource + */ + private ProvisioningState provisioningState; + + /* + * Nested resource description. + */ + private String description; + + /** + * Creates an instance of NestedProxyResourceProperties class. + */ + public NestedProxyResourceProperties() { + } + + /** + * Get the provisioningState property: Provisioning State of the nested child Resource. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the description property: Nested resource description. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: Nested resource description. + * + * @param description the description value to set. + * @return the NestedProxyResourceProperties object itself. + */ + public NestedProxyResourceProperties withDescription(String description) { + this.description = description; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NestedProxyResourceProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NestedProxyResourceProperties 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 NestedProxyResourceProperties. + */ + public static NestedProxyResourceProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + NestedProxyResourceProperties deserializedNestedProxyResourceProperties + = new NestedProxyResourceProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedNestedProxyResourceProperties.provisioningState + = ProvisioningState.fromString(reader.getString()); + } else if ("description".equals(fieldName)) { + deserializedNestedProxyResourceProperties.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedNestedProxyResourceProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/NestedProxyResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/NestedProxyResources.java new file mode 100644 index 000000000..36603839d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/NestedProxyResources.java @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of NestedProxyResources. + */ +public interface NestedProxyResources { + /** + * Get a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 NestedProxyResource along with {@link Response}. + */ + Response getWithResponse(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName, Context context); + + /** + * Get a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 NestedProxyResource. + */ + NestedProxyResource get(String resourceGroupName, String topLevelTrackedResourceName, + String nextedProxyResourceName); + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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 delete(String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName); + + /** + * Delete a NestedProxyResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName arm resource name for path. + * @param nextedProxyResourceName Name of the nested resource. + * @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. + */ + void delete(String resourceGroupName, String topLevelTrackedResourceName, String nextedProxyResourceName, + Context context); + + /** + * List NestedProxyResource resources by TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the response of a NestedProxyResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByTopLevelTrackedResource(String resourceGroupName, + String topLevelTrackedResourceName); + + /** + * List NestedProxyResource resources by TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 the response of a NestedProxyResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByTopLevelTrackedResource(String resourceGroupName, + String topLevelTrackedResourceName, Context context); + + /** + * Get a NestedProxyResource. + * + * @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 NestedProxyResource along with {@link Response}. + */ + NestedProxyResource getById(String id); + + /** + * Get a NestedProxyResource. + * + * @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 NestedProxyResource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a NestedProxyResource. + * + * @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. + */ + void deleteById(String id); + + /** + * Delete a NestedProxyResource. + * + * @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. + */ + void deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new NestedProxyResource resource. + * + * @param name resource name. + * @return the first stage of the new NestedProxyResource definition. + */ + NestedProxyResource.DefinitionStages.Blank define(String name); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/ProvisioningState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/ProvisioningState.java new file mode 100644 index 000000000..49207cad9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/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 com.azure.resourcemanager.models.resources.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for ProvisioningState. + */ +public final class ProvisioningState extends ExpandableStringEnum { + /** + * Static value Succeeded for ProvisioningState. + */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Static value Failed for ProvisioningState. + */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** + * Static value Canceled for ProvisioningState. + */ + 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/com/azure/resourcemanager/models/resources/models/TopLevelTrackedResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/TopLevelTrackedResource.java new file mode 100644 index 000000000..b82b88add --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/TopLevelTrackedResource.java @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.models.resources.fluent.models.TopLevelTrackedResourceInner; +import java.util.Map; + +/** + * An immutable client-side representation of TopLevelTrackedResource. + */ +public interface TopLevelTrackedResource { + /** + * 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. + */ + TopLevelTrackedResourceProperties 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 name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.models.resources.fluent.models.TopLevelTrackedResourceInner object. + * + * @return the inner object. + */ + TopLevelTrackedResourceInner innerModel(); + + /** + * The entirety of the TopLevelTrackedResource definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The TopLevelTrackedResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the TopLevelTrackedResource definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the TopLevelTrackedResource 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 TopLevelTrackedResource 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 TopLevelTrackedResource 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. + */ + TopLevelTrackedResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + TopLevelTrackedResource create(Context context); + } + + /** + * The stage of the TopLevelTrackedResource 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 TopLevelTrackedResource 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(TopLevelTrackedResourceProperties properties); + } + } + + /** + * Begins update for the TopLevelTrackedResource resource. + * + * @return the stage of resource update. + */ + TopLevelTrackedResource.Update update(); + + /** + * The template for TopLevelTrackedResource update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + TopLevelTrackedResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + TopLevelTrackedResource apply(Context context); + } + + /** + * The TopLevelTrackedResource update stages. + */ + interface UpdateStages { + /** + * The stage of the TopLevelTrackedResource update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the TopLevelTrackedResource update 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. + */ + Update withProperties(TopLevelTrackedResourceProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + TopLevelTrackedResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + TopLevelTrackedResource refresh(Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/TopLevelTrackedResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/TopLevelTrackedResourceProperties.java new file mode 100644 index 000000000..44b1e5f9f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/TopLevelTrackedResourceProperties.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.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; + +/** + * Top Level Arm Resource Properties. + */ +@Fluent +public final class TopLevelTrackedResourceProperties implements JsonSerializable { + /* + * The status of the last operation. + */ + private ProvisioningState provisioningState; + + /* + * The description of the resource. + */ + private String description; + + /** + * Creates an instance of TopLevelTrackedResourceProperties class. + */ + public TopLevelTrackedResourceProperties() { + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * 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 TopLevelTrackedResourceProperties object itself. + */ + public TopLevelTrackedResourceProperties withDescription(String description) { + this.description = description; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TopLevelTrackedResourceProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TopLevelTrackedResourceProperties 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 TopLevelTrackedResourceProperties. + */ + public static TopLevelTrackedResourceProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TopLevelTrackedResourceProperties deserializedTopLevelTrackedResourceProperties + = new TopLevelTrackedResourceProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedTopLevelTrackedResourceProperties.provisioningState + = ProvisioningState.fromString(reader.getString()); + } else if ("description".equals(fieldName)) { + deserializedTopLevelTrackedResourceProperties.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedTopLevelTrackedResourceProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/TopLevelTrackedResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/TopLevelTrackedResources.java new file mode 100644 index 000000000..e251c8212 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/TopLevelTrackedResources.java @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.models.resources.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of TopLevelTrackedResources. + */ +public interface TopLevelTrackedResources { + /** + * Get a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 TopLevelTrackedResource along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelTrackedResourceName, Context context); + + /** + * Get a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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 TopLevelTrackedResource. + */ + TopLevelTrackedResource getByResourceGroup(String resourceGroupName, String topLevelTrackedResourceName); + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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. + */ + void deleteByResourceGroup(String resourceGroupName, String topLevelTrackedResourceName); + + /** + * Delete a TopLevelTrackedResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelTrackedResourceName 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. + */ + void delete(String resourceGroupName, String topLevelTrackedResourceName, Context context); + + /** + * List TopLevelTrackedResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelTrackedResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List TopLevelTrackedResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelTrackedResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * List TopLevelTrackedResource resources by subscription ID. + * + * @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 TopLevelTrackedResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List TopLevelTrackedResource resources by subscription 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 TopLevelTrackedResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * Get a TopLevelTrackedResource. + * + * @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 TopLevelTrackedResource along with {@link Response}. + */ + TopLevelTrackedResource getById(String id); + + /** + * Get a TopLevelTrackedResource. + * + * @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 TopLevelTrackedResource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a TopLevelTrackedResource. + * + * @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. + */ + void deleteById(String id); + + /** + * Delete a TopLevelTrackedResource. + * + * @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. + */ + void deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new TopLevelTrackedResource resource. + * + * @param name resource name. + * @return the first stage of the new TopLevelTrackedResource definition. + */ + TopLevelTrackedResource.DefinitionStages.Blank define(String name); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/models/package-info.java new file mode 100644 index 000000000..01322e3cf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/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 Resources. + * Arm Resource Provider management API. + */ +package com.azure.resourcemanager.models.resources.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/package-info.java new file mode 100644 index 000000000..657748440 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/resourcemanager/models/resources/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 Resources. + * Arm Resource Provider management API. + */ +package com.azure.resourcemanager.models.resources; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdAsyncClient.java new file mode 100644 index 000000000..e67c74892 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdAsyncClient.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.specialheaders.xmsclientrequestid; + +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 com.azure.specialheaders.xmsclientrequestid.implementation.XmsClientRequestIdClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous XmsClientRequestIdClient type. + */ +@ServiceClient(builder = XmsClientRequestIdClientBuilder.class, isAsync = true) +public final class XmsClientRequestIdAsyncClient { + @Generated + private final XmsClientRequestIdClientImpl serviceClient; + + /** + * Initializes an instance of XmsClientRequestIdAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + XmsClientRequestIdAsyncClient(XmsClientRequestIdClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get operation with azure `x-ms-client-request-id` header. + * + * @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 operation with azure `x-ms-client-request-id` header along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Get operation with azure `x-ms-client-request-id` header. + * + * @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 operation with azure `x-ms-client-request-id` header on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdClient.java new file mode 100644 index 000000000..b5db477c0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdClient.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.specialheaders.xmsclientrequestid; + +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.specialheaders.xmsclientrequestid.implementation.XmsClientRequestIdClientImpl; + +/** + * Initializes a new instance of the synchronous XmsClientRequestIdClient type. + */ +@ServiceClient(builder = XmsClientRequestIdClientBuilder.class) +public final class XmsClientRequestIdClient { + @Generated + private final XmsClientRequestIdClientImpl serviceClient; + + /** + * Initializes an instance of XmsClientRequestIdClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + XmsClientRequestIdClient(XmsClientRequestIdClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get operation with azure `x-ms-client-request-id` header. + * + * @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 operation with azure `x-ms-client-request-id` header along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Get operation with azure `x-ms-client-request-id` header. + * + * @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 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + getWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdClientBuilder.java new file mode 100644 index 000000000..2fe64474b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/XmsClientRequestIdClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.specialheaders.xmsclientrequestid; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.azure.specialheaders.xmsclientrequestid.implementation.XmsClientRequestIdClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the XmsClientRequestIdClient type. + */ +@ServiceClientBuilder(serviceClients = { XmsClientRequestIdClient.class, XmsClientRequestIdAsyncClient.class }) +public final class XmsClientRequestIdClientBuilder 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("azure-specialheaders-xmsclientrequestid.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the XmsClientRequestIdClientBuilder. + */ + @Generated + public XmsClientRequestIdClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public XmsClientRequestIdClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public XmsClientRequestIdClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public XmsClientRequestIdClientBuilder 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 XmsClientRequestIdClientBuilder 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 XmsClientRequestIdClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public XmsClientRequestIdClientBuilder 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 XmsClientRequestIdClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public XmsClientRequestIdClientBuilder 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 XmsClientRequestIdClientBuilder. + */ + @Generated + public XmsClientRequestIdClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of XmsClientRequestIdClientImpl with the provided parameters. + * + * @return an instance of XmsClientRequestIdClientImpl. + */ + @Generated + private XmsClientRequestIdClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + XmsClientRequestIdClientImpl client = new XmsClientRequestIdClientImpl(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 XmsClientRequestIdAsyncClient class. + * + * @return an instance of XmsClientRequestIdAsyncClient. + */ + @Generated + public XmsClientRequestIdAsyncClient buildAsyncClient() { + return new XmsClientRequestIdAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of XmsClientRequestIdClient class. + * + * @return an instance of XmsClientRequestIdClient. + */ + @Generated + public XmsClientRequestIdClient buildClient() { + return new XmsClientRequestIdClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(XmsClientRequestIdClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/implementation/XmsClientRequestIdClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/implementation/XmsClientRequestIdClientImpl.java new file mode 100644 index 000000000..d416106f3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/implementation/XmsClientRequestIdClientImpl.java @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.specialheaders.xmsclientrequestid.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.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.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 XmsClientRequestIdClient type. + */ +public final class XmsClientRequestIdClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final XmsClientRequestIdClientService 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 XmsClientRequestIdClient client. + * + * @param endpoint Service host. + */ + public XmsClientRequestIdClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of XmsClientRequestIdClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public XmsClientRequestIdClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of XmsClientRequestIdClient 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 XmsClientRequestIdClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service + = RestProxy.create(XmsClientRequestIdClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for XmsClientRequestIdClient to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "XmsClientRequestIdCl") + public interface XmsClientRequestIdClientService { + @Get("/azure/special-headers/x-ms-client-request-id/") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/azure/special-headers/x-ms-client-request-id/") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + } + + /** + * Get operation with azure `x-ms-client-request-id` header. + * + * @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 operation with azure `x-ms-client-request-id` header along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.get(this.getEndpoint(), requestOptions, context)); + } + + /** + * Get operation with azure `x-ms-client-request-id` header. + * + * @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 operation with azure `x-ms-client-request-id` header along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return service.getSync(this.getEndpoint(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/implementation/package-info.java new file mode 100644 index 000000000..4b439337b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/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 XmsClientRequestId. + * Azure client request id header configurations. + * + */ +package com.azure.specialheaders.xmsclientrequestid.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/package-info.java new file mode 100644 index 000000000..fc28b7f3b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/azure/specialheaders/xmsclientrequestid/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 XmsClientRequestId. + * Azure client request id header configurations. + * + */ +package com.azure.specialheaders.xmsclientrequestid; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/ArmResourceProviderManager.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/ArmResourceProviderManager.java new file mode 100644 index 000000000..ee9870419 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/ArmResourceProviderManager.java @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpPipeline; +import com.azure.core.management.profile.AzureProfile; +import com.cadl.armresourceprovider.fluent.ArmResourceProviderClient; +import com.cadl.armresourceprovider.implementation.ArmResourceProviderClientBuilder; +import com.cadl.armresourceprovider.implementation.ChildExtensionResourceInterfacesImpl; +import com.cadl.armresourceprovider.implementation.ChildResourcesInterfacesImpl; +import com.cadl.armresourceprovider.implementation.CustomTemplateResourceInterfacesImpl; +import com.cadl.armresourceprovider.implementation.OperationsImpl; +import com.cadl.armresourceprovider.implementation.TopLevelArmResourceInterfacesImpl; +import com.cadl.armresourceprovider.models.ChildExtensionResourceInterfaces; +import com.cadl.armresourceprovider.models.ChildResourcesInterfaces; +import com.cadl.armresourceprovider.models.CustomTemplateResourceInterfaces; +import com.cadl.armresourceprovider.models.Operations; +import com.cadl.armresourceprovider.models.TopLevelArmResourceInterfaces; +import java.time.Duration; +import java.util.Objects; + +/** + * Entry point to ArmResourceProviderManager. + * Arm Resource Provider management API. + */ +public final class ArmResourceProviderManager { + private ChildResourcesInterfaces childResourcesInterfaces; + + private TopLevelArmResourceInterfaces topLevelArmResourceInterfaces; + + private CustomTemplateResourceInterfaces customTemplateResourceInterfaces; + + private Operations operations; + + private ChildExtensionResourceInterfaces childExtensionResourceInterfaces; + + private final ArmResourceProviderClient clientObject; + + private ArmResourceProviderManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new ArmResourceProviderClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of ArmResourceProvider service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ArmResourceProvider service API instance. + */ + public static ArmResourceProviderManager 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 ArmResourceProvider service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the ArmResourceProvider service API instance. + */ + public static ArmResourceProviderManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new ArmResourceProviderManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create ArmResourceProviderManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new ArmResourceProviderManager.Configurable(); + } + + /** + * Gets the resource collection API of ChildResourcesInterfaces. It manages ChildResource. + * + * @return Resource collection API of ChildResourcesInterfaces. + */ + public ChildResourcesInterfaces childResourcesInterfaces() { + if (this.childResourcesInterfaces == null) { + this.childResourcesInterfaces + = new ChildResourcesInterfacesImpl(clientObject.getChildResourcesInterfaces(), this); + } + return childResourcesInterfaces; + } + + /** + * Gets the resource collection API of TopLevelArmResourceInterfaces. It manages TopLevelArmResource. + * + * @return Resource collection API of TopLevelArmResourceInterfaces. + */ + public TopLevelArmResourceInterfaces topLevelArmResourceInterfaces() { + if (this.topLevelArmResourceInterfaces == null) { + this.topLevelArmResourceInterfaces + = new TopLevelArmResourceInterfacesImpl(clientObject.getTopLevelArmResourceInterfaces(), this); + } + return topLevelArmResourceInterfaces; + } + + /** + * Gets the resource collection API of CustomTemplateResourceInterfaces. It manages CustomTemplateResource. + * + * @return Resource collection API of CustomTemplateResourceInterfaces. + */ + public CustomTemplateResourceInterfaces customTemplateResourceInterfaces() { + if (this.customTemplateResourceInterfaces == null) { + this.customTemplateResourceInterfaces + = new CustomTemplateResourceInterfacesImpl(clientObject.getCustomTemplateResourceInterfaces(), this); + } + return customTemplateResourceInterfaces; + } + + /** + * Gets the resource collection API of Operations. + * + * @return Resource collection API of Operations. + */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** + * Gets the resource collection API of ChildExtensionResourceInterfaces. It manages ChildExtensionResource. + * + * @return Resource collection API of ChildExtensionResourceInterfaces. + */ + public ChildExtensionResourceInterfaces childExtensionResourceInterfaces() { + if (this.childExtensionResourceInterfaces == null) { + this.childExtensionResourceInterfaces + = new ChildExtensionResourceInterfacesImpl(clientObject.getChildExtensionResourceInterfaces(), this); + } + return childExtensionResourceInterfaces; + } + + /** + * Gets wrapped service client ArmResourceProviderClient providing direct access to the underlying auto-generated + * API implementation, based on Azure REST API. + * + * @return Wrapped service client ArmResourceProviderClient. + */ + public ArmResourceProviderClient serviceClient() { + return this.clientObject; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/ArmResourceProviderClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/ArmResourceProviderClient.java new file mode 100644 index 000000000..aabdbaebb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/ArmResourceProviderClient.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for ArmResourceProviderClient class. + */ +public interface ArmResourceProviderClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * 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 ChildResourcesInterfacesClient object to access its operations. + * + * @return the ChildResourcesInterfacesClient object. + */ + ChildResourcesInterfacesClient getChildResourcesInterfaces(); + + /** + * Gets the TopLevelArmResourceInterfacesClient object to access its operations. + * + * @return the TopLevelArmResourceInterfacesClient object. + */ + TopLevelArmResourceInterfacesClient getTopLevelArmResourceInterfaces(); + + /** + * Gets the CustomTemplateResourceInterfacesClient object to access its operations. + * + * @return the CustomTemplateResourceInterfacesClient object. + */ + CustomTemplateResourceInterfacesClient getCustomTemplateResourceInterfaces(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); + + /** + * Gets the ChildExtensionResourceInterfacesClient object to access its operations. + * + * @return the ChildExtensionResourceInterfacesClient object. + */ + ChildExtensionResourceInterfacesClient getChildExtensionResourceInterfaces(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/ChildExtensionResourceInterfacesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/ChildExtensionResourceInterfacesClient.java new file mode 100644 index 000000000..e5295fe97 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/ChildExtensionResourceInterfacesClient.java @@ -0,0 +1,239 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.fluent; + +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; +import com.cadl.armresourceprovider.fluent.models.ChildExtensionResourceInner; +import com.cadl.armresourceprovider.models.ChildExtensionResourceUpdate; + +/** + * An instance of this class provides access to all the operations defined in ChildExtensionResourceInterfacesClient. + */ +public interface ChildExtensionResourceInterfacesClient { + /** + * Get a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 ChildExtensionResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, Context context); + + /** + * Get a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 ChildExtensionResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ChildExtensionResourceInner get(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName); + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ChildExtensionResourceInner> beginCreateOrUpdate( + String resourceUri, String topLevelArmResourceName, String childExtensionResourceName, + ChildExtensionResourceInner resource); + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ChildExtensionResourceInner> beginCreateOrUpdate( + String resourceUri, String topLevelArmResourceName, String childExtensionResourceName, + ChildExtensionResourceInner resource, Context context); + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ChildExtensionResourceInner createOrUpdate(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, ChildExtensionResourceInner resource); + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ChildExtensionResourceInner createOrUpdate(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, ChildExtensionResourceInner resource, Context context); + + /** + * Update a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, ChildExtensionResourceUpdate properties, Context context); + + /** + * Update a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ChildExtensionResourceInner update(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, ChildExtensionResourceUpdate properties); + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName); + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, Context context); + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 resourceUri, String topLevelArmResourceName, String childExtensionResourceName); + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceUri, String topLevelArmResourceName, String childExtensionResourceName, Context context); + + /** + * List ChildExtensionResource resources by TopLevelArmResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName 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 the response of a ChildExtensionResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByTopLevelArmResource(String resourceUri, + String topLevelArmResourceName); + + /** + * List ChildExtensionResource resources by TopLevelArmResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName 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 the response of a ChildExtensionResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByTopLevelArmResource(String resourceUri, + String topLevelArmResourceName, Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/ChildResourcesInterfacesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/ChildResourcesInterfacesClient.java new file mode 100644 index 000000000..c06553db4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/ChildResourcesInterfacesClient.java @@ -0,0 +1,295 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.fluent; + +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; +import com.cadl.armresourceprovider.fluent.models.ChildResourceInner; +import com.cadl.armresourceprovider.models.ChildResourceUpdate; + +/** + * An instance of this class provides access to all the operations defined in ChildResourcesInterfacesClient. + */ +public interface ChildResourcesInterfacesClient { + /** + * Get a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 ChildResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, Context context); + + /** + * Get a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 ChildResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ChildResourceInner get(String resourceGroupName, String topLevelArmResourceName, String childResourceName); + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ChildResourceInner> beginCreateOrUpdate(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, ChildResourceInner resource); + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ChildResourceInner> beginCreateOrUpdate(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, ChildResourceInner resource, Context context); + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ChildResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, ChildResourceInner resource); + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ChildResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, ChildResourceInner resource, Context context); + + /** + * Update a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, ChildResourceUpdate properties, Context context); + + /** + * Update a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ChildResourceInner update(String resourceGroupName, String topLevelArmResourceName, String childResourceName, + ChildResourceUpdate properties); + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourceName, + String childResourceName); + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, Context context); + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 resourceGroupName, String topLevelArmResourceName, String childResourceName); + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String topLevelArmResourceName, String childResourceName, Context context); + + /** + * List ChildResource resources by TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response of a ChildResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByTopLevelArmResource(String resourceGroupName, + String topLevelArmResourceName); + + /** + * List ChildResource resources by TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response of a ChildResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByTopLevelArmResource(String resourceGroupName, + String topLevelArmResourceName, Context context); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginActionWithoutBody(String resourceGroupName, String topLevelArmResourceName, + String childResourceName); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginActionWithoutBody(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, Context context); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 actionWithoutBody(String resourceGroupName, String topLevelArmResourceName, String childResourceName); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void actionWithoutBody(String resourceGroupName, String topLevelArmResourceName, String childResourceName, + Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/CustomTemplateResourceInterfacesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/CustomTemplateResourceInterfacesClient.java new file mode 100644 index 000000000..63a543d3c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/CustomTemplateResourceInterfacesClient.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.cadl.armresourceprovider.fluent.models.CustomTemplateResourceInner; +import com.cadl.armresourceprovider.models.CustomTemplateResourcePatch; + +/** + * An instance of this class provides access to all the operations defined in CustomTemplateResourceInterfacesClient. + */ +public interface CustomTemplateResourceInterfacesClient { + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName 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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, CustomTemplateResourceInner> beginCreateOrUpdate( + String resourceGroupName, String customTemplateResourceName, CustomTemplateResourceInner resource); + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param ifMatch The request should only proceed if an entity matches this string. + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @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 tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, CustomTemplateResourceInner> beginCreateOrUpdate( + String resourceGroupName, String customTemplateResourceName, CustomTemplateResourceInner resource, + String ifMatch, String ifNoneMatch, Context context); + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName 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) + CustomTemplateResourceInner createOrUpdate(String resourceGroupName, String customTemplateResourceName, + CustomTemplateResourceInner resource); + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param ifMatch The request should only proceed if an entity matches this string. + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CustomTemplateResourceInner createOrUpdate(String resourceGroupName, String customTemplateResourceName, + CustomTemplateResourceInner resource, String ifMatch, String ifNoneMatch, Context context); + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, CustomTemplateResourceInner> beginUpdateLongRunning( + String resourceGroupName, String customTemplateResourceName, CustomTemplateResourcePatch properties); + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, CustomTemplateResourceInner> beginUpdateLongRunning( + String resourceGroupName, String customTemplateResourceName, CustomTemplateResourcePatch properties, + Context context); + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CustomTemplateResourceInner updateLongRunning(String resourceGroupName, String customTemplateResourceName, + CustomTemplateResourcePatch properties); + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CustomTemplateResourceInner updateLongRunning(String resourceGroupName, String customTemplateResourceName, + CustomTemplateResourcePatch properties, Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/OperationsClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/OperationsClient.java new file mode 100644 index 000000000..846b21e5b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/OperationsClient.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.cadl.armresourceprovider.fluent.models.OperationInner; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public interface OperationsClient { + /** + * List the operations for the provider. + * + * @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 list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @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 list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/TopLevelArmResourceInterfacesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/TopLevelArmResourceInterfacesClient.java new file mode 100644 index 000000000..96977bf12 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/TopLevelArmResourceInterfacesClient.java @@ -0,0 +1,301 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.fluent; + +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; +import com.cadl.armresourceprovider.fluent.models.ResultInner; +import com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceInner; +import com.cadl.armresourceprovider.models.TopLevelArmResourceUpdate; + +/** + * An instance of this class provides access to all the operations defined in TopLevelArmResourceInterfacesClient. + */ +public interface TopLevelArmResourceInterfacesClient { + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 TopLevelArmResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourceName, Context context); + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 TopLevelArmResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelArmResourceInner getByResourceGroup(String resourceGroupName, String topLevelArmResourceName); + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceInner resource); + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceInner resource, Context context); + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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) + TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceInner resource); + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceInner resource, Context context); + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 tracked 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 resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceUpdate properties, Context context); + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelArmResourceInner update(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceUpdate properties); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourceName); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourceName, + Context context); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String topLevelArmResourceName); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String topLevelArmResourceName, Context context); + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @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 TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List TopLevelArmResource resources by subscription 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 TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ResultInner> beginAction(String resourceGroupName, + String topLevelArmResourceName); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ResultInner> beginAction(String resourceGroupName, + String topLevelArmResourceName, Context context); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ResultInner action(String resourceGroupName, String topLevelArmResourceName); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ResultInner action(String resourceGroupName, String topLevelArmResourceName, Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/ChildExtensionResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/ChildExtensionResourceInner.java new file mode 100644 index 000000000..943807d6b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/ChildExtensionResourceInner.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 com.cadl.armresourceprovider.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.cadl.armresourceprovider.models.ChildExtensionResourceProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * ExtensionResource of Top Level Arm Resource. + */ +@Fluent +public final class ChildExtensionResourceInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + @JsonProperty(value = "properties") + private ChildExtensionResourceProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY) + private SystemData systemData; + + /** + * Creates an instance of ChildExtensionResourceInner class. + */ + public ChildExtensionResourceInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public ChildExtensionResourceProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the ChildExtensionResourceInner object itself. + */ + public ChildExtensionResourceInner withProperties(ChildExtensionResourceProperties 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; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/ChildResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/ChildResourceInner.java new file mode 100644 index 000000000..5eef80f99 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/ChildResourceInner.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.cadl.armresourceprovider.models.ProvisioningState; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** + * Subresource of Top Level Arm Resource. + */ +@Fluent +public final class ChildResourceInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + @JsonProperty(value = "properties") + private ChildResourceProperties innerProperties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY) + private SystemData systemData; + + /** + * Creates an instance of ChildResourceInner class. + */ + public ChildResourceInner() { + } + + /** + * Get the innerProperties property: The resource-specific properties for this resource. + * + * @return the innerProperties value. + */ + private ChildResourceProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * {@inheritDoc} + */ + @Override + public ChildResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ChildResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Get the provisioningState property: Provisioning State of Top Level Arm Resource. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.innerProperties() == null ? null : this.innerProperties().provisioningState(); + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/ChildResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/ChildResourceProperties.java new file mode 100644 index 000000000..ddc9a0f35 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/ChildResourceProperties.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.cadl.armresourceprovider.models.ProvisioningState; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Child Resource Properties. + */ +@Immutable +public final class ChildResourceProperties { + /* + * Provisioning State of Top Level Arm Resource + */ + @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private ProvisioningState provisioningState; + + /** + * Creates an instance of ChildResourceProperties class. + */ + public ChildResourceProperties() { + } + + /** + * Get the provisioningState property: Provisioning State of Top Level Arm Resource. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/CustomTemplateResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/CustomTemplateResourceInner.java new file mode 100644 index 000000000..5848e6a53 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/CustomTemplateResourceInner.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 com.cadl.armresourceprovider.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.cadl.armresourceprovider.models.CustomTemplateResourcePropertiesAnonymousEmptyModel; +import com.cadl.armresourceprovider.models.Dog; +import com.cadl.armresourceprovider.models.EmptyModel; +import com.cadl.armresourceprovider.models.ManagedServiceIdentity; +import com.cadl.armresourceprovider.models.ProvisioningState; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** + * Concrete tracked resource types can be created by aliasing this type using a specific property type. + */ +@Fluent +public final class CustomTemplateResourceInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + @JsonProperty(value = "properties") + private CustomTemplateResourceProperties innerProperties; + + /* + * Managed identity. + */ + @JsonProperty(value = "identity") + private ManagedServiceIdentity identity; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY) + private SystemData systemData; + + /** + * Creates an instance of CustomTemplateResourceInner class. + */ + public CustomTemplateResourceInner() { + } + + /** + * Get the innerProperties property: The resource-specific properties for this resource. + * + * @return the innerProperties value. + */ + private CustomTemplateResourceProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the identity property: Managed identity. + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: Managed identity. + * + * @param identity the identity value to set. + * @return the CustomTemplateResourceInner object itself. + */ + public CustomTemplateResourceInner withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + 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; + } + + /** + * {@inheritDoc} + */ + @Override + public CustomTemplateResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CustomTemplateResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.innerProperties() == null ? null : this.innerProperties().provisioningState(); + } + + /** + * Get the dog property: The dog property. + * + * @return the dog value. + */ + public Dog dog() { + return this.innerProperties() == null ? null : this.innerProperties().dog(); + } + + /** + * Set the dog property: The dog property. + * + * @param dog the dog value to set. + * @return the CustomTemplateResourceInner object itself. + */ + public CustomTemplateResourceInner withDog(Dog dog) { + if (this.innerProperties() == null) { + this.innerProperties = new CustomTemplateResourceProperties(); + } + this.innerProperties().withDog(dog); + return this; + } + + /** + * Get the namedEmptyModel property: The namedEmptyModel property. + * + * @return the namedEmptyModel value. + */ + public EmptyModel namedEmptyModel() { + return this.innerProperties() == null ? null : this.innerProperties().namedEmptyModel(); + } + + /** + * Set the namedEmptyModel property: The namedEmptyModel property. + * + * @param namedEmptyModel the namedEmptyModel value to set. + * @return the CustomTemplateResourceInner object itself. + */ + public CustomTemplateResourceInner withNamedEmptyModel(EmptyModel namedEmptyModel) { + if (this.innerProperties() == null) { + this.innerProperties = new CustomTemplateResourceProperties(); + } + this.innerProperties().withNamedEmptyModel(namedEmptyModel); + return this; + } + + /** + * Get the anonymousEmptyModel property: The anonymousEmptyModel property. + * + * @return the anonymousEmptyModel value. + */ + public CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel() { + return this.innerProperties() == null ? null : this.innerProperties().anonymousEmptyModel(); + } + + /** + * Set the anonymousEmptyModel property: The anonymousEmptyModel property. + * + * @param anonymousEmptyModel the anonymousEmptyModel value to set. + * @return the CustomTemplateResourceInner object itself. + */ + public CustomTemplateResourceInner + withAnonymousEmptyModel(CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel) { + if (this.innerProperties() == null) { + this.innerProperties = new CustomTemplateResourceProperties(); + } + this.innerProperties().withAnonymousEmptyModel(anonymousEmptyModel); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + if (identity() != null) { + identity().validate(); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/CustomTemplateResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/CustomTemplateResourceProperties.java new file mode 100644 index 000000000..f64a539f5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/CustomTemplateResourceProperties.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 com.cadl.armresourceprovider.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.cadl.armresourceprovider.models.CustomTemplateResourcePropertiesAnonymousEmptyModel; +import com.cadl.armresourceprovider.models.Dog; +import com.cadl.armresourceprovider.models.EmptyModel; +import com.cadl.armresourceprovider.models.ProvisioningState; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Top Level Arm Resource Properties. + */ +@Fluent +public final class CustomTemplateResourceProperties { + /* + * The status of the last operation. + */ + @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private ProvisioningState provisioningState; + + /* + * The dog property. + */ + @JsonProperty(value = "dog", required = true) + private Dog dog; + + /* + * The namedEmptyModel property. + */ + @JsonProperty(value = "namedEmptyModel", required = true) + private EmptyModel namedEmptyModel; + + /* + * The anonymousEmptyModel property. + */ + @JsonProperty(value = "anonymousEmptyModel", required = true) + private CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel; + + /** + * Creates an instance of CustomTemplateResourceProperties class. + */ + public CustomTemplateResourceProperties() { + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the dog property: The dog property. + * + * @return the dog value. + */ + public Dog dog() { + return this.dog; + } + + /** + * Set the dog property: The dog property. + * + * @param dog the dog value to set. + * @return the CustomTemplateResourceProperties object itself. + */ + public CustomTemplateResourceProperties withDog(Dog dog) { + this.dog = dog; + return this; + } + + /** + * Get the namedEmptyModel property: The namedEmptyModel property. + * + * @return the namedEmptyModel value. + */ + public EmptyModel namedEmptyModel() { + return this.namedEmptyModel; + } + + /** + * Set the namedEmptyModel property: The namedEmptyModel property. + * + * @param namedEmptyModel the namedEmptyModel value to set. + * @return the CustomTemplateResourceProperties object itself. + */ + public CustomTemplateResourceProperties withNamedEmptyModel(EmptyModel namedEmptyModel) { + this.namedEmptyModel = namedEmptyModel; + return this; + } + + /** + * Get the anonymousEmptyModel property: The anonymousEmptyModel property. + * + * @return the anonymousEmptyModel value. + */ + public CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel() { + return this.anonymousEmptyModel; + } + + /** + * Set the anonymousEmptyModel property: The anonymousEmptyModel property. + * + * @param anonymousEmptyModel the anonymousEmptyModel value to set. + * @return the CustomTemplateResourceProperties object itself. + */ + public CustomTemplateResourceProperties + withAnonymousEmptyModel(CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel) { + this.anonymousEmptyModel = anonymousEmptyModel; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (dog() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property dog in model CustomTemplateResourceProperties")); + } else { + dog().validate(); + } + if (namedEmptyModel() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property namedEmptyModel in model CustomTemplateResourceProperties")); + } else { + namedEmptyModel().validate(); + } + if (anonymousEmptyModel() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property anonymousEmptyModel in model CustomTemplateResourceProperties")); + } else { + anonymousEmptyModel().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CustomTemplateResourceProperties.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/OperationInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/OperationInner.java new file mode 100644 index 000000000..09742b937 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/OperationInner.java @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.cadl.armresourceprovider.models.ActionType; +import com.cadl.armresourceprovider.models.OperationDisplay; +import com.cadl.armresourceprovider.models.Origin; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Details of a REST API operation, returned from the Resource Provider Operations API. + */ +@Immutable +public final class OperationInner { + /* + * The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /* + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure + * Resource Manager/control-plane operations. + */ + @JsonProperty(value = "isDataAction", access = JsonProperty.Access.WRITE_ONLY) + private Boolean isDataAction; + + /* + * Localized display information for this particular operation. + */ + @JsonProperty(value = "display", access = JsonProperty.Access.WRITE_ONLY) + private OperationDisplay display; + + /* + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + * value is "user,system" + */ + @JsonProperty(value = "origin", access = JsonProperty.Access.WRITE_ONLY) + private Origin origin; + + /* + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ + @JsonProperty(value = "actionType") + private ActionType actionType; + + /** + * Creates an instance of OperationInner class. + */ + private OperationInner() { + } + + /** + * Get the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for Azure Resource Manager/control-plane operations. + * + * @return the isDataAction value. + */ + public Boolean isDataAction() { + return this.isDataAction; + } + + /** + * Get the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Get the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + public Origin origin() { + return this.origin; + } + + /** + * Get the actionType property: Extensible enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + * + * @return the actionType value. + */ + public ActionType actionType() { + return this.actionType; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/ResultInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/ResultInner.java new file mode 100644 index 000000000..3eedc937b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/ResultInner.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The Result model. + */ +@Immutable +public final class ResultInner { + /* + * The reason property. + */ + @JsonProperty(value = "reason") + private String reason; + + /** + * Creates an instance of ResultInner class. + */ + private ResultInner() { + } + + /** + * Get the reason property: The reason property. + * + * @return the reason value. + */ + public String reason() { + return this.reason; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/TopLevelArmResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/TopLevelArmResourceInner.java new file mode 100644 index 000000000..ce4bcd3d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/TopLevelArmResourceInner.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 com.cadl.armresourceprovider.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.cadl.armresourceprovider.models.ProvisioningState; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Map; + +/** + * Concrete tracked resource types can be created by aliasing this type using a specific property type. + */ +@Fluent +public final class TopLevelArmResourceInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + @JsonProperty(value = "properties") + private TopLevelArmResourceProperties innerProperties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY) + private SystemData systemData; + + /** + * Creates an instance of TopLevelArmResourceInner class. + */ + public TopLevelArmResourceInner() { + } + + /** + * Get the innerProperties property: The resource-specific properties for this resource. + * + * @return the innerProperties value. + */ + private TopLevelArmResourceProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * {@inheritDoc} + */ + @Override + public TopLevelArmResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopLevelArmResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Get the configurationEndpoints property: Configuration Endpoints. + * + * @return the configurationEndpoints value. + */ + public List configurationEndpoints() { + return this.innerProperties() == null ? null : this.innerProperties().configurationEndpoints(); + } + + /** + * Get the userName property: The userName property. + * + * @return the userName value. + */ + public String userName() { + return this.innerProperties() == null ? null : this.innerProperties().userName(); + } + + /** + * Set the userName property: The userName property. + * + * @param userName the userName value to set. + * @return the TopLevelArmResourceInner object itself. + */ + public TopLevelArmResourceInner withUserName(String userName) { + if (this.innerProperties() == null) { + this.innerProperties = new TopLevelArmResourceProperties(); + } + this.innerProperties().withUserName(userName); + return this; + } + + /** + * Get the userNames property: The userNames property. + * + * @return the userNames value. + */ + public String userNames() { + return this.innerProperties() == null ? null : this.innerProperties().userNames(); + } + + /** + * Set the userNames property: The userNames property. + * + * @param userNames the userNames value to set. + * @return the TopLevelArmResourceInner object itself. + */ + public TopLevelArmResourceInner withUserNames(String userNames) { + if (this.innerProperties() == null) { + this.innerProperties = new TopLevelArmResourceProperties(); + } + this.innerProperties().withUserNames(userNames); + return this; + } + + /** + * Get the accuserName property: The accuserName property. + * + * @return the accuserName value. + */ + public String accuserName() { + return this.innerProperties() == null ? null : this.innerProperties().accuserName(); + } + + /** + * Set the accuserName property: The accuserName property. + * + * @param accuserName the accuserName value to set. + * @return the TopLevelArmResourceInner object itself. + */ + public TopLevelArmResourceInner withAccuserName(String accuserName) { + if (this.innerProperties() == null) { + this.innerProperties = new TopLevelArmResourceProperties(); + } + this.innerProperties().withAccuserName(accuserName); + return this; + } + + /** + * Get the startTimeStamp property: The startTimeStamp property. + * + * @return the startTimeStamp value. + */ + public OffsetDateTime startTimeStamp() { + return this.innerProperties() == null ? null : this.innerProperties().startTimeStamp(); + } + + /** + * Set the startTimeStamp property: The startTimeStamp property. + * + * @param startTimeStamp the startTimeStamp value to set. + * @return the TopLevelArmResourceInner object itself. + */ + public TopLevelArmResourceInner withStartTimeStamp(OffsetDateTime startTimeStamp) { + if (this.innerProperties() == null) { + this.innerProperties = new TopLevelArmResourceProperties(); + } + this.innerProperties().withStartTimeStamp(startTimeStamp); + return this; + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.innerProperties() == null ? null : this.innerProperties().provisioningState(); + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/TopLevelArmResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/TopLevelArmResourceProperties.java new file mode 100644 index 000000000..3e9321df1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/TopLevelArmResourceProperties.java @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.cadl.armresourceprovider.models.ProvisioningState; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; +import java.util.List; + +/** + * Top Level Arm Resource Properties. + */ +@Fluent +public final class TopLevelArmResourceProperties { + /* + * Configuration Endpoints. + */ + @JsonProperty(value = "configurationEndpoints", access = JsonProperty.Access.WRITE_ONLY) + private List configurationEndpoints; + + /* + * The userName property. + */ + @JsonProperty(value = "userName", required = true) + private String userName; + + /* + * The userNames property. + */ + @JsonProperty(value = "userNames", required = true) + private String userNames; + + /* + * The accuserName property. + */ + @JsonProperty(value = "accuserName", required = true) + private String accuserName; + + /* + * The startTimeStamp property. + */ + @JsonProperty(value = "startTimeStamp", required = true) + private OffsetDateTime startTimeStamp; + + /* + * The status of the last operation. + */ + @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private ProvisioningState provisioningState; + + /** + * Creates an instance of TopLevelArmResourceProperties class. + */ + public TopLevelArmResourceProperties() { + } + + /** + * Get the configurationEndpoints property: Configuration Endpoints. + * + * @return the configurationEndpoints value. + */ + public List configurationEndpoints() { + return this.configurationEndpoints; + } + + /** + * Get the userName property: The userName property. + * + * @return the userName value. + */ + public String userName() { + return this.userName; + } + + /** + * Set the userName property: The userName property. + * + * @param userName the userName value to set. + * @return the TopLevelArmResourceProperties object itself. + */ + public TopLevelArmResourceProperties withUserName(String userName) { + this.userName = userName; + return this; + } + + /** + * Get the userNames property: The userNames property. + * + * @return the userNames value. + */ + public String userNames() { + return this.userNames; + } + + /** + * Set the userNames property: The userNames property. + * + * @param userNames the userNames value to set. + * @return the TopLevelArmResourceProperties object itself. + */ + public TopLevelArmResourceProperties withUserNames(String userNames) { + this.userNames = userNames; + return this; + } + + /** + * Get the accuserName property: The accuserName property. + * + * @return the accuserName value. + */ + public String accuserName() { + return this.accuserName; + } + + /** + * Set the accuserName property: The accuserName property. + * + * @param accuserName the accuserName value to set. + * @return the TopLevelArmResourceProperties object itself. + */ + public TopLevelArmResourceProperties withAccuserName(String accuserName) { + this.accuserName = accuserName; + return this; + } + + /** + * Get the startTimeStamp property: The startTimeStamp property. + * + * @return the startTimeStamp value. + */ + public OffsetDateTime startTimeStamp() { + return this.startTimeStamp; + } + + /** + * Set the startTimeStamp property: The startTimeStamp property. + * + * @param startTimeStamp the startTimeStamp value to set. + * @return the TopLevelArmResourceProperties object itself. + */ + public TopLevelArmResourceProperties withStartTimeStamp(OffsetDateTime startTimeStamp) { + this.startTimeStamp = startTimeStamp; + return this; + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (userName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property userName in model TopLevelArmResourceProperties")); + } + if (userNames() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property userNames in model TopLevelArmResourceProperties")); + } + if (accuserName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property accuserName in model TopLevelArmResourceProperties")); + } + if (startTimeStamp() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property startTimeStamp in model TopLevelArmResourceProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(TopLevelArmResourceProperties.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/TopLevelArmResourceUpdateProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/TopLevelArmResourceUpdateProperties.java new file mode 100644 index 000000000..937f6eed6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/TopLevelArmResourceUpdateProperties.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 com.cadl.armresourceprovider.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The updatable properties of the TopLevelArmResource. + */ +@Fluent +public final class TopLevelArmResourceUpdateProperties { + /* + * The userName property. + */ + @JsonProperty(value = "userName") + private String userName; + + /* + * The userNames property. + */ + @JsonProperty(value = "userNames") + private String userNames; + + /* + * The accuserName property. + */ + @JsonProperty(value = "accuserName") + private String accuserName; + + /** + * Creates an instance of TopLevelArmResourceUpdateProperties class. + */ + public TopLevelArmResourceUpdateProperties() { + } + + /** + * Get the userName property: The userName property. + * + * @return the userName value. + */ + public String userName() { + return this.userName; + } + + /** + * Set the userName property: The userName property. + * + * @param userName the userName value to set. + * @return the TopLevelArmResourceUpdateProperties object itself. + */ + public TopLevelArmResourceUpdateProperties withUserName(String userName) { + this.userName = userName; + return this; + } + + /** + * Get the userNames property: The userNames property. + * + * @return the userNames value. + */ + public String userNames() { + return this.userNames; + } + + /** + * Set the userNames property: The userNames property. + * + * @param userNames the userNames value to set. + * @return the TopLevelArmResourceUpdateProperties object itself. + */ + public TopLevelArmResourceUpdateProperties withUserNames(String userNames) { + this.userNames = userNames; + return this; + } + + /** + * Get the accuserName property: The accuserName property. + * + * @return the accuserName value. + */ + public String accuserName() { + return this.accuserName; + } + + /** + * Set the accuserName property: The accuserName property. + * + * @param accuserName the accuserName value to set. + * @return the TopLevelArmResourceUpdateProperties object itself. + */ + public TopLevelArmResourceUpdateProperties withAccuserName(String accuserName) { + this.accuserName = accuserName; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/models/package-info.java new file mode 100644 index 000000000..b73801915 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/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 ArmResourceProvider. + * Arm Resource Provider management API. + */ +package com.cadl.armresourceprovider.fluent.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/fluent/package-info.java new file mode 100644 index 000000000..813482fce --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/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 ArmResourceProvider. + * Arm Resource Provider management API. + */ +package com.cadl.armresourceprovider.fluent; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientBuilder.java new file mode 100644 index 000000000..2a1cab121 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.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 ArmResourceProviderClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { ArmResourceProviderClientImpl.class }) +public final class ArmResourceProviderClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the ArmResourceProviderClientBuilder. + */ + public ArmResourceProviderClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the ArmResourceProviderClientBuilder. + */ + public ArmResourceProviderClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the ArmResourceProviderClientBuilder. + */ + public ArmResourceProviderClientBuilder 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 ArmResourceProviderClientBuilder. + */ + public ArmResourceProviderClientBuilder 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 ArmResourceProviderClientBuilder. + */ + public ArmResourceProviderClientBuilder 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 ArmResourceProviderClientBuilder. + */ + public ArmResourceProviderClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of ArmResourceProviderClientImpl with the provided parameters. + * + * @return an instance of ArmResourceProviderClientImpl. + */ + public ArmResourceProviderClientImpl 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(); + ArmResourceProviderClientImpl client = new ArmResourceProviderClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientImpl.java new file mode 100644 index 000000000..03d53e9da --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientImpl.java @@ -0,0 +1,309 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +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.polling.PollerFactory; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.cadl.armresourceprovider.fluent.ArmResourceProviderClient; +import com.cadl.armresourceprovider.fluent.ChildExtensionResourceInterfacesClient; +import com.cadl.armresourceprovider.fluent.ChildResourcesInterfacesClient; +import com.cadl.armresourceprovider.fluent.CustomTemplateResourceInterfacesClient; +import com.cadl.armresourceprovider.fluent.OperationsClient; +import com.cadl.armresourceprovider.fluent.TopLevelArmResourceInterfacesClient; +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 ArmResourceProviderClientImpl type. + */ +@ServiceClient(builder = ArmResourceProviderClientBuilder.class) +public final class ArmResourceProviderClientImpl implements ArmResourceProviderClient { + /** + * 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 ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * 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 ChildResourcesInterfacesClient object to access its operations. + */ + private final ChildResourcesInterfacesClient childResourcesInterfaces; + + /** + * Gets the ChildResourcesInterfacesClient object to access its operations. + * + * @return the ChildResourcesInterfacesClient object. + */ + public ChildResourcesInterfacesClient getChildResourcesInterfaces() { + return this.childResourcesInterfaces; + } + + /** + * The TopLevelArmResourceInterfacesClient object to access its operations. + */ + private final TopLevelArmResourceInterfacesClient topLevelArmResourceInterfaces; + + /** + * Gets the TopLevelArmResourceInterfacesClient object to access its operations. + * + * @return the TopLevelArmResourceInterfacesClient object. + */ + public TopLevelArmResourceInterfacesClient getTopLevelArmResourceInterfaces() { + return this.topLevelArmResourceInterfaces; + } + + /** + * The CustomTemplateResourceInterfacesClient object to access its operations. + */ + private final CustomTemplateResourceInterfacesClient customTemplateResourceInterfaces; + + /** + * Gets the CustomTemplateResourceInterfacesClient object to access its operations. + * + * @return the CustomTemplateResourceInterfacesClient object. + */ + public CustomTemplateResourceInterfacesClient getCustomTemplateResourceInterfaces() { + return this.customTemplateResourceInterfaces; + } + + /** + * The OperationsClient object to access its operations. + */ + private final OperationsClient operations; + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + public OperationsClient getOperations() { + return this.operations; + } + + /** + * The ChildExtensionResourceInterfacesClient object to access its operations. + */ + private final ChildExtensionResourceInterfacesClient childExtensionResourceInterfaces; + + /** + * Gets the ChildExtensionResourceInterfacesClient object to access its operations. + * + * @return the ChildExtensionResourceInterfacesClient object. + */ + public ChildExtensionResourceInterfacesClient getChildExtensionResourceInterfaces() { + return this.childExtensionResourceInterfaces; + } + + /** + * Initializes an instance of ArmResourceProviderClient 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. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + ArmResourceProviderClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.apiVersion = "2023-11-01"; + this.childResourcesInterfaces = new ChildResourcesInterfacesClientImpl(this); + this.topLevelArmResourceInterfaces = new TopLevelArmResourceInterfacesClientImpl(this); + this.customTemplateResourceInterfaces = new CustomTemplateResourceInterfacesClientImpl(this); + this.operations = new OperationsClientImpl(this); + this.childExtensionResourceInterfaces = new ChildExtensionResourceInterfacesClientImpl(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 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) { + } + + 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)); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildExtensionResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildExtensionResourceImpl.java new file mode 100644 index 000000000..bf62ed4cf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildExtensionResourceImpl.java @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.cadl.armresourceprovider.fluent.models.ChildExtensionResourceInner; +import com.cadl.armresourceprovider.models.ChildExtensionResource; +import com.cadl.armresourceprovider.models.ChildExtensionResourceProperties; +import com.cadl.armresourceprovider.models.ChildExtensionResourceUpdate; + +public final class ChildExtensionResourceImpl + implements ChildExtensionResource, ChildExtensionResource.Definition, ChildExtensionResource.Update { + private ChildExtensionResourceInner innerObject; + + private final com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public ChildExtensionResourceProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public ChildExtensionResourceInner innerModel() { + return this.innerObject; + } + + private com.cadl.armresourceprovider.ArmResourceProviderManager manager() { + return this.serviceManager; + } + + private String resourceUri; + + private String topLevelArmResourceName; + + private String childExtensionResourceName; + + private ChildExtensionResourceUpdate updateProperties; + + public ChildExtensionResourceImpl withExistingTopLevelArmResource(String resourceUri, + String topLevelArmResourceName) { + this.resourceUri = resourceUri; + this.topLevelArmResourceName = topLevelArmResourceName; + return this; + } + + public ChildExtensionResource create() { + this.innerObject = serviceManager.serviceClient() + .getChildExtensionResourceInterfaces() + .createOrUpdate(resourceUri, topLevelArmResourceName, childExtensionResourceName, this.innerModel(), + Context.NONE); + return this; + } + + public ChildExtensionResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getChildExtensionResourceInterfaces() + .createOrUpdate(resourceUri, topLevelArmResourceName, childExtensionResourceName, this.innerModel(), + context); + return this; + } + + ChildExtensionResourceImpl(String name, com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerObject = new ChildExtensionResourceInner(); + this.serviceManager = serviceManager; + this.childExtensionResourceName = name; + } + + public ChildExtensionResourceImpl update() { + this.updateProperties = new ChildExtensionResourceUpdate(); + return this; + } + + public ChildExtensionResource apply() { + this.innerObject = serviceManager.serviceClient() + .getChildExtensionResourceInterfaces() + .updateWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, updateProperties, + Context.NONE) + .getValue(); + return this; + } + + public ChildExtensionResource apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getChildExtensionResourceInterfaces() + .updateWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, updateProperties, + context) + .getValue(); + return this; + } + + ChildExtensionResourceImpl(ChildExtensionResourceInner innerObject, + com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(innerObject.id(), + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "resourceUri"); + this.topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByParameterName(innerObject.id(), + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "topLevelArmResourceName"); + this.childExtensionResourceName = ResourceManagerUtils.getValueFromIdByParameterName(innerObject.id(), + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "childExtensionResourceName"); + } + + public ChildExtensionResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getChildExtensionResourceInterfaces() + .getWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, Context.NONE) + .getValue(); + return this; + } + + public ChildExtensionResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getChildExtensionResourceInterfaces() + .getWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, context) + .getValue(); + return this; + } + + public ChildExtensionResourceImpl withProperties(ChildExtensionResourceProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildExtensionResourceInterfacesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildExtensionResourceInterfacesClientImpl.java new file mode 100644 index 000000000..26aab6766 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildExtensionResourceInterfacesClientImpl.java @@ -0,0 +1,1083 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +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.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.cadl.armresourceprovider.fluent.ChildExtensionResourceInterfacesClient; +import com.cadl.armresourceprovider.fluent.models.ChildExtensionResourceInner; +import com.cadl.armresourceprovider.implementation.models.ChildExtensionResourceListResult; +import com.cadl.armresourceprovider.models.ChildExtensionResourceUpdate; +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 ChildExtensionResourceInterfacesClient. + */ +public final class ChildExtensionResourceInterfacesClientImpl implements ChildExtensionResourceInterfacesClient { + /** + * The proxy service used to perform REST calls. + */ + private final ChildExtensionResourceInterfacesService service; + + /** + * The service client containing this operation class. + */ + private final ArmResourceProviderClientImpl client; + + /** + * Initializes an instance of ChildExtensionResourceInterfacesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ChildExtensionResourceInterfacesClientImpl(ArmResourceProviderClientImpl client) { + this.service = RestProxy.create(ChildExtensionResourceInterfacesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArmResourceProviderClientChildExtensionResourceInterfaces to be used + * by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArmResourceProviderC") + public interface ChildExtensionResourceInterfacesService { + @Headers({ "Content-Type: application/json" }) + @Get("/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("resourceUri") String resourceUri, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @PathParam("childExtensionResourceName") String childExtensionResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("resourceUri") String resourceUri, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @PathParam("childExtensionResourceName") String childExtensionResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ChildExtensionResourceInner resource, Context context); + + @Patch("/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("resourceUri") String resourceUri, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @PathParam("childExtensionResourceName") String childExtensionResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ChildExtensionResourceUpdate properties, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}") + @ExpectedResponses({ 200, 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("resourceUri") String resourceUri, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @PathParam("childExtensionResourceName") String childExtensionResourceName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByTopLevelArmResource( + @HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("resourceUri") String resourceUri, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByTopLevelArmResourceNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 ChildExtensionResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceUri, + String topLevelArmResourceName, String childExtensionResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childExtensionResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter childExtensionResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, + topLevelArmResourceName, childExtensionResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 ChildExtensionResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceUri, + String topLevelArmResourceName, String childExtensionResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childExtensionResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter childExtensionResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, topLevelArmResourceName, + childExtensionResourceName, accept, context); + } + + /** + * Get a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 ChildExtensionResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName) { + return getWithResponseAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 ChildExtensionResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, Context context) { + return getWithResponseAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, context).block(); + } + + /** + * Get a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 ChildExtensionResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ChildExtensionResourceInner get(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName) { + return getWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, Context.NONE) + .getValue(); + } + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceUri, + String topLevelArmResourceName, String childExtensionResourceName, ChildExtensionResourceInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childExtensionResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter childExtensionResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, + topLevelArmResourceName, childExtensionResourceName, contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceUri, + String topLevelArmResourceName, String childExtensionResourceName, ChildExtensionResourceInner resource, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childExtensionResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter childExtensionResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, + topLevelArmResourceName, childExtensionResourceName, contentType, accept, resource, context); + } + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, ChildExtensionResourceInner> beginCreateOrUpdateAsync( + String resourceUri, String topLevelArmResourceName, String childExtensionResourceName, + ChildExtensionResourceInner resource) { + Mono>> mono = createOrUpdateWithResponseAsync(resourceUri, topLevelArmResourceName, + childExtensionResourceName, resource); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), ChildExtensionResourceInner.class, ChildExtensionResourceInner.class, + this.client.getContext()); + } + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 PollerFlux} for polling of extensionResource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, ChildExtensionResourceInner> beginCreateOrUpdateAsync( + String resourceUri, String topLevelArmResourceName, String childExtensionResourceName, + ChildExtensionResourceInner resource, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = createOrUpdateWithResponseAsync(resourceUri, topLevelArmResourceName, + childExtensionResourceName, resource, context); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), ChildExtensionResourceInner.class, ChildExtensionResourceInner.class, + context); + } + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ChildExtensionResourceInner> beginCreateOrUpdate( + String resourceUri, String topLevelArmResourceName, String childExtensionResourceName, + ChildExtensionResourceInner resource) { + return this.beginCreateOrUpdateAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, resource) + .getSyncPoller(); + } + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ChildExtensionResourceInner> beginCreateOrUpdate( + String resourceUri, String topLevelArmResourceName, String childExtensionResourceName, + ChildExtensionResourceInner resource, Context context) { + return this + .beginCreateOrUpdateAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, resource, + context) + .getSyncPoller(); + } + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, ChildExtensionResourceInner resource) { + return beginCreateOrUpdateAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, resource) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, ChildExtensionResourceInner resource, Context context) { + return beginCreateOrUpdateAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, resource, + context).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ChildExtensionResourceInner createOrUpdate(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, ChildExtensionResourceInner resource) { + return createOrUpdateAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, resource).block(); + } + + /** + * Create a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ChildExtensionResourceInner createOrUpdate(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, ChildExtensionResourceInner resource, Context context) { + return createOrUpdateAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, resource, context) + .block(); + } + + /** + * Update a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String resourceUri, + String topLevelArmResourceName, String childExtensionResourceName, ChildExtensionResourceUpdate properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childExtensionResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter childExtensionResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, + topLevelArmResourceName, childExtensionResourceName, contentType, accept, properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String resourceUri, + String topLevelArmResourceName, String childExtensionResourceName, ChildExtensionResourceUpdate properties, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childExtensionResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter childExtensionResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, + topLevelArmResourceName, childExtensionResourceName, contentType, accept, properties, context); + } + + /** + * Update a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, ChildExtensionResourceUpdate properties) { + return updateWithResponseAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, properties) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Update a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, ChildExtensionResourceUpdate properties, Context context) { + return updateWithResponseAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, properties, + context).block(); + } + + /** + * Update a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 extensionResource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ChildExtensionResourceInner update(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, ChildExtensionResourceUpdate properties) { + return updateWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, properties, + Context.NONE).getValue(); + } + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 resourceUri, String topLevelArmResourceName, + String childExtensionResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childExtensionResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter childExtensionResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, + topLevelArmResourceName, childExtensionResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childExtensionResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter childExtensionResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, + topLevelArmResourceName, childExtensionResourceName, accept, context); + } + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName) { + Mono>> mono + = deleteWithResponseAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = deleteWithResponseAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + context); + } + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName) { + return this.beginDeleteAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName).getSyncPoller(); + } + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, Context context) { + return this.beginDeleteAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, context) + .getSyncPoller(); + } + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 resourceUri, String topLevelArmResourceName, + String childExtensionResourceName) { + return beginDeleteAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, Context context) { + return beginDeleteAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 resourceUri, String topLevelArmResourceName, String childExtensionResourceName) { + deleteAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName).block(); + } + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceUri, String topLevelArmResourceName, String childExtensionResourceName, + Context context) { + deleteAsync(resourceUri, topLevelArmResourceName, childExtensionResourceName, context).block(); + } + + /** + * List ChildExtensionResource resources by TopLevelArmResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName 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 the response of a ChildExtensionResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByTopLevelArmResourceSinglePageAsync(String resourceUri, String topLevelArmResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByTopLevelArmResource(this.client.getEndpoint(), + this.client.getApiVersion(), resourceUri, topLevelArmResourceName, 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 ChildExtensionResource resources by TopLevelArmResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName 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 the response of a ChildExtensionResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByTopLevelArmResourceSinglePageAsync(String resourceUri, String topLevelArmResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceUri == null) { + return Mono.error(new IllegalArgumentException("Parameter resourceUri is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByTopLevelArmResource(this.client.getEndpoint(), this.client.getApiVersion(), resourceUri, + topLevelArmResourceName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List ChildExtensionResource resources by TopLevelArmResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName 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 the response of a ChildExtensionResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByTopLevelArmResourceAsync(String resourceUri, + String topLevelArmResourceName) { + return new PagedFlux<>(() -> listByTopLevelArmResourceSinglePageAsync(resourceUri, topLevelArmResourceName), + nextLink -> listByTopLevelArmResourceNextSinglePageAsync(nextLink)); + } + + /** + * List ChildExtensionResource resources by TopLevelArmResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName 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 the response of a ChildExtensionResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByTopLevelArmResourceAsync(String resourceUri, + String topLevelArmResourceName, Context context) { + return new PagedFlux<>( + () -> listByTopLevelArmResourceSinglePageAsync(resourceUri, topLevelArmResourceName, context), + nextLink -> listByTopLevelArmResourceNextSinglePageAsync(nextLink, context)); + } + + /** + * List ChildExtensionResource resources by TopLevelArmResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName 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 the response of a ChildExtensionResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByTopLevelArmResource(String resourceUri, + String topLevelArmResourceName) { + return new PagedIterable<>(listByTopLevelArmResourceAsync(resourceUri, topLevelArmResourceName)); + } + + /** + * List ChildExtensionResource resources by TopLevelArmResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName 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 the response of a ChildExtensionResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByTopLevelArmResource(String resourceUri, + String topLevelArmResourceName, Context context) { + return new PagedIterable<>(listByTopLevelArmResourceAsync(resourceUri, topLevelArmResourceName, context)); + } + + /** + * List ChildExtensionResource resources by TopLevelArmResource + * + * 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 ChildExtensionResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByTopLevelArmResourceNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByTopLevelArmResourceNext(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())); + } + + /** + * List ChildExtensionResource resources by TopLevelArmResource + * + * 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 ChildExtensionResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByTopLevelArmResourceNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByTopLevelArmResourceNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> 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/com/cadl/armresourceprovider/implementation/ChildExtensionResourceInterfacesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildExtensionResourceInterfacesImpl.java new file mode 100644 index 000000000..1dede586a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildExtensionResourceInterfacesImpl.java @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +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; +import com.cadl.armresourceprovider.fluent.ChildExtensionResourceInterfacesClient; +import com.cadl.armresourceprovider.fluent.models.ChildExtensionResourceInner; +import com.cadl.armresourceprovider.models.ChildExtensionResource; +import com.cadl.armresourceprovider.models.ChildExtensionResourceInterfaces; + +public final class ChildExtensionResourceInterfacesImpl implements ChildExtensionResourceInterfaces { + private static final ClientLogger LOGGER = new ClientLogger(ChildExtensionResourceInterfacesImpl.class); + + private final ChildExtensionResourceInterfacesClient innerClient; + + private final com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager; + + public ChildExtensionResourceInterfacesImpl(ChildExtensionResourceInterfacesClient innerClient, + com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, Context context) { + Response inner = this.serviceClient() + .getWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new ChildExtensionResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public ChildExtensionResource get(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName) { + ChildExtensionResourceInner inner + = this.serviceClient().get(resourceUri, topLevelArmResourceName, childExtensionResourceName); + if (inner != null) { + return new ChildExtensionResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public void delete(String resourceUri, String topLevelArmResourceName, String childExtensionResourceName) { + this.serviceClient().delete(resourceUri, topLevelArmResourceName, childExtensionResourceName); + } + + public void delete(String resourceUri, String topLevelArmResourceName, String childExtensionResourceName, + Context context) { + this.serviceClient().delete(resourceUri, topLevelArmResourceName, childExtensionResourceName, context); + } + + public PagedIterable listByTopLevelArmResource(String resourceUri, + String topLevelArmResourceName) { + PagedIterable inner + = this.serviceClient().listByTopLevelArmResource(resourceUri, topLevelArmResourceName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new ChildExtensionResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByTopLevelArmResource(String resourceUri, + String topLevelArmResourceName, Context context) { + PagedIterable inner + = this.serviceClient().listByTopLevelArmResource(resourceUri, topLevelArmResourceName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new ChildExtensionResourceImpl(inner1, this.manager())); + } + + public ChildExtensionResource getById(String id) { + String resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "resourceUri"); + if (resourceUri == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id))); + } + String topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "topLevelArmResourceName"); + if (topLevelArmResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + String childExtensionResourceName = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "childExtensionResourceName"); + if (childExtensionResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'childExtensionResources'.", id))); + } + return this.getWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, Context.NONE) + .getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "resourceUri"); + if (resourceUri == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id))); + } + String topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "topLevelArmResourceName"); + if (topLevelArmResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + String childExtensionResourceName = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "childExtensionResourceName"); + if (childExtensionResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'childExtensionResources'.", id))); + } + return this.getWithResponse(resourceUri, topLevelArmResourceName, childExtensionResourceName, context); + } + + public void deleteById(String id) { + String resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "resourceUri"); + if (resourceUri == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id))); + } + String topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "topLevelArmResourceName"); + if (topLevelArmResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + String childExtensionResourceName = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "childExtensionResourceName"); + if (childExtensionResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'childExtensionResources'.", id))); + } + this.delete(resourceUri, topLevelArmResourceName, childExtensionResourceName, Context.NONE); + } + + public void deleteByIdWithResponse(String id, Context context) { + String resourceUri = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "resourceUri"); + if (resourceUri == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceUri'.", id))); + } + String topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "topLevelArmResourceName"); + if (topLevelArmResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + String childExtensionResourceName = ResourceManagerUtils.getValueFromIdByParameterName(id, + "/{resourceUri}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childExtensionResources/{childExtensionResourceName}", + "childExtensionResourceName"); + if (childExtensionResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'childExtensionResources'.", id))); + } + this.delete(resourceUri, topLevelArmResourceName, childExtensionResourceName, context); + } + + private ChildExtensionResourceInterfacesClient serviceClient() { + return this.innerClient; + } + + private com.cadl.armresourceprovider.ArmResourceProviderManager manager() { + return this.serviceManager; + } + + public ChildExtensionResourceImpl define(String name) { + return new ChildExtensionResourceImpl(name, this.manager()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourceImpl.java new file mode 100644 index 000000000..2f24ac118 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourceImpl.java @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.cadl.armresourceprovider.fluent.models.ChildResourceInner; +import com.cadl.armresourceprovider.models.ChildResource; +import com.cadl.armresourceprovider.models.ChildResourceUpdate; +import com.cadl.armresourceprovider.models.ProvisioningState; +import java.util.Collections; +import java.util.Map; + +public final class ChildResourceImpl implements ChildResource, ChildResource.Definition, ChildResource.Update { + private ChildResourceInner innerObject; + + private final com.cadl.armresourceprovider.ArmResourceProviderManager 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 SystemData systemData() { + return this.innerModel().systemData(); + } + + public ProvisioningState provisioningState() { + return this.innerModel().provisioningState(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public ChildResourceInner innerModel() { + return this.innerObject; + } + + private com.cadl.armresourceprovider.ArmResourceProviderManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String topLevelArmResourceName; + + private String childResourceName; + + private ChildResourceUpdate updateProperties; + + public ChildResourceImpl withExistingTopLevelArmResource(String resourceGroupName, String topLevelArmResourceName) { + this.resourceGroupName = resourceGroupName; + this.topLevelArmResourceName = topLevelArmResourceName; + return this; + } + + public ChildResource create() { + this.innerObject = serviceManager.serviceClient() + .getChildResourcesInterfaces() + .createOrUpdate(resourceGroupName, topLevelArmResourceName, childResourceName, this.innerModel(), + Context.NONE); + return this; + } + + public ChildResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getChildResourcesInterfaces() + .createOrUpdate(resourceGroupName, topLevelArmResourceName, childResourceName, this.innerModel(), context); + return this; + } + + ChildResourceImpl(String name, com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerObject = new ChildResourceInner(); + this.serviceManager = serviceManager; + this.childResourceName = name; + } + + public ChildResourceImpl update() { + this.updateProperties = new ChildResourceUpdate(); + return this; + } + + public ChildResource apply() { + this.innerObject = serviceManager.serviceClient() + .getChildResourcesInterfaces() + .updateWithResponse(resourceGroupName, topLevelArmResourceName, childResourceName, updateProperties, + Context.NONE) + .getValue(); + return this; + } + + public ChildResource apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getChildResourcesInterfaces() + .updateWithResponse(resourceGroupName, topLevelArmResourceName, childResourceName, updateProperties, + context) + .getValue(); + return this; + } + + ChildResourceImpl(ChildResourceInner innerObject, + com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.topLevelArmResourceName + = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "topLevelArmResources"); + this.childResourceName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "childResources"); + } + + public ChildResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getChildResourcesInterfaces() + .getWithResponse(resourceGroupName, topLevelArmResourceName, childResourceName, Context.NONE) + .getValue(); + return this; + } + + public ChildResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getChildResourcesInterfaces() + .getWithResponse(resourceGroupName, topLevelArmResourceName, childResourceName, context) + .getValue(); + return this; + } + + public void actionWithoutBody() { + serviceManager.childResourcesInterfaces() + .actionWithoutBody(resourceGroupName, topLevelArmResourceName, childResourceName); + } + + public void actionWithoutBody(Context context) { + serviceManager.childResourcesInterfaces() + .actionWithoutBody(resourceGroupName, topLevelArmResourceName, childResourceName, context); + } + + public ChildResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public ChildResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public ChildResourceImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateProperties.withTags(tags); + return this; + } + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesClientImpl.java new file mode 100644 index 000000000..ec02ebc5f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesClientImpl.java @@ -0,0 +1,1376 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +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.Post; +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.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.cadl.armresourceprovider.fluent.ChildResourcesInterfacesClient; +import com.cadl.armresourceprovider.fluent.models.ChildResourceInner; +import com.cadl.armresourceprovider.implementation.models.ChildResourceListResult; +import com.cadl.armresourceprovider.models.ChildResourceUpdate; +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 ChildResourcesInterfacesClient. + */ +public final class ChildResourcesInterfacesClientImpl implements ChildResourcesInterfacesClient { + /** + * The proxy service used to perform REST calls. + */ + private final ChildResourcesInterfacesService service; + + /** + * The service client containing this operation class. + */ + private final ArmResourceProviderClientImpl client; + + /** + * Initializes an instance of ChildResourcesInterfacesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ChildResourcesInterfacesClientImpl(ArmResourceProviderClientImpl client) { + this.service = RestProxy.create(ChildResourcesInterfacesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArmResourceProviderClientChildResourcesInterfaces to be used by the + * proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArmResourceProviderC") + public interface ChildResourcesInterfacesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources/{childResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @PathParam("childResourceName") String childResourceName, @HeaderParam("Accept") String accept, + Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources/{childResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @PathParam("childResourceName") String childResourceName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") ChildResourceInner resource, + Context context); + + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources/{childResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @PathParam("childResourceName") String childResourceName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") ChildResourceUpdate properties, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources/{childResourceName}") + @ExpectedResponses({ 200, 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @PathParam("childResourceName") String childResourceName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByTopLevelArmResource(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources/{childResourceName}/actionWithoutBody") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> actionWithoutBody(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @PathParam("childResourceName") String childResourceName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByTopLevelArmResourceNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 ChildResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter childResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 ChildResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter childResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelArmResourceName, childResourceName, accept, context); + } + + /** + * Get a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 ChildResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceGroupName, String topLevelArmResourceName, + String childResourceName) { + return getWithResponseAsync(resourceGroupName, topLevelArmResourceName, childResourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 ChildResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, Context context) { + return getWithResponseAsync(resourceGroupName, topLevelArmResourceName, childResourceName, context).block(); + } + + /** + * Get a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 ChildResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ChildResourceInner get(String resourceGroupName, String topLevelArmResourceName, String childResourceName) { + return getWithResponse(resourceGroupName, topLevelArmResourceName, childResourceName, Context.NONE).getValue(); + } + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, ChildResourceInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter childResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, + contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, ChildResourceInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter childResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, contentType, + accept, resource, context); + } + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, ChildResourceInner> beginCreateOrUpdateAsync( + String resourceGroupName, String topLevelArmResourceName, String childResourceName, + ChildResourceInner resource) { + Mono>> mono + = createOrUpdateWithResponseAsync(resourceGroupName, topLevelArmResourceName, childResourceName, resource); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + ChildResourceInner.class, ChildResourceInner.class, this.client.getContext()); + } + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 PollerFlux} for polling of subresource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, ChildResourceInner> beginCreateOrUpdateAsync( + String resourceGroupName, String topLevelArmResourceName, String childResourceName, ChildResourceInner resource, + Context context) { + context = this.client.mergeContext(context); + Mono>> mono = createOrUpdateWithResponseAsync(resourceGroupName, + topLevelArmResourceName, childResourceName, resource, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + ChildResourceInner.class, ChildResourceInner.class, context); + } + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ChildResourceInner> beginCreateOrUpdate(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, ChildResourceInner resource) { + return this.beginCreateOrUpdateAsync(resourceGroupName, topLevelArmResourceName, childResourceName, resource) + .getSyncPoller(); + } + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ChildResourceInner> beginCreateOrUpdate(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, ChildResourceInner resource, Context context) { + return this + .beginCreateOrUpdateAsync(resourceGroupName, topLevelArmResourceName, childResourceName, resource, context) + .getSyncPoller(); + } + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, ChildResourceInner resource) { + return beginCreateOrUpdateAsync(resourceGroupName, topLevelArmResourceName, childResourceName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, ChildResourceInner resource, Context context) { + return beginCreateOrUpdateAsync(resourceGroupName, topLevelArmResourceName, childResourceName, resource, + context).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ChildResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, ChildResourceInner resource) { + return createOrUpdateAsync(resourceGroupName, topLevelArmResourceName, childResourceName, resource).block(); + } + + /** + * Create a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ChildResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, ChildResourceInner resource, Context context) { + return createOrUpdateAsync(resourceGroupName, topLevelArmResourceName, childResourceName, resource, context) + .block(); + } + + /** + * Update a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, ChildResourceUpdate properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter childResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, + contentType, accept, properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, ChildResourceUpdate properties, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter childResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelArmResourceName, childResourceName, contentType, accept, properties, context); + } + + /** + * Update a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, ChildResourceUpdate properties) { + return updateWithResponseAsync(resourceGroupName, topLevelArmResourceName, childResourceName, properties) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Update a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, ChildResourceUpdate properties, Context context) { + return updateWithResponseAsync(resourceGroupName, topLevelArmResourceName, childResourceName, properties, + context).block(); + } + + /** + * Update a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 subresource of Top Level Arm Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ChildResourceInner update(String resourceGroupName, String topLevelArmResourceName, String childResourceName, + ChildResourceUpdate properties) { + return updateWithResponse(resourceGroupName, topLevelArmResourceName, childResourceName, properties, + Context.NONE).getValue(); + } + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 resourceGroupName, + String topLevelArmResourceName, String childResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter childResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter childResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelArmResourceName, childResourceName, accept, context); + } + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName) { + Mono>> mono + = deleteWithResponseAsync(resourceGroupName, topLevelArmResourceName, childResourceName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = deleteWithResponseAsync(resourceGroupName, topLevelArmResourceName, childResourceName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + context); + } + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourceName, + String childResourceName) { + return this.beginDeleteAsync(resourceGroupName, topLevelArmResourceName, childResourceName).getSyncPoller(); + } + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, Context context) { + return this.beginDeleteAsync(resourceGroupName, topLevelArmResourceName, childResourceName, context) + .getSyncPoller(); + } + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 resourceGroupName, String topLevelArmResourceName, String childResourceName) { + return beginDeleteAsync(resourceGroupName, topLevelArmResourceName, childResourceName).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String topLevelArmResourceName, String childResourceName, + Context context) { + return beginDeleteAsync(resourceGroupName, topLevelArmResourceName, childResourceName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 resourceGroupName, String topLevelArmResourceName, String childResourceName) { + deleteAsync(resourceGroupName, topLevelArmResourceName, childResourceName).block(); + } + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String topLevelArmResourceName, String childResourceName, + Context context) { + deleteAsync(resourceGroupName, topLevelArmResourceName, childResourceName, context).block(); + } + + /** + * List ChildResource resources by TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response of a ChildResource list operation along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByTopLevelArmResourceSinglePageAsync(String resourceGroupName, + String topLevelArmResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByTopLevelArmResource(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, 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 ChildResource resources by TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response of a ChildResource list operation along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByTopLevelArmResourceSinglePageAsync(String resourceGroupName, + String topLevelArmResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByTopLevelArmResource(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List ChildResource resources by TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response of a ChildResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByTopLevelArmResourceAsync(String resourceGroupName, + String topLevelArmResourceName) { + return new PagedFlux<>( + () -> listByTopLevelArmResourceSinglePageAsync(resourceGroupName, topLevelArmResourceName), + nextLink -> listByTopLevelArmResourceNextSinglePageAsync(nextLink)); + } + + /** + * List ChildResource resources by TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response of a ChildResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByTopLevelArmResourceAsync(String resourceGroupName, + String topLevelArmResourceName, Context context) { + return new PagedFlux<>( + () -> listByTopLevelArmResourceSinglePageAsync(resourceGroupName, topLevelArmResourceName, context), + nextLink -> listByTopLevelArmResourceNextSinglePageAsync(nextLink, context)); + } + + /** + * List ChildResource resources by TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response of a ChildResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByTopLevelArmResource(String resourceGroupName, + String topLevelArmResourceName) { + return new PagedIterable<>(listByTopLevelArmResourceAsync(resourceGroupName, topLevelArmResourceName)); + } + + /** + * List ChildResource resources by TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response of a ChildResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByTopLevelArmResource(String resourceGroupName, + String topLevelArmResourceName, Context context) { + return new PagedIterable<>(listByTopLevelArmResourceAsync(resourceGroupName, topLevelArmResourceName, context)); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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>> actionWithoutBodyWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter childResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.actionWithoutBody(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> actionWithoutBodyWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (childResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter childResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.actionWithoutBody(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, accept, + context); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginActionWithoutBodyAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName) { + Mono>> mono + = actionWithoutBodyWithResponseAsync(resourceGroupName, topLevelArmResourceName, childResourceName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginActionWithoutBodyAsync(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = actionWithoutBodyWithResponseAsync(resourceGroupName, + topLevelArmResourceName, childResourceName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + context); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginActionWithoutBody(String resourceGroupName, + String topLevelArmResourceName, String childResourceName) { + return this.beginActionWithoutBodyAsync(resourceGroupName, topLevelArmResourceName, childResourceName) + .getSyncPoller(); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginActionWithoutBody(String resourceGroupName, + String topLevelArmResourceName, String childResourceName, Context context) { + return this.beginActionWithoutBodyAsync(resourceGroupName, topLevelArmResourceName, childResourceName, context) + .getSyncPoller(); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 actionWithoutBodyAsync(String resourceGroupName, String topLevelArmResourceName, + String childResourceName) { + return beginActionWithoutBodyAsync(resourceGroupName, topLevelArmResourceName, childResourceName).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono actionWithoutBodyAsync(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, Context context) { + return beginActionWithoutBodyAsync(resourceGroupName, topLevelArmResourceName, childResourceName, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 actionWithoutBody(String resourceGroupName, String topLevelArmResourceName, String childResourceName) { + actionWithoutBodyAsync(resourceGroupName, topLevelArmResourceName, childResourceName).block(); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void actionWithoutBody(String resourceGroupName, String topLevelArmResourceName, String childResourceName, + Context context) { + actionWithoutBodyAsync(resourceGroupName, topLevelArmResourceName, childResourceName, context).block(); + } + + /** + * List ChildResource resources by TopLevelArmResource + * + * 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 ChildResource list operation along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByTopLevelArmResourceNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByTopLevelArmResourceNext(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())); + } + + /** + * List ChildResource resources by TopLevelArmResource + * + * 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 ChildResource list operation along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByTopLevelArmResourceNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByTopLevelArmResourceNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> 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/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesImpl.java new file mode 100644 index 000000000..6cab4d7a0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesImpl.java @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +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; +import com.cadl.armresourceprovider.fluent.ChildResourcesInterfacesClient; +import com.cadl.armresourceprovider.fluent.models.ChildResourceInner; +import com.cadl.armresourceprovider.models.ChildResource; +import com.cadl.armresourceprovider.models.ChildResourcesInterfaces; + +public final class ChildResourcesInterfacesImpl implements ChildResourcesInterfaces { + private static final ClientLogger LOGGER = new ClientLogger(ChildResourcesInterfacesImpl.class); + + private final ChildResourcesInterfacesClient innerClient; + + private final com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager; + + public ChildResourcesInterfacesImpl(ChildResourcesInterfacesClient innerClient, + com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, Context context) { + Response inner = this.serviceClient() + .getWithResponse(resourceGroupName, topLevelArmResourceName, childResourceName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new ChildResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public ChildResource get(String resourceGroupName, String topLevelArmResourceName, String childResourceName) { + ChildResourceInner inner + = this.serviceClient().get(resourceGroupName, topLevelArmResourceName, childResourceName); + if (inner != null) { + return new ChildResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public void delete(String resourceGroupName, String topLevelArmResourceName, String childResourceName) { + this.serviceClient().delete(resourceGroupName, topLevelArmResourceName, childResourceName); + } + + public void delete(String resourceGroupName, String topLevelArmResourceName, String childResourceName, + Context context) { + this.serviceClient().delete(resourceGroupName, topLevelArmResourceName, childResourceName, context); + } + + public PagedIterable listByTopLevelArmResource(String resourceGroupName, + String topLevelArmResourceName) { + PagedIterable inner + = this.serviceClient().listByTopLevelArmResource(resourceGroupName, topLevelArmResourceName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new ChildResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByTopLevelArmResource(String resourceGroupName, + String topLevelArmResourceName, Context context) { + PagedIterable inner + = this.serviceClient().listByTopLevelArmResource(resourceGroupName, topLevelArmResourceName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new ChildResourceImpl(inner1, this.manager())); + } + + public void actionWithoutBody(String resourceGroupName, String topLevelArmResourceName, String childResourceName) { + this.serviceClient().actionWithoutBody(resourceGroupName, topLevelArmResourceName, childResourceName); + } + + public void actionWithoutBody(String resourceGroupName, String topLevelArmResourceName, String childResourceName, + Context context) { + this.serviceClient().actionWithoutBody(resourceGroupName, topLevelArmResourceName, childResourceName, context); + } + + public ChildResource 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 topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + String childResourceName = ResourceManagerUtils.getValueFromIdByName(id, "childResources"); + if (childResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'childResources'.", id))); + } + return this.getWithResponse(resourceGroupName, topLevelArmResourceName, childResourceName, 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 topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + String childResourceName = ResourceManagerUtils.getValueFromIdByName(id, "childResources"); + if (childResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'childResources'.", id))); + } + return this.getWithResponse(resourceGroupName, topLevelArmResourceName, childResourceName, context); + } + + public void deleteById(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 topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + String childResourceName = ResourceManagerUtils.getValueFromIdByName(id, "childResources"); + if (childResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'childResources'.", id))); + } + this.delete(resourceGroupName, topLevelArmResourceName, childResourceName, Context.NONE); + } + + public void deleteByIdWithResponse(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 topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + String childResourceName = ResourceManagerUtils.getValueFromIdByName(id, "childResources"); + if (childResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'childResources'.", id))); + } + this.delete(resourceGroupName, topLevelArmResourceName, childResourceName, context); + } + + private ChildResourcesInterfacesClient serviceClient() { + return this.innerClient; + } + + private com.cadl.armresourceprovider.ArmResourceProviderManager manager() { + return this.serviceManager; + } + + public ChildResourceImpl define(String name) { + return new ChildResourceImpl(name, this.manager()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceImpl.java new file mode 100644 index 000000000..7e155b166 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceImpl.java @@ -0,0 +1,217 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.cadl.armresourceprovider.fluent.models.CustomTemplateResourceInner; +import com.cadl.armresourceprovider.models.CustomTemplateResource; +import com.cadl.armresourceprovider.models.CustomTemplateResourcePatch; +import com.cadl.armresourceprovider.models.CustomTemplateResourcePropertiesAnonymousEmptyModel; +import com.cadl.armresourceprovider.models.Dog; +import com.cadl.armresourceprovider.models.EmptyModel; +import com.cadl.armresourceprovider.models.ManagedServiceIdentity; +import com.cadl.armresourceprovider.models.ProvisioningState; +import java.util.Collections; +import java.util.Map; + +public final class CustomTemplateResourceImpl + implements CustomTemplateResource, CustomTemplateResource.Definition, CustomTemplateResource.Update { + private CustomTemplateResourceInner innerObject; + + private final com.cadl.armresourceprovider.ArmResourceProviderManager 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 ManagedServiceIdentity identity() { + return this.innerModel().identity(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public ProvisioningState provisioningState() { + return this.innerModel().provisioningState(); + } + + public Dog dog() { + return this.innerModel().dog(); + } + + public EmptyModel namedEmptyModel() { + return this.innerModel().namedEmptyModel(); + } + + public CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel() { + return this.innerModel().anonymousEmptyModel(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public CustomTemplateResourceInner innerModel() { + return this.innerObject; + } + + private com.cadl.armresourceprovider.ArmResourceProviderManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String customTemplateResourceName; + + private String createIfMatch; + + private String createIfNoneMatch; + + private CustomTemplateResourcePatch updateProperties; + + public CustomTemplateResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public CustomTemplateResource create() { + this.innerObject = serviceManager.serviceClient() + .getCustomTemplateResourceInterfaces() + .createOrUpdate(resourceGroupName, customTemplateResourceName, this.innerModel(), createIfMatch, + createIfNoneMatch, Context.NONE); + return this; + } + + public CustomTemplateResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getCustomTemplateResourceInterfaces() + .createOrUpdate(resourceGroupName, customTemplateResourceName, this.innerModel(), createIfMatch, + createIfNoneMatch, context); + return this; + } + + CustomTemplateResourceImpl(String name, com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerObject = new CustomTemplateResourceInner(); + this.serviceManager = serviceManager; + this.customTemplateResourceName = name; + this.createIfMatch = null; + this.createIfNoneMatch = null; + } + + public CustomTemplateResourceImpl update() { + this.updateProperties = new CustomTemplateResourcePatch(); + return this; + } + + public CustomTemplateResource apply() { + this.innerObject = serviceManager.serviceClient() + .getCustomTemplateResourceInterfaces() + .updateLongRunning(resourceGroupName, customTemplateResourceName, updateProperties, Context.NONE); + return this; + } + + public CustomTemplateResource apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getCustomTemplateResourceInterfaces() + .updateLongRunning(resourceGroupName, customTemplateResourceName, updateProperties, context); + return this; + } + + CustomTemplateResourceImpl(CustomTemplateResourceInner innerObject, + com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.customTemplateResourceName + = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "customTemplateResources"); + } + + public CustomTemplateResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public CustomTemplateResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public CustomTemplateResourceImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public CustomTemplateResourceImpl withIdentity(ManagedServiceIdentity identity) { + if (isInCreateMode()) { + this.innerModel().withIdentity(identity); + return this; + } else { + this.updateProperties.withIdentity(identity); + return this; + } + } + + public CustomTemplateResourceImpl withDog(Dog dog) { + this.innerModel().withDog(dog); + return this; + } + + public CustomTemplateResourceImpl withNamedEmptyModel(EmptyModel namedEmptyModel) { + this.innerModel().withNamedEmptyModel(namedEmptyModel); + return this; + } + + public CustomTemplateResourceImpl + withAnonymousEmptyModel(CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel) { + this.innerModel().withAnonymousEmptyModel(anonymousEmptyModel); + return this; + } + + public CustomTemplateResourceImpl withIfMatch(String ifMatch) { + this.createIfMatch = ifMatch; + return this; + } + + public CustomTemplateResourceImpl withIfNoneMatch(String ifNoneMatch) { + this.createIfNoneMatch = ifNoneMatch; + return this; + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceInterfacesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceInterfacesClientImpl.java new file mode 100644 index 000000000..8b208a856 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceInterfacesClientImpl.java @@ -0,0 +1,666 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.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.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.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.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.cadl.armresourceprovider.fluent.CustomTemplateResourceInterfacesClient; +import com.cadl.armresourceprovider.fluent.models.CustomTemplateResourceInner; +import com.cadl.armresourceprovider.models.CustomTemplateResourcePatch; +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 CustomTemplateResourceInterfacesClient. + */ +public final class CustomTemplateResourceInterfacesClientImpl implements CustomTemplateResourceInterfacesClient { + /** + * The proxy service used to perform REST calls. + */ + private final CustomTemplateResourceInterfacesService service; + + /** + * The service client containing this operation class. + */ + private final ArmResourceProviderClientImpl client; + + /** + * Initializes an instance of CustomTemplateResourceInterfacesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CustomTemplateResourceInterfacesClientImpl(ArmResourceProviderClientImpl client) { + this.service = RestProxy.create(CustomTemplateResourceInterfacesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArmResourceProviderClientCustomTemplateResourceInterfaces to be used + * by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArmResourceProviderC") + public interface CustomTemplateResourceInterfacesService { + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/customTemplateResources/{customTemplateResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("If-Match") String ifMatch, + @HeaderParam("If-None-Match") String ifNoneMatch, + @PathParam("customTemplateResourceName") String customTemplateResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") CustomTemplateResourceInner resource, Context context); + + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/customTemplateResources/{customTemplateResourceName}") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> updateLongRunning(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("customTemplateResourceName") String customTemplateResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") CustomTemplateResourcePatch properties, Context context); + } + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param ifMatch The request should only proceed if an entity matches this string. + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @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>> createOrUpdateWithResponseAsync(String resourceGroupName, + String customTemplateResourceName, CustomTemplateResourceInner resource, String ifMatch, String ifNoneMatch) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (customTemplateResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter customTemplateResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, ifMatch, ifNoneMatch, customTemplateResourceName, + contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param ifMatch The request should only proceed if an entity matches this string. + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @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} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, + String customTemplateResourceName, CustomTemplateResourceInner resource, String ifMatch, String ifNoneMatch, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (customTemplateResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter customTemplateResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, ifMatch, ifNoneMatch, customTemplateResourceName, + contentType, accept, resource, context); + } + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param ifMatch The request should only proceed if an entity matches this string. + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @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 tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, CustomTemplateResourceInner> beginCreateOrUpdateAsync( + String resourceGroupName, String customTemplateResourceName, CustomTemplateResourceInner resource, + String ifMatch, String ifNoneMatch) { + Mono>> mono = createOrUpdateWithResponseAsync(resourceGroupName, + customTemplateResourceName, resource, ifMatch, ifNoneMatch); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), CustomTemplateResourceInner.class, CustomTemplateResourceInner.class, + this.client.getContext()); + } + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName 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 the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, CustomTemplateResourceInner> beginCreateOrUpdateAsync( + String resourceGroupName, String customTemplateResourceName, CustomTemplateResourceInner resource) { + final String ifMatch = null; + final String ifNoneMatch = null; + Mono>> mono = createOrUpdateWithResponseAsync(resourceGroupName, + customTemplateResourceName, resource, ifMatch, ifNoneMatch); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), CustomTemplateResourceInner.class, CustomTemplateResourceInner.class, + this.client.getContext()); + } + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param ifMatch The request should only proceed if an entity matches this string. + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @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 PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, CustomTemplateResourceInner> beginCreateOrUpdateAsync( + String resourceGroupName, String customTemplateResourceName, CustomTemplateResourceInner resource, + String ifMatch, String ifNoneMatch, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = createOrUpdateWithResponseAsync(resourceGroupName, + customTemplateResourceName, resource, ifMatch, ifNoneMatch, context); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), CustomTemplateResourceInner.class, CustomTemplateResourceInner.class, + context); + } + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName 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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, CustomTemplateResourceInner> beginCreateOrUpdate( + String resourceGroupName, String customTemplateResourceName, CustomTemplateResourceInner resource) { + final String ifMatch = null; + final String ifNoneMatch = null; + return this + .beginCreateOrUpdateAsync(resourceGroupName, customTemplateResourceName, resource, ifMatch, ifNoneMatch) + .getSyncPoller(); + } + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param ifMatch The request should only proceed if an entity matches this string. + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @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 tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, CustomTemplateResourceInner> beginCreateOrUpdate( + String resourceGroupName, String customTemplateResourceName, CustomTemplateResourceInner resource, + String ifMatch, String ifNoneMatch, Context context) { + return this + .beginCreateOrUpdateAsync(resourceGroupName, customTemplateResourceName, resource, ifMatch, ifNoneMatch, + context) + .getSyncPoller(); + } + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param ifMatch The request should only proceed if an entity matches this string. + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @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 createOrUpdateAsync(String resourceGroupName, + String customTemplateResourceName, CustomTemplateResourceInner resource, String ifMatch, String ifNoneMatch) { + return beginCreateOrUpdateAsync(resourceGroupName, customTemplateResourceName, resource, ifMatch, ifNoneMatch) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName 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 createOrUpdateAsync(String resourceGroupName, + String customTemplateResourceName, CustomTemplateResourceInner resource) { + final String ifMatch = null; + final String ifNoneMatch = null; + return beginCreateOrUpdateAsync(resourceGroupName, customTemplateResourceName, resource, ifMatch, ifNoneMatch) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param ifMatch The request should only proceed if an entity matches this string. + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @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 on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, + String customTemplateResourceName, CustomTemplateResourceInner resource, String ifMatch, String ifNoneMatch, + Context context) { + return beginCreateOrUpdateAsync(resourceGroupName, customTemplateResourceName, resource, ifMatch, ifNoneMatch, + context).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName 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 CustomTemplateResourceInner createOrUpdate(String resourceGroupName, String customTemplateResourceName, + CustomTemplateResourceInner resource) { + final String ifMatch = null; + final String ifNoneMatch = null; + return createOrUpdateAsync(resourceGroupName, customTemplateResourceName, resource, ifMatch, ifNoneMatch) + .block(); + } + + /** + * Create a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @param resource Resource create parameters. + * @param ifMatch The request should only proceed if an entity matches this string. + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CustomTemplateResourceInner createOrUpdate(String resourceGroupName, String customTemplateResourceName, + CustomTemplateResourceInner resource, String ifMatch, String ifNoneMatch, Context context) { + return createOrUpdateAsync(resourceGroupName, customTemplateResourceName, resource, ifMatch, ifNoneMatch, + context).block(); + } + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 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>> updateLongRunningWithResponseAsync(String resourceGroupName, + String customTemplateResourceName, CustomTemplateResourcePatch properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (customTemplateResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter customTemplateResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.updateLongRunning(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, customTemplateResourceName, contentType, accept, + properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 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>> updateLongRunningWithResponseAsync(String resourceGroupName, + String customTemplateResourceName, CustomTemplateResourcePatch properties, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (customTemplateResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter customTemplateResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.updateLongRunning(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, customTemplateResourceName, contentType, accept, + properties, context); + } + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, CustomTemplateResourceInner> + beginUpdateLongRunningAsync(String resourceGroupName, String customTemplateResourceName, + CustomTemplateResourcePatch properties) { + Mono>> mono + = updateLongRunningWithResponseAsync(resourceGroupName, customTemplateResourceName, properties); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), CustomTemplateResourceInner.class, CustomTemplateResourceInner.class, + this.client.getContext()); + } + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, CustomTemplateResourceInner> + beginUpdateLongRunningAsync(String resourceGroupName, String customTemplateResourceName, + CustomTemplateResourcePatch properties, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = updateLongRunningWithResponseAsync(resourceGroupName, customTemplateResourceName, properties, context); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), CustomTemplateResourceInner.class, CustomTemplateResourceInner.class, + context); + } + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, CustomTemplateResourceInner> beginUpdateLongRunning( + String resourceGroupName, String customTemplateResourceName, CustomTemplateResourcePatch properties) { + return this.beginUpdateLongRunningAsync(resourceGroupName, customTemplateResourceName, properties) + .getSyncPoller(); + } + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, CustomTemplateResourceInner> beginUpdateLongRunning( + String resourceGroupName, String customTemplateResourceName, CustomTemplateResourcePatch properties, + Context context) { + return this.beginUpdateLongRunningAsync(resourceGroupName, customTemplateResourceName, properties, context) + .getSyncPoller(); + } + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 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 updateLongRunningAsync(String resourceGroupName, + String customTemplateResourceName, CustomTemplateResourcePatch properties) { + return beginUpdateLongRunningAsync(resourceGroupName, customTemplateResourceName, properties).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 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 updateLongRunningAsync(String resourceGroupName, + String customTemplateResourceName, CustomTemplateResourcePatch properties, Context context) { + return beginUpdateLongRunningAsync(resourceGroupName, customTemplateResourceName, properties, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CustomTemplateResourceInner updateLongRunning(String resourceGroupName, String customTemplateResourceName, + CustomTemplateResourcePatch properties) { + return updateLongRunningAsync(resourceGroupName, customTemplateResourceName, properties).block(); + } + + /** + * Update a CustomTemplateResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param customTemplateResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CustomTemplateResourceInner updateLongRunning(String resourceGroupName, String customTemplateResourceName, + CustomTemplateResourcePatch properties, Context context) { + return updateLongRunningAsync(resourceGroupName, customTemplateResourceName, properties, context).block(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceInterfacesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceInterfacesImpl.java new file mode 100644 index 000000000..47694fb06 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/CustomTemplateResourceInterfacesImpl.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +import com.azure.core.util.logging.ClientLogger; +import com.cadl.armresourceprovider.fluent.CustomTemplateResourceInterfacesClient; +import com.cadl.armresourceprovider.models.CustomTemplateResourceInterfaces; + +public final class CustomTemplateResourceInterfacesImpl implements CustomTemplateResourceInterfaces { + private static final ClientLogger LOGGER = new ClientLogger(CustomTemplateResourceInterfacesImpl.class); + + private final CustomTemplateResourceInterfacesClient innerClient; + + private final com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager; + + public CustomTemplateResourceInterfacesImpl(CustomTemplateResourceInterfacesClient innerClient, + com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + private CustomTemplateResourceInterfacesClient serviceClient() { + return this.innerClient; + } + + private com.cadl.armresourceprovider.ArmResourceProviderManager manager() { + return this.serviceManager; + } + + public CustomTemplateResourceImpl define(String name) { + return new CustomTemplateResourceImpl(name, this.manager()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/OperationImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/OperationImpl.java new file mode 100644 index 000000000..0480f8591 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/OperationImpl.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 com.cadl.armresourceprovider.implementation; + +import com.cadl.armresourceprovider.fluent.models.OperationInner; +import com.cadl.armresourceprovider.models.ActionType; +import com.cadl.armresourceprovider.models.Operation; +import com.cadl.armresourceprovider.models.OperationDisplay; +import com.cadl.armresourceprovider.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager; + + OperationImpl(OperationInner innerObject, com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public Boolean isDataAction() { + return this.innerModel().isDataAction(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public Origin origin() { + return this.innerModel().origin(); + } + + public ActionType actionType() { + return this.innerModel().actionType(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private com.cadl.armresourceprovider.ArmResourceProviderManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/OperationsClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/OperationsClientImpl.java new file mode 100644 index 000000000..0c2de7e03 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/OperationsClientImpl.java @@ -0,0 +1,239 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +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.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.util.Context; +import com.azure.core.util.FluxUtil; +import com.cadl.armresourceprovider.fluent.OperationsClient; +import com.cadl.armresourceprovider.fluent.models.OperationInner; +import com.cadl.armresourceprovider.implementation.models.OperationListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public final class OperationsClientImpl implements OperationsClient { + /** + * The proxy service used to perform REST calls. + */ + private final OperationsService service; + + /** + * The service client containing this operation class. + */ + private final ArmResourceProviderClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(ArmResourceProviderClientImpl client) { + this.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArmResourceProviderClientOperations to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArmResourceProviderC") + public interface OperationsService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Cadl.ArmResourceProvider/operations") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); + } + + /** + * List the operations for the provider. + * + * @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 list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), 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 the operations for the provider. + * + * @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 list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List the operations for the provider. + * + * @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 list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List the operations for the provider. + * + * @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 list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List the operations for the provider. + * + * @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 list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List the operations for the provider. + * + * @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 list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * List the operations for the provider + * + * 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 a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.listNext(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())); + } + + /** + * List the operations for the provider + * + * 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 a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> 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/com/cadl/armresourceprovider/implementation/OperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/OperationsImpl.java new file mode 100644 index 000000000..dcffdb968 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/OperationsImpl.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.cadl.armresourceprovider.fluent.OperationsClient; +import com.cadl.armresourceprovider.fluent.models.OperationInner; +import com.cadl.armresourceprovider.models.Operation; +import com.cadl.armresourceprovider.models.Operations; + +public final class OperationsImpl implements Operations { + private static final ClientLogger LOGGER = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, + com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.cadl.armresourceprovider.ArmResourceProviderManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ResourceManagerUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ResourceManagerUtils.java new file mode 100644 index 000000000..63dbaf833 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ResourceManagerUtils.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + + } + +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ResultImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ResultImpl.java new file mode 100644 index 000000000..8da1e4426 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/ResultImpl.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +import com.cadl.armresourceprovider.fluent.models.ResultInner; +import com.cadl.armresourceprovider.models.Result; + +public final class ResultImpl implements Result { + private ResultInner innerObject; + + private final com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager; + + ResultImpl(ResultInner innerObject, com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String reason() { + return this.innerModel().reason(); + } + + public ResultInner innerModel() { + return this.innerObject; + } + + private com.cadl.armresourceprovider.ArmResourceProviderManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceImpl.java new file mode 100644 index 000000000..17251a498 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceImpl.java @@ -0,0 +1,248 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceInner; +import com.cadl.armresourceprovider.models.ProvisioningState; +import com.cadl.armresourceprovider.models.Result; +import com.cadl.armresourceprovider.models.TopLevelArmResource; +import com.cadl.armresourceprovider.models.TopLevelArmResourceUpdate; +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public final class TopLevelArmResourceImpl + implements TopLevelArmResource, TopLevelArmResource.Definition, TopLevelArmResource.Update { + private TopLevelArmResourceInner innerObject; + + private final com.cadl.armresourceprovider.ArmResourceProviderManager 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 SystemData systemData() { + return this.innerModel().systemData(); + } + + public List configurationEndpoints() { + List inner = this.innerModel().configurationEndpoints(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public String userName() { + return this.innerModel().userName(); + } + + public String userNames() { + return this.innerModel().userNames(); + } + + public String accuserName() { + return this.innerModel().accuserName(); + } + + public OffsetDateTime startTimeStamp() { + return this.innerModel().startTimeStamp(); + } + + public ProvisioningState provisioningState() { + return this.innerModel().provisioningState(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public TopLevelArmResourceInner innerModel() { + return this.innerObject; + } + + private com.cadl.armresourceprovider.ArmResourceProviderManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String topLevelArmResourceName; + + private TopLevelArmResourceUpdate updateProperties; + + public TopLevelArmResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public TopLevelArmResource create() { + this.innerObject = serviceManager.serviceClient() + .getTopLevelArmResourceInterfaces() + .createOrUpdate(resourceGroupName, topLevelArmResourceName, this.innerModel(), Context.NONE); + return this; + } + + public TopLevelArmResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTopLevelArmResourceInterfaces() + .createOrUpdate(resourceGroupName, topLevelArmResourceName, this.innerModel(), context); + return this; + } + + TopLevelArmResourceImpl(String name, com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerObject = new TopLevelArmResourceInner(); + this.serviceManager = serviceManager; + this.topLevelArmResourceName = name; + } + + public TopLevelArmResourceImpl update() { + this.updateProperties = new TopLevelArmResourceUpdate(); + return this; + } + + public TopLevelArmResource apply() { + this.innerObject = serviceManager.serviceClient() + .getTopLevelArmResourceInterfaces() + .updateWithResponse(resourceGroupName, topLevelArmResourceName, updateProperties, Context.NONE) + .getValue(); + return this; + } + + public TopLevelArmResource apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTopLevelArmResourceInterfaces() + .updateWithResponse(resourceGroupName, topLevelArmResourceName, updateProperties, context) + .getValue(); + return this; + } + + TopLevelArmResourceImpl(TopLevelArmResourceInner innerObject, + com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.topLevelArmResourceName + = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "topLevelArmResources"); + } + + public TopLevelArmResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getTopLevelArmResourceInterfaces() + .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourceName, Context.NONE) + .getValue(); + return this; + } + + public TopLevelArmResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTopLevelArmResourceInterfaces() + .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourceName, context) + .getValue(); + return this; + } + + public Result action() { + return serviceManager.topLevelArmResourceInterfaces().action(resourceGroupName, topLevelArmResourceName); + } + + public Result action(Context context) { + return serviceManager.topLevelArmResourceInterfaces() + .action(resourceGroupName, topLevelArmResourceName, context); + } + + public TopLevelArmResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public TopLevelArmResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public TopLevelArmResourceImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateProperties.withTags(tags); + return this; + } + } + + public TopLevelArmResourceImpl withUserName(String userName) { + if (isInCreateMode()) { + this.innerModel().withUserName(userName); + return this; + } else { + this.updateProperties.withUserName(userName); + return this; + } + } + + public TopLevelArmResourceImpl withUserNames(String userNames) { + if (isInCreateMode()) { + this.innerModel().withUserNames(userNames); + return this; + } else { + this.updateProperties.withUserNames(userNames); + return this; + } + } + + public TopLevelArmResourceImpl withAccuserName(String accuserName) { + if (isInCreateMode()) { + this.innerModel().withAccuserName(accuserName); + return this; + } else { + this.updateProperties.withAccuserName(accuserName); + return this; + } + } + + public TopLevelArmResourceImpl withStartTimeStamp(OffsetDateTime startTimeStamp) { + this.innerModel().withStartTimeStamp(startTimeStamp); + return this; + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesClientImpl.java new file mode 100644 index 000000000..7b5b9ce13 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesClientImpl.java @@ -0,0 +1,1443 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +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.Post; +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.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.cadl.armresourceprovider.fluent.TopLevelArmResourceInterfacesClient; +import com.cadl.armresourceprovider.fluent.models.ResultInner; +import com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceInner; +import com.cadl.armresourceprovider.implementation.models.TopLevelArmResourceListResult; +import com.cadl.armresourceprovider.models.TopLevelArmResourceUpdate; +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 TopLevelArmResourceInterfacesClient. + */ +public final class TopLevelArmResourceInterfacesClientImpl implements TopLevelArmResourceInterfacesClient { + /** + * The proxy service used to perform REST calls. + */ + private final TopLevelArmResourceInterfacesService service; + + /** + * The service client containing this operation class. + */ + private final ArmResourceProviderClientImpl client; + + /** + * Initializes an instance of TopLevelArmResourceInterfacesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + TopLevelArmResourceInterfacesClientImpl(ArmResourceProviderClientImpl client) { + this.service = RestProxy.create(TopLevelArmResourceInterfacesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArmResourceProviderClientTopLevelArmResourceInterfaces to be used by + * the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArmResourceProviderC") + public interface TopLevelArmResourceInterfacesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}") + @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("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("Accept") String accept, + Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") TopLevelArmResourceInner resource, Context context); + + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") TopLevelArmResourceUpdate properties, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}") + @ExpectedResponses({ 200, 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Cadl.ArmResourceProvider/topLevelArmResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/action") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> action(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroupNext( + @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) + Mono> listBySubscriptionNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 TopLevelArmResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 TopLevelArmResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, context); + } + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 TopLevelArmResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, + String topLevelArmResourceName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, topLevelArmResourceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 TopLevelArmResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourceName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, topLevelArmResourceName, context).block(); + } + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 TopLevelArmResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelArmResourceInner getByResourceGroup(String resourceGroupName, String topLevelArmResourceName) { + return getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourceName, Context.NONE).getValue(); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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>> createOrUpdateWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, TopLevelArmResourceInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, contentType, accept, + resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, TopLevelArmResourceInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, contentType, accept, resource, + context); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TopLevelArmResourceInner> beginCreateOrUpdateAsync( + String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceInner resource) { + Mono>> mono + = createOrUpdateWithResponseAsync(resourceGroupName, topLevelArmResourceName, resource); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, + this.client.getContext()); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TopLevelArmResourceInner> beginCreateOrUpdateAsync( + String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceInner resource, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = createOrUpdateWithResponseAsync(resourceGroupName, topLevelArmResourceName, resource, context); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, context); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceInner resource) { + return this.beginCreateOrUpdateAsync(resourceGroupName, topLevelArmResourceName, resource).getSyncPoller(); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceInner resource, Context context) { + return this.beginCreateOrUpdateAsync(resourceGroupName, topLevelArmResourceName, resource, context) + .getSyncPoller(); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 createOrUpdateAsync(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceInner resource) { + return beginCreateOrUpdateAsync(resourceGroupName, topLevelArmResourceName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceInner resource, Context context) { + return beginCreateOrUpdateAsync(resourceGroupName, topLevelArmResourceName, resource, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceInner resource) { + return createOrUpdateAsync(resourceGroupName, topLevelArmResourceName, resource).block(); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceInner resource, Context context) { + return createOrUpdateAsync(resourceGroupName, topLevelArmResourceName, resource, context).block(); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 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> updateWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, TopLevelArmResourceUpdate properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, contentType, accept, + properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 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> updateWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, TopLevelArmResourceUpdate properties, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelArmResourceName, contentType, accept, properties, context); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 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 updateAsync(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceUpdate properties) { + return updateWithResponseAsync(resourceGroupName, topLevelArmResourceName, properties) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 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 updateWithResponse(String resourceGroupName, + String topLevelArmResourceName, TopLevelArmResourceUpdate properties, Context context) { + return updateWithResponseAsync(resourceGroupName, topLevelArmResourceName, properties, context).block(); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelArmResourceInner update(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceUpdate properties) { + return updateWithResponse(resourceGroupName, topLevelArmResourceName, properties, Context.NONE).getValue(); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelArmResourceName, accept, context); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, + String topLevelArmResourceName) { + Mono>> mono = deleteWithResponseAsync(resourceGroupName, topLevelArmResourceName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, + String topLevelArmResourceName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = deleteWithResponseAsync(resourceGroupName, topLevelArmResourceName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + context); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourceName) { + return this.beginDeleteAsync(resourceGroupName, topLevelArmResourceName).getSyncPoller(); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourceName, + Context context) { + return this.beginDeleteAsync(resourceGroupName, topLevelArmResourceName, context).getSyncPoller(); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String topLevelArmResourceName) { + return beginDeleteAsync(resourceGroupName, topLevelArmResourceName).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String topLevelArmResourceName, Context context) { + return beginDeleteAsync(resourceGroupName, topLevelArmResourceName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String topLevelArmResourceName) { + deleteAsync(resourceGroupName, topLevelArmResourceName).block(); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String topLevelArmResourceName, Context context) { + deleteAsync(resourceGroupName, topLevelArmResourceName, context).block(); + } + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, 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 TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelArmResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelArmResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, Context context) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @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 TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), 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 TopLevelArmResource resources by subscription 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 TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), accept, + context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @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 TopLevelArmResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * List TopLevelArmResource resources by subscription 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 TopLevelArmResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @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 TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List TopLevelArmResource resources by subscription 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 TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> actionWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.action(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> actionWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.action(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelArmResourceName, accept, context); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, ResultInner> beginActionAsync(String resourceGroupName, + String topLevelArmResourceName) { + Mono>> mono = actionWithResponseAsync(resourceGroupName, topLevelArmResourceName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + ResultInner.class, ResultInner.class, this.client.getContext()); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, ResultInner> beginActionAsync(String resourceGroupName, + String topLevelArmResourceName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = actionWithResponseAsync(resourceGroupName, topLevelArmResourceName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + ResultInner.class, ResultInner.class, context); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ResultInner> beginAction(String resourceGroupName, + String topLevelArmResourceName) { + return this.beginActionAsync(resourceGroupName, topLevelArmResourceName).getSyncPoller(); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ResultInner> beginAction(String resourceGroupName, + String topLevelArmResourceName, Context context) { + return this.beginActionAsync(resourceGroupName, topLevelArmResourceName, context).getSyncPoller(); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response body on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono actionAsync(String resourceGroupName, String topLevelArmResourceName) { + return beginActionAsync(resourceGroupName, topLevelArmResourceName).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response body on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono actionAsync(String resourceGroupName, String topLevelArmResourceName, Context context) { + return beginActionAsync(resourceGroupName, topLevelArmResourceName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResultInner action(String resourceGroupName, String topLevelArmResourceName) { + return actionAsync(resourceGroupName, topLevelArmResourceName).block(); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResultInner action(String resourceGroupName, String topLevelArmResourceName, Context context) { + return actionAsync(resourceGroupName, topLevelArmResourceName, context).block(); + } + + /** + * List TopLevelArmResource resources by resource group + * + * 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 TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByResourceGroupNext(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())); + } + + /** + * List TopLevelArmResource resources by resource group + * + * 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 TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List TopLevelArmResource resources by subscription ID + * + * 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 TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listBySubscriptionNext(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())); + } + + /** + * List TopLevelArmResource resources by subscription ID + * + * 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 TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> 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/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesImpl.java new file mode 100644 index 000000000..47f61a11d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesImpl.java @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation; + +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; +import com.cadl.armresourceprovider.fluent.TopLevelArmResourceInterfacesClient; +import com.cadl.armresourceprovider.fluent.models.ResultInner; +import com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceInner; +import com.cadl.armresourceprovider.models.Result; +import com.cadl.armresourceprovider.models.TopLevelArmResource; +import com.cadl.armresourceprovider.models.TopLevelArmResourceInterfaces; + +public final class TopLevelArmResourceInterfacesImpl implements TopLevelArmResourceInterfaces { + private static final ClientLogger LOGGER = new ClientLogger(TopLevelArmResourceInterfacesImpl.class); + + private final TopLevelArmResourceInterfacesClient innerClient; + + private final com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager; + + public TopLevelArmResourceInterfacesImpl(TopLevelArmResourceInterfacesClient innerClient, + com.cadl.armresourceprovider.ArmResourceProviderManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourceName, Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourceName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new TopLevelArmResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public TopLevelArmResource getByResourceGroup(String resourceGroupName, String topLevelArmResourceName) { + TopLevelArmResourceInner inner + = this.serviceClient().getByResourceGroup(resourceGroupName, topLevelArmResourceName); + if (inner != null) { + return new TopLevelArmResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String topLevelArmResourceName) { + this.serviceClient().delete(resourceGroupName, topLevelArmResourceName); + } + + public void delete(String resourceGroupName, String topLevelArmResourceName, Context context) { + this.serviceClient().delete(resourceGroupName, topLevelArmResourceName, context); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner + = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + + public Result action(String resourceGroupName, String topLevelArmResourceName) { + ResultInner inner = this.serviceClient().action(resourceGroupName, topLevelArmResourceName); + if (inner != null) { + return new ResultImpl(inner, this.manager()); + } else { + return null; + } + } + + public Result action(String resourceGroupName, String topLevelArmResourceName, Context context) { + ResultInner inner = this.serviceClient().action(resourceGroupName, topLevelArmResourceName, context); + if (inner != null) { + return new ResultImpl(inner, this.manager()); + } else { + return null; + } + } + + public TopLevelArmResource 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 topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourceName, 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 topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourceName, context); + } + + public void deleteById(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 topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + this.delete(resourceGroupName, topLevelArmResourceName, Context.NONE); + } + + public void deleteByIdWithResponse(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 topLevelArmResourceName = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourceName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + this.delete(resourceGroupName, topLevelArmResourceName, context); + } + + private TopLevelArmResourceInterfacesClient serviceClient() { + return this.innerClient; + } + + private com.cadl.armresourceprovider.ArmResourceProviderManager manager() { + return this.serviceManager; + } + + public TopLevelArmResourceImpl define(String name) { + return new TopLevelArmResourceImpl(name, this.manager()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/models/ChildExtensionResourceListResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/models/ChildExtensionResourceListResult.java new file mode 100644 index 000000000..bbe6be259 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/models/ChildExtensionResourceListResult.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.cadl.armresourceprovider.fluent.models.ChildExtensionResourceInner; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * The response of a ChildExtensionResource list operation. + */ +@Immutable +public final class ChildExtensionResourceListResult { + /* + * The ChildExtensionResource items on this page + */ + @JsonProperty(value = "value", required = true) + private List value; + + /* + * The link to the next page of items + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Creates an instance of ChildExtensionResourceListResult class. + */ + private ChildExtensionResourceListResult() { + } + + /** + * Get the value property: The ChildExtensionResource 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; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property value in model ChildExtensionResourceListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ChildExtensionResourceListResult.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/models/ChildResourceListResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/models/ChildResourceListResult.java new file mode 100644 index 000000000..fc49c2baf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/models/ChildResourceListResult.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.cadl.armresourceprovider.fluent.models.ChildResourceInner; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * The response of a ChildResource list operation. + */ +@Immutable +public final class ChildResourceListResult { + /* + * The ChildResource items on this page + */ + @JsonProperty(value = "value", required = true) + private List value; + + /* + * The link to the next page of items + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Creates an instance of ChildResourceListResult class. + */ + private ChildResourceListResult() { + } + + /** + * Get the value property: The ChildResource 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; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model ChildResourceListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ChildResourceListResult.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/models/OperationListResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/models/OperationListResult.java new file mode 100644 index 000000000..a0b13e0cd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/models/OperationListResult.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.cadl.armresourceprovider.fluent.models.OperationInner; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of + * results. + */ +@Immutable +public final class OperationListResult { + /* + * The Operation items on this page + */ + @JsonProperty(value = "value", required = true) + private List value; + + /* + * The link to the next page of items + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Creates an instance of OperationListResult class. + */ + private OperationListResult() { + } + + /** + * Get the value property: The Operation 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; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model OperationListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(OperationListResult.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/models/TopLevelArmResourceListResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/models/TopLevelArmResourceListResult.java new file mode 100644 index 000000000..cca4923b3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/models/TopLevelArmResourceListResult.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceInner; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * The response of a TopLevelArmResource list operation. + */ +@Immutable +public final class TopLevelArmResourceListResult { + /* + * The TopLevelArmResource items on this page + */ + @JsonProperty(value = "value", required = true) + private List value; + + /* + * The link to the next page of items + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Creates an instance of TopLevelArmResourceListResult class. + */ + private TopLevelArmResourceListResult() { + } + + /** + * Get the value property: The TopLevelArmResource 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; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property value in model TopLevelArmResourceListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(TopLevelArmResourceListResult.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/implementation/package-info.java new file mode 100644 index 000000000..0fca36a76 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/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 ArmResourceProvider. + * Arm Resource Provider management API. + */ +package com.cadl.armresourceprovider.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ActionType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ActionType.java new file mode 100644 index 000000000..93a5a6f09 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ActionType.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 com.cadl.armresourceprovider.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ +public final class ActionType extends ExpandableStringEnum { + /** + * Static value Internal for ActionType. + */ + public static final ActionType INTERNAL = fromString("Internal"); + + /** + * Creates a new instance of ActionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ActionType() { + } + + /** + * Creates or finds a ActionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ActionType. + */ + @JsonCreator + public static ActionType fromString(String name) { + return fromString(name, ActionType.class); + } + + /** + * Gets known ActionType values. + * + * @return known ActionType values. + */ + public static Collection values() { + return values(ActionType.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildExtensionResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildExtensionResource.java new file mode 100644 index 000000000..e22d58cb5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildExtensionResource.java @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.cadl.armresourceprovider.fluent.models.ChildExtensionResourceInner; + +/** + * An immutable client-side representation of ChildExtensionResource. + */ +public interface ChildExtensionResource { + /** + * 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. + */ + ChildExtensionResourceProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the inner com.cadl.armresourceprovider.fluent.models.ChildExtensionResourceInner object. + * + * @return the inner object. + */ + ChildExtensionResourceInner innerModel(); + + /** + * The entirety of the ChildExtensionResource definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The ChildExtensionResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the ChildExtensionResource definition. + */ + interface Blank extends WithParentResource { + } + + /** + * The stage of the ChildExtensionResource definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies resourceUri, topLevelArmResourceName. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @return the next definition stage. + */ + WithCreate withExistingTopLevelArmResource(String resourceUri, String topLevelArmResourceName); + } + + /** + * The stage of the ChildExtensionResource 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.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + ChildExtensionResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + ChildExtensionResource create(Context context); + } + + /** + * The stage of the ChildExtensionResource 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(ChildExtensionResourceProperties properties); + } + } + + /** + * Begins update for the ChildExtensionResource resource. + * + * @return the stage of resource update. + */ + ChildExtensionResource.Update update(); + + /** + * The template for ChildExtensionResource update. + */ + interface Update { + /** + * Executes the update request. + * + * @return the updated resource. + */ + ChildExtensionResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + ChildExtensionResource apply(Context context); + } + + /** + * The ChildExtensionResource update stages. + */ + interface UpdateStages { + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + ChildExtensionResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + ChildExtensionResource refresh(Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildExtensionResourceInterfaces.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildExtensionResourceInterfaces.java new file mode 100644 index 000000000..2c917a5c3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildExtensionResourceInterfaces.java @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of ChildExtensionResourceInterfaces. + */ +public interface ChildExtensionResourceInterfaces { + /** + * Get a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 ChildExtensionResource along with {@link Response}. + */ + Response getWithResponse(String resourceUri, String topLevelArmResourceName, + String childExtensionResourceName, Context context); + + /** + * Get a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 ChildExtensionResource. + */ + ChildExtensionResource get(String resourceUri, String topLevelArmResourceName, String childExtensionResourceName); + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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 delete(String resourceUri, String topLevelArmResourceName, String childExtensionResourceName); + + /** + * Delete a ChildExtensionResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName arm resource name for path. + * @param childExtensionResourceName ChildExtensionResources. + * @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. + */ + void delete(String resourceUri, String topLevelArmResourceName, String childExtensionResourceName, Context context); + + /** + * List ChildExtensionResource resources by TopLevelArmResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName 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 the response of a ChildExtensionResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByTopLevelArmResource(String resourceUri, String topLevelArmResourceName); + + /** + * List ChildExtensionResource resources by TopLevelArmResource. + * + * @param resourceUri The fully qualified Azure Resource manager identifier of the resource. + * @param topLevelArmResourceName 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 the response of a ChildExtensionResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByTopLevelArmResource(String resourceUri, String topLevelArmResourceName, + Context context); + + /** + * Get a ChildExtensionResource. + * + * @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 ChildExtensionResource along with {@link Response}. + */ + ChildExtensionResource getById(String id); + + /** + * Get a ChildExtensionResource. + * + * @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 ChildExtensionResource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a ChildExtensionResource. + * + * @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. + */ + void deleteById(String id); + + /** + * Delete a ChildExtensionResource. + * + * @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. + */ + void deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new ChildExtensionResource resource. + * + * @param name resource name. + * @return the first stage of the new ChildExtensionResource definition. + */ + ChildExtensionResource.DefinitionStages.Blank define(String name); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildExtensionResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildExtensionResourceProperties.java new file mode 100644 index 000000000..407738f85 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildExtensionResourceProperties.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Child ExtensionResource properties. + */ +@Immutable +public final class ChildExtensionResourceProperties { + /* + * Provisioning State of the Resource + */ + @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private ProvisioningState provisioningState; + + /** + * Creates an instance of ChildExtensionResourceProperties class. + */ + public ChildExtensionResourceProperties() { + } + + /** + * Get the provisioningState property: Provisioning State of the Resource. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildExtensionResourceUpdate.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildExtensionResourceUpdate.java new file mode 100644 index 000000000..4c79751ef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildExtensionResourceUpdate.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.annotation.Immutable; + +/** + * The type used for update operations of the ChildExtensionResource. + */ +@Immutable +public final class ChildExtensionResourceUpdate { + /** + * Creates an instance of ChildExtensionResourceUpdate class. + */ + public ChildExtensionResourceUpdate() { + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildResource.java new file mode 100644 index 000000000..6225e9254 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildResource.java @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.cadl.armresourceprovider.fluent.models.ChildResourceInner; +import java.util.Map; + +/** + * An immutable client-side representation of ChildResource. + */ +public interface ChildResource { + /** + * 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 systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the provisioningState property: Provisioning State of Top Level Arm Resource. + * + * @return the provisioningState value. + */ + ProvisioningState provisioningState(); + + /** + * 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 name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.cadl.armresourceprovider.fluent.models.ChildResourceInner object. + * + * @return the inner object. + */ + ChildResourceInner innerModel(); + + /** + * The entirety of the ChildResource definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The ChildResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the ChildResource definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the ChildResource 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. + */ + WithParentResource withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithParentResource withRegion(String location); + } + + /** + * The stage of the ChildResource definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies resourceGroupName, topLevelArmResourceName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @return the next definition stage. + */ + WithCreate withExistingTopLevelArmResource(String resourceGroupName, String topLevelArmResourceName); + } + + /** + * The stage of the ChildResource 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 { + /** + * Executes the create request. + * + * @return the created resource. + */ + ChildResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + ChildResource create(Context context); + } + + /** + * The stage of the ChildResource 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); + } + } + + /** + * Begins update for the ChildResource resource. + * + * @return the stage of resource update. + */ + ChildResource.Update update(); + + /** + * The template for ChildResource update. + */ + interface Update extends UpdateStages.WithTags { + /** + * Executes the update request. + * + * @return the updated resource. + */ + ChildResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + ChildResource apply(Context context); + } + + /** + * The ChildResource update stages. + */ + interface UpdateStages { + /** + * The stage of the ChildResource update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + ChildResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + ChildResource refresh(Context context); + + /** + * A long-running resource action. + * + * @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 actionWithoutBody(); + + /** + * A long-running resource action. + * + * @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. + */ + void actionWithoutBody(Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildResourceUpdate.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildResourceUpdate.java new file mode 100644 index 000000000..ddd79fccb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildResourceUpdate.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** + * The type used for update operations of the ChildResource. + */ +@Fluent +public final class ChildResourceUpdate { + /* + * Resource tags. + */ + @JsonProperty(value = "tags") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) + private Map tags; + + /** + * Creates an instance of ChildResourceUpdate class. + */ + public ChildResourceUpdate() { + } + + /** + * Get the tags property: Resource tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Resource tags. + * + * @param tags the tags value to set. + * @return the ChildResourceUpdate object itself. + */ + public ChildResourceUpdate withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildResourcesInterfaces.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildResourcesInterfaces.java new file mode 100644 index 000000000..36c43f566 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ChildResourcesInterfaces.java @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of ChildResourcesInterfaces. + */ +public interface ChildResourcesInterfaces { + /** + * Get a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 ChildResource along with {@link Response}. + */ + Response getWithResponse(String resourceGroupName, String topLevelArmResourceName, + String childResourceName, Context context); + + /** + * Get a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 ChildResource. + */ + ChildResource get(String resourceGroupName, String topLevelArmResourceName, String childResourceName); + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 delete(String resourceGroupName, String topLevelArmResourceName, String childResourceName); + + /** + * Delete a ChildResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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. + */ + void delete(String resourceGroupName, String topLevelArmResourceName, String childResourceName, Context context); + + /** + * List ChildResource resources by TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response of a ChildResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByTopLevelArmResource(String resourceGroupName, String topLevelArmResourceName); + + /** + * List ChildResource resources by TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response of a ChildResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByTopLevelArmResource(String resourceGroupName, String topLevelArmResourceName, + Context context); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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 actionWithoutBody(String resourceGroupName, String topLevelArmResourceName, String childResourceName); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @param childResourceName ChildResources. + * @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. + */ + void actionWithoutBody(String resourceGroupName, String topLevelArmResourceName, String childResourceName, + Context context); + + /** + * Get a ChildResource. + * + * @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 ChildResource along with {@link Response}. + */ + ChildResource getById(String id); + + /** + * Get a ChildResource. + * + * @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 ChildResource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a ChildResource. + * + * @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. + */ + void deleteById(String id); + + /** + * Delete a ChildResource. + * + * @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. + */ + void deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new ChildResource resource. + * + * @param name resource name. + * @return the first stage of the new ChildResource definition. + */ + ChildResource.DefinitionStages.Blank define(String name); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/CustomTemplateResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/CustomTemplateResource.java new file mode 100644 index 000000000..5414d91d9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/CustomTemplateResource.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.cadl.armresourceprovider.fluent.models.CustomTemplateResourceInner; +import java.util.Map; + +/** + * An immutable client-side representation of CustomTemplateResource. + */ +public interface CustomTemplateResource { + /** + * 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 identity property: Managed identity. + * + * @return the identity value. + */ + ManagedServiceIdentity identity(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + ProvisioningState provisioningState(); + + /** + * Gets the dog property: The dog property. + * + * @return the dog value. + */ + Dog dog(); + + /** + * Gets the namedEmptyModel property: The namedEmptyModel property. + * + * @return the namedEmptyModel value. + */ + EmptyModel namedEmptyModel(); + + /** + * Gets the anonymousEmptyModel property: The anonymousEmptyModel property. + * + * @return the anonymousEmptyModel value. + */ + CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel(); + + /** + * 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 name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.cadl.armresourceprovider.fluent.models.CustomTemplateResourceInner object. + * + * @return the inner object. + */ + CustomTemplateResourceInner innerModel(); + + /** + * The entirety of the CustomTemplateResource definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The CustomTemplateResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the CustomTemplateResource definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the CustomTemplateResource 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 CustomTemplateResource 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 CustomTemplateResource 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.WithIdentity, DefinitionStages.WithDog, + DefinitionStages.WithNamedEmptyModel, DefinitionStages.WithAnonymousEmptyModel, + DefinitionStages.WithIfMatch, DefinitionStages.WithIfNoneMatch { + /** + * Executes the create request. + * + * @return the created resource. + */ + CustomTemplateResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + CustomTemplateResource create(Context context); + } + + /** + * The stage of the CustomTemplateResource 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 CustomTemplateResource definition allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: Managed identity.. + * + * @param identity Managed identity. + * @return the next definition stage. + */ + WithCreate withIdentity(ManagedServiceIdentity identity); + } + + /** + * The stage of the CustomTemplateResource definition allowing to specify dog. + */ + interface WithDog { + /** + * Specifies the dog property: The dog property.. + * + * @param dog The dog property. + * @return the next definition stage. + */ + WithCreate withDog(Dog dog); + } + + /** + * The stage of the CustomTemplateResource definition allowing to specify namedEmptyModel. + */ + interface WithNamedEmptyModel { + /** + * Specifies the namedEmptyModel property: The namedEmptyModel property.. + * + * @param namedEmptyModel The namedEmptyModel property. + * @return the next definition stage. + */ + WithCreate withNamedEmptyModel(EmptyModel namedEmptyModel); + } + + /** + * The stage of the CustomTemplateResource definition allowing to specify anonymousEmptyModel. + */ + interface WithAnonymousEmptyModel { + /** + * Specifies the anonymousEmptyModel property: The anonymousEmptyModel property.. + * + * @param anonymousEmptyModel The anonymousEmptyModel property. + * @return the next definition stage. + */ + WithCreate withAnonymousEmptyModel(CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel); + } + + /** + * The stage of the CustomTemplateResource definition allowing to specify ifMatch. + */ + interface WithIfMatch { + /** + * Specifies the ifMatch property: The request should only proceed if an entity matches this string.. + * + * @param ifMatch The request should only proceed if an entity matches this string. + * @return the next definition stage. + */ + WithCreate withIfMatch(String ifMatch); + } + + /** + * The stage of the CustomTemplateResource definition allowing to specify ifNoneMatch. + */ + interface WithIfNoneMatch { + /** + * Specifies the ifNoneMatch property: The request should only proceed if no entity matches this string.. + * + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @return the next definition stage. + */ + WithCreate withIfNoneMatch(String ifNoneMatch); + } + } + + /** + * Begins update for the CustomTemplateResource resource. + * + * @return the stage of resource update. + */ + CustomTemplateResource.Update update(); + + /** + * The template for CustomTemplateResource update. + */ + interface Update extends UpdateStages.WithIdentity { + /** + * Executes the update request. + * + * @return the updated resource. + */ + CustomTemplateResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + CustomTemplateResource apply(Context context); + } + + /** + * The CustomTemplateResource update stages. + */ + interface UpdateStages { + /** + * The stage of the CustomTemplateResource update allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: Managed identity.. + * + * @param identity Managed identity. + * @return the next definition stage. + */ + Update withIdentity(ManagedServiceIdentity identity); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/CustomTemplateResourceInterfaces.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/CustomTemplateResourceInterfaces.java new file mode 100644 index 000000000..50a2b4277 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/CustomTemplateResourceInterfaces.java @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +/** + * Resource collection API of CustomTemplateResourceInterfaces. + */ +public interface CustomTemplateResourceInterfaces { + /** + * Begins definition for a new CustomTemplateResource resource. + * + * @param name resource name. + * @return the first stage of the new CustomTemplateResource definition. + */ + CustomTemplateResource.DefinitionStages.Blank define(String name); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/CustomTemplateResourcePatch.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/CustomTemplateResourcePatch.java new file mode 100644 index 000000000..8aa002350 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/CustomTemplateResourcePatch.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The CustomTemplateResourcePatch model. + */ +@Fluent +public final class CustomTemplateResourcePatch { + /* + * Managed identity. + */ + @JsonProperty(value = "identity") + private ManagedServiceIdentity identity; + + /** + * Creates an instance of CustomTemplateResourcePatch class. + */ + public CustomTemplateResourcePatch() { + } + + /** + * Get the identity property: Managed identity. + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: Managed identity. + * + * @param identity the identity value to set. + * @return the CustomTemplateResourcePatch object itself. + */ + public CustomTemplateResourcePatch withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (identity() != null) { + identity().validate(); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/CustomTemplateResourcePropertiesAnonymousEmptyModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/CustomTemplateResourcePropertiesAnonymousEmptyModel.java new file mode 100644 index 000000000..ac4c616b1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/CustomTemplateResourcePropertiesAnonymousEmptyModel.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.annotation.Immutable; + +/** + * The CustomTemplateResourcePropertiesAnonymousEmptyModel model. + */ +@Immutable +public final class CustomTemplateResourcePropertiesAnonymousEmptyModel { + /** + * Creates an instance of CustomTemplateResourcePropertiesAnonymousEmptyModel class. + */ + public CustomTemplateResourcePropertiesAnonymousEmptyModel() { + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Dog.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Dog.java new file mode 100644 index 000000000..86e782823 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Dog.java @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeId; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Test extensible enum type for discriminator. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "kind", defaultImpl = Dog.class, visible = true) +@JsonTypeName("Dog") +@JsonSubTypes({ @JsonSubTypes.Type(name = "golden", value = Golden.class) }) +@Fluent +public class Dog { + /* + * discriminator property + */ + @JsonTypeId + @JsonProperty(value = "kind", required = true) + DogKind kind; + + /* + * Weight of the dog + */ + @JsonProperty(value = "weight", required = true) + private int weight; + + /** + * Creates an instance of Dog class. + */ + public Dog() { + this.kind = DogKind.fromString("Dog"); + } + + /** + * Get the kind property: discriminator property. + * + * @return the kind value. + */ + public DogKind kind() { + return this.kind; + } + + /** + * Get the weight property: Weight of the dog. + * + * @return the weight value. + */ + public int weight() { + return this.weight; + } + + /** + * Set the weight property: Weight of the dog. + * + * @param weight the weight value to set. + * @return the Dog object itself. + */ + public Dog withWeight(int weight) { + this.weight = weight; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/DogKind.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/DogKind.java new file mode 100644 index 000000000..5346ed18c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/DogKind.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 com.cadl.armresourceprovider.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** + * extensible enum type for discriminator. + */ +public final class DogKind extends ExpandableStringEnum { + /** + * Static value golden for DogKind. + */ + public static final DogKind GOLDEN = fromString("golden"); + + /** + * Creates a new instance of DogKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DogKind() { + } + + /** + * Creates or finds a DogKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding DogKind. + */ + @JsonCreator + public static DogKind fromString(String name) { + return fromString(name, DogKind.class); + } + + /** + * Gets known DogKind values. + * + * @return known DogKind values. + */ + public static Collection values() { + return values(DogKind.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/EmptyModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/EmptyModel.java new file mode 100644 index 000000000..bbae5879e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/EmptyModel.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.annotation.Immutable; + +/** + * Empty model. + */ +@Immutable +public final class EmptyModel { + /** + * Creates an instance of EmptyModel class. + */ + public EmptyModel() { + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Golden.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Golden.java new file mode 100644 index 000000000..077195d19 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Golden.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Golden dog model. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "kind", defaultImpl = Golden.class, visible = true) +@JsonTypeName("golden") +@Fluent +public final class Golden extends Dog { + /** + * Creates an instance of Golden class. + */ + public Golden() { + this.kind = DogKind.GOLDEN; + } + + /** + * {@inheritDoc} + */ + @Override + public Golden withWeight(int weight) { + super.withWeight(weight); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ManagedServiceIdentity.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ManagedServiceIdentity.java new file mode 100644 index 000000000..1fea7ca78 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ManagedServiceIdentity.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** + * Managed service identity (system assigned and/or user assigned identities). + */ +@Fluent +public final class ManagedServiceIdentity { + /* + * The service principal ID of the system assigned identity. This property will only be provided for a system + * assigned identity. + */ + @JsonProperty(value = "principalId", access = JsonProperty.Access.WRITE_ONLY) + private String principalId; + + /* + * The tenant ID of the system assigned identity. This property will only be provided for a system assigned + * identity. + */ + @JsonProperty(value = "tenantId", access = JsonProperty.Access.WRITE_ONLY) + private String tenantId; + + /* + * The type of managed identity assigned to this resource. + */ + @JsonProperty(value = "type", required = true) + private ManagedServiceIdentityType type; + + /* + * The identities assigned to this resource by the user. + */ + @JsonProperty(value = "userAssignedIdentities") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) + private Map userAssignedIdentities; + + /** + * Creates an instance of ManagedServiceIdentity class. + */ + public ManagedServiceIdentity() { + } + + /** + * Get the principalId property: The service principal ID of the system assigned identity. This property will only + * be provided for a system assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The tenant ID of the system assigned identity. This property will only be provided for + * a system assigned identity. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Get the type property: The type of managed identity assigned to this resource. + * + * @return the type value. + */ + public ManagedServiceIdentityType type() { + return this.type; + } + + /** + * Set the type property: The type of managed identity assigned to this resource. + * + * @param type the type value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withType(ManagedServiceIdentityType type) { + this.type = type; + return this; + } + + /** + * Get the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (type() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property type in model ManagedServiceIdentity")); + } + if (userAssignedIdentities() != null) { + userAssignedIdentities().values().forEach(e -> { + if (e != null) { + e.validate(); + } + }); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ManagedServiceIdentity.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ManagedServiceIdentityType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ManagedServiceIdentityType.java new file mode 100644 index 000000000..3870b028d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ManagedServiceIdentityType.java @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + */ +public final class ManagedServiceIdentityType extends ExpandableStringEnum { + /** + * Static value None for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType NONE = fromString("None"); + + /** + * Static value SystemAssigned for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); + + /** + * Static value UserAssigned for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType USER_ASSIGNED = fromString("UserAssigned"); + + /** + * Static value SystemAssigned,UserAssigned for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED_USER_ASSIGNED + = fromString("SystemAssigned,UserAssigned"); + + /** + * Creates a new instance of ManagedServiceIdentityType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ManagedServiceIdentityType() { + } + + /** + * Creates or finds a ManagedServiceIdentityType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ManagedServiceIdentityType. + */ + @JsonCreator + public static ManagedServiceIdentityType fromString(String name) { + return fromString(name, ManagedServiceIdentityType.class); + } + + /** + * Gets known ManagedServiceIdentityType values. + * + * @return known ManagedServiceIdentityType values. + */ + public static Collection values() { + return values(ManagedServiceIdentityType.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Operation.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Operation.java new file mode 100644 index 000000000..550f03e49 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Operation.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.cadl.armresourceprovider.fluent.models.OperationInner; + +/** + * An immutable client-side representation of Operation. + */ +public interface Operation { + /** + * Gets the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + String name(); + + /** + * Gets the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for Azure Resource Manager/control-plane operations. + * + * @return the isDataAction value. + */ + Boolean isDataAction(); + + /** + * Gets the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + Origin origin(); + + /** + * Gets the actionType property: Extensible enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + * + * @return the actionType value. + */ + ActionType actionType(); + + /** + * Gets the inner com.cadl.armresourceprovider.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/OperationDisplay.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/OperationDisplay.java new file mode 100644 index 000000000..423f6898a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/OperationDisplay.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Localized display information for and operation. + */ +@Immutable +public final class OperationDisplay { + /* + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or + * "Microsoft Compute". + */ + @JsonProperty(value = "provider", access = JsonProperty.Access.WRITE_ONLY) + private String provider; + + /* + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or + * "Job Schedule Collections". + */ + @JsonProperty(value = "resource", access = JsonProperty.Access.WRITE_ONLY) + private String resource; + + /* + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + */ + @JsonProperty(value = "operation", access = JsonProperty.Access.WRITE_ONLY) + private String operation; + + /* + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + */ + @JsonProperty(value = "description", access = JsonProperty.Access.WRITE_ONLY) + private String description; + + /** + * Creates an instance of OperationDisplay class. + */ + private OperationDisplay() { + } + + /** + * Get the provider property: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring + * Insights" or "Microsoft Compute". + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Get the resource property: The localized friendly name of the resource type related to this operation. E.g. + * "Virtual Machines" or "Job Schedule Collections". + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation property: The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Get the description property: The short, localized friendly description of the operation; suitable for tool tips + * and detailed views. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Operations.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Operations.java new file mode 100644 index 000000000..79825d9b2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Operations.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** + * Resource collection API of Operations. + */ +public interface Operations { + /** + * List the operations for the provider. + * + * @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 list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @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 list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Origin.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Origin.java new file mode 100644 index 000000000..9292d338d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Origin.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value + * is "user,system". + */ +public final class Origin extends ExpandableStringEnum { + /** + * Static value user for Origin. + */ + public static final Origin USER = fromString("user"); + + /** + * Static value system for Origin. + */ + public static final Origin SYSTEM = fromString("system"); + + /** + * Static value user,system for Origin. + */ + public static final Origin USER_SYSTEM = fromString("user,system"); + + /** + * Creates a new instance of Origin value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Origin() { + } + + /** + * Creates or finds a Origin from its string representation. + * + * @param name a name to look for. + * @return the corresponding Origin. + */ + @JsonCreator + public static Origin fromString(String name) { + return fromString(name, Origin.class); + } + + /** + * Gets known Origin values. + * + * @return known Origin values. + */ + public static Collection values() { + return values(Origin.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ProvisioningState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ProvisioningState.java new file mode 100644 index 000000000..858787464 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/ProvisioningState.java @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** + * Defines values for ProvisioningState. + */ +public final class ProvisioningState extends ExpandableStringEnum { + /** + * Static value Succeeded for ProvisioningState. + */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Static value Failed for ProvisioningState. + */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** + * Static value Canceled for ProvisioningState. + */ + 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. + */ + @JsonCreator + 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/com/cadl/armresourceprovider/models/Result.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Result.java new file mode 100644 index 000000000..859ffb8e2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/Result.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.cadl.armresourceprovider.fluent.models.ResultInner; + +/** + * An immutable client-side representation of Result. + */ +public interface Result { + /** + * Gets the reason property: The reason property. + * + * @return the reason value. + */ + String reason(); + + /** + * Gets the inner com.cadl.armresourceprovider.fluent.models.ResultInner object. + * + * @return the inner object. + */ + ResultInner innerModel(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/TopLevelArmResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/TopLevelArmResource.java new file mode 100644 index 000000000..42ba3705d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/TopLevelArmResource.java @@ -0,0 +1,389 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceInner; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Map; + +/** + * An immutable client-side representation of TopLevelArmResource. + */ +public interface TopLevelArmResource { + /** + * 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 systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the configurationEndpoints property: Configuration Endpoints. + * + * @return the configurationEndpoints value. + */ + List configurationEndpoints(); + + /** + * Gets the userName property: The userName property. + * + * @return the userName value. + */ + String userName(); + + /** + * Gets the userNames property: The userNames property. + * + * @return the userNames value. + */ + String userNames(); + + /** + * Gets the accuserName property: The accuserName property. + * + * @return the accuserName value. + */ + String accuserName(); + + /** + * Gets the startTimeStamp property: The startTimeStamp property. + * + * @return the startTimeStamp value. + */ + OffsetDateTime startTimeStamp(); + + /** + * Gets the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + ProvisioningState provisioningState(); + + /** + * 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 name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceInner object. + * + * @return the inner object. + */ + TopLevelArmResourceInner innerModel(); + + /** + * The entirety of the TopLevelArmResource definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The TopLevelArmResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the TopLevelArmResource definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the TopLevelArmResource 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 TopLevelArmResource 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 TopLevelArmResource 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.WithUserName, + DefinitionStages.WithUserNames, DefinitionStages.WithAccuserName, DefinitionStages.WithStartTimeStamp { + /** + * Executes the create request. + * + * @return the created resource. + */ + TopLevelArmResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + TopLevelArmResource create(Context context); + } + + /** + * The stage of the TopLevelArmResource 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 TopLevelArmResource definition allowing to specify userName. + */ + interface WithUserName { + /** + * Specifies the userName property: The userName property.. + * + * @param userName The userName property. + * @return the next definition stage. + */ + WithCreate withUserName(String userName); + } + + /** + * The stage of the TopLevelArmResource definition allowing to specify userNames. + */ + interface WithUserNames { + /** + * Specifies the userNames property: The userNames property.. + * + * @param userNames The userNames property. + * @return the next definition stage. + */ + WithCreate withUserNames(String userNames); + } + + /** + * The stage of the TopLevelArmResource definition allowing to specify accuserName. + */ + interface WithAccuserName { + /** + * Specifies the accuserName property: The accuserName property.. + * + * @param accuserName The accuserName property. + * @return the next definition stage. + */ + WithCreate withAccuserName(String accuserName); + } + + /** + * The stage of the TopLevelArmResource definition allowing to specify startTimeStamp. + */ + interface WithStartTimeStamp { + /** + * Specifies the startTimeStamp property: The startTimeStamp property.. + * + * @param startTimeStamp The startTimeStamp property. + * @return the next definition stage. + */ + WithCreate withStartTimeStamp(OffsetDateTime startTimeStamp); + } + } + + /** + * Begins update for the TopLevelArmResource resource. + * + * @return the stage of resource update. + */ + TopLevelArmResource.Update update(); + + /** + * The template for TopLevelArmResource update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithUserName, UpdateStages.WithUserNames, + UpdateStages.WithAccuserName { + /** + * Executes the update request. + * + * @return the updated resource. + */ + TopLevelArmResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + TopLevelArmResource apply(Context context); + } + + /** + * The TopLevelArmResource update stages. + */ + interface UpdateStages { + /** + * The stage of the TopLevelArmResource update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the TopLevelArmResource update allowing to specify userName. + */ + interface WithUserName { + /** + * Specifies the userName property: The userName property.. + * + * @param userName The userName property. + * @return the next definition stage. + */ + Update withUserName(String userName); + } + + /** + * The stage of the TopLevelArmResource update allowing to specify userNames. + */ + interface WithUserNames { + /** + * Specifies the userNames property: The userNames property.. + * + * @param userNames The userNames property. + * @return the next definition stage. + */ + Update withUserNames(String userNames); + } + + /** + * The stage of the TopLevelArmResource update allowing to specify accuserName. + */ + interface WithAccuserName { + /** + * Specifies the accuserName property: The accuserName property.. + * + * @param accuserName The accuserName property. + * @return the next definition stage. + */ + Update withAccuserName(String accuserName); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + TopLevelArmResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + TopLevelArmResource refresh(Context context); + + /** + * A long-running resource action. + * + * @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. + */ + Result action(); + + /** + * A long-running resource action. + * + * @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. + */ + Result action(Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/TopLevelArmResourceInterfaces.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/TopLevelArmResourceInterfaces.java new file mode 100644 index 000000000..b084c3eed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/TopLevelArmResourceInterfaces.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 com.cadl.armresourceprovider.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of TopLevelArmResourceInterfaces. + */ +public interface TopLevelArmResourceInterfaces { + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 TopLevelArmResource along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourceName, Context context); + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 TopLevelArmResource. + */ + TopLevelArmResource getByResourceGroup(String resourceGroupName, String topLevelArmResourceName); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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. + */ + void deleteByResourceGroup(String resourceGroupName, String topLevelArmResourceName); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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. + */ + void delete(String resourceGroupName, String topLevelArmResourceName, Context context); + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @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 TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @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 TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List TopLevelArmResource resources by subscription 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 TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response. + */ + Result action(String resourceGroupName, String topLevelArmResourceName); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName 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 the response. + */ + Result action(String resourceGroupName, String topLevelArmResourceName, Context context); + + /** + * Get a TopLevelArmResource. + * + * @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 TopLevelArmResource along with {@link Response}. + */ + TopLevelArmResource getById(String id); + + /** + * Get a TopLevelArmResource. + * + * @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 TopLevelArmResource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a TopLevelArmResource. + * + * @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. + */ + void deleteById(String id); + + /** + * Delete a TopLevelArmResource. + * + * @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. + */ + void deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new TopLevelArmResource resource. + * + * @param name resource name. + * @return the first stage of the new TopLevelArmResource definition. + */ + TopLevelArmResource.DefinitionStages.Blank define(String name); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/TopLevelArmResourceUpdate.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/TopLevelArmResourceUpdate.java new file mode 100644 index 000000000..c23f6abcb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/TopLevelArmResourceUpdate.java @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.annotation.Fluent; +import com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceUpdateProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** + * The type used for update operations of the TopLevelArmResource. + */ +@Fluent +public final class TopLevelArmResourceUpdate { + /* + * Resource tags. + */ + @JsonProperty(value = "tags") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) + private Map tags; + + /* + * The resource-specific properties for this resource. + */ + @JsonProperty(value = "properties") + private TopLevelArmResourceUpdateProperties innerProperties; + + /** + * Creates an instance of TopLevelArmResourceUpdate class. + */ + public TopLevelArmResourceUpdate() { + } + + /** + * Get the tags property: Resource tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Resource tags. + * + * @param tags the tags value to set. + * @return the TopLevelArmResourceUpdate object itself. + */ + public TopLevelArmResourceUpdate withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the innerProperties property: The resource-specific properties for this resource. + * + * @return the innerProperties value. + */ + private TopLevelArmResourceUpdateProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the userName property: The userName property. + * + * @return the userName value. + */ + public String userName() { + return this.innerProperties() == null ? null : this.innerProperties().userName(); + } + + /** + * Set the userName property: The userName property. + * + * @param userName the userName value to set. + * @return the TopLevelArmResourceUpdate object itself. + */ + public TopLevelArmResourceUpdate withUserName(String userName) { + if (this.innerProperties() == null) { + this.innerProperties = new TopLevelArmResourceUpdateProperties(); + } + this.innerProperties().withUserName(userName); + return this; + } + + /** + * Get the userNames property: The userNames property. + * + * @return the userNames value. + */ + public String userNames() { + return this.innerProperties() == null ? null : this.innerProperties().userNames(); + } + + /** + * Set the userNames property: The userNames property. + * + * @param userNames the userNames value to set. + * @return the TopLevelArmResourceUpdate object itself. + */ + public TopLevelArmResourceUpdate withUserNames(String userNames) { + if (this.innerProperties() == null) { + this.innerProperties = new TopLevelArmResourceUpdateProperties(); + } + this.innerProperties().withUserNames(userNames); + return this; + } + + /** + * Get the accuserName property: The accuserName property. + * + * @return the accuserName value. + */ + public String accuserName() { + return this.innerProperties() == null ? null : this.innerProperties().accuserName(); + } + + /** + * Set the accuserName property: The accuserName property. + * + * @param accuserName the accuserName value to set. + * @return the TopLevelArmResourceUpdate object itself. + */ + public TopLevelArmResourceUpdate withAccuserName(String accuserName) { + if (this.innerProperties() == null) { + this.innerProperties = new TopLevelArmResourceUpdateProperties(); + } + this.innerProperties().withAccuserName(accuserName); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/UserAssignedIdentity.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/UserAssignedIdentity.java new file mode 100644 index 000000000..9e87ef5b4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/UserAssignedIdentity.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armresourceprovider.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * User assigned identity properties. + */ +@Immutable +public final class UserAssignedIdentity { + /* + * The principal ID of the assigned identity. + */ + @JsonProperty(value = "principalId", access = JsonProperty.Access.WRITE_ONLY) + private String principalId; + + /* + * The client ID of the assigned identity. + */ + @JsonProperty(value = "clientId", access = JsonProperty.Access.WRITE_ONLY) + private String clientId; + + /** + * Creates an instance of UserAssignedIdentity class. + */ + public UserAssignedIdentity() { + } + + /** + * Get the principalId property: The principal ID of the assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the clientId property: The client ID of the assigned identity. + * + * @return the clientId value. + */ + public String clientId() { + return this.clientId; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/models/package-info.java new file mode 100644 index 000000000..98913fc60 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/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 ArmResourceProvider. + * Arm Resource Provider management API. + */ +package com.cadl.armresourceprovider.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/package-info.java new file mode 100644 index 000000000..306851c83 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armresourceprovider/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 ArmResourceProvider. + * Arm Resource Provider management API. + */ +package com.cadl.armresourceprovider; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/ArmStreamStyleSerializationManager.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/ArmStreamStyleSerializationManager.java new file mode 100644 index 000000000..40fc78d92 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/ArmStreamStyleSerializationManager.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 com.cadl.armstreamstyleserialization; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpPipeline; +import com.azure.core.management.profile.AzureProfile; +import com.cadl.armstreamstyleserialization.fluent.ArmStreamStyleSerializationClient; +import com.cadl.armstreamstyleserialization.implementation.ArmStreamStyleSerializationClientBuilder; +import com.cadl.armstreamstyleserialization.implementation.FishesImpl; +import com.cadl.armstreamstyleserialization.implementation.TopLevelArmResourcesImpl; +import com.cadl.armstreamstyleserialization.models.Fishes; +import com.cadl.armstreamstyleserialization.models.TopLevelArmResources; +import java.time.Duration; +import java.util.Objects; + +/** + * Entry point to ArmStreamStyleSerializationManager. + * Arm Resource Provider management API. + */ +public final class ArmStreamStyleSerializationManager { + private Fishes fishes; + + private TopLevelArmResources topLevelArmResources; + + private final ArmStreamStyleSerializationClient clientObject; + + private ArmStreamStyleSerializationManager(HttpPipeline httpPipeline, AzureProfile profile, + Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new ArmStreamStyleSerializationClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of ArmStreamStyleSerialization service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ArmStreamStyleSerialization service API instance. + */ + public static ArmStreamStyleSerializationManager 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 ArmStreamStyleSerialization service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the ArmStreamStyleSerialization service API instance. + */ + public static ArmStreamStyleSerializationManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new ArmStreamStyleSerializationManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create ArmStreamStyleSerializationManager with optional + * configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new ArmStreamStyleSerializationManager.Configurable(); + } + + /** + * Gets the resource collection API of Fishes. + * + * @return Resource collection API of Fishes. + */ + public Fishes fishes() { + if (this.fishes == null) { + this.fishes = new FishesImpl(clientObject.getFishes(), this); + } + return fishes; + } + + /** + * Gets the resource collection API of TopLevelArmResources. + * + * @return Resource collection API of TopLevelArmResources. + */ + public TopLevelArmResources topLevelArmResources() { + if (this.topLevelArmResources == null) { + this.topLevelArmResources = new TopLevelArmResourcesImpl(clientObject.getTopLevelArmResources(), this); + } + return topLevelArmResources; + } + + /** + * Gets wrapped service client ArmStreamStyleSerializationClient providing direct access to the underlying + * auto-generated API implementation, based on Azure REST API. + * + * @return Wrapped service client ArmStreamStyleSerializationClient. + */ + public ArmStreamStyleSerializationClient serviceClient() { + return this.clientObject; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/ArmStreamStyleSerializationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/ArmStreamStyleSerializationClient.java new file mode 100644 index 000000000..ce6c002ee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/ArmStreamStyleSerializationClient.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for ArmStreamStyleSerializationClient class. + */ +public interface ArmStreamStyleSerializationClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * 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 FishesClient object to access its operations. + * + * @return the FishesClient object. + */ + FishesClient getFishes(); + + /** + * Gets the TopLevelArmResourcesClient object to access its operations. + * + * @return the TopLevelArmResourcesClient object. + */ + TopLevelArmResourcesClient getTopLevelArmResources(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/FishesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/FishesClient.java new file mode 100644 index 000000000..099569dab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/FishesClient.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 com.cadl.armstreamstyleserialization.fluent; + +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; +import com.cadl.armstreamstyleserialization.fluent.models.FishInner; +import com.cadl.armstreamstyleserialization.fluent.models.OutputOnlyModelInner; + +/** + * An instance of this class provides access to all the operations defined in FishesClient. + */ +public interface FishesClient { + /** + * The getModel operation. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.cadl.armstreamstyleserialization.models.ErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getModelWithResponse(Context context); + + /** + * The getModel operation. + * + * @throws com.cadl.armstreamstyleserialization.models.ErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + FishInner getModel(); + + /** + * The putModel operation. + * + * @param fish The fish parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.cadl.armstreamstyleserialization.models.ErrorMinException thrown if the request is rejected by + * server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response putModelWithResponse(FishInner fish, Context context); + + /** + * The putModel operation. + * + * @param fish The fish parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.cadl.armstreamstyleserialization.models.ErrorMinException thrown if the request is rejected by + * server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + FishInner putModel(FishInner fish); + + /** + * The getOutputOnlyModel operation. + * + * @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 this is base model for polymorphic OutputOnlyModel along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getOutputOnlyModelWithResponse(Context context); + + /** + * The getOutputOnlyModel operation. + * + * @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 this is base model for polymorphic OutputOnlyModel. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + OutputOnlyModelInner getOutputOnlyModel(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/TopLevelArmResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/TopLevelArmResourcesClient.java new file mode 100644 index 000000000..cd76b3fb4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/TopLevelArmResourcesClient.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.cadl.armstreamstyleserialization.fluent.models.TopLevelArmResourceInner; +import com.cadl.armstreamstyleserialization.models.TopLevelArmResourceTagsUpdate; + +/** + * An instance of this class provides access to all the operations defined in TopLevelArmResourcesClient. + */ +public interface TopLevelArmResourcesClient { + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelArmResourceInner> beginUpdate(String resourceGroupName, + String topLevelArmResourceName, TopLevelArmResourceTagsUpdate properties); + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelArmResourceInner> beginUpdate(String resourceGroupName, + String topLevelArmResourceName, TopLevelArmResourceTagsUpdate properties, Context context); + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelArmResourceInner update(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceTagsUpdate properties); + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelArmResourceInner update(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceTagsUpdate properties, Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/AnotherFishProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/AnotherFishProperties.java new file mode 100644 index 000000000..8032e5368 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/AnotherFishProperties.java @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +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 AnotherFishProperties model. + */ +@Fluent +public final class AnotherFishProperties implements JsonSerializable { + /* + * The eyeProperties property. + */ + private EyeProperties innerEyeProperties = new EyeProperties(); + + /** + * Creates an instance of AnotherFishProperties class. + */ + public AnotherFishProperties() { + } + + /** + * Get the innerEyeProperties property: The eyeProperties property. + * + * @return the innerEyeProperties value. + */ + private EyeProperties innerEyeProperties() { + return this.innerEyeProperties; + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double length() { + return this.innerEyeProperties() == null ? 0.0 : this.innerEyeProperties().length(); + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the AnotherFishProperties object itself. + */ + public AnotherFishProperties withLength(double length) { + if (this.innerEyeProperties() == null) { + this.innerEyeProperties = new EyeProperties(); + } + this.innerEyeProperties().withLength(length); + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String patten() { + return this.innerEyeProperties() == null ? null : this.innerEyeProperties().patten(); + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredString() { + return this.innerEyeProperties() == null ? null : this.innerEyeProperties().requiredString(); + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the AnotherFishProperties object itself. + */ + public AnotherFishProperties withRequiredString(String requiredString) { + if (this.innerEyeProperties() == null) { + this.innerEyeProperties = new EyeProperties(); + } + this.innerEyeProperties().withRequiredString(requiredString); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerEyeProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property innerEyeProperties in model AnotherFishProperties")); + } else { + innerEyeProperties().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AnotherFishProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("eyeProperties", this.innerEyeProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AnotherFishProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AnotherFishProperties 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 AnotherFishProperties. + */ + public static AnotherFishProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AnotherFishProperties deserializedAnotherFishProperties = new AnotherFishProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("eyeProperties".equals(fieldName)) { + deserializedAnotherFishProperties.innerEyeProperties = EyeProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedAnotherFishProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/EyeProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/EyeProperties.java new file mode 100644 index 000000000..dcabce41a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/EyeProperties.java @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +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 EyeProperties model. + */ +@Fluent +public final class EyeProperties implements JsonSerializable { + /* + * The length property. + */ + private double length; + + /* + * The patten property. + */ + private String patten; + + /* + * The requiredString property. + */ + private String requiredString; + + /** + * Creates an instance of EyeProperties class. + */ + public EyeProperties() { + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double length() { + return this.length; + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the EyeProperties object itself. + */ + public EyeProperties withLength(double length) { + this.length = length; + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String patten() { + return this.patten; + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredString() { + return this.requiredString; + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the EyeProperties object itself. + */ + public EyeProperties withRequiredString(String requiredString) { + this.requiredString = requiredString; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (requiredString() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property requiredString in model EyeProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(EyeProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("length", this.length); + jsonWriter.writeStringField("requiredString", this.requiredString); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EyeProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EyeProperties 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 EyeProperties. + */ + public static EyeProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EyeProperties deserializedEyeProperties = new EyeProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("length".equals(fieldName)) { + deserializedEyeProperties.length = reader.getDouble(); + } else if ("patten".equals(fieldName)) { + deserializedEyeProperties.patten = reader.getString(); + } else if ("requiredString".equals(fieldName)) { + deserializedEyeProperties.requiredString = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedEyeProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/FishInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/FishInner.java new file mode 100644 index 000000000..0bfad9d1e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/FishInner.java @@ -0,0 +1,348 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.armstreamstyleserialization.models.Shark; +import java.io.IOException; + +/** + * This is base model for polymorphic multiple levels inheritance with a discriminator. + */ +@Fluent +public class FishInner implements JsonSerializable { + /* + * Discriminator property for Fish. + */ + private String kind = "Fish"; + + /* + * The age property. + */ + private int age; + + /* + * The dna property. + */ + private String dna; + + /* + * The properties property. + */ + private FishProperties innerProperties = new FishProperties(); + + /* + * The anotherProperties property. + */ + private AnotherFishProperties innerAnotherProperties = new AnotherFishProperties(); + + /** + * Creates an instance of FishInner class. + */ + public FishInner() { + } + + /** + * Get the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + public String kind() { + return this.kind; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + public int age() { + return this.age; + } + + /** + * Set the age property: The age property. + * + * @param age the age value to set. + * @return the FishInner object itself. + */ + public FishInner withAge(int age) { + this.age = age; + return this; + } + + /** + * Get the dna property: The dna property. + * + * @return the dna value. + */ + public String dna() { + return this.dna; + } + + /** + * Set the dna property: The dna property. + * + * @param dna the dna value to set. + * @return the FishInner object itself. + */ + FishInner withDna(String dna) { + this.dna = dna; + return this; + } + + /** + * Get the innerProperties property: The properties property. + * + * @return the innerProperties value. + */ + private FishProperties innerProperties() { + return this.innerProperties; + } + + /** + * Set the innerProperties property: The properties property. + * + * @param innerProperties the innerProperties value to set. + * @return the FishInner object itself. + */ + FishInner withInnerProperties(FishProperties innerProperties) { + this.innerProperties = innerProperties; + return this; + } + + /** + * Get the innerAnotherProperties property: The anotherProperties property. + * + * @return the innerAnotherProperties value. + */ + private AnotherFishProperties innerAnotherProperties() { + return this.innerAnotherProperties; + } + + /** + * Set the innerAnotherProperties property: The anotherProperties property. + * + * @param innerAnotherProperties the innerAnotherProperties value to set. + * @return the FishInner object itself. + */ + FishInner withInnerAnotherProperties(AnotherFishProperties innerAnotherProperties) { + this.innerAnotherProperties = innerAnotherProperties; + return this; + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double length() { + return this.innerProperties() == null ? 0.0 : this.innerProperties().length(); + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the FishInner object itself. + */ + public FishInner withLength(double length) { + if (this.innerProperties() == null) { + this.innerProperties = new FishProperties(); + } + this.innerProperties().withLength(length); + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String patten() { + return this.innerProperties() == null ? null : this.innerProperties().patten(); + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredString() { + return this.innerProperties() == null ? null : this.innerProperties().requiredString(); + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the FishInner object itself. + */ + public FishInner withRequiredString(String requiredString) { + if (this.innerProperties() == null) { + this.innerProperties = new FishProperties(); + } + this.innerProperties().withRequiredString(requiredString); + return this; + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double lengthAnotherPropertiesLength() { + return this.innerAnotherProperties() == null ? 0.0 : this.innerAnotherProperties().length(); + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the FishInner object itself. + */ + public FishInner withLengthAnotherPropertiesLength(double length) { + if (this.innerAnotherProperties() == null) { + this.innerAnotherProperties = new AnotherFishProperties(); + } + this.innerAnotherProperties().withLength(length); + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String pattenAnotherPropertiesPatten() { + return this.innerAnotherProperties() == null ? null : this.innerAnotherProperties().patten(); + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredStringAnotherPropertiesRequiredString() { + return this.innerAnotherProperties() == null ? null : this.innerAnotherProperties().requiredString(); + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the FishInner object itself. + */ + public FishInner withRequiredStringAnotherPropertiesRequiredString(String requiredString) { + if (this.innerAnotherProperties() == null) { + this.innerAnotherProperties = new AnotherFishProperties(); + } + this.innerAnotherProperties().withRequiredString(requiredString); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property innerProperties in model FishInner")); + } else { + innerProperties().validate(); + } + if (innerAnotherProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property innerAnotherProperties in model FishInner")); + } else { + innerAnotherProperties().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(FishInner.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("age", this.age); + jsonWriter.writeJsonField("properties", this.innerProperties); + jsonWriter.writeJsonField("anotherProperties", this.innerAnotherProperties); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FishInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FishInner 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 FishInner. + */ + public static FishInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("shark".equals(discriminatorValue)) { + return Shark.fromJson(readerToUse.reset()); + } else if ("salmon".equals(discriminatorValue)) { + return SalmonInner.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static FishInner fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FishInner deserializedFishInner = new FishInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + deserializedFishInner.age = reader.getInt(); + } else if ("dna".equals(fieldName)) { + deserializedFishInner.dna = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedFishInner.innerProperties = FishProperties.fromJson(reader); + } else if ("anotherProperties".equals(fieldName)) { + deserializedFishInner.innerAnotherProperties = AnotherFishProperties.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedFishInner.kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedFishInner; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/FishProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/FishProperties.java new file mode 100644 index 000000000..990e863cc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/FishProperties.java @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +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 FishProperties model. + */ +@Fluent +public final class FishProperties implements JsonSerializable { + /* + * The tailProperties property. + */ + private TailProperties innerTailProperties = new TailProperties(); + + /** + * Creates an instance of FishProperties class. + */ + public FishProperties() { + } + + /** + * Get the innerTailProperties property: The tailProperties property. + * + * @return the innerTailProperties value. + */ + private TailProperties innerTailProperties() { + return this.innerTailProperties; + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double length() { + return this.innerTailProperties() == null ? 0.0 : this.innerTailProperties().length(); + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the FishProperties object itself. + */ + public FishProperties withLength(double length) { + if (this.innerTailProperties() == null) { + this.innerTailProperties = new TailProperties(); + } + this.innerTailProperties().withLength(length); + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String patten() { + return this.innerTailProperties() == null ? null : this.innerTailProperties().patten(); + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredString() { + return this.innerTailProperties() == null ? null : this.innerTailProperties().requiredString(); + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the FishProperties object itself. + */ + public FishProperties withRequiredString(String requiredString) { + if (this.innerTailProperties() == null) { + this.innerTailProperties = new TailProperties(); + } + this.innerTailProperties().withRequiredString(requiredString); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerTailProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property innerTailProperties in model FishProperties")); + } else { + innerTailProperties().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(FishProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("tailProperties", this.innerTailProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FishProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FishProperties 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 FishProperties. + */ + public static FishProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FishProperties deserializedFishProperties = new FishProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("tailProperties".equals(fieldName)) { + deserializedFishProperties.innerTailProperties = TailProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedFishProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/OutputOnlyModelInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/OutputOnlyModelInner.java new file mode 100644 index 000000000..8657f412d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/OutputOnlyModelInner.java @@ -0,0 +1,215 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.armstreamstyleserialization.models.OutputOnlyModelChild; +import java.io.IOException; + +/** + * This is base model for polymorphic OutputOnlyModel. + */ +@Immutable +public class OutputOnlyModelInner implements JsonSerializable { + /* + * Discriminator property for OutputOnlyModel. + */ + private String kind = "OutputOnlyModel"; + + /* + * The name property. + */ + private String name; + + /* + * The id property. + */ + private String id; + + /* + * The properties property. + */ + private OutputOnlyModelProperties innerProperties; + + /** + * Creates an instance of OutputOnlyModelInner class. + */ + protected OutputOnlyModelInner() { + } + + /** + * Get the kind property: Discriminator property for OutputOnlyModel. + * + * @return the kind value. + */ + public String kind() { + return this.kind; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name property. + * + * @param name the name value to set. + * @return the OutputOnlyModelInner object itself. + */ + OutputOnlyModelInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + public String id() { + return this.id; + } + + /** + * Set the id property: The id property. + * + * @param id the id value to set. + * @return the OutputOnlyModelInner object itself. + */ + OutputOnlyModelInner withId(String id) { + this.id = id; + return this; + } + + /** + * Get the innerProperties property: The properties property. + * + * @return the innerProperties value. + */ + private OutputOnlyModelProperties innerProperties() { + return this.innerProperties; + } + + /** + * Set the innerProperties property: The properties property. + * + * @param innerProperties the innerProperties value to set. + * @return the OutputOnlyModelInner object itself. + */ + OutputOnlyModelInner withInnerProperties(OutputOnlyModelProperties innerProperties) { + this.innerProperties = innerProperties; + return this; + } + + /** + * Get the title property: The title property. + * + * @return the title value. + */ + public String title() { + return this.innerProperties() == null ? null : this.innerProperties().title(); + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model OutputOnlyModelInner")); + } + if (innerProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property innerProperties in model OutputOnlyModelInner")); + } else { + innerProperties().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(OutputOnlyModelInner.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeJsonField("properties", this.innerProperties); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OutputOnlyModelInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OutputOnlyModelInner 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 OutputOnlyModelInner. + */ + public static OutputOnlyModelInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("child".equals(discriminatorValue)) { + return OutputOnlyModelChild.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static OutputOnlyModelInner fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OutputOnlyModelInner deserializedOutputOnlyModelInner = new OutputOnlyModelInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedOutputOnlyModelInner.name = reader.getString(); + } else if ("id".equals(fieldName)) { + deserializedOutputOnlyModelInner.id = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedOutputOnlyModelInner.innerProperties = OutputOnlyModelProperties.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedOutputOnlyModelInner.kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOutputOnlyModelInner; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/OutputOnlyModelProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/OutputOnlyModelProperties.java new file mode 100644 index 000000000..03d90440f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/OutputOnlyModelProperties.java @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +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 OutputOnlyModelProperties model. + */ +@Immutable +public final class OutputOnlyModelProperties implements JsonSerializable { + /* + * The title property. + */ + private String title; + + /** + * Creates an instance of OutputOnlyModelProperties class. + */ + private OutputOnlyModelProperties() { + } + + /** + * Get the title property: The title property. + * + * @return the title value. + */ + public String title() { + return this.title; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (title() == null) { + throw LOGGER.atError() + .log( + new IllegalArgumentException("Missing required property title in model OutputOnlyModelProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(OutputOnlyModelProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("title", this.title); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OutputOnlyModelProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OutputOnlyModelProperties 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 OutputOnlyModelProperties. + */ + public static OutputOnlyModelProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OutputOnlyModelProperties deserializedOutputOnlyModelProperties = new OutputOnlyModelProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("title".equals(fieldName)) { + deserializedOutputOnlyModelProperties.title = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOutputOnlyModelProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/SalmonInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/SalmonInner.java new file mode 100644 index 000000000..f02a79a5b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/SalmonInner.java @@ -0,0 +1,375 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The second level model in polymorphic multiple levels inheritance which contains references to other polymorphic + * instances. + */ +@Fluent +public final class SalmonInner extends FishInner { + /* + * Discriminator property for Fish. + */ + private String kind = "salmon"; + + /* + * The friends property. + */ + private List friends; + + /* + * The hate property. + */ + private Map hate; + + /* + * The partner property. + */ + private FishInner partner; + + /* + * The anotherProperties property. + */ + private AnotherFishProperties innerAnotherProperties = new AnotherFishProperties(); + + /* + * The properties property. + */ + private FishProperties innerProperties = new FishProperties(); + + /* + * The dna property. + */ + private String dna; + + /** + * Creates an instance of SalmonInner class. + */ + public SalmonInner() { + } + + /** + * Get the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + @Override + public String kind() { + return this.kind; + } + + /** + * Get the friends property: The friends property. + * + * @return the friends value. + */ + public List friends() { + return this.friends; + } + + /** + * Set the friends property: The friends property. + * + * @param friends the friends value to set. + * @return the SalmonInner object itself. + */ + public SalmonInner withFriends(List friends) { + this.friends = friends; + return this; + } + + /** + * Get the hate property: The hate property. + * + * @return the hate value. + */ + public Map hate() { + return this.hate; + } + + /** + * Set the hate property: The hate property. + * + * @param hate the hate value to set. + * @return the SalmonInner object itself. + */ + public SalmonInner withHate(Map hate) { + this.hate = hate; + return this; + } + + /** + * Get the partner property: The partner property. + * + * @return the partner value. + */ + public FishInner partner() { + return this.partner; + } + + /** + * Set the partner property: The partner property. + * + * @param partner the partner value to set. + * @return the SalmonInner object itself. + */ + public SalmonInner withPartner(FishInner partner) { + this.partner = partner; + return this; + } + + /** + * Get the innerAnotherProperties property: The anotherProperties property. + * + * @return the innerAnotherProperties value. + */ + private AnotherFishProperties innerAnotherProperties() { + return this.innerAnotherProperties; + } + + /** + * Get the innerProperties property: The properties property. + * + * @return the innerProperties value. + */ + private FishProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the dna property: The dna property. + * + * @return the dna value. + */ + @Override + public String dna() { + return this.dna; + } + + /** + * {@inheritDoc} + */ + @Override + public SalmonInner withAge(int age) { + super.withAge(age); + return this; + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double length() { + return this.innerProperties() == null ? 0.0 : this.innerProperties().length(); + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the SalmonInner object itself. + */ + public SalmonInner withLength(double length) { + if (this.innerProperties() == null) { + this.innerProperties = new FishProperties(); + } + this.innerProperties().withLength(length); + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String patten() { + return this.innerProperties() == null ? null : this.innerProperties().patten(); + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredString() { + return this.innerProperties() == null ? null : this.innerProperties().requiredString(); + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the SalmonInner object itself. + */ + public SalmonInner withRequiredString(String requiredString) { + if (this.innerProperties() == null) { + this.innerProperties = new FishProperties(); + } + this.innerProperties().withRequiredString(requiredString); + return this; + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double lengthAnotherPropertiesLength() { + return this.innerAnotherProperties() == null ? 0.0 : this.innerAnotherProperties().length(); + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the SalmonInner object itself. + */ + public SalmonInner withLengthAnotherPropertiesLength(double length) { + if (this.innerAnotherProperties() == null) { + this.innerAnotherProperties = new AnotherFishProperties(); + } + this.innerAnotherProperties().withLength(length); + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String pattenAnotherPropertiesPatten() { + return this.innerAnotherProperties() == null ? null : this.innerAnotherProperties().patten(); + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredStringAnotherPropertiesRequiredString() { + return this.innerAnotherProperties() == null ? null : this.innerAnotherProperties().requiredString(); + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the SalmonInner object itself. + */ + public SalmonInner withRequiredStringAnotherPropertiesRequiredString(String requiredString) { + if (this.innerAnotherProperties() == null) { + this.innerAnotherProperties = new AnotherFishProperties(); + } + this.innerAnotherProperties().withRequiredString(requiredString); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (friends() != null) { + friends().forEach(e -> e.validate()); + } + if (hate() != null) { + hate().values().forEach(e -> { + if (e != null) { + e.validate(); + } + }); + } + if (partner() != null) { + partner().validate(); + } + if (innerProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property innerProperties in model SalmonInner")); + } else { + innerProperties().validate(); + } + if (innerAnotherProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property innerAnotherProperties in model SalmonInner")); + } else { + innerAnotherProperties().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SalmonInner.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("age", age()); + jsonWriter.writeJsonField("properties", innerProperties()); + jsonWriter.writeJsonField("anotherProperties", innerAnotherProperties()); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeArrayField("friends", this.friends, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeMapField("hate", this.hate, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("partner", this.partner); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SalmonInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SalmonInner 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 SalmonInner. + */ + public static SalmonInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SalmonInner deserializedSalmonInner = new SalmonInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + deserializedSalmonInner.withAge(reader.getInt()); + } else if ("dna".equals(fieldName)) { + deserializedSalmonInner.dna = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedSalmonInner.innerProperties = FishProperties.fromJson(reader); + } else if ("anotherProperties".equals(fieldName)) { + deserializedSalmonInner.innerAnotherProperties = AnotherFishProperties.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedSalmonInner.kind = reader.getString(); + } else if ("friends".equals(fieldName)) { + List friends = reader.readArray(reader1 -> FishInner.fromJson(reader1)); + deserializedSalmonInner.friends = friends; + } else if ("hate".equals(fieldName)) { + Map hate = reader.readMap(reader1 -> FishInner.fromJson(reader1)); + deserializedSalmonInner.hate = hate; + } else if ("partner".equals(fieldName)) { + deserializedSalmonInner.partner = FishInner.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSalmonInner; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/TailProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/TailProperties.java new file mode 100644 index 000000000..3e6950134 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/TailProperties.java @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +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 TailProperties model. + */ +@Fluent +public final class TailProperties implements JsonSerializable { + /* + * The length property. + */ + private double length; + + /* + * The patten property. + */ + private String patten; + + /* + * The requiredString property. + */ + private String requiredString; + + /** + * Creates an instance of TailProperties class. + */ + public TailProperties() { + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double length() { + return this.length; + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the TailProperties object itself. + */ + public TailProperties withLength(double length) { + this.length = length; + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String patten() { + return this.patten; + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredString() { + return this.requiredString; + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the TailProperties object itself. + */ + public TailProperties withRequiredString(String requiredString) { + this.requiredString = requiredString; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (requiredString() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property requiredString in model TailProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(TailProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("length", this.length); + jsonWriter.writeStringField("requiredString", this.requiredString); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TailProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TailProperties 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 TailProperties. + */ + public static TailProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TailProperties deserializedTailProperties = new TailProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("length".equals(fieldName)) { + deserializedTailProperties.length = reader.getDouble(); + } else if ("patten".equals(fieldName)) { + deserializedTailProperties.patten = reader.getString(); + } else if ("requiredString".equals(fieldName)) { + deserializedTailProperties.requiredString = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedTailProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/TopLevelArmResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/TopLevelArmResourceInner.java new file mode 100644 index 000000000..b2f7aa1de --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/TopLevelArmResourceInner.java @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.armstreamstyleserialization.models.TopLevelArmResourceProperties; +import java.io.IOException; +import java.util.Map; + +/** + * Concrete tracked resource types can be created by aliasing this type using a specific property type. + */ +@Immutable +public final class TopLevelArmResourceInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private TopLevelArmResourceProperties 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 TopLevelArmResourceInner class. + */ + private TopLevelArmResourceInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public TopLevelArmResourceProperties properties() { + return this.properties; + } + + /** + * 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; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + if (location() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property location in model TopLevelArmResourceInner")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(TopLevelArmResourceInner.class); + + /** + * {@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 TopLevelArmResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TopLevelArmResourceInner 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 TopLevelArmResourceInner. + */ + public static TopLevelArmResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TopLevelArmResourceInner deserializedTopLevelArmResourceInner = new TopLevelArmResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedTopLevelArmResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedTopLevelArmResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedTopLevelArmResourceInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedTopLevelArmResourceInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedTopLevelArmResourceInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedTopLevelArmResourceInner.properties = TopLevelArmResourceProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedTopLevelArmResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedTopLevelArmResourceInner; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/models/package-info.java new file mode 100644 index 000000000..60eed42f7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/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 ArmStreamStyleSerialization. + * Arm Resource Provider management API. + */ +package com.cadl.armstreamstyleserialization.fluent.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/fluent/package-info.java new file mode 100644 index 000000000..3be04d976 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/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 ArmStreamStyleSerialization. + * Arm Resource Provider management API. + */ +package com.cadl.armstreamstyleserialization.fluent; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientBuilder.java new file mode 100644 index 000000000..035c58e4c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.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 ArmStreamStyleSerializationClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { ArmStreamStyleSerializationClientImpl.class }) +public final class ArmStreamStyleSerializationClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the ArmStreamStyleSerializationClientBuilder. + */ + public ArmStreamStyleSerializationClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the ArmStreamStyleSerializationClientBuilder. + */ + public ArmStreamStyleSerializationClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the ArmStreamStyleSerializationClientBuilder. + */ + public ArmStreamStyleSerializationClientBuilder 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 ArmStreamStyleSerializationClientBuilder. + */ + public ArmStreamStyleSerializationClientBuilder 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 ArmStreamStyleSerializationClientBuilder. + */ + public ArmStreamStyleSerializationClientBuilder 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 ArmStreamStyleSerializationClientBuilder. + */ + public ArmStreamStyleSerializationClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of ArmStreamStyleSerializationClientImpl with the provided parameters. + * + * @return an instance of ArmStreamStyleSerializationClientImpl. + */ + public ArmStreamStyleSerializationClientImpl 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(); + ArmStreamStyleSerializationClientImpl client = new ArmStreamStyleSerializationClientImpl(localPipeline, + localSerializerAdapter, localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientImpl.java new file mode 100644 index 000000000..d3d1e6e74 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientImpl.java @@ -0,0 +1,261 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.implementation; + +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.polling.PollerFactory; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.cadl.armstreamstyleserialization.fluent.ArmStreamStyleSerializationClient; +import com.cadl.armstreamstyleserialization.fluent.FishesClient; +import com.cadl.armstreamstyleserialization.fluent.TopLevelArmResourcesClient; +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 ArmStreamStyleSerializationClientImpl type. + */ +@ServiceClient(builder = ArmStreamStyleSerializationClientBuilder.class) +public final class ArmStreamStyleSerializationClientImpl implements ArmStreamStyleSerializationClient { + /** + * 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 ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * 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 FishesClient object to access its operations. + */ + private final FishesClient fishes; + + /** + * Gets the FishesClient object to access its operations. + * + * @return the FishesClient object. + */ + public FishesClient getFishes() { + return this.fishes; + } + + /** + * The TopLevelArmResourcesClient object to access its operations. + */ + private final TopLevelArmResourcesClient topLevelArmResources; + + /** + * Gets the TopLevelArmResourcesClient object to access its operations. + * + * @return the TopLevelArmResourcesClient object. + */ + public TopLevelArmResourcesClient getTopLevelArmResources() { + return this.topLevelArmResources; + } + + /** + * Initializes an instance of ArmStreamStyleSerializationClient 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. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + ArmStreamStyleSerializationClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.apiVersion = "2023-12-01-preview"; + this.fishes = new FishesClientImpl(this); + this.topLevelArmResources = new TopLevelArmResourcesClientImpl(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 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) { + } + + 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)); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishImpl.java new file mode 100644 index 000000000..058e830db --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishImpl.java @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.implementation; + +import com.cadl.armstreamstyleserialization.fluent.models.FishInner; +import com.cadl.armstreamstyleserialization.models.Fish; + +public final class FishImpl implements Fish { + private FishInner innerObject; + + private final com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager serviceManager; + + FishImpl(FishInner innerObject, + com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String kind() { + return this.innerModel().kind(); + } + + public int age() { + return this.innerModel().age(); + } + + public String dna() { + return this.innerModel().dna(); + } + + public double length() { + return this.innerModel().length(); + } + + public String patten() { + return this.innerModel().patten(); + } + + public String requiredString() { + return this.innerModel().requiredString(); + } + + public double lengthAnotherPropertiesLength() { + return this.innerModel().lengthAnotherPropertiesLength(); + } + + public String pattenAnotherPropertiesPatten() { + return this.innerModel().pattenAnotherPropertiesPatten(); + } + + public String requiredStringAnotherPropertiesRequiredString() { + return this.innerModel().requiredStringAnotherPropertiesRequiredString(); + } + + public FishInner innerModel() { + return this.innerObject; + } + + private com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishesClientImpl.java new file mode 100644 index 000000000..e3fea3a3e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishesClientImpl.java @@ -0,0 +1,342 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.implementation; + +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.Put; +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 com.cadl.armstreamstyleserialization.fluent.FishesClient; +import com.cadl.armstreamstyleserialization.fluent.models.FishInner; +import com.cadl.armstreamstyleserialization.fluent.models.OutputOnlyModelInner; +import com.cadl.armstreamstyleserialization.models.ErrorException; +import com.cadl.armstreamstyleserialization.models.ErrorMinException; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in FishesClient. + */ +public final class FishesClientImpl implements FishesClient { + /** + * The proxy service used to perform REST calls. + */ + private final FishesService service; + + /** + * The service client containing this operation class. + */ + private final ArmStreamStyleSerializationClientImpl client; + + /** + * Initializes an instance of FishesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FishesClientImpl(ArmStreamStyleSerializationClientImpl client) { + this.service = RestProxy.create(FishesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArmStreamStyleSerializationClientFishes to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArmStreamStyleSerial") + public interface FishesService { + @Headers({ "Content-Type: application/json" }) + @Get("/model") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ErrorException.class) + Mono> getModel(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + Context context); + + @Put("/model") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ErrorMinException.class) + Mono> putModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") FishInner fish, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/model/output") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getOutputOnlyModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * The getModel operation. + * + * @throws ErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getModelWithResponseAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getModel(this.client.getEndpoint(), accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * The getModel operation. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getModelWithResponseAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.getModel(this.client.getEndpoint(), accept, context); + } + + /** + * The getModel operation. + * + * @throws ErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getModelAsync() { + return getModelWithResponseAsync().flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * The getModel operation. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getModelWithResponse(Context context) { + return getModelWithResponseAsync(context).block(); + } + + /** + * The getModel operation. + * + * @throws ErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public FishInner getModel() { + return getModelWithResponse(Context.NONE).getValue(); + } + + /** + * The putModel operation. + * + * @param fish The fish parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorMinException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> putModelWithResponseAsync(FishInner fish) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (fish == null) { + return Mono.error(new IllegalArgumentException("Parameter fish is required and cannot be null.")); + } else { + fish.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.putModel(this.client.getEndpoint(), contentType, accept, fish, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * The putModel operation. + * + * @param fish The fish parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorMinException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> putModelWithResponseAsync(FishInner fish, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (fish == null) { + return Mono.error(new IllegalArgumentException("Parameter fish is required and cannot be null.")); + } else { + fish.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.putModel(this.client.getEndpoint(), contentType, accept, fish, context); + } + + /** + * The putModel operation. + * + * @param fish The fish parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorMinException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono putModelAsync(FishInner fish) { + return putModelWithResponseAsync(fish).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * The putModel operation. + * + * @param fish The fish parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorMinException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putModelWithResponse(FishInner fish, Context context) { + return putModelWithResponseAsync(fish, context).block(); + } + + /** + * The putModel operation. + * + * @param fish The fish parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ErrorMinException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public FishInner putModel(FishInner fish) { + return putModelWithResponse(fish, Context.NONE).getValue(); + } + + /** + * The getOutputOnlyModel operation. + * + * @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 this is base model for polymorphic OutputOnlyModel along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getOutputOnlyModelWithResponseAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getOutputOnlyModel(this.client.getEndpoint(), accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * The getOutputOnlyModel operation. + * + * @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 this is base model for polymorphic OutputOnlyModel along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getOutputOnlyModelWithResponseAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.getOutputOnlyModel(this.client.getEndpoint(), accept, context); + } + + /** + * The getOutputOnlyModel operation. + * + * @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 this is base model for polymorphic OutputOnlyModel on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getOutputOnlyModelAsync() { + return getOutputOnlyModelWithResponseAsync().flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * The getOutputOnlyModel operation. + * + * @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 this is base model for polymorphic OutputOnlyModel along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getOutputOnlyModelWithResponse(Context context) { + return getOutputOnlyModelWithResponseAsync(context).block(); + } + + /** + * The getOutputOnlyModel operation. + * + * @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 this is base model for polymorphic OutputOnlyModel. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public OutputOnlyModelInner getOutputOnlyModel() { + return getOutputOnlyModelWithResponse(Context.NONE).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishesImpl.java new file mode 100644 index 000000000..36e0cb773 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/FishesImpl.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.implementation; + +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; +import com.cadl.armstreamstyleserialization.fluent.FishesClient; +import com.cadl.armstreamstyleserialization.fluent.models.FishInner; +import com.cadl.armstreamstyleserialization.fluent.models.OutputOnlyModelInner; +import com.cadl.armstreamstyleserialization.models.Fish; +import com.cadl.armstreamstyleserialization.models.Fishes; +import com.cadl.armstreamstyleserialization.models.OutputOnlyModel; + +public final class FishesImpl implements Fishes { + private static final ClientLogger LOGGER = new ClientLogger(FishesImpl.class); + + private final FishesClient innerClient; + + private final com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager serviceManager; + + public FishesImpl(FishesClient innerClient, + com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getModelWithResponse(Context context) { + Response inner = this.serviceClient().getModelWithResponse(context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new FishImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Fish getModel() { + FishInner inner = this.serviceClient().getModel(); + if (inner != null) { + return new FishImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response putModelWithResponse(FishInner fish, Context context) { + Response inner = this.serviceClient().putModelWithResponse(fish, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new FishImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Fish putModel(FishInner fish) { + FishInner inner = this.serviceClient().putModel(fish); + if (inner != null) { + return new FishImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getOutputOnlyModelWithResponse(Context context) { + Response inner = this.serviceClient().getOutputOnlyModelWithResponse(context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new OutputOnlyModelImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public OutputOnlyModel getOutputOnlyModel() { + OutputOnlyModelInner inner = this.serviceClient().getOutputOnlyModel(); + if (inner != null) { + return new OutputOnlyModelImpl(inner, this.manager()); + } else { + return null; + } + } + + private FishesClient serviceClient() { + return this.innerClient; + } + + private com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/OutputOnlyModelImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/OutputOnlyModelImpl.java new file mode 100644 index 000000000..262154529 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/OutputOnlyModelImpl.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.implementation; + +import com.cadl.armstreamstyleserialization.fluent.models.OutputOnlyModelInner; +import com.cadl.armstreamstyleserialization.models.OutputOnlyModel; + +public final class OutputOnlyModelImpl implements OutputOnlyModel { + private OutputOnlyModelInner innerObject; + + private final com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager serviceManager; + + OutputOnlyModelImpl(OutputOnlyModelInner innerObject, + com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String kind() { + return this.innerModel().kind(); + } + + public String name() { + return this.innerModel().name(); + } + + public String id() { + return this.innerModel().id(); + } + + public String title() { + return this.innerModel().title(); + } + + public OutputOnlyModelInner innerModel() { + return this.innerObject; + } + + private com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/ResourceManagerUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/ResourceManagerUtils.java new file mode 100644 index 000000000..a61e5a8fd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/ResourceManagerUtils.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.implementation; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + + } + +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/SalmonImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/SalmonImpl.java new file mode 100644 index 000000000..2db61281d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/SalmonImpl.java @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.implementation; + +import com.cadl.armstreamstyleserialization.fluent.models.FishInner; +import com.cadl.armstreamstyleserialization.fluent.models.SalmonInner; +import com.cadl.armstreamstyleserialization.models.Fish; +import com.cadl.armstreamstyleserialization.models.Salmon; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public final class SalmonImpl implements Salmon { + private SalmonInner innerObject; + + private final com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager serviceManager; + + SalmonImpl(SalmonInner innerObject, + com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public int age() { + return this.innerModel().age(); + } + + public String dna() { + return this.innerModel().dna(); + } + + public double length() { + return this.innerModel().length(); + } + + public String patten() { + return this.innerModel().patten(); + } + + public String requiredString() { + return this.innerModel().requiredString(); + } + + public double lengthAnotherPropertiesLength() { + return this.innerModel().lengthAnotherPropertiesLength(); + } + + public String pattenAnotherPropertiesPatten() { + return this.innerModel().pattenAnotherPropertiesPatten(); + } + + public String requiredStringAnotherPropertiesRequiredString() { + return this.innerModel().requiredStringAnotherPropertiesRequiredString(); + } + + public String kind() { + return this.innerModel().kind(); + } + + public List friends() { + List inner = this.innerModel().friends(); + if (inner != null) { + return Collections.unmodifiableList( + inner.stream().map(inner1 -> new FishImpl(inner1, this.manager())).collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } + + public Map hate() { + Map inner = this.innerModel().hate(); + if (inner != null) { + return Collections.unmodifiableMap(inner.entrySet() + .stream() + .collect( + Collectors.toMap(Map.Entry::getKey, inner1 -> new FishImpl(inner1.getValue(), this.manager())))); + } else { + return Collections.emptyMap(); + } + } + + public Fish partner() { + FishInner inner = this.innerModel().partner(); + if (inner != null) { + return new FishImpl(inner, this.manager()); + } else { + return null; + } + } + + public SalmonInner innerModel() { + return this.innerObject; + } + + private com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourceImpl.java new file mode 100644 index 000000000..190944f60 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourceImpl.java @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.implementation; + +import com.azure.core.management.SystemData; +import com.cadl.armstreamstyleserialization.fluent.models.TopLevelArmResourceInner; +import com.cadl.armstreamstyleserialization.models.TopLevelArmResource; +import com.cadl.armstreamstyleserialization.models.TopLevelArmResourceProperties; +import java.util.Collections; +import java.util.Map; + +public final class TopLevelArmResourceImpl implements TopLevelArmResource { + private TopLevelArmResourceInner innerObject; + + private final com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager serviceManager; + + TopLevelArmResourceImpl(TopLevelArmResourceInner innerObject, + com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager 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 TopLevelArmResourceProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public TopLevelArmResourceInner innerModel() { + return this.innerObject; + } + + private com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourcesClientImpl.java new file mode 100644 index 000000000..9392abb7b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourcesClientImpl.java @@ -0,0 +1,323 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.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.Patch; +import com.azure.core.annotation.PathParam; +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.management.polling.PollResult; +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 com.cadl.armstreamstyleserialization.fluent.TopLevelArmResourcesClient; +import com.cadl.armstreamstyleserialization.fluent.models.TopLevelArmResourceInner; +import com.cadl.armstreamstyleserialization.models.TopLevelArmResourceTagsUpdate; +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 TopLevelArmResourcesClient. + */ +public final class TopLevelArmResourcesClientImpl implements TopLevelArmResourcesClient { + /** + * The proxy service used to perform REST calls. + */ + private final TopLevelArmResourcesService service; + + /** + * The service client containing this operation class. + */ + private final ArmStreamStyleSerializationClientImpl client; + + /** + * Initializes an instance of TopLevelArmResourcesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + TopLevelArmResourcesClientImpl(ArmStreamStyleSerializationClientImpl client) { + this.service = RestProxy.create(TopLevelArmResourcesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArmStreamStyleSerializationClientTopLevelArmResources to be used by + * the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArmStreamStyleSerial") + public interface TopLevelArmResourcesService { + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmStreamStyleSerialization/topLevelArmResources/{topLevelArmResourceName}") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourceName") String topLevelArmResourceName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") TopLevelArmResourceTagsUpdate properties, Context context); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 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>> updateWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, TopLevelArmResourceTagsUpdate properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, contentType, accept, + properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 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>> updateWithResponseAsync(String resourceGroupName, + String topLevelArmResourceName, TopLevelArmResourceTagsUpdate properties, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (topLevelArmResourceName == null) { + return Mono.error( + new IllegalArgumentException("Parameter topLevelArmResourceName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelArmResourceName, contentType, accept, properties, context); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TopLevelArmResourceInner> beginUpdateAsync( + String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceTagsUpdate properties) { + Mono>> mono + = updateWithResponseAsync(resourceGroupName, topLevelArmResourceName, properties); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, + this.client.getContext()); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TopLevelArmResourceInner> beginUpdateAsync( + String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceTagsUpdate properties, + Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = updateWithResponseAsync(resourceGroupName, topLevelArmResourceName, properties, context); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, context); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelArmResourceInner> beginUpdate( + String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceTagsUpdate properties) { + return this.beginUpdateAsync(resourceGroupName, topLevelArmResourceName, properties).getSyncPoller(); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelArmResourceInner> beginUpdate( + String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceTagsUpdate properties, + Context context) { + return this.beginUpdateAsync(resourceGroupName, topLevelArmResourceName, properties, context).getSyncPoller(); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 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 updateAsync(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceTagsUpdate properties) { + return beginUpdateAsync(resourceGroupName, topLevelArmResourceName, properties).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 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 updateAsync(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceTagsUpdate properties, Context context) { + return beginUpdateAsync(resourceGroupName, topLevelArmResourceName, properties, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelArmResourceInner update(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceTagsUpdate properties) { + return updateAsync(resourceGroupName, topLevelArmResourceName, properties).block(); + } + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelArmResourceInner update(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceTagsUpdate properties, Context context) { + return updateAsync(resourceGroupName, topLevelArmResourceName, properties, context).block(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourcesImpl.java new file mode 100644 index 000000000..e643c94bd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/TopLevelArmResourcesImpl.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.implementation; + +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.cadl.armstreamstyleserialization.fluent.TopLevelArmResourcesClient; +import com.cadl.armstreamstyleserialization.fluent.models.TopLevelArmResourceInner; +import com.cadl.armstreamstyleserialization.models.TopLevelArmResource; +import com.cadl.armstreamstyleserialization.models.TopLevelArmResources; +import com.cadl.armstreamstyleserialization.models.TopLevelArmResourceTagsUpdate; + +public final class TopLevelArmResourcesImpl implements TopLevelArmResources { + private static final ClientLogger LOGGER = new ClientLogger(TopLevelArmResourcesImpl.class); + + private final TopLevelArmResourcesClient innerClient; + + private final com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager serviceManager; + + public TopLevelArmResourcesImpl(TopLevelArmResourcesClient innerClient, + com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public TopLevelArmResource update(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceTagsUpdate properties) { + TopLevelArmResourceInner inner + = this.serviceClient().update(resourceGroupName, topLevelArmResourceName, properties); + if (inner != null) { + return new TopLevelArmResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public TopLevelArmResource update(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceTagsUpdate properties, Context context) { + TopLevelArmResourceInner inner + = this.serviceClient().update(resourceGroupName, topLevelArmResourceName, properties, context); + if (inner != null) { + return new TopLevelArmResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + private TopLevelArmResourcesClient serviceClient() { + return this.innerClient; + } + + private com.cadl.armstreamstyleserialization.ArmStreamStyleSerializationManager manager() { + return this.serviceManager; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/implementation/package-info.java new file mode 100644 index 000000000..6829a0952 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/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 ArmStreamStyleSerialization. + * Arm Resource Provider management API. + */ +package com.cadl.armstreamstyleserialization.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Error.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Error.java new file mode 100644 index 000000000..e3969a26c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Error.java @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.management.exception.AdditionalInfo; +import com.azure.core.management.exception.ManagementError; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The Error model. + */ +@Immutable +public final class Error extends ManagementError { + /* + * The details property. + */ + private List details; + + /* + * The additionalProperty property. + */ + private String additionalProperty; + + /* + * Additional info for the error. + */ + private List additionalInfo; + + /* + * The target of the error. + */ + private String target; + + /* + * The error message parsed from the body of the http error response. + */ + private String message; + + /* + * The error code parsed from the body of the http error response. + */ + private String code; + + /** + * Creates an instance of Error class. + */ + private Error() { + } + + /** + * Get the details property: The details property. + * + * @return the details value. + */ + @Override + public List getDetails() { + return this.details; + } + + /** + * Get the additionalProperty property: The additionalProperty property. + * + * @return the additionalProperty value. + */ + public String getAdditionalProperty() { + return this.additionalProperty; + } + + /** + * Get the additionalInfo property: Additional info for the error. + * + * @return the additionalInfo value. + */ + @Override + public List getAdditionalInfo() { + return this.additionalInfo; + } + + /** + * Get the target property: The target of the error. + * + * @return the target value. + */ + @Override + public String getTarget() { + return this.target; + } + + /** + * Get the message property: The error message parsed from the body of the http error response. + * + * @return the message value. + */ + @Override + public String getMessage() { + return this.message; + } + + /** + * Get the code property: The error code parsed from the body of the http error response. + * + * @return the code value. + */ + @Override + public String getCode() { + return this.code; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (getDetails() != null) { + getDetails().forEach(e -> e.validate()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Error from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Error 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 Error. + */ + public static Error fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + JsonReader bufferedReader = reader.bufferObject(); + bufferedReader.nextToken(); + while (bufferedReader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = bufferedReader.getFieldName(); + bufferedReader.nextToken(); + + if ("error".equals(fieldName)) { + return readManagementError(bufferedReader); + } else { + bufferedReader.skipChildren(); + } + } + return readManagementError(bufferedReader.reset()); + }); + } + + private static Error readManagementError(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Error deserializedError = new Error(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("code".equals(fieldName)) { + deserializedError.code = reader.getString(); + } else if ("message".equals(fieldName)) { + deserializedError.message = reader.getString(); + } else if ("target".equals(fieldName)) { + deserializedError.target = reader.getString(); + } else if ("additionalInfo".equals(fieldName)) { + List additionalInfo = reader.readArray(reader1 -> AdditionalInfo.fromJson(reader1)); + deserializedError.additionalInfo = additionalInfo; + } else if ("additionalProperty".equals(fieldName)) { + deserializedError.additionalProperty = reader.getString(); + } else if ("details".equals(fieldName)) { + List details = reader.readArray(reader1 -> Error.fromJson(reader1)); + deserializedError.details = details; + } else { + reader.skipChildren(); + } + } + + return deserializedError; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/ErrorException.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/ErrorException.java new file mode 100644 index 000000000..a83a0452e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/ErrorException.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.azure.core.http.HttpResponse; +import com.azure.core.management.exception.ManagementException; + +/** + * Exception thrown for an invalid response with Error information. + */ +public final class ErrorException extends ManagementException { + /** + * Initializes a new instance of the ErrorException class. + * + * @param message the exception message or the response content if a message is not available. + * @param response the HTTP response. + */ + public ErrorException(String message, HttpResponse response) { + super(message, response); + } + + /** + * Initializes a new instance of the ErrorException class. + * + * @param message the exception message or the response content if a message is not available. + * @param response the HTTP response. + * @param value the deserialized response value. + */ + public ErrorException(String message, HttpResponse response, Error value) { + super(message, response, value); + } + + /** + * {@inheritDoc} + */ + @Override + public Error getValue() { + return (Error) super.getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/ErrorMin.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/ErrorMin.java new file mode 100644 index 000000000..214e7681d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/ErrorMin.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 com.cadl.armstreamstyleserialization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.management.exception.AdditionalInfo; +import com.azure.core.management.exception.ManagementError; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The ErrorMin model. + */ +@Immutable +public final class ErrorMin extends ManagementError { + /* + * The additionalProperty property. + */ + private String additionalProperty; + + /* + * Additional info for the error. + */ + private List additionalInfo; + + /* + * Details for the error. + */ + private List details; + + /* + * The target of the error. + */ + private String target; + + /* + * The error message parsed from the body of the http error response. + */ + private String message; + + /* + * The error code parsed from the body of the http error response. + */ + private String code; + + /** + * Creates an instance of ErrorMin class. + */ + private ErrorMin() { + } + + /** + * Get the additionalProperty property: The additionalProperty property. + * + * @return the additionalProperty value. + */ + public String getAdditionalProperty() { + return this.additionalProperty; + } + + /** + * Get the additionalInfo property: Additional info for the error. + * + * @return the additionalInfo value. + */ + @Override + public List getAdditionalInfo() { + return this.additionalInfo; + } + + /** + * Get the details property: Details for the error. + * + * @return the details value. + */ + @Override + public List getDetails() { + return this.details; + } + + /** + * Get the target property: The target of the error. + * + * @return the target value. + */ + @Override + public String getTarget() { + return this.target; + } + + /** + * Get the message property: The error message parsed from the body of the http error response. + * + * @return the message value. + */ + @Override + public String getMessage() { + return this.message; + } + + /** + * Get the code property: The error code parsed from the body of the http error response. + * + * @return the code value. + */ + @Override + public String getCode() { + return this.code; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ErrorMin from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ErrorMin 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 ErrorMin. + */ + public static ErrorMin fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + JsonReader bufferedReader = reader.bufferObject(); + bufferedReader.nextToken(); + while (bufferedReader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = bufferedReader.getFieldName(); + bufferedReader.nextToken(); + + if ("error".equals(fieldName)) { + return readManagementError(bufferedReader); + } else { + bufferedReader.skipChildren(); + } + } + return readManagementError(bufferedReader.reset()); + }); + } + + private static ErrorMin readManagementError(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ErrorMin deserializedErrorMin = new ErrorMin(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("code".equals(fieldName)) { + deserializedErrorMin.code = reader.getString(); + } else if ("message".equals(fieldName)) { + deserializedErrorMin.message = reader.getString(); + } else if ("target".equals(fieldName)) { + deserializedErrorMin.target = reader.getString(); + } else if ("details".equals(fieldName)) { + List details = reader.readArray(reader1 -> ManagementError.fromJson(reader1)); + deserializedErrorMin.details = details; + } else if ("additionalInfo".equals(fieldName)) { + List additionalInfo = reader.readArray(reader1 -> AdditionalInfo.fromJson(reader1)); + deserializedErrorMin.additionalInfo = additionalInfo; + } else if ("additionalProperty".equals(fieldName)) { + deserializedErrorMin.additionalProperty = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedErrorMin; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/ErrorMinException.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/ErrorMinException.java new file mode 100644 index 000000000..99271951a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/ErrorMinException.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.azure.core.http.HttpResponse; +import com.azure.core.management.exception.ManagementException; + +/** + * Exception thrown for an invalid response with ErrorMin information. + */ +public final class ErrorMinException extends ManagementException { + /** + * Initializes a new instance of the ErrorMinException class. + * + * @param message the exception message or the response content if a message is not available. + * @param response the HTTP response. + */ + public ErrorMinException(String message, HttpResponse response) { + super(message, response); + } + + /** + * Initializes a new instance of the ErrorMinException class. + * + * @param message the exception message or the response content if a message is not available. + * @param response the HTTP response. + * @param value the deserialized response value. + */ + public ErrorMinException(String message, HttpResponse response, ErrorMin value) { + super(message, response, value); + } + + /** + * {@inheritDoc} + */ + @Override + public ErrorMin getValue() { + return (ErrorMin) super.getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Fish.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Fish.java new file mode 100644 index 000000000..071df0495 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Fish.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.cadl.armstreamstyleserialization.fluent.models.FishInner; + +/** + * An immutable client-side representation of Fish. + */ +public interface Fish { + /** + * Gets the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + String kind(); + + /** + * Gets the age property: The age property. + * + * @return the age value. + */ + int age(); + + /** + * Gets the dna property: The dna property. + * + * @return the dna value. + */ + String dna(); + + /** + * Gets the length property: The length property. + * + * @return the length value. + */ + double length(); + + /** + * Gets the patten property: The patten property. + * + * @return the patten value. + */ + String patten(); + + /** + * Gets the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + String requiredString(); + + /** + * Gets the lengthAnotherPropertiesLength property: The length property. + * + * @return the lengthAnotherPropertiesLength value. + */ + double lengthAnotherPropertiesLength(); + + /** + * Gets the pattenAnotherPropertiesPatten property: The patten property. + * + * @return the pattenAnotherPropertiesPatten value. + */ + String pattenAnotherPropertiesPatten(); + + /** + * Gets the requiredStringAnotherPropertiesRequiredString property: The requiredString property. + * + * @return the requiredStringAnotherPropertiesRequiredString value. + */ + String requiredStringAnotherPropertiesRequiredString(); + + /** + * Gets the inner com.cadl.armstreamstyleserialization.fluent.models.FishInner object. + * + * @return the inner object. + */ + FishInner innerModel(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Fishes.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Fishes.java new file mode 100644 index 000000000..9092188be --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Fishes.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.cadl.armstreamstyleserialization.fluent.models.FishInner; + +/** + * Resource collection API of Fishes. + */ +public interface Fishes { + /** + * The getModel operation. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.cadl.armstreamstyleserialization.models.ErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + Response getModelWithResponse(Context context); + + /** + * The getModel operation. + * + * @throws com.cadl.armstreamstyleserialization.models.ErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + Fish getModel(); + + /** + * The putModel operation. + * + * @param fish The fish parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.cadl.armstreamstyleserialization.models.ErrorMinException thrown if the request is rejected by + * server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + Response putModelWithResponse(FishInner fish, Context context); + + /** + * The putModel operation. + * + * @param fish The fish parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.cadl.armstreamstyleserialization.models.ErrorMinException thrown if the request is rejected by + * server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + Fish putModel(FishInner fish); + + /** + * The getOutputOnlyModel operation. + * + * @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 this is base model for polymorphic OutputOnlyModel along with {@link Response}. + */ + Response getOutputOnlyModelWithResponse(Context context); + + /** + * The getOutputOnlyModel operation. + * + * @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 this is base model for polymorphic OutputOnlyModel. + */ + OutputOnlyModel getOutputOnlyModel(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/GoblinShark.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/GoblinShark.java new file mode 100644 index 000000000..9109e9031 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/GoblinShark.java @@ -0,0 +1,291 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.armstreamstyleserialization.fluent.models.AnotherFishProperties; +import com.cadl.armstreamstyleserialization.fluent.models.FishProperties; +import java.io.IOException; + +/** + * The third level model GoblinShark in polymorphic multiple levels inheritance. + */ +@Fluent +public final class GoblinShark extends Shark { + /* + * Discriminator property for Fish. + */ + private String kind = "shark"; + + /* + * The sharktype property. + */ + private String sharktype = "goblin"; + + /* + * The anotherProperties property. + */ + private AnotherFishProperties innerAnotherProperties = new AnotherFishProperties(); + + /* + * The properties property. + */ + private FishProperties innerProperties = new FishProperties(); + + /* + * The dna property. + */ + private String dna; + + /** + * Creates an instance of GoblinShark class. + */ + public GoblinShark() { + } + + /** + * Get the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + @Override + public String kind() { + return this.kind; + } + + /** + * Get the sharktype property: The sharktype property. + * + * @return the sharktype value. + */ + @Override + public String sharktype() { + return this.sharktype; + } + + /** + * Get the innerAnotherProperties property: The anotherProperties property. + * + * @return the innerAnotherProperties value. + */ + private AnotherFishProperties innerAnotherProperties() { + return this.innerAnotherProperties; + } + + /** + * Get the innerProperties property: The properties property. + * + * @return the innerProperties value. + */ + private FishProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the dna property: The dna property. + * + * @return the dna value. + */ + @Override + public String dna() { + return this.dna; + } + + /** + * {@inheritDoc} + */ + @Override + public GoblinShark withAge(int age) { + super.withAge(age); + return this; + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double length() { + return this.innerProperties() == null ? 0.0 : this.innerProperties().length(); + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the GoblinShark object itself. + */ + public GoblinShark withLength(double length) { + if (this.innerProperties() == null) { + this.innerProperties = new FishProperties(); + } + this.innerProperties().withLength(length); + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String patten() { + return this.innerProperties() == null ? null : this.innerProperties().patten(); + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredString() { + return this.innerProperties() == null ? null : this.innerProperties().requiredString(); + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the GoblinShark object itself. + */ + public GoblinShark withRequiredString(String requiredString) { + if (this.innerProperties() == null) { + this.innerProperties = new FishProperties(); + } + this.innerProperties().withRequiredString(requiredString); + return this; + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double lengthAnotherPropertiesLength() { + return this.innerAnotherProperties() == null ? 0.0 : this.innerAnotherProperties().length(); + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the GoblinShark object itself. + */ + public GoblinShark withLengthAnotherPropertiesLength(double length) { + if (this.innerAnotherProperties() == null) { + this.innerAnotherProperties = new AnotherFishProperties(); + } + this.innerAnotherProperties().withLength(length); + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String pattenAnotherPropertiesPatten() { + return this.innerAnotherProperties() == null ? null : this.innerAnotherProperties().patten(); + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredStringAnotherPropertiesRequiredString() { + return this.innerAnotherProperties() == null ? null : this.innerAnotherProperties().requiredString(); + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the GoblinShark object itself. + */ + public GoblinShark withRequiredStringAnotherPropertiesRequiredString(String requiredString) { + if (this.innerAnotherProperties() == null) { + this.innerAnotherProperties = new AnotherFishProperties(); + } + this.innerAnotherProperties().withRequiredString(requiredString); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (innerProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property innerProperties in model GoblinShark")); + } else { + innerProperties().validate(); + } + if (innerAnotherProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property innerAnotherProperties in model GoblinShark")); + } else { + innerAnotherProperties().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(GoblinShark.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeIntField("age", age()); + jsonWriter.writeJsonField("properties", innerProperties()); + jsonWriter.writeJsonField("anotherProperties", innerAnotherProperties()); + jsonWriter.writeStringField("sharktype", this.sharktype); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GoblinShark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GoblinShark 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 GoblinShark. + */ + public static GoblinShark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GoblinShark deserializedGoblinShark = new GoblinShark(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + deserializedGoblinShark.withAge(reader.getInt()); + } else if ("dna".equals(fieldName)) { + deserializedGoblinShark.dna = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedGoblinShark.innerProperties = FishProperties.fromJson(reader); + } else if ("anotherProperties".equals(fieldName)) { + deserializedGoblinShark.innerAnotherProperties = AnotherFishProperties.fromJson(reader); + } else if ("sharktype".equals(fieldName)) { + deserializedGoblinShark.sharktype = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedGoblinShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/OutputOnlyModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/OutputOnlyModel.java new file mode 100644 index 000000000..d36533238 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/OutputOnlyModel.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.cadl.armstreamstyleserialization.fluent.models.OutputOnlyModelInner; + +/** + * An immutable client-side representation of OutputOnlyModel. + */ +public interface OutputOnlyModel { + /** + * Gets the kind property: Discriminator property for OutputOnlyModel. + * + * @return the kind value. + */ + String kind(); + + /** + * Gets the name property: The name property. + * + * @return the name value. + */ + String name(); + + /** + * Gets the id property: The id property. + * + * @return the id value. + */ + String id(); + + /** + * Gets the title property: The title property. + * + * @return the title value. + */ + String title(); + + /** + * Gets the inner com.cadl.armstreamstyleserialization.fluent.models.OutputOnlyModelInner object. + * + * @return the inner object. + */ + OutputOnlyModelInner innerModel(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/OutputOnlyModelChild.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/OutputOnlyModelChild.java new file mode 100644 index 000000000..46141c21d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/OutputOnlyModelChild.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.armstreamstyleserialization.fluent.models.OutputOnlyModelInner; +import com.cadl.armstreamstyleserialization.fluent.models.OutputOnlyModelProperties; +import java.io.IOException; + +/** + * The OutputOnlyModelChild model. + */ +@Immutable +public final class OutputOnlyModelChild extends OutputOnlyModelInner { + /* + * Discriminator property for OutputOnlyModel. + */ + private String kind = "child"; + + /* + * The childName property. + */ + private String childName; + + /* + * The properties property. + */ + private OutputOnlyModelProperties innerProperties; + + /* + * The id property. + */ + private String id; + + /* + * The name property. + */ + private String name; + + /** + * Creates an instance of OutputOnlyModelChild class. + */ + private OutputOnlyModelChild() { + } + + /** + * Get the kind property: Discriminator property for OutputOnlyModel. + * + * @return the kind value. + */ + @Override + public String kind() { + return this.kind; + } + + /** + * Get the childName property: The childName property. + * + * @return the childName value. + */ + public String childName() { + return this.childName; + } + + /** + * Get the innerProperties property: The properties property. + * + * @return the innerProperties value. + */ + private OutputOnlyModelProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the title property: The title property. + * + * @return the title value. + */ + public String title() { + return this.innerProperties() == null ? null : this.innerProperties().title(); + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (childName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property childName in model OutputOnlyModelChild")); + } + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model OutputOnlyModelChild")); + } + if (innerProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property innerProperties in model OutputOnlyModelChild")); + } else { + innerProperties().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(OutputOnlyModelChild.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", name()); + jsonWriter.writeJsonField("properties", innerProperties()); + jsonWriter.writeStringField("childName", this.childName); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OutputOnlyModelChild from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OutputOnlyModelChild 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 OutputOnlyModelChild. + */ + public static OutputOnlyModelChild fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OutputOnlyModelChild deserializedOutputOnlyModelChild = new OutputOnlyModelChild(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedOutputOnlyModelChild.name = reader.getString(); + } else if ("id".equals(fieldName)) { + deserializedOutputOnlyModelChild.id = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedOutputOnlyModelChild.innerProperties = OutputOnlyModelProperties.fromJson(reader); + } else if ("childName".equals(fieldName)) { + deserializedOutputOnlyModelChild.childName = reader.getString(); + } else if ("kind".equals(fieldName)) { + deserializedOutputOnlyModelChild.kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOutputOnlyModelChild; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Salmon.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Salmon.java new file mode 100644 index 000000000..20319126e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Salmon.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.cadl.armstreamstyleserialization.fluent.models.SalmonInner; +import java.util.List; +import java.util.Map; + +/** + * An immutable client-side representation of Salmon. + */ +public interface Salmon { + /** + * Gets the age property: The age property. + * + * @return the age value. + */ + int age(); + + /** + * Gets the dna property: The dna property. + * + * @return the dna value. + */ + String dna(); + + /** + * Gets the length property: The length property. + * + * @return the length value. + */ + double length(); + + /** + * Gets the patten property: The patten property. + * + * @return the patten value. + */ + String patten(); + + /** + * Gets the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + String requiredString(); + + /** + * Gets the lengthAnotherPropertiesLength property: The length property. + * + * @return the lengthAnotherPropertiesLength value. + */ + double lengthAnotherPropertiesLength(); + + /** + * Gets the pattenAnotherPropertiesPatten property: The patten property. + * + * @return the pattenAnotherPropertiesPatten value. + */ + String pattenAnotherPropertiesPatten(); + + /** + * Gets the requiredStringAnotherPropertiesRequiredString property: The requiredString property. + * + * @return the requiredStringAnotherPropertiesRequiredString value. + */ + String requiredStringAnotherPropertiesRequiredString(); + + /** + * Gets the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + String kind(); + + /** + * Gets the friends property: The friends property. + * + * @return the friends value. + */ + List friends(); + + /** + * Gets the hate property: The hate property. + * + * @return the hate value. + */ + Map hate(); + + /** + * Gets the partner property: The partner property. + * + * @return the partner value. + */ + Fish partner(); + + /** + * Gets the inner com.cadl.armstreamstyleserialization.fluent.models.SalmonInner object. + * + * @return the inner object. + */ + SalmonInner innerModel(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/SawShark.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/SawShark.java new file mode 100644 index 000000000..914dfa530 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/SawShark.java @@ -0,0 +1,322 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.armstreamstyleserialization.fluent.models.AnotherFishProperties; +import com.cadl.armstreamstyleserialization.fluent.models.FishProperties; +import java.io.IOException; + +/** + * The third level model SawShark in polymorphic multiple levels inheritance. + */ +@Fluent +public final class SawShark extends Shark { + /* + * Discriminator property for Fish. + */ + private String kind = "shark"; + + /* + * The sharktype property. + */ + private String sharktype = "saw"; + + /* + * The dna property. + */ + private String dna; + + /* + * The age property. + */ + private int age; + + /* + * The anotherProperties property. + */ + private AnotherFishProperties innerAnotherProperties = new AnotherFishProperties(); + + /* + * The properties property. + */ + private FishProperties innerProperties = new FishProperties(); + + /** + * Creates an instance of SawShark class. + */ + public SawShark() { + } + + /** + * Get the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + @Override + public String kind() { + return this.kind; + } + + /** + * Get the sharktype property: The sharktype property. + * + * @return the sharktype value. + */ + @Override + public String sharktype() { + return this.sharktype; + } + + /** + * Get the dna property: The dna property. + * + * @return the dna value. + */ + public String dna() { + return this.dna; + } + + /** + * Set the dna property: The dna property. + * + * @param dna the dna value to set. + * @return the SawShark object itself. + */ + public SawShark withDna(String dna) { + this.dna = dna; + return this; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + public int age() { + return this.age; + } + + /** + * Set the age property: The age property. + * + * @param age the age value to set. + * @return the SawShark object itself. + */ + public SawShark withAge(int age) { + this.age = age; + return this; + } + + /** + * Get the innerAnotherProperties property: The anotherProperties property. + * + * @return the innerAnotherProperties value. + */ + private AnotherFishProperties innerAnotherProperties() { + return this.innerAnotherProperties; + } + + /** + * Get the innerProperties property: The properties property. + * + * @return the innerProperties value. + */ + private FishProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double length() { + return this.innerProperties() == null ? 0.0 : this.innerProperties().length(); + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the SawShark object itself. + */ + public SawShark withLength(double length) { + if (this.innerProperties() == null) { + this.innerProperties = new FishProperties(); + } + this.innerProperties().withLength(length); + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String patten() { + return this.innerProperties() == null ? null : this.innerProperties().patten(); + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredString() { + return this.innerProperties() == null ? null : this.innerProperties().requiredString(); + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the SawShark object itself. + */ + public SawShark withRequiredString(String requiredString) { + if (this.innerProperties() == null) { + this.innerProperties = new FishProperties(); + } + this.innerProperties().withRequiredString(requiredString); + return this; + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double lengthAnotherPropertiesLength() { + return this.innerAnotherProperties() == null ? 0.0 : this.innerAnotherProperties().length(); + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the SawShark object itself. + */ + public SawShark withLengthAnotherPropertiesLength(double length) { + if (this.innerAnotherProperties() == null) { + this.innerAnotherProperties = new AnotherFishProperties(); + } + this.innerAnotherProperties().withLength(length); + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String pattenAnotherPropertiesPatten() { + return this.innerAnotherProperties() == null ? null : this.innerAnotherProperties().patten(); + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredStringAnotherPropertiesRequiredString() { + return this.innerAnotherProperties() == null ? null : this.innerAnotherProperties().requiredString(); + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the SawShark object itself. + */ + public SawShark withRequiredStringAnotherPropertiesRequiredString(String requiredString) { + if (this.innerAnotherProperties() == null) { + this.innerAnotherProperties = new AnotherFishProperties(); + } + this.innerAnotherProperties().withRequiredString(requiredString); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (dna() == null) { + throw LOGGER.atError().log(new IllegalArgumentException("Missing required property dna in model SawShark")); + } + if (innerProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property innerProperties in model SawShark")); + } else { + innerProperties().validate(); + } + if (innerAnotherProperties() == null) { + throw LOGGER.atError() + .log( + new IllegalArgumentException("Missing required property innerAnotherProperties in model SawShark")); + } else { + innerAnotherProperties().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SawShark.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeIntField("age", age()); + jsonWriter.writeJsonField("properties", innerProperties()); + jsonWriter.writeJsonField("anotherProperties", innerAnotherProperties()); + jsonWriter.writeStringField("dna", this.dna); + jsonWriter.writeIntField("age", this.age); + jsonWriter.writeStringField("sharktype", this.sharktype); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SawShark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SawShark 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 SawShark. + */ + public static SawShark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SawShark deserializedSawShark = new SawShark(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("properties".equals(fieldName)) { + deserializedSawShark.innerProperties = FishProperties.fromJson(reader); + } else if ("anotherProperties".equals(fieldName)) { + deserializedSawShark.innerAnotherProperties = AnotherFishProperties.fromJson(reader); + } else if ("dna".equals(fieldName)) { + deserializedSawShark.dna = reader.getString(); + } else if ("age".equals(fieldName)) { + deserializedSawShark.age = reader.getInt(); + } else if ("sharktype".equals(fieldName)) { + deserializedSawShark.sharktype = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSawShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Shark.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Shark.java new file mode 100644 index 000000000..df15d3fe6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/Shark.java @@ -0,0 +1,317 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.armstreamstyleserialization.fluent.models.AnotherFishProperties; +import com.cadl.armstreamstyleserialization.fluent.models.FishInner; +import com.cadl.armstreamstyleserialization.fluent.models.FishProperties; +import java.io.IOException; + +/** + * The second level model in polymorphic multiple levels inheritance and it defines a new discriminator. + */ +@Fluent +public class Shark extends FishInner { + /* + * Discriminator property for Fish. + */ + private String kind = "shark"; + + /* + * The sharktype property. + */ + private String sharktype = "shark"; + + /* + * The anotherProperties property. + */ + private AnotherFishProperties innerAnotherProperties = new AnotherFishProperties(); + + /* + * The properties property. + */ + private FishProperties innerProperties = new FishProperties(); + + /* + * The dna property. + */ + private String dna; + + /** + * Creates an instance of Shark class. + */ + public Shark() { + } + + /** + * Get the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + @Override + public String kind() { + return this.kind; + } + + /** + * Get the sharktype property: The sharktype property. + * + * @return the sharktype value. + */ + public String sharktype() { + return this.sharktype; + } + + /** + * Get the innerAnotherProperties property: The anotherProperties property. + * + * @return the innerAnotherProperties value. + */ + private AnotherFishProperties innerAnotherProperties() { + return this.innerAnotherProperties; + } + + /** + * Get the innerProperties property: The properties property. + * + * @return the innerProperties value. + */ + private FishProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the dna property: The dna property. + * + * @return the dna value. + */ + @Override + public String dna() { + return this.dna; + } + + /** + * {@inheritDoc} + */ + @Override + public Shark withAge(int age) { + super.withAge(age); + return this; + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double length() { + return this.innerProperties() == null ? 0.0 : this.innerProperties().length(); + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the Shark object itself. + */ + public Shark withLength(double length) { + if (this.innerProperties() == null) { + this.innerProperties = new FishProperties(); + } + this.innerProperties().withLength(length); + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String patten() { + return this.innerProperties() == null ? null : this.innerProperties().patten(); + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredString() { + return this.innerProperties() == null ? null : this.innerProperties().requiredString(); + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the Shark object itself. + */ + public Shark withRequiredString(String requiredString) { + if (this.innerProperties() == null) { + this.innerProperties = new FishProperties(); + } + this.innerProperties().withRequiredString(requiredString); + return this; + } + + /** + * Get the length property: The length property. + * + * @return the length value. + */ + public double lengthAnotherPropertiesLength() { + return this.innerAnotherProperties() == null ? 0.0 : this.innerAnotherProperties().length(); + } + + /** + * Set the length property: The length property. + * + * @param length the length value to set. + * @return the Shark object itself. + */ + public Shark withLengthAnotherPropertiesLength(double length) { + if (this.innerAnotherProperties() == null) { + this.innerAnotherProperties = new AnotherFishProperties(); + } + this.innerAnotherProperties().withLength(length); + return this; + } + + /** + * Get the patten property: The patten property. + * + * @return the patten value. + */ + public String pattenAnotherPropertiesPatten() { + return this.innerAnotherProperties() == null ? null : this.innerAnotherProperties().patten(); + } + + /** + * Get the requiredString property: The requiredString property. + * + * @return the requiredString value. + */ + public String requiredStringAnotherPropertiesRequiredString() { + return this.innerAnotherProperties() == null ? null : this.innerAnotherProperties().requiredString(); + } + + /** + * Set the requiredString property: The requiredString property. + * + * @param requiredString the requiredString value to set. + * @return the Shark object itself. + */ + public Shark withRequiredStringAnotherPropertiesRequiredString(String requiredString) { + if (this.innerAnotherProperties() == null) { + this.innerAnotherProperties = new AnotherFishProperties(); + } + this.innerAnotherProperties().withRequiredString(requiredString); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (innerProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property innerProperties in model Shark")); + } else { + innerProperties().validate(); + } + if (innerAnotherProperties() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property innerAnotherProperties in model Shark")); + } else { + innerAnotherProperties().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(Shark.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeIntField("age", age()); + jsonWriter.writeJsonField("properties", innerProperties()); + jsonWriter.writeJsonField("anotherProperties", innerAnotherProperties()); + jsonWriter.writeStringField("sharktype", this.sharktype); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Shark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Shark 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 Shark. + */ + public static Shark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("sharktype".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("saw".equals(discriminatorValue)) { + return SawShark.fromJson(readerToUse.reset()); + } else if ("goblin".equals(discriminatorValue)) { + return GoblinShark.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static Shark fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Shark deserializedShark = new Shark(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + deserializedShark.withAge(reader.getInt()); + } else if ("dna".equals(fieldName)) { + deserializedShark.dna = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedShark.innerProperties = FishProperties.fromJson(reader); + } else if ("anotherProperties".equals(fieldName)) { + deserializedShark.innerAnotherProperties = AnotherFishProperties.fromJson(reader); + } else if ("sharktype".equals(fieldName)) { + deserializedShark.sharktype = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/TopLevelArmResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/TopLevelArmResource.java new file mode 100644 index 000000000..091eaecb0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/TopLevelArmResource.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.azure.core.management.SystemData; +import com.cadl.armstreamstyleserialization.fluent.models.TopLevelArmResourceInner; +import java.util.Map; + +/** + * An immutable client-side representation of TopLevelArmResource. + */ +public interface TopLevelArmResource { + /** + * 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. + */ + TopLevelArmResourceProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the inner com.cadl.armstreamstyleserialization.fluent.models.TopLevelArmResourceInner object. + * + * @return the inner object. + */ + TopLevelArmResourceInner innerModel(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/TopLevelArmResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/TopLevelArmResourceProperties.java new file mode 100644 index 000000000..1ee97ab2f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/TopLevelArmResourceProperties.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +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; + +/** + * Top Level Arm Resource Properties. + */ +@Immutable +public final class TopLevelArmResourceProperties implements JsonSerializable { + /* + * The description property. + */ + private String description; + + /** + * Creates an instance of TopLevelArmResourceProperties class. + */ + private TopLevelArmResourceProperties() { + } + + /** + * Get the description property: The description property. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TopLevelArmResourceProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TopLevelArmResourceProperties 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 TopLevelArmResourceProperties. + */ + public static TopLevelArmResourceProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TopLevelArmResourceProperties deserializedTopLevelArmResourceProperties + = new TopLevelArmResourceProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("description".equals(fieldName)) { + deserializedTopLevelArmResourceProperties.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedTopLevelArmResourceProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/TopLevelArmResourceTagsUpdate.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/TopLevelArmResourceTagsUpdate.java new file mode 100644 index 000000000..fb42270ea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/TopLevelArmResourceTagsUpdate.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.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; +import java.util.Map; + +/** + * The type used for updating tags in TopLevelArmResource resources. + */ +@Fluent +public final class TopLevelArmResourceTagsUpdate implements JsonSerializable { + /* + * Resource tags. + */ + private Map tags; + + /** + * Creates an instance of TopLevelArmResourceTagsUpdate class. + */ + public TopLevelArmResourceTagsUpdate() { + } + + /** + * Get the tags property: Resource tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Resource tags. + * + * @param tags the tags value to set. + * @return the TopLevelArmResourceTagsUpdate object itself. + */ + public TopLevelArmResourceTagsUpdate withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TopLevelArmResourceTagsUpdate from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TopLevelArmResourceTagsUpdate 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 TopLevelArmResourceTagsUpdate. + */ + public static TopLevelArmResourceTagsUpdate fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TopLevelArmResourceTagsUpdate deserializedTopLevelArmResourceTagsUpdate + = new TopLevelArmResourceTagsUpdate(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedTopLevelArmResourceTagsUpdate.tags = tags; + } else { + reader.skipChildren(); + } + } + + return deserializedTopLevelArmResourceTagsUpdate; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/TopLevelArmResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/TopLevelArmResources.java new file mode 100644 index 000000000..f96999841 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/TopLevelArmResources.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.armstreamstyleserialization.models; + +import com.azure.core.util.Context; + +/** + * Resource collection API of TopLevelArmResources. + */ +public interface TopLevelArmResources { + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + TopLevelArmResource update(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceTagsUpdate properties); + + /** + * Update a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourceName arm resource name for path. + * @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 tracked resource types can be created by aliasing this type using a specific property type. + */ + TopLevelArmResource update(String resourceGroupName, String topLevelArmResourceName, + TopLevelArmResourceTagsUpdate properties, Context context); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/models/package-info.java new file mode 100644 index 000000000..4f8dd1f1d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/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 ArmStreamStyleSerialization. + * Arm Resource Provider management API. + */ +package com.cadl.armstreamstyleserialization.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/package-info.java new file mode 100644 index 000000000..8f52a7121 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/armstreamstyleserialization/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 ArmStreamStyleSerialization. + * Arm Resource Provider management API. + */ +package com.cadl.armstreamstyleserialization; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/BuiltinAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/BuiltinAsyncClient.java new file mode 100644 index 000000000..3ad2476dd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/BuiltinAsyncClient.java @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.builtin; + +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.HttpHeaderName; +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.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.cadl.builtin.implementation.BuiltinOpsImpl; +import com.cadl.builtin.models.Builtin; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BuiltinClient type. + */ +@ServiceClient(builder = BuiltinClientBuilder.class, isAsync = true) +public final class BuiltinAsyncClient { + @Generated + private final BuiltinOpsImpl serviceClient; + + /** + * Initializes an instance of BuiltinAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BuiltinAsyncClient(BuiltinOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The read operation. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
query-optStringNoThe queryParamOptional parameter
query-opt-encodedStringNoThe queryParamOptionalEncoded parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-dateOffsetDateTimeNoThe dateTime parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     int: int (Required)
+     *     safeint: long (Required)
+     *     decimal: BigDecimal (Required)
+     *     long: long (Required)
+     *     float: double (Required)
+     *     double: double (Required)
+     *     duration: Duration (Required)
+     *     date: LocalDate (Required)
+     *     dateTime: OffsetDateTime (Required)
+     *     stringList (Required): [
+     *         String (Required)
+     *     ]
+     *     bytesDict (Required): {
+     *         String: byte[] (Required)
+     *     }
+     *     url: String (Required)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     *     encoded (Required): {
+     *         timeInSeconds: Long (Optional)
+     *         timeInSecondsFraction: Double (Optional)
+     *         dateTime: OffsetDateTime (Optional)
+     *         dateTimeRfc7231: DateTimeRfc1123 (Optional)
+     *         unixTimestamp: Long (Optional)
+     *         base64: byte[] (Optional)
+     *         base64url: Base64Url (Optional)
+     *     }
+     * }
+     * }
+ * + * @param queryParam The queryParam parameter. + * @param queryParamEncoded The queryParamEncoded 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> readWithResponse(String queryParam, String queryParamEncoded, + RequestOptions requestOptions) { + return this.serviceClient.readWithResponseAsync(queryParam, queryParamEncoded, requestOptions); + } + + /** + * The write operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     int: int (Required)
+     *     safeint: long (Required)
+     *     decimal: BigDecimal (Required)
+     *     long: long (Required)
+     *     float: double (Required)
+     *     double: double (Required)
+     *     duration: Duration (Required)
+     *     date: LocalDate (Required)
+     *     dateTime: OffsetDateTime (Required)
+     *     stringList (Required): [
+     *         String (Required)
+     *     ]
+     *     bytesDict (Required): {
+     *         String: byte[] (Required)
+     *     }
+     *     url: String (Required)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     *     encoded (Required): {
+     *         timeInSeconds: Long (Optional)
+     *         timeInSecondsFraction: Double (Optional)
+     *         dateTime: OffsetDateTime (Optional)
+     *         dateTimeRfc7231: DateTimeRfc1123 (Optional)
+     *         unixTimestamp: Long (Optional)
+     *         base64: byte[] (Optional)
+     *         base64url: Base64Url (Optional)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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> writeWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.writeWithResponseAsync(body, requestOptions); + } + + /** + * The read operation. + * + * @param queryParam The queryParam parameter. + * @param queryParamEncoded The queryParamEncoded parameter. + * @param dateTime The dateTime parameter. + * @param filter The filter parameter. + * @param queryParamOptional The queryParamOptional parameter. + * @param queryParamOptionalEncoded The queryParamOptionalEncoded 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono read(String queryParam, String queryParamEncoded, OffsetDateTime dateTime, String filter, + String queryParamOptional, String queryParamOptionalEncoded) { + // Generated convenience method for readWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (dateTime != null) { + requestOptions.setHeader(HttpHeaderName.X_MS_DATE, String.valueOf(new DateTimeRfc1123(dateTime))); + } + if (filter != null) { + requestOptions.addQueryParam("filter", filter, false); + } + if (queryParamOptional != null) { + requestOptions.addQueryParam("query-opt", queryParamOptional, false); + } + if (queryParamOptionalEncoded != null) { + requestOptions.addQueryParam("query-opt-encoded", queryParamOptionalEncoded, true); + } + return readWithResponse(queryParam, queryParamEncoded, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Builtin.class)); + } + + /** + * The read operation. + * + * @param queryParam The queryParam parameter. + * @param queryParamEncoded The queryParamEncoded 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono read(String queryParam, String queryParamEncoded) { + // Generated convenience method for readWithResponse + RequestOptions requestOptions = new RequestOptions(); + return readWithResponse(queryParam, queryParamEncoded, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Builtin.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/BuiltinClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/BuiltinClient.java new file mode 100644 index 000000000..c221fdec1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/BuiltinClient.java @@ -0,0 +1,226 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.builtin; + +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.HttpHeaderName; +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.DateTimeRfc1123; +import com.cadl.builtin.implementation.BuiltinOpsImpl; +import com.cadl.builtin.models.Builtin; +import java.time.OffsetDateTime; + +/** + * Initializes a new instance of the synchronous BuiltinClient type. + */ +@ServiceClient(builder = BuiltinClientBuilder.class) +public final class BuiltinClient { + @Generated + private final BuiltinOpsImpl serviceClient; + + /** + * Initializes an instance of BuiltinClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BuiltinClient(BuiltinOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The read operation. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
query-optStringNoThe queryParamOptional parameter
query-opt-encodedStringNoThe queryParamOptionalEncoded parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-dateOffsetDateTimeNoThe dateTime parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     int: int (Required)
+     *     safeint: long (Required)
+     *     decimal: BigDecimal (Required)
+     *     long: long (Required)
+     *     float: double (Required)
+     *     double: double (Required)
+     *     duration: Duration (Required)
+     *     date: LocalDate (Required)
+     *     dateTime: OffsetDateTime (Required)
+     *     stringList (Required): [
+     *         String (Required)
+     *     ]
+     *     bytesDict (Required): {
+     *         String: byte[] (Required)
+     *     }
+     *     url: String (Required)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     *     encoded (Required): {
+     *         timeInSeconds: Long (Optional)
+     *         timeInSecondsFraction: Double (Optional)
+     *         dateTime: OffsetDateTime (Optional)
+     *         dateTimeRfc7231: DateTimeRfc1123 (Optional)
+     *         unixTimestamp: Long (Optional)
+     *         base64: byte[] (Optional)
+     *         base64url: Base64Url (Optional)
+     *     }
+     * }
+     * }
+ * + * @param queryParam The queryParam parameter. + * @param queryParamEncoded The queryParamEncoded 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response readWithResponse(String queryParam, String queryParamEncoded, + RequestOptions requestOptions) { + return this.serviceClient.readWithResponse(queryParam, queryParamEncoded, requestOptions); + } + + /** + * The write operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     int: int (Required)
+     *     safeint: long (Required)
+     *     decimal: BigDecimal (Required)
+     *     long: long (Required)
+     *     float: double (Required)
+     *     double: double (Required)
+     *     duration: Duration (Required)
+     *     date: LocalDate (Required)
+     *     dateTime: OffsetDateTime (Required)
+     *     stringList (Required): [
+     *         String (Required)
+     *     ]
+     *     bytesDict (Required): {
+     *         String: byte[] (Required)
+     *     }
+     *     url: String (Required)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     *     encoded (Required): {
+     *         timeInSeconds: Long (Optional)
+     *         timeInSecondsFraction: Double (Optional)
+     *         dateTime: OffsetDateTime (Optional)
+     *         dateTimeRfc7231: DateTimeRfc1123 (Optional)
+     *         unixTimestamp: Long (Optional)
+     *         base64: byte[] (Optional)
+     *         base64url: Base64Url (Optional)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 writeWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.writeWithResponse(body, requestOptions); + } + + /** + * The read operation. + * + * @param queryParam The queryParam parameter. + * @param queryParamEncoded The queryParamEncoded parameter. + * @param dateTime The dateTime parameter. + * @param filter The filter parameter. + * @param queryParamOptional The queryParamOptional parameter. + * @param queryParamOptionalEncoded The queryParamOptionalEncoded 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Builtin read(String queryParam, String queryParamEncoded, OffsetDateTime dateTime, String filter, + String queryParamOptional, String queryParamOptionalEncoded) { + // Generated convenience method for readWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (dateTime != null) { + requestOptions.setHeader(HttpHeaderName.X_MS_DATE, String.valueOf(new DateTimeRfc1123(dateTime))); + } + if (filter != null) { + requestOptions.addQueryParam("filter", filter, false); + } + if (queryParamOptional != null) { + requestOptions.addQueryParam("query-opt", queryParamOptional, false); + } + if (queryParamOptionalEncoded != null) { + requestOptions.addQueryParam("query-opt-encoded", queryParamOptionalEncoded, true); + } + return readWithResponse(queryParam, queryParamEncoded, requestOptions).getValue().toObject(Builtin.class); + } + + /** + * The read operation. + * + * @param queryParam The queryParam parameter. + * @param queryParamEncoded The queryParamEncoded 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Builtin read(String queryParam, String queryParamEncoded) { + // Generated convenience method for readWithResponse + RequestOptions requestOptions = new RequestOptions(); + return readWithResponse(queryParam, queryParamEncoded, requestOptions).getValue().toObject(Builtin.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/BuiltinClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/BuiltinClientBuilder.java new file mode 100644 index 000000000..c6a138900 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/BuiltinClientBuilder.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 com.cadl.builtin; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.builtin.implementation.BuiltinClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the BuiltinClient type. + */ +@ServiceClientBuilder(serviceClients = { BuiltinClient.class, BuiltinAsyncClient.class }) +public final class BuiltinClientBuilder 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("cadl-builtin.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the BuiltinClientBuilder. + */ + @Generated + public BuiltinClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BuiltinClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BuiltinClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BuiltinClientBuilder 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 BuiltinClientBuilder 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 BuiltinClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BuiltinClientBuilder 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 BuiltinClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BuiltinClientBuilder 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 BuiltinClientBuilder. + */ + @Generated + public BuiltinClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of BuiltinClientImpl with the provided parameters. + * + * @return an instance of BuiltinClientImpl. + */ + @Generated + private BuiltinClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + BuiltinClientImpl client + = new BuiltinClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 BuiltinAsyncClient class. + * + * @return an instance of BuiltinAsyncClient. + */ + @Generated + public BuiltinAsyncClient buildAsyncClient() { + return new BuiltinAsyncClient(buildInnerClient().getBuiltinOps()); + } + + /** + * Builds an instance of BuiltinClient class. + * + * @return an instance of BuiltinClient. + */ + @Generated + public BuiltinClient buildClient() { + return new BuiltinClient(buildInnerClient().getBuiltinOps()); + } + + private static final ClientLogger LOGGER = new ClientLogger(BuiltinClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/implementation/BuiltinClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/implementation/BuiltinClientImpl.java new file mode 100644 index 000000000..5bfa37980 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/implementation/BuiltinClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.builtin.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the BuiltinClient type. + */ +public final class BuiltinClientImpl { + /** + * 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; + } + + /** + * The BuiltinOpsImpl object to access its operations. + */ + private final BuiltinOpsImpl builtinOps; + + /** + * Gets the BuiltinOpsImpl object to access its operations. + * + * @return the BuiltinOpsImpl object. + */ + public BuiltinOpsImpl getBuiltinOps() { + return this.builtinOps; + } + + /** + * Initializes an instance of BuiltinClient client. + * + * @param endpoint Service host. + */ + public BuiltinClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of BuiltinClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public BuiltinClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of BuiltinClient 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 BuiltinClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.builtinOps = new BuiltinOpsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/implementation/BuiltinOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/implementation/BuiltinOpsImpl.java new file mode 100644 index 000000000..7ea2c40fd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/implementation/BuiltinOpsImpl.java @@ -0,0 +1,358 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.builtin.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +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.BinaryData; +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 BuiltinOps. + */ +public final class BuiltinOpsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BuiltinOpsService service; + + /** + * The service client containing this operation class. + */ + private final BuiltinClientImpl client; + + /** + * Initializes an instance of BuiltinOpsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BuiltinOpsImpl(BuiltinClientImpl client) { + this.service + = RestProxy.create(BuiltinOpsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for BuiltinClientBuiltinOps to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BuiltinClientBuiltin") + public interface BuiltinOpsService { + @Get("/builtin") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> read(@HostParam("endpoint") String endpoint, @QueryParam("query") String queryParam, + @QueryParam(value = "query-encoded", encoded = true) String queryParamEncoded, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/builtin") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response readSync(@HostParam("endpoint") String endpoint, @QueryParam("query") String queryParam, + @QueryParam(value = "query-encoded", encoded = true) String queryParamEncoded, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/builtin") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> write(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/builtin") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response writeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The read operation. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
query-optStringNoThe queryParamOptional parameter
query-opt-encodedStringNoThe queryParamOptionalEncoded parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-dateOffsetDateTimeNoThe dateTime parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     int: int (Required)
+     *     safeint: long (Required)
+     *     decimal: BigDecimal (Required)
+     *     long: long (Required)
+     *     float: double (Required)
+     *     double: double (Required)
+     *     duration: Duration (Required)
+     *     date: LocalDate (Required)
+     *     dateTime: OffsetDateTime (Required)
+     *     stringList (Required): [
+     *         String (Required)
+     *     ]
+     *     bytesDict (Required): {
+     *         String: byte[] (Required)
+     *     }
+     *     url: String (Required)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     *     encoded (Required): {
+     *         timeInSeconds: Long (Optional)
+     *         timeInSecondsFraction: Double (Optional)
+     *         dateTime: OffsetDateTime (Optional)
+     *         dateTimeRfc7231: DateTimeRfc1123 (Optional)
+     *         unixTimestamp: Long (Optional)
+     *         base64: byte[] (Optional)
+     *         base64url: Base64Url (Optional)
+     *     }
+     * }
+     * }
+ * + * @param queryParam The queryParam parameter. + * @param queryParamEncoded The queryParamEncoded 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> readWithResponseAsync(String queryParam, String queryParamEncoded, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.read(this.client.getEndpoint(), queryParam, queryParamEncoded, + accept, requestOptions, context)); + } + + /** + * The read operation. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
query-optStringNoThe queryParamOptional parameter
query-opt-encodedStringNoThe queryParamOptionalEncoded parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
x-ms-dateOffsetDateTimeNoThe dateTime parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     int: int (Required)
+     *     safeint: long (Required)
+     *     decimal: BigDecimal (Required)
+     *     long: long (Required)
+     *     float: double (Required)
+     *     double: double (Required)
+     *     duration: Duration (Required)
+     *     date: LocalDate (Required)
+     *     dateTime: OffsetDateTime (Required)
+     *     stringList (Required): [
+     *         String (Required)
+     *     ]
+     *     bytesDict (Required): {
+     *         String: byte[] (Required)
+     *     }
+     *     url: String (Required)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     *     encoded (Required): {
+     *         timeInSeconds: Long (Optional)
+     *         timeInSecondsFraction: Double (Optional)
+     *         dateTime: OffsetDateTime (Optional)
+     *         dateTimeRfc7231: DateTimeRfc1123 (Optional)
+     *         unixTimestamp: Long (Optional)
+     *         base64: byte[] (Optional)
+     *         base64url: Base64Url (Optional)
+     *     }
+     * }
+     * }
+ * + * @param queryParam The queryParam parameter. + * @param queryParamEncoded The queryParamEncoded 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response readWithResponse(String queryParam, String queryParamEncoded, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.readSync(this.client.getEndpoint(), queryParam, queryParamEncoded, accept, requestOptions, + Context.NONE); + } + + /** + * The write operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     int: int (Required)
+     *     safeint: long (Required)
+     *     decimal: BigDecimal (Required)
+     *     long: long (Required)
+     *     float: double (Required)
+     *     double: double (Required)
+     *     duration: Duration (Required)
+     *     date: LocalDate (Required)
+     *     dateTime: OffsetDateTime (Required)
+     *     stringList (Required): [
+     *         String (Required)
+     *     ]
+     *     bytesDict (Required): {
+     *         String: byte[] (Required)
+     *     }
+     *     url: String (Required)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     *     encoded (Required): {
+     *         timeInSeconds: Long (Optional)
+     *         timeInSecondsFraction: Double (Optional)
+     *         dateTime: OffsetDateTime (Optional)
+     *         dateTimeRfc7231: DateTimeRfc1123 (Optional)
+     *         unixTimestamp: Long (Optional)
+     *         base64: byte[] (Optional)
+     *         base64url: Base64Url (Optional)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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> writeWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.write(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The write operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     int: int (Required)
+     *     safeint: long (Required)
+     *     decimal: BigDecimal (Required)
+     *     long: long (Required)
+     *     float: double (Required)
+     *     double: double (Required)
+     *     duration: Duration (Required)
+     *     date: LocalDate (Required)
+     *     dateTime: OffsetDateTime (Required)
+     *     stringList (Required): [
+     *         String (Required)
+     *     ]
+     *     bytesDict (Required): {
+     *         String: byte[] (Required)
+     *     }
+     *     url: String (Required)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     *     encoded (Required): {
+     *         timeInSeconds: Long (Optional)
+     *         timeInSecondsFraction: Double (Optional)
+     *         dateTime: OffsetDateTime (Optional)
+     *         dateTimeRfc7231: DateTimeRfc1123 (Optional)
+     *         unixTimestamp: Long (Optional)
+     *         base64: byte[] (Optional)
+     *         base64url: Base64Url (Optional)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 writeWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.writeSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/implementation/package-info.java new file mode 100644 index 000000000..8fe15dad8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Builtin. + * + */ +package com.cadl.builtin.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Builtin.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Builtin.java new file mode 100644 index 000000000..31f5db273 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Builtin.java @@ -0,0 +1,452 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.builtin.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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.math.BigDecimal; +import java.time.Duration; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * The Builtin model. + */ +@Immutable +public final class Builtin implements JsonSerializable { + /* + * The boolean property. + */ + @Generated + private final boolean booleanProperty; + + /* + * The string property. + */ + @Generated + private final String string; + + /* + * The bytes property. + */ + @Generated + private final byte[] bytes; + + /* + * The int property. + */ + @Generated + private final int intProperty; + + /* + * The safeint property. + */ + @Generated + private final long safeint; + + /* + * The decimal property. + */ + @Generated + private final BigDecimal decimal; + + /* + * The long property. + */ + @Generated + private final long longProperty; + + /* + * The float property. + */ + @Generated + private final double floatProperty; + + /* + * The double property. + */ + @Generated + private final double doubleProperty; + + /* + * The duration property. + */ + @Generated + private final Duration duration; + + /* + * The date property. + */ + @Generated + private final LocalDate date; + + /* + * The dateTime property. + */ + @Generated + private final OffsetDateTime dateTime; + + /* + * The stringList property. + */ + @Generated + private final List stringList; + + /* + * The bytesDict property. + */ + @Generated + private final Map bytesDict; + + /* + * The url property. + */ + @Generated + private final String url; + + /* + * The nullableFloatDict property. + */ + @Generated + private final Map nullableFloatDict; + + /* + * The encoded property. + */ + @Generated + private final Encoded encoded; + + /** + * Creates an instance of Builtin class. + * + * @param booleanProperty the booleanProperty value to set. + * @param string the string value to set. + * @param bytes the bytes value to set. + * @param intProperty the intProperty value to set. + * @param safeint the safeint value to set. + * @param decimal the decimal value to set. + * @param longProperty the longProperty value to set. + * @param floatProperty the floatProperty value to set. + * @param doubleProperty the doubleProperty value to set. + * @param duration the duration value to set. + * @param date the date value to set. + * @param dateTime the dateTime value to set. + * @param stringList the stringList value to set. + * @param bytesDict the bytesDict value to set. + * @param url the url value to set. + * @param nullableFloatDict the nullableFloatDict value to set. + * @param encoded the encoded value to set. + */ + @Generated + public Builtin(boolean booleanProperty, String string, byte[] bytes, int intProperty, long safeint, + BigDecimal decimal, long longProperty, double floatProperty, double doubleProperty, Duration duration, + LocalDate date, OffsetDateTime dateTime, List stringList, Map bytesDict, String url, + Map nullableFloatDict, Encoded encoded) { + this.booleanProperty = booleanProperty; + this.string = string; + this.bytes = bytes; + this.intProperty = intProperty; + this.safeint = safeint; + this.decimal = decimal; + this.longProperty = longProperty; + this.floatProperty = floatProperty; + this.doubleProperty = doubleProperty; + this.duration = duration; + this.date = date; + this.dateTime = dateTime; + this.stringList = stringList; + this.bytesDict = bytesDict; + this.url = url; + this.nullableFloatDict = nullableFloatDict; + this.encoded = encoded; + } + + /** + * Get the booleanProperty property: The boolean property. + * + * @return the booleanProperty value. + */ + @Generated + public boolean isBooleanProperty() { + return this.booleanProperty; + } + + /** + * Get the string property: The string property. + * + * @return the string value. + */ + @Generated + public String getString() { + return this.string; + } + + /** + * Get the bytes property: The bytes property. + * + * @return the bytes value. + */ + @Generated + public byte[] getBytes() { + return CoreUtils.clone(this.bytes); + } + + /** + * Get the intProperty property: The int property. + * + * @return the intProperty value. + */ + @Generated + public int getIntProperty() { + return this.intProperty; + } + + /** + * Get the safeint property: The safeint property. + * + * @return the safeint value. + */ + @Generated + public long getSafeint() { + return this.safeint; + } + + /** + * Get the decimal property: The decimal property. + * + * @return the decimal value. + */ + @Generated + public BigDecimal getDecimal() { + return this.decimal; + } + + /** + * Get the longProperty property: The long property. + * + * @return the longProperty value. + */ + @Generated + public long getLongProperty() { + return this.longProperty; + } + + /** + * Get the floatProperty property: The float property. + * + * @return the floatProperty value. + */ + @Generated + public double getFloatProperty() { + return this.floatProperty; + } + + /** + * Get the doubleProperty property: The double property. + * + * @return the doubleProperty value. + */ + @Generated + public double getDoubleProperty() { + return this.doubleProperty; + } + + /** + * Get the duration property: The duration property. + * + * @return the duration value. + */ + @Generated + public Duration getDuration() { + return this.duration; + } + + /** + * Get the date property: The date property. + * + * @return the date value. + */ + @Generated + public LocalDate getDate() { + return this.date; + } + + /** + * Get the dateTime property: The dateTime property. + * + * @return the dateTime value. + */ + @Generated + public OffsetDateTime getDateTime() { + return this.dateTime; + } + + /** + * Get the stringList property: The stringList property. + * + * @return the stringList value. + */ + @Generated + public List getStringList() { + return this.stringList; + } + + /** + * Get the bytesDict property: The bytesDict property. + * + * @return the bytesDict value. + */ + @Generated + public Map getBytesDict() { + return this.bytesDict; + } + + /** + * Get the url property: The url property. + * + * @return the url value. + */ + @Generated + public String getUrl() { + return this.url; + } + + /** + * Get the nullableFloatDict property: The nullableFloatDict property. + * + * @return the nullableFloatDict value. + */ + @Generated + public Map getNullableFloatDict() { + return this.nullableFloatDict; + } + + /** + * Get the encoded property: The encoded property. + * + * @return the encoded value. + */ + @Generated + public Encoded getEncoded() { + return this.encoded; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("boolean", this.booleanProperty); + jsonWriter.writeStringField("string", this.string); + jsonWriter.writeBinaryField("bytes", this.bytes); + jsonWriter.writeIntField("int", this.intProperty); + jsonWriter.writeLongField("safeint", this.safeint); + jsonWriter.writeNumberField("decimal", this.decimal); + jsonWriter.writeLongField("long", this.longProperty); + jsonWriter.writeDoubleField("float", this.floatProperty); + jsonWriter.writeDoubleField("double", this.doubleProperty); + jsonWriter.writeStringField("duration", CoreUtils.durationToStringWithDays(this.duration)); + jsonWriter.writeStringField("date", Objects.toString(this.date, null)); + jsonWriter.writeStringField("dateTime", + this.dateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.dateTime)); + jsonWriter.writeArrayField("stringList", this.stringList, (writer, element) -> writer.writeString(element)); + jsonWriter.writeMapField("bytesDict", this.bytesDict, (writer, element) -> writer.writeBinary(element)); + jsonWriter.writeStringField("url", this.url); + jsonWriter.writeMapField("nullableFloatDict", this.nullableFloatDict, + (writer, element) -> writer.writeNumber(element)); + jsonWriter.writeJsonField("encoded", this.encoded); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Builtin from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Builtin 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 Builtin. + */ + @Generated + public static Builtin fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean booleanProperty = false; + String string = null; + byte[] bytes = null; + int intProperty = 0; + long safeint = 0L; + BigDecimal decimal = null; + long longProperty = 0L; + double floatProperty = 0.0; + double doubleProperty = 0.0; + Duration duration = null; + LocalDate date = null; + OffsetDateTime dateTime = null; + List stringList = null; + Map bytesDict = null; + String url = null; + Map nullableFloatDict = null; + Encoded encoded = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("boolean".equals(fieldName)) { + booleanProperty = reader.getBoolean(); + } else if ("string".equals(fieldName)) { + string = reader.getString(); + } else if ("bytes".equals(fieldName)) { + bytes = reader.getBinary(); + } else if ("int".equals(fieldName)) { + intProperty = reader.getInt(); + } else if ("safeint".equals(fieldName)) { + safeint = reader.getLong(); + } else if ("decimal".equals(fieldName)) { + decimal = reader.getNullable(nonNullReader -> new BigDecimal(nonNullReader.getString())); + } else if ("long".equals(fieldName)) { + longProperty = reader.getLong(); + } else if ("float".equals(fieldName)) { + floatProperty = reader.getDouble(); + } else if ("double".equals(fieldName)) { + doubleProperty = reader.getDouble(); + } else if ("duration".equals(fieldName)) { + duration = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else if ("date".equals(fieldName)) { + date = reader.getNullable(nonNullReader -> LocalDate.parse(nonNullReader.getString())); + } else if ("dateTime".equals(fieldName)) { + dateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("stringList".equals(fieldName)) { + stringList = reader.readArray(reader1 -> reader1.getString()); + } else if ("bytesDict".equals(fieldName)) { + bytesDict = reader.readMap(reader1 -> reader1.getBinary()); + } else if ("url".equals(fieldName)) { + url = reader.getString(); + } else if ("nullableFloatDict".equals(fieldName)) { + nullableFloatDict = reader.readMap(reader1 -> reader1.getNullable(JsonReader::getDouble)); + } else if ("encoded".equals(fieldName)) { + encoded = Encoded.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new Builtin(booleanProperty, string, bytes, intProperty, safeint, decimal, longProperty, + floatProperty, doubleProperty, duration, date, dateTime, stringList, bytesDict, url, nullableFloatDict, + encoded); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Encoded.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Encoded.java new file mode 100644 index 000000000..ec6c81b64 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/Encoded.java @@ -0,0 +1,326 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.builtin.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.Base64Url; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +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.time.Duration; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.util.Objects; + +/** + * The Encoded model. + */ +@Fluent +public final class Encoded implements JsonSerializable { + /* + * The timeInSeconds property. + */ + @Generated + private Long timeInSeconds; + + /* + * The timeInSecondsFraction property. + */ + @Generated + private Double timeInSecondsFraction; + + /* + * The dateTime property. + */ + @Generated + private OffsetDateTime dateTime; + + /* + * The dateTimeRfc7231 property. + */ + @Generated + private DateTimeRfc1123 dateTimeRfc7231; + + /* + * The unixTimestamp property. + */ + @Generated + private Long unixTimestamp; + + /* + * The base64 property. + */ + @Generated + private byte[] base64; + + /* + * The base64url property. + */ + @Generated + private Base64Url base64url; + + /** + * Creates an instance of Encoded class. + */ + @Generated + public Encoded() { + } + + /** + * Get the timeInSeconds property: The timeInSeconds property. + * + * @return the timeInSeconds value. + */ + @Generated + public Duration getTimeInSeconds() { + if (this.timeInSeconds == null) { + return null; + } + return Duration.ofSeconds(this.timeInSeconds); + } + + /** + * Set the timeInSeconds property: The timeInSeconds property. + * + * @param timeInSeconds the timeInSeconds value to set. + * @return the Encoded object itself. + */ + @Generated + public Encoded setTimeInSeconds(Duration timeInSeconds) { + if (timeInSeconds == null) { + this.timeInSeconds = null; + } else { + this.timeInSeconds = timeInSeconds.getSeconds(); + } + return this; + } + + /** + * Get the timeInSecondsFraction property: The timeInSecondsFraction property. + * + * @return the timeInSecondsFraction value. + */ + @Generated + public Duration getTimeInSecondsFraction() { + if (this.timeInSecondsFraction == null) { + return null; + } + return Duration.ofNanos((long) (this.timeInSecondsFraction * 1000_000_000L)); + } + + /** + * Set the timeInSecondsFraction property: The timeInSecondsFraction property. + * + * @param timeInSecondsFraction the timeInSecondsFraction value to set. + * @return the Encoded object itself. + */ + @Generated + public Encoded setTimeInSecondsFraction(Duration timeInSecondsFraction) { + if (timeInSecondsFraction == null) { + this.timeInSecondsFraction = null; + } else { + this.timeInSecondsFraction = (double) timeInSecondsFraction.toNanos() / 1000_000_000L; + } + return this; + } + + /** + * Get the dateTime property: The dateTime property. + * + * @return the dateTime value. + */ + @Generated + public OffsetDateTime getDateTime() { + return this.dateTime; + } + + /** + * Set the dateTime property: The dateTime property. + * + * @param dateTime the dateTime value to set. + * @return the Encoded object itself. + */ + @Generated + public Encoded setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get the dateTimeRfc7231 property: The dateTimeRfc7231 property. + * + * @return the dateTimeRfc7231 value. + */ + @Generated + public OffsetDateTime getDateTimeRfc7231() { + if (this.dateTimeRfc7231 == null) { + return null; + } + return this.dateTimeRfc7231.getDateTime(); + } + + /** + * Set the dateTimeRfc7231 property: The dateTimeRfc7231 property. + * + * @param dateTimeRfc7231 the dateTimeRfc7231 value to set. + * @return the Encoded object itself. + */ + @Generated + public Encoded setDateTimeRfc7231(OffsetDateTime dateTimeRfc7231) { + if (dateTimeRfc7231 == null) { + this.dateTimeRfc7231 = null; + } else { + this.dateTimeRfc7231 = new DateTimeRfc1123(dateTimeRfc7231); + } + return this; + } + + /** + * Get the unixTimestamp property: The unixTimestamp property. + * + * @return the unixTimestamp value. + */ + @Generated + public OffsetDateTime getUnixTimestamp() { + if (this.unixTimestamp == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.unixTimestamp), ZoneOffset.UTC); + } + + /** + * Set the unixTimestamp property: The unixTimestamp property. + * + * @param unixTimestamp the unixTimestamp value to set. + * @return the Encoded object itself. + */ + @Generated + public Encoded setUnixTimestamp(OffsetDateTime unixTimestamp) { + if (unixTimestamp == null) { + this.unixTimestamp = null; + } else { + this.unixTimestamp = unixTimestamp.toEpochSecond(); + } + return this; + } + + /** + * Get the base64 property: The base64 property. + * + * @return the base64 value. + */ + @Generated + public byte[] getBase64() { + return CoreUtils.clone(this.base64); + } + + /** + * Set the base64 property: The base64 property. + * + * @param base64 the base64 value to set. + * @return the Encoded object itself. + */ + @Generated + public Encoded setBase64(byte[] base64) { + this.base64 = CoreUtils.clone(base64); + return this; + } + + /** + * Get the base64url property: The base64url property. + * + * @return the base64url value. + */ + @Generated + public byte[] getBase64url() { + if (this.base64url == null) { + return null; + } + return this.base64url.decodedBytes(); + } + + /** + * Set the base64url property: The base64url property. + * + * @param base64url the base64url value to set. + * @return the Encoded object itself. + */ + @Generated + public Encoded setBase64url(byte[] base64url) { + if (base64url == null) { + this.base64url = null; + } else { + this.base64url = Base64Url.encode(CoreUtils.clone(base64url)); + } + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("timeInSeconds", this.timeInSeconds); + jsonWriter.writeNumberField("timeInSecondsFraction", this.timeInSecondsFraction); + jsonWriter.writeStringField("dateTime", + this.dateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.dateTime)); + jsonWriter.writeStringField("dateTimeRfc7231", Objects.toString(this.dateTimeRfc7231, null)); + jsonWriter.writeNumberField("unixTimestamp", this.unixTimestamp); + jsonWriter.writeBinaryField("base64", this.base64); + jsonWriter.writeStringField("base64url", Objects.toString(this.base64url, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Encoded from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Encoded 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 Encoded. + */ + @Generated + public static Encoded fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Encoded deserializedEncoded = new Encoded(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("timeInSeconds".equals(fieldName)) { + deserializedEncoded.timeInSeconds = reader.getNullable(JsonReader::getLong); + } else if ("timeInSecondsFraction".equals(fieldName)) { + deserializedEncoded.timeInSecondsFraction = reader.getNullable(JsonReader::getDouble); + } else if ("dateTime".equals(fieldName)) { + deserializedEncoded.dateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("dateTimeRfc7231".equals(fieldName)) { + deserializedEncoded.dateTimeRfc7231 + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + } else if ("unixTimestamp".equals(fieldName)) { + deserializedEncoded.unixTimestamp = reader.getNullable(JsonReader::getLong); + } else if ("base64".equals(fieldName)) { + deserializedEncoded.base64 = reader.getBinary(); + } else if ("base64url".equals(fieldName)) { + deserializedEncoded.base64url + = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedEncoded; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/package-info.java new file mode 100644 index 000000000..1b284b1ce --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Builtin. + * + */ +package com.cadl.builtin.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/package-info.java new file mode 100644 index 000000000..a2ace4126 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/builtin/package-info.java @@ -0,0 +1,10 @@ +// 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 Builtin. + * + */ +package com.cadl.builtin; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/EnumServiceAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/EnumServiceAsyncClient.java new file mode 100644 index 000000000..51b5c4cfc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/EnumServiceAsyncClient.java @@ -0,0 +1,1084 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.enumservice; + +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.HttpHeaderName; +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 com.azure.core.util.serializer.CollectionFormat; +import com.azure.core.util.serializer.JacksonAdapter; +import com.cadl.enumservice.implementation.EnumServiceClientImpl; +import com.cadl.enumservice.models.Color; +import com.cadl.enumservice.models.ColorModel; +import com.cadl.enumservice.models.Operation; +import com.cadl.enumservice.models.OperationStateValues; +import com.cadl.enumservice.models.Priority; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous EnumServiceClient type. + */ +@ServiceClient(builder = EnumServiceClientBuilder.class, isAsync = true) +public final class EnumServiceAsyncClient { + @Generated + private final EnumServiceClientImpl serviceClient; + + /** + * Initializes an instance of EnumServiceAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EnumServiceAsyncClient(EnumServiceClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getColor operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Red / Blue / Green)
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getColorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getColorWithResponseAsync(requestOptions); + } + + /** + * The getColorModel operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Red / Blue / Green)
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getColorModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getColorModelWithResponseAsync(requestOptions); + } + + /** + * The setColorModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @param color The color parameter. Allowed values: "Red", "Blue", "Green". + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setColorModelWithResponse(String color, RequestOptions requestOptions) { + return this.serviceClient.setColorModelWithResponseAsync(color, requestOptions); + } + + /** + * The setPriority operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @param priority The priority parameter. Allowed values: 100, 0. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setPriorityWithResponse(String priority, RequestOptions requestOptions) { + return this.serviceClient.setPriorityWithResponseAsync(priority, requestOptions); + } + + /** + * The getRunningOperation operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRunningOperationWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRunningOperationWithResponseAsync(requestOptions); + } + + /** + * The getOperation operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @param state The state parameter. Allowed values: "Running", "Completed", "Failed". + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getOperationWithResponse(String state, RequestOptions requestOptions) { + return this.serviceClient.getOperationWithResponseAsync(state, requestOptions); + } + + /** + * The setStringEnumArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
colorArrayOptList<String>NoThe colorArrayOpt parameter. In the form of + * "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param colorArray The colorArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setStringEnumArrayWithResponse(List colorArray, + RequestOptions requestOptions) { + return this.serviceClient.setStringEnumArrayWithResponseAsync(colorArray, requestOptions); + } + + /** + * The setIntEnumArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
priorityArrayOptList<String>NoThe priorityArrayOpt parameter. In the + * form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param priorityArray The priorityArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setIntEnumArrayWithResponse(List priorityArray, + RequestOptions requestOptions) { + return this.serviceClient.setIntEnumArrayWithResponseAsync(priorityArray, requestOptions); + } + + /** + * The setStringArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringArrayOptList<String>NoThe stringArrayOpt parameter. In the form of + * "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param stringArray The stringArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setStringArrayWithResponse(List stringArray, + RequestOptions requestOptions) { + return this.serviceClient.setStringArrayWithResponseAsync(stringArray, requestOptions); + } + + /** + * The setIntArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
intArrayOptList<Integer>NoThe intArrayOpt parameter. In the form of "," + * separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param intArray The intArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setIntArrayWithResponse(List intArray, RequestOptions requestOptions) { + return this.serviceClient.setIntArrayWithResponseAsync(intArray, requestOptions); + } + + /** + * The setStringEnumMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
colorArrayOptList<String>NoThe colorArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param colorArray The colorArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setStringEnumMultiWithResponse(List colorArray, + RequestOptions requestOptions) { + return this.serviceClient.setStringEnumMultiWithResponseAsync(colorArray, requestOptions); + } + + /** + * The setIntEnumMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
priorityArrayOptList<String>NoThe priorityArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param priorityArray The priorityArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setIntEnumMultiWithResponse(List priorityArray, + RequestOptions requestOptions) { + return this.serviceClient.setIntEnumMultiWithResponseAsync(priorityArray, requestOptions); + } + + /** + * The setStringMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringArrayOptList<String>NoThe stringArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param stringArray The stringArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setStringMultiWithResponse(List stringArray, + RequestOptions requestOptions) { + return this.serviceClient.setStringMultiWithResponseAsync(stringArray, requestOptions); + } + + /** + * The setIntMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
intArrayOptList<Integer>NoThe intArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param intArray The intArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setIntMultiWithResponse(List intArray, RequestOptions requestOptions) { + return this.serviceClient.setIntMultiWithResponseAsync(intArray, requestOptions); + } + + /** + * The setStringEnumArrayHeader operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
color-array-optList<String>NoThe colorArrayOpt parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param colorArray The colorArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setStringEnumArrayHeaderWithResponse(List colorArray, + RequestOptions requestOptions) { + return this.serviceClient.setStringEnumArrayHeaderWithResponseAsync(colorArray, requestOptions); + } + + /** + * The getColor 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getColor() { + // Generated convenience method for getColorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getColorWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> Color.fromString(protocolMethodData.toObject(String.class))); + } + + /** + * The getColorModel 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getColorModel() { + // Generated convenience method for getColorModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getColorModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> ColorModel.fromString(protocolMethodData.toObject(String.class))); + } + + /** + * The setColorModel operation. + * + * @param color The color 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setColorModel(ColorModel color) { + // Generated convenience method for setColorModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setColorModelWithResponse(color.toString(), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Operation.class)); + } + + /** + * The setPriority operation. + * + * @param priority The priority 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setPriority(Priority priority) { + // Generated convenience method for setPriorityWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setPriorityWithResponse(String.valueOf(priority.toInt()), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Operation.class)); + } + + /** + * The getRunningOperation 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getRunningOperation() { + // Generated convenience method for getRunningOperationWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRunningOperationWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Operation.class)); + } + + /** + * The getOperation operation. + * + * @param state The state 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getOperation(OperationStateValues state) { + // Generated convenience method for getOperationWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOperationWithResponse(state.toString(), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Operation.class)); + } + + /** + * The setStringEnumArray operation. + * + * @param colorArray The colorArray parameter. + * @param colorArrayOpt The colorArrayOpt 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setStringEnumArray(List colorArray, List colorArrayOpt) { + // Generated convenience method for setStringEnumArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (colorArrayOpt != null) { + requestOptions.addQueryParam("colorArrayOpt", + colorArrayOpt.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return setStringEnumArrayWithResponse(colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.toList()), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setStringEnumArray operation. + * + * @param colorArray The colorArray 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setStringEnumArray(List colorArray) { + // Generated convenience method for setStringEnumArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setStringEnumArrayWithResponse(colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.toList()), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setIntEnumArray operation. + * + * @param priorityArray The priorityArray parameter. + * @param priorityArrayOpt The priorityArrayOpt 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setIntEnumArray(List priorityArray, List priorityArrayOpt) { + // Generated convenience method for setIntEnumArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (priorityArrayOpt != null) { + requestOptions.addQueryParam("priorityArrayOpt", + priorityArrayOpt.stream() + .map(paramItemValue -> Objects.toString(paramItemValue == null ? null : paramItemValue.toInt(), "")) + .collect(Collectors.joining(",")), + false); + } + return setIntEnumArrayWithResponse(priorityArray.stream() + .map(paramItemValue -> paramItemValue == null ? "" : String.valueOf(paramItemValue.toInt())) + .collect(Collectors.toList()), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setIntEnumArray operation. + * + * @param priorityArray The priorityArray 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setIntEnumArray(List priorityArray) { + // Generated convenience method for setIntEnumArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setIntEnumArrayWithResponse(priorityArray.stream() + .map(paramItemValue -> paramItemValue == null ? "" : String.valueOf(paramItemValue.toInt())) + .collect(Collectors.toList()), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setStringArray operation. + * + * @param stringArray The stringArray parameter. + * @param stringArrayOpt The stringArrayOpt 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setStringArray(List stringArray, List stringArrayOpt) { + // Generated convenience method for setStringArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (stringArrayOpt != null) { + requestOptions.addQueryParam("stringArrayOpt", + stringArrayOpt.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return setStringArrayWithResponse(stringArray, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setStringArray operation. + * + * @param stringArray The stringArray 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setStringArray(List stringArray) { + // Generated convenience method for setStringArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setStringArrayWithResponse(stringArray, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setIntArray operation. + * + * @param intArray The intArray parameter. + * @param intArrayOpt The intArrayOpt 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setIntArray(List intArray, List intArrayOpt) { + // Generated convenience method for setIntArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (intArrayOpt != null) { + requestOptions.addQueryParam("intArrayOpt", + JacksonAdapter.createDefaultSerializerAdapter().serializeIterable(intArrayOpt, CollectionFormat.CSV), + false); + } + return setIntArrayWithResponse(intArray, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setIntArray operation. + * + * @param intArray The intArray 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setIntArray(List intArray) { + // Generated convenience method for setIntArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setIntArrayWithResponse(intArray, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setStringEnumMulti operation. + * + * @param colorArray The colorArray parameter. + * @param colorArrayOpt The colorArrayOpt 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setStringEnumMulti(List colorArray, List colorArrayOpt) { + // Generated convenience method for setStringEnumMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (colorArrayOpt != null) { + for (ColorModel paramItemValue : colorArrayOpt) { + if (paramItemValue != null) { + requestOptions.addQueryParam("colorArrayOpt", paramItemValue.toString(), false); + } + } + } + return setStringEnumMultiWithResponse(colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.toList()), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setStringEnumMulti operation. + * + * @param colorArray The colorArray 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setStringEnumMulti(List colorArray) { + // Generated convenience method for setStringEnumMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setStringEnumMultiWithResponse(colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.toList()), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setIntEnumMulti operation. + * + * @param priorityArray The priorityArray parameter. + * @param priorityArrayOpt The priorityArrayOpt 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setIntEnumMulti(List priorityArray, List priorityArrayOpt) { + // Generated convenience method for setIntEnumMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (priorityArrayOpt != null) { + for (Priority paramItemValue : priorityArrayOpt) { + if (paramItemValue != null) { + requestOptions.addQueryParam("priorityArrayOpt", String.valueOf(paramItemValue.toInt()), false); + } + } + } + return setIntEnumMultiWithResponse(priorityArray.stream() + .map(paramItemValue -> paramItemValue == null ? "" : String.valueOf(paramItemValue.toInt())) + .collect(Collectors.toList()), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setIntEnumMulti operation. + * + * @param priorityArray The priorityArray 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setIntEnumMulti(List priorityArray) { + // Generated convenience method for setIntEnumMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setIntEnumMultiWithResponse(priorityArray.stream() + .map(paramItemValue -> paramItemValue == null ? "" : String.valueOf(paramItemValue.toInt())) + .collect(Collectors.toList()), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setStringMulti operation. + * + * @param stringArray The stringArray parameter. + * @param stringArrayOpt The stringArrayOpt 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setStringMulti(List stringArray, List stringArrayOpt) { + // Generated convenience method for setStringMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (stringArrayOpt != null) { + for (String paramItemValue : stringArrayOpt) { + if (paramItemValue != null) { + requestOptions.addQueryParam("stringArrayOpt", paramItemValue, false); + } + } + } + return setStringMultiWithResponse(stringArray, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setStringMulti operation. + * + * @param stringArray The stringArray 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setStringMulti(List stringArray) { + // Generated convenience method for setStringMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setStringMultiWithResponse(stringArray, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setIntMulti operation. + * + * @param intArray The intArray parameter. + * @param intArrayOpt The intArrayOpt 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setIntMulti(List intArray, List intArrayOpt) { + // Generated convenience method for setIntMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (intArrayOpt != null) { + for (int paramItemValue : intArrayOpt) { + requestOptions.addQueryParam("intArrayOpt", String.valueOf(paramItemValue), false); + } + } + return setIntMultiWithResponse(intArray, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setIntMulti operation. + * + * @param intArray The intArray 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setIntMulti(List intArray) { + // Generated convenience method for setIntMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setIntMultiWithResponse(intArray, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setStringEnumArrayHeader operation. + * + * @param colorArray The colorArray parameter. + * @param colorArrayOpt The colorArrayOpt 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setStringEnumArrayHeader(List colorArray, List colorArrayOpt) { + // Generated convenience method for setStringEnumArrayHeaderWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (colorArrayOpt != null) { + requestOptions.setHeader(HttpHeaderName.fromString("color-array-opt"), + colorArrayOpt.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(","))); + } + return setStringEnumArrayHeaderWithResponse(colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.toList()), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * The setStringEnumArrayHeader operation. + * + * @param colorArray The colorArray 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setStringEnumArrayHeader(List colorArray) { + // Generated convenience method for setStringEnumArrayHeaderWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setStringEnumArrayHeaderWithResponse(colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.toList()), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/EnumServiceClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/EnumServiceClient.java new file mode 100644 index 000000000..97b21c8f1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/EnumServiceClient.java @@ -0,0 +1,1053 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.enumservice; + +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.HttpHeaderName; +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.serializer.CollectionFormat; +import com.azure.core.util.serializer.JacksonAdapter; +import com.cadl.enumservice.implementation.EnumServiceClientImpl; +import com.cadl.enumservice.models.Color; +import com.cadl.enumservice.models.ColorModel; +import com.cadl.enumservice.models.Operation; +import com.cadl.enumservice.models.OperationStateValues; +import com.cadl.enumservice.models.Priority; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Initializes a new instance of the synchronous EnumServiceClient type. + */ +@ServiceClient(builder = EnumServiceClientBuilder.class) +public final class EnumServiceClient { + @Generated + private final EnumServiceClientImpl serviceClient; + + /** + * Initializes an instance of EnumServiceClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EnumServiceClient(EnumServiceClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getColor operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Red / Blue / Green)
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getColorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getColorWithResponse(requestOptions); + } + + /** + * The getColorModel operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Red / Blue / Green)
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getColorModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getColorModelWithResponse(requestOptions); + } + + /** + * The setColorModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @param color The color parameter. Allowed values: "Red", "Blue", "Green". + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setColorModelWithResponse(String color, RequestOptions requestOptions) { + return this.serviceClient.setColorModelWithResponse(color, requestOptions); + } + + /** + * The setPriority operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @param priority The priority parameter. Allowed values: 100, 0. + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setPriorityWithResponse(String priority, RequestOptions requestOptions) { + return this.serviceClient.setPriorityWithResponse(priority, requestOptions); + } + + /** + * The getRunningOperation operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRunningOperationWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRunningOperationWithResponse(requestOptions); + } + + /** + * The getOperation operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @param state The state parameter. Allowed values: "Running", "Completed", "Failed". + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getOperationWithResponse(String state, RequestOptions requestOptions) { + return this.serviceClient.getOperationWithResponse(state, requestOptions); + } + + /** + * The setStringEnumArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
colorArrayOptList<String>NoThe colorArrayOpt parameter. In the form of + * "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param colorArray The colorArray 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 a sequence of textual characters along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setStringEnumArrayWithResponse(List colorArray, RequestOptions requestOptions) { + return this.serviceClient.setStringEnumArrayWithResponse(colorArray, requestOptions); + } + + /** + * The setIntEnumArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
priorityArrayOptList<String>NoThe priorityArrayOpt parameter. In the + * form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param priorityArray The priorityArray 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 a sequence of textual characters along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setIntEnumArrayWithResponse(List priorityArray, RequestOptions requestOptions) { + return this.serviceClient.setIntEnumArrayWithResponse(priorityArray, requestOptions); + } + + /** + * The setStringArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringArrayOptList<String>NoThe stringArrayOpt parameter. In the form of + * "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param stringArray The stringArray 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 a sequence of textual characters along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setStringArrayWithResponse(List stringArray, RequestOptions requestOptions) { + return this.serviceClient.setStringArrayWithResponse(stringArray, requestOptions); + } + + /** + * The setIntArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
intArrayOptList<Integer>NoThe intArrayOpt parameter. In the form of "," + * separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param intArray The intArray 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 a sequence of textual characters along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setIntArrayWithResponse(List intArray, RequestOptions requestOptions) { + return this.serviceClient.setIntArrayWithResponse(intArray, requestOptions); + } + + /** + * The setStringEnumMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
colorArrayOptList<String>NoThe colorArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param colorArray The colorArray 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 a sequence of textual characters along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setStringEnumMultiWithResponse(List colorArray, RequestOptions requestOptions) { + return this.serviceClient.setStringEnumMultiWithResponse(colorArray, requestOptions); + } + + /** + * The setIntEnumMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
priorityArrayOptList<String>NoThe priorityArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param priorityArray The priorityArray 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 a sequence of textual characters along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setIntEnumMultiWithResponse(List priorityArray, RequestOptions requestOptions) { + return this.serviceClient.setIntEnumMultiWithResponse(priorityArray, requestOptions); + } + + /** + * The setStringMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringArrayOptList<String>NoThe stringArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param stringArray The stringArray 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 a sequence of textual characters along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setStringMultiWithResponse(List stringArray, RequestOptions requestOptions) { + return this.serviceClient.setStringMultiWithResponse(stringArray, requestOptions); + } + + /** + * The setIntMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
intArrayOptList<Integer>NoThe intArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param intArray The intArray 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 a sequence of textual characters along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setIntMultiWithResponse(List intArray, RequestOptions requestOptions) { + return this.serviceClient.setIntMultiWithResponse(intArray, requestOptions); + } + + /** + * The setStringEnumArrayHeader operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
color-array-optList<String>NoThe colorArrayOpt parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param colorArray The colorArray 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 a sequence of textual characters along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setStringEnumArrayHeaderWithResponse(List colorArray, + RequestOptions requestOptions) { + return this.serviceClient.setStringEnumArrayHeaderWithResponse(colorArray, requestOptions); + } + + /** + * The getColor 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Color getColor() { + // Generated convenience method for getColorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return Color.fromString(getColorWithResponse(requestOptions).getValue().toObject(String.class)); + } + + /** + * The getColorModel 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ColorModel getColorModel() { + // Generated convenience method for getColorModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return ColorModel.fromString(getColorModelWithResponse(requestOptions).getValue().toObject(String.class)); + } + + /** + * The setColorModel operation. + * + * @param color The color 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Operation setColorModel(ColorModel color) { + // Generated convenience method for setColorModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setColorModelWithResponse(color.toString(), requestOptions).getValue().toObject(Operation.class); + } + + /** + * The setPriority operation. + * + * @param priority The priority 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Operation setPriority(Priority priority) { + // Generated convenience method for setPriorityWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setPriorityWithResponse(String.valueOf(priority.toInt()), requestOptions).getValue() + .toObject(Operation.class); + } + + /** + * The getRunningOperation 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Operation getRunningOperation() { + // Generated convenience method for getRunningOperationWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRunningOperationWithResponse(requestOptions).getValue().toObject(Operation.class); + } + + /** + * The getOperation operation. + * + * @param state The state 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Operation getOperation(OperationStateValues state) { + // Generated convenience method for getOperationWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOperationWithResponse(state.toString(), requestOptions).getValue().toObject(Operation.class); + } + + /** + * The setStringEnumArray operation. + * + * @param colorArray The colorArray parameter. + * @param colorArrayOpt The colorArrayOpt 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setStringEnumArray(List colorArray, List colorArrayOpt) { + // Generated convenience method for setStringEnumArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (colorArrayOpt != null) { + requestOptions.addQueryParam("colorArrayOpt", + colorArrayOpt.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return setStringEnumArrayWithResponse(colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.toList()), requestOptions).getValue().toObject(String.class); + } + + /** + * The setStringEnumArray operation. + * + * @param colorArray The colorArray 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setStringEnumArray(List colorArray) { + // Generated convenience method for setStringEnumArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setStringEnumArrayWithResponse(colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.toList()), requestOptions).getValue().toObject(String.class); + } + + /** + * The setIntEnumArray operation. + * + * @param priorityArray The priorityArray parameter. + * @param priorityArrayOpt The priorityArrayOpt 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setIntEnumArray(List priorityArray, List priorityArrayOpt) { + // Generated convenience method for setIntEnumArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (priorityArrayOpt != null) { + requestOptions.addQueryParam("priorityArrayOpt", + priorityArrayOpt.stream() + .map(paramItemValue -> Objects.toString(paramItemValue == null ? null : paramItemValue.toInt(), "")) + .collect(Collectors.joining(",")), + false); + } + return setIntEnumArrayWithResponse(priorityArray.stream() + .map(paramItemValue -> paramItemValue == null ? "" : String.valueOf(paramItemValue.toInt())) + .collect(Collectors.toList()), requestOptions).getValue().toObject(String.class); + } + + /** + * The setIntEnumArray operation. + * + * @param priorityArray The priorityArray 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setIntEnumArray(List priorityArray) { + // Generated convenience method for setIntEnumArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setIntEnumArrayWithResponse(priorityArray.stream() + .map(paramItemValue -> paramItemValue == null ? "" : String.valueOf(paramItemValue.toInt())) + .collect(Collectors.toList()), requestOptions).getValue().toObject(String.class); + } + + /** + * The setStringArray operation. + * + * @param stringArray The stringArray parameter. + * @param stringArrayOpt The stringArrayOpt 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setStringArray(List stringArray, List stringArrayOpt) { + // Generated convenience method for setStringArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (stringArrayOpt != null) { + requestOptions.addQueryParam("stringArrayOpt", + stringArrayOpt.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return setStringArrayWithResponse(stringArray, requestOptions).getValue().toObject(String.class); + } + + /** + * The setStringArray operation. + * + * @param stringArray The stringArray 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setStringArray(List stringArray) { + // Generated convenience method for setStringArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setStringArrayWithResponse(stringArray, requestOptions).getValue().toObject(String.class); + } + + /** + * The setIntArray operation. + * + * @param intArray The intArray parameter. + * @param intArrayOpt The intArrayOpt 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setIntArray(List intArray, List intArrayOpt) { + // Generated convenience method for setIntArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (intArrayOpt != null) { + requestOptions.addQueryParam("intArrayOpt", + JacksonAdapter.createDefaultSerializerAdapter().serializeIterable(intArrayOpt, CollectionFormat.CSV), + false); + } + return setIntArrayWithResponse(intArray, requestOptions).getValue().toObject(String.class); + } + + /** + * The setIntArray operation. + * + * @param intArray The intArray 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setIntArray(List intArray) { + // Generated convenience method for setIntArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setIntArrayWithResponse(intArray, requestOptions).getValue().toObject(String.class); + } + + /** + * The setStringEnumMulti operation. + * + * @param colorArray The colorArray parameter. + * @param colorArrayOpt The colorArrayOpt 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setStringEnumMulti(List colorArray, List colorArrayOpt) { + // Generated convenience method for setStringEnumMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (colorArrayOpt != null) { + for (ColorModel paramItemValue : colorArrayOpt) { + if (paramItemValue != null) { + requestOptions.addQueryParam("colorArrayOpt", paramItemValue.toString(), false); + } + } + } + return setStringEnumMultiWithResponse(colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.toList()), requestOptions).getValue().toObject(String.class); + } + + /** + * The setStringEnumMulti operation. + * + * @param colorArray The colorArray 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setStringEnumMulti(List colorArray) { + // Generated convenience method for setStringEnumMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setStringEnumMultiWithResponse(colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.toList()), requestOptions).getValue().toObject(String.class); + } + + /** + * The setIntEnumMulti operation. + * + * @param priorityArray The priorityArray parameter. + * @param priorityArrayOpt The priorityArrayOpt 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setIntEnumMulti(List priorityArray, List priorityArrayOpt) { + // Generated convenience method for setIntEnumMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (priorityArrayOpt != null) { + for (Priority paramItemValue : priorityArrayOpt) { + if (paramItemValue != null) { + requestOptions.addQueryParam("priorityArrayOpt", String.valueOf(paramItemValue.toInt()), false); + } + } + } + return setIntEnumMultiWithResponse(priorityArray.stream() + .map(paramItemValue -> paramItemValue == null ? "" : String.valueOf(paramItemValue.toInt())) + .collect(Collectors.toList()), requestOptions).getValue().toObject(String.class); + } + + /** + * The setIntEnumMulti operation. + * + * @param priorityArray The priorityArray 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setIntEnumMulti(List priorityArray) { + // Generated convenience method for setIntEnumMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setIntEnumMultiWithResponse(priorityArray.stream() + .map(paramItemValue -> paramItemValue == null ? "" : String.valueOf(paramItemValue.toInt())) + .collect(Collectors.toList()), requestOptions).getValue().toObject(String.class); + } + + /** + * The setStringMulti operation. + * + * @param stringArray The stringArray parameter. + * @param stringArrayOpt The stringArrayOpt 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setStringMulti(List stringArray, List stringArrayOpt) { + // Generated convenience method for setStringMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (stringArrayOpt != null) { + for (String paramItemValue : stringArrayOpt) { + if (paramItemValue != null) { + requestOptions.addQueryParam("stringArrayOpt", paramItemValue, false); + } + } + } + return setStringMultiWithResponse(stringArray, requestOptions).getValue().toObject(String.class); + } + + /** + * The setStringMulti operation. + * + * @param stringArray The stringArray 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setStringMulti(List stringArray) { + // Generated convenience method for setStringMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setStringMultiWithResponse(stringArray, requestOptions).getValue().toObject(String.class); + } + + /** + * The setIntMulti operation. + * + * @param intArray The intArray parameter. + * @param intArrayOpt The intArrayOpt 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setIntMulti(List intArray, List intArrayOpt) { + // Generated convenience method for setIntMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (intArrayOpt != null) { + for (int paramItemValue : intArrayOpt) { + requestOptions.addQueryParam("intArrayOpt", String.valueOf(paramItemValue), false); + } + } + return setIntMultiWithResponse(intArray, requestOptions).getValue().toObject(String.class); + } + + /** + * The setIntMulti operation. + * + * @param intArray The intArray 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setIntMulti(List intArray) { + // Generated convenience method for setIntMultiWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setIntMultiWithResponse(intArray, requestOptions).getValue().toObject(String.class); + } + + /** + * The setStringEnumArrayHeader operation. + * + * @param colorArray The colorArray parameter. + * @param colorArrayOpt The colorArrayOpt 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setStringEnumArrayHeader(List colorArray, List colorArrayOpt) { + // Generated convenience method for setStringEnumArrayHeaderWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (colorArrayOpt != null) { + requestOptions.setHeader(HttpHeaderName.fromString("color-array-opt"), + colorArrayOpt.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(","))); + } + return setStringEnumArrayHeaderWithResponse(colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.toList()), requestOptions).getValue().toObject(String.class); + } + + /** + * The setStringEnumArrayHeader operation. + * + * @param colorArray The colorArray 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String setStringEnumArrayHeader(List colorArray) { + // Generated convenience method for setStringEnumArrayHeaderWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setStringEnumArrayHeaderWithResponse(colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.toList()), requestOptions).getValue().toObject(String.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/EnumServiceClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/EnumServiceClientBuilder.java new file mode 100644 index 000000000..f53db8021 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/EnumServiceClientBuilder.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 com.cadl.enumservice; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.enumservice.implementation.EnumServiceClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the EnumServiceClient type. + */ +@ServiceClientBuilder(serviceClients = { EnumServiceClient.class, EnumServiceAsyncClient.class }) +public final class EnumServiceClientBuilder 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("cadl-enumservice.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the EnumServiceClientBuilder. + */ + @Generated + public EnumServiceClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumServiceClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumServiceClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumServiceClientBuilder 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 EnumServiceClientBuilder 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 EnumServiceClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumServiceClientBuilder 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 EnumServiceClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumServiceClientBuilder 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 EnumServiceClientBuilder. + */ + @Generated + public EnumServiceClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of EnumServiceClientImpl with the provided parameters. + * + * @return an instance of EnumServiceClientImpl. + */ + @Generated + private EnumServiceClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + EnumServiceClientImpl client + = new EnumServiceClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 EnumServiceAsyncClient class. + * + * @return an instance of EnumServiceAsyncClient. + */ + @Generated + public EnumServiceAsyncClient buildAsyncClient() { + return new EnumServiceAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of EnumServiceClient class. + * + * @return an instance of EnumServiceClient. + */ + @Generated + public EnumServiceClient buildClient() { + return new EnumServiceClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(EnumServiceClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/implementation/EnumServiceClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/implementation/EnumServiceClientImpl.java new file mode 100644 index 000000000..12b6c2711 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/implementation/EnumServiceClientImpl.java @@ -0,0 +1,1388 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.enumservice.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +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.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.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.CollectionFormat; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the EnumServiceClient type. + */ +public final class EnumServiceClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EnumServiceClientService 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 EnumServiceClient client. + * + * @param endpoint Service host. + */ + public EnumServiceClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of EnumServiceClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public EnumServiceClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of EnumServiceClient 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 EnumServiceClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(EnumServiceClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for EnumServiceClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "EnumServiceClient") + public interface EnumServiceClientService { + @Get("/enum/color") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getColor(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/enum/color") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getColorSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/enum/colormodel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getColorModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/enum/colormodel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getColorModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/enum/operation/colormodel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setColorModel(@HostParam("endpoint") String endpoint, + @QueryParam("color") String color, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Post("/enum/operation/colormodel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setColorModelSync(@HostParam("endpoint") String endpoint, + @QueryParam("color") String color, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Post("/enum/operation/priority") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setPriority(@HostParam("endpoint") String endpoint, + @QueryParam("priority") String priority, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/enum/operation/priority") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setPrioritySync(@HostParam("endpoint") String endpoint, + @QueryParam("priority") String priority, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/enum/operation/state/running") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getRunningOperation(@HostParam("endpoint") String endpoint, + @QueryParam("state") String state, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/enum/operation/state/running") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getRunningOperationSync(@HostParam("endpoint") String endpoint, + @QueryParam("state") String state, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/enum/operation/state") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getOperation(@HostParam("endpoint") String endpoint, + @QueryParam("state") String state, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/enum/operation/state") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getOperationSync(@HostParam("endpoint") String endpoint, @QueryParam("state") String state, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/enum/operation/stringenumarray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setStringEnumArray(@HostParam("endpoint") String endpoint, + @QueryParam("colorArray") String colorArray, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/enum/operation/stringenumarray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setStringEnumArraySync(@HostParam("endpoint") String endpoint, + @QueryParam("colorArray") String colorArray, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/enum/operation/intenumarray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setIntEnumArray(@HostParam("endpoint") String endpoint, + @QueryParam("priorityArray") String priorityArray, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/enum/operation/intenumarray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setIntEnumArraySync(@HostParam("endpoint") String endpoint, + @QueryParam("priorityArray") String priorityArray, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/enum/operation/stringarray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setStringArray(@HostParam("endpoint") String endpoint, + @QueryParam("stringArray") String stringArray, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/enum/operation/stringarray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setStringArraySync(@HostParam("endpoint") String endpoint, + @QueryParam("stringArray") String stringArray, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/enum/operation/intarray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setIntArray(@HostParam("endpoint") String endpoint, + @QueryParam("intArray") String intArray, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/enum/operation/intarray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setIntArraySync(@HostParam("endpoint") String endpoint, + @QueryParam("intArray") String intArray, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/enum/operation/stringenummulti") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setStringEnumMulti(@HostParam("endpoint") String endpoint, + @QueryParam(value = "colorArray", multipleQueryParams = true) List colorArray, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/enum/operation/stringenummulti") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setStringEnumMultiSync(@HostParam("endpoint") String endpoint, + @QueryParam(value = "colorArray", multipleQueryParams = true) List colorArray, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/enum/operation/intenummulti") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setIntEnumMulti(@HostParam("endpoint") String endpoint, + @QueryParam(value = "priorityArray", multipleQueryParams = true) List priorityArray, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/enum/operation/intenummulti") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setIntEnumMultiSync(@HostParam("endpoint") String endpoint, + @QueryParam(value = "priorityArray", multipleQueryParams = true) List priorityArray, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/enum/operation/stringmulti") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setStringMulti(@HostParam("endpoint") String endpoint, + @QueryParam(value = "stringArray", multipleQueryParams = true) List stringArray, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/enum/operation/stringmulti") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setStringMultiSync(@HostParam("endpoint") String endpoint, + @QueryParam(value = "stringArray", multipleQueryParams = true) List stringArray, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/enum/operation/intmulti") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setIntMulti(@HostParam("endpoint") String endpoint, + @QueryParam(value = "intArray", multipleQueryParams = true) List intArray, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/enum/operation/intmulti") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setIntMultiSync(@HostParam("endpoint") String endpoint, + @QueryParam(value = "intArray", multipleQueryParams = true) List intArray, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/enum/operation/stringenumarrayheader") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> setStringEnumArrayHeader(@HostParam("endpoint") String endpoint, + @HeaderParam("color-array") String colorArray, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/enum/operation/stringenumarrayheader") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setStringEnumArrayHeaderSync(@HostParam("endpoint") String endpoint, + @HeaderParam("color-array") String colorArray, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * The getColor operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Red / Blue / Green)
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getColorWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getColor(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getColor operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Red / Blue / Green)
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getColorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getColorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The getColorModel operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Red / Blue / Green)
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getColorModelWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getColorModel(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getColorModel operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Red / Blue / Green)
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getColorModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getColorModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The setColorModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @param color The color parameter. Allowed values: "Red", "Blue", "Green". + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setColorModelWithResponseAsync(String color, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.setColorModel(this.getEndpoint(), color, accept, requestOptions, context)); + } + + /** + * The setColorModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @param color The color parameter. Allowed values: "Red", "Blue", "Green". + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setColorModelWithResponse(String color, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.setColorModelSync(this.getEndpoint(), color, accept, requestOptions, Context.NONE); + } + + /** + * The setPriority operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @param priority The priority parameter. Allowed values: 100, 0. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setPriorityWithResponseAsync(String priority, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.setPriority(this.getEndpoint(), priority, accept, requestOptions, context)); + } + + /** + * The setPriority operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @param priority The priority parameter. Allowed values: 100, 0. + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setPriorityWithResponse(String priority, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.setPrioritySync(this.getEndpoint(), priority, accept, requestOptions, Context.NONE); + } + + /** + * The getRunningOperation operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRunningOperationWithResponseAsync(RequestOptions requestOptions) { + final String state = "Running"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getRunningOperation(this.getEndpoint(), state, accept, requestOptions, context)); + } + + /** + * The getRunningOperation operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRunningOperationWithResponse(RequestOptions requestOptions) { + final String state = "Running"; + final String accept = "application/json"; + return service.getRunningOperationSync(this.getEndpoint(), state, accept, requestOptions, Context.NONE); + } + + /** + * The getOperation operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @param state The state parameter. Allowed values: "Running", "Completed", "Failed". + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getOperationWithResponseAsync(String state, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getOperation(this.getEndpoint(), state, accept, requestOptions, context)); + } + + /** + * The getOperation operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String(Read/Write) (Required)
+     *     best: boolean (Required)
+     *     age: int (Required)
+     *     priority: String(100/0) (Required)
+     *     color: String(Red/Blue/Green) (Required)
+     *     unit: String(1/0.001/1000) (Required)
+     *     priorityValue: String(100/0) (Required)
+     *     colorValue: String(Red/Blue/Green) (Required)
+     *     colorModelValue: String(Red/Blue/Green) (Required)
+     *     unitValue: String(1/0.001/1000) (Optional)
+     * }
+     * }
+ * + * @param state The state parameter. Allowed values: "Running", "Completed", "Failed". + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getOperationWithResponse(String state, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getOperationSync(this.getEndpoint(), state, accept, requestOptions, Context.NONE); + } + + /** + * The setStringEnumArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
colorArrayOptList<String>NoThe colorArrayOpt parameter. In the form of + * "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param colorArray The colorArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setStringEnumArrayWithResponseAsync(List colorArray, + RequestOptions requestOptions) { + final String accept = "application/json"; + String colorArrayConverted = colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return FluxUtil.withContext(context -> service.setStringEnumArray(this.getEndpoint(), colorArrayConverted, + accept, requestOptions, context)); + } + + /** + * The setStringEnumArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
colorArrayOptList<String>NoThe colorArrayOpt parameter. In the form of + * "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param colorArray The colorArray 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 a sequence of textual characters along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setStringEnumArrayWithResponse(List colorArray, RequestOptions requestOptions) { + final String accept = "application/json"; + String colorArrayConverted = colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.setStringEnumArraySync(this.getEndpoint(), colorArrayConverted, accept, requestOptions, + Context.NONE); + } + + /** + * The setIntEnumArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
priorityArrayOptList<String>NoThe priorityArrayOpt parameter. In the + * form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param priorityArray The priorityArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setIntEnumArrayWithResponseAsync(List priorityArray, + RequestOptions requestOptions) { + final String accept = "application/json"; + String priorityArrayConverted = priorityArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return FluxUtil.withContext(context -> service.setIntEnumArray(this.getEndpoint(), priorityArrayConverted, + accept, requestOptions, context)); + } + + /** + * The setIntEnumArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
priorityArrayOptList<String>NoThe priorityArrayOpt parameter. In the + * form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param priorityArray The priorityArray 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 a sequence of textual characters along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setIntEnumArrayWithResponse(List priorityArray, RequestOptions requestOptions) { + final String accept = "application/json"; + String priorityArrayConverted = priorityArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.setIntEnumArraySync(this.getEndpoint(), priorityArrayConverted, accept, requestOptions, + Context.NONE); + } + + /** + * The setStringArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringArrayOptList<String>NoThe stringArrayOpt parameter. In the form of + * "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param stringArray The stringArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setStringArrayWithResponseAsync(List stringArray, + RequestOptions requestOptions) { + final String accept = "application/json"; + String stringArrayConverted = stringArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return FluxUtil.withContext(context -> service.setStringArray(this.getEndpoint(), stringArrayConverted, accept, + requestOptions, context)); + } + + /** + * The setStringArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringArrayOptList<String>NoThe stringArrayOpt parameter. In the form of + * "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param stringArray The stringArray 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 a sequence of textual characters along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setStringArrayWithResponse(List stringArray, RequestOptions requestOptions) { + final String accept = "application/json"; + String stringArrayConverted = stringArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.setStringArraySync(this.getEndpoint(), stringArrayConverted, accept, requestOptions, + Context.NONE); + } + + /** + * The setIntArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
intArrayOptList<Integer>NoThe intArrayOpt parameter. In the form of "," + * separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param intArray The intArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setIntArrayWithResponseAsync(List intArray, + RequestOptions requestOptions) { + final String accept = "application/json"; + String intArrayConverted + = JacksonAdapter.createDefaultSerializerAdapter().serializeIterable(intArray, CollectionFormat.CSV); + return FluxUtil.withContext( + context -> service.setIntArray(this.getEndpoint(), intArrayConverted, accept, requestOptions, context)); + } + + /** + * The setIntArray operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
intArrayOptList<Integer>NoThe intArrayOpt parameter. In the form of "," + * separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param intArray The intArray 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 a sequence of textual characters along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setIntArrayWithResponse(List intArray, RequestOptions requestOptions) { + final String accept = "application/json"; + String intArrayConverted + = JacksonAdapter.createDefaultSerializerAdapter().serializeIterable(intArray, CollectionFormat.CSV); + return service.setIntArraySync(this.getEndpoint(), intArrayConverted, accept, requestOptions, Context.NONE); + } + + /** + * The setStringEnumMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
colorArrayOptList<String>NoThe colorArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param colorArray The colorArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setStringEnumMultiWithResponseAsync(List colorArray, + RequestOptions requestOptions) { + final String accept = "application/json"; + List colorArrayConverted + = colorArray.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return FluxUtil.withContext(context -> service.setStringEnumMulti(this.getEndpoint(), colorArrayConverted, + accept, requestOptions, context)); + } + + /** + * The setStringEnumMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
colorArrayOptList<String>NoThe colorArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param colorArray The colorArray 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 a sequence of textual characters along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setStringEnumMultiWithResponse(List colorArray, RequestOptions requestOptions) { + final String accept = "application/json"; + List colorArrayConverted + = colorArray.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return service.setStringEnumMultiSync(this.getEndpoint(), colorArrayConverted, accept, requestOptions, + Context.NONE); + } + + /** + * The setIntEnumMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
priorityArrayOptList<String>NoThe priorityArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param priorityArray The priorityArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setIntEnumMultiWithResponseAsync(List priorityArray, + RequestOptions requestOptions) { + final String accept = "application/json"; + List priorityArrayConverted + = priorityArray.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return FluxUtil.withContext(context -> service.setIntEnumMulti(this.getEndpoint(), priorityArrayConverted, + accept, requestOptions, context)); + } + + /** + * The setIntEnumMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
priorityArrayOptList<String>NoThe priorityArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param priorityArray The priorityArray 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 a sequence of textual characters along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setIntEnumMultiWithResponse(List priorityArray, RequestOptions requestOptions) { + final String accept = "application/json"; + List priorityArrayConverted + = priorityArray.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return service.setIntEnumMultiSync(this.getEndpoint(), priorityArrayConverted, accept, requestOptions, + Context.NONE); + } + + /** + * The setStringMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringArrayOptList<String>NoThe stringArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param stringArray The stringArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setStringMultiWithResponseAsync(List stringArray, + RequestOptions requestOptions) { + final String accept = "application/json"; + List stringArrayConverted + = stringArray.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return FluxUtil.withContext(context -> service.setStringMulti(this.getEndpoint(), stringArrayConverted, accept, + requestOptions, context)); + } + + /** + * The setStringMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringArrayOptList<String>NoThe stringArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param stringArray The stringArray 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 a sequence of textual characters along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setStringMultiWithResponse(List stringArray, RequestOptions requestOptions) { + final String accept = "application/json"; + List stringArrayConverted + = stringArray.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return service.setStringMultiSync(this.getEndpoint(), stringArrayConverted, accept, requestOptions, + Context.NONE); + } + + /** + * The setIntMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
intArrayOptList<Integer>NoThe intArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param intArray The intArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setIntMultiWithResponseAsync(List intArray, + RequestOptions requestOptions) { + final String accept = "application/json"; + List intArrayConverted + = intArray.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return FluxUtil.withContext( + context -> service.setIntMulti(this.getEndpoint(), intArrayConverted, accept, requestOptions, context)); + } + + /** + * The setIntMulti operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
intArrayOptList<Integer>NoThe intArrayOpt parameter. Call + * {@link RequestOptions#addQueryParam} to add string to array.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param intArray The intArray 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 a sequence of textual characters along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setIntMultiWithResponse(List intArray, RequestOptions requestOptions) { + final String accept = "application/json"; + List intArrayConverted + = intArray.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return service.setIntMultiSync(this.getEndpoint(), intArrayConverted, accept, requestOptions, Context.NONE); + } + + /** + * The setStringEnumArrayHeader operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
color-array-optList<String>NoThe colorArrayOpt parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param colorArray The colorArray 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setStringEnumArrayHeaderWithResponseAsync(List colorArray, + RequestOptions requestOptions) { + final String accept = "application/json"; + String colorArrayConverted = colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return FluxUtil.withContext(context -> service.setStringEnumArrayHeader(this.getEndpoint(), colorArrayConverted, + accept, requestOptions, context)); + } + + /** + * The setStringEnumArrayHeader operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
color-array-optList<String>NoThe colorArrayOpt parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param colorArray The colorArray 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 a sequence of textual characters along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setStringEnumArrayHeaderWithResponse(List colorArray, + RequestOptions requestOptions) { + final String accept = "application/json"; + String colorArrayConverted = colorArray.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.setStringEnumArrayHeaderSync(this.getEndpoint(), colorArrayConverted, accept, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/implementation/package-info.java new file mode 100644 index 000000000..124c05d25 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 EnumService. + * + */ +package com.cadl.enumservice.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Color.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Color.java new file mode 100644 index 000000000..fda844ec1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Color.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.enumservice.models; + +/** + * Defines values for Color. + */ +public enum Color { + /** + * Enum value Red. + */ + RED("Red"), + + /** + * Enum value Blue. + */ + BLUE("Blue"), + + /** + * Enum value Green. + */ + GREEN("Green"); + + /** + * The actual serialized value for a Color instance. + */ + private final String value; + + Color(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a Color instance. + * + * @param value the serialized value to parse. + * @return the parsed Color object, or null if unable to parse. + */ + public static Color fromString(String value) { + if (value == null) { + return null; + } + Color[] items = Color.values(); + for (Color item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/ColorModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/ColorModel.java new file mode 100644 index 000000000..5ef92f184 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/ColorModel.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.enumservice.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for ColorModel. + */ +public final class ColorModel extends ExpandableStringEnum { + /** + * Static value Red for ColorModel. + */ + @Generated + public static final ColorModel RED = fromString("Red"); + + /** + * Static value Blue for ColorModel. + */ + @Generated + public static final ColorModel BLUE = fromString("Blue"); + + /** + * Static value Green for ColorModel. + */ + @Generated + public static final ColorModel GREEN = fromString("Green"); + + /** + * Creates a new instance of ColorModel value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ColorModel() { + } + + /** + * Creates or finds a ColorModel from its string representation. + * + * @param name a name to look for. + * @return the corresponding ColorModel. + */ + @Generated + public static ColorModel fromString(String name) { + return fromString(name, ColorModel.class); + } + + /** + * Gets known ColorModel values. + * + * @return known ColorModel values. + */ + @Generated + public static Collection values() { + return values(ColorModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java new file mode 100644 index 000000000..ccadb1868 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Operation.java @@ -0,0 +1,270 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.enumservice.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 Operation model. + */ +@Fluent +public final class Operation implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final OperationName name; + + /* + * The best property. + */ + @Generated + private final boolean best = true; + + /* + * The age property. + */ + @Generated + private final int age = 50; + + /* + * The priority property. + */ + @Generated + private final Priority priority; + + /* + * The color property. + */ + @Generated + private final ColorModel color; + + /* + * The unit property. + */ + @Generated + private final Unit unit; + + /* + * The priorityValue property. + */ + @Generated + private final Priority priorityValue = Priority.LOW; + + /* + * The colorValue property. + */ + @Generated + private final Color colorValue = Color.GREEN; + + /* + * The colorModelValue property. + */ + @Generated + private final ColorModel colorModelValue = ColorModel.BLUE; + + /* + * The unitValue property. + */ + @Generated + private Unit unitValue; + + /** + * Creates an instance of Operation class. + * + * @param name the name value to set. + * @param priority the priority value to set. + * @param color the color value to set. + * @param unit the unit value to set. + */ + @Generated + public Operation(OperationName name, Priority priority, ColorModel color, Unit unit) { + this.name = name; + this.priority = priority; + this.color = color; + this.unit = unit; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public OperationName getName() { + return this.name; + } + + /** + * Get the best property: The best property. + * + * @return the best value. + */ + @Generated + public boolean isBest() { + return this.best; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Generated + public int getAge() { + return this.age; + } + + /** + * Get the priority property: The priority property. + * + * @return the priority value. + */ + @Generated + public Priority getPriority() { + return this.priority; + } + + /** + * Get the color property: The color property. + * + * @return the color value. + */ + @Generated + public ColorModel getColor() { + return this.color; + } + + /** + * Get the unit property: The unit property. + * + * @return the unit value. + */ + @Generated + public Unit getUnit() { + return this.unit; + } + + /** + * Get the priorityValue property: The priorityValue property. + * + * @return the priorityValue value. + */ + @Generated + public Priority getPriorityValue() { + return this.priorityValue; + } + + /** + * Get the colorValue property: The colorValue property. + * + * @return the colorValue value. + */ + @Generated + public Color getColorValue() { + return this.colorValue; + } + + /** + * Get the colorModelValue property: The colorModelValue property. + * + * @return the colorModelValue value. + */ + @Generated + public ColorModel getColorModelValue() { + return this.colorModelValue; + } + + /** + * Get the unitValue property: The unitValue property. + * + * @return the unitValue value. + */ + @Generated + public Unit getUnitValue() { + return this.unitValue; + } + + /** + * Set the unitValue property: The unitValue property. + * + * @param unitValue the unitValue value to set. + * @return the Operation object itself. + */ + @Generated + public Operation setUnitValue(Unit unitValue) { + this.unitValue = unitValue; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name == null ? null : this.name.toString()); + jsonWriter.writeBooleanField("best", this.best); + jsonWriter.writeIntField("age", this.age); + jsonWriter.writeNumberField("priority", this.priority == null ? null : this.priority.toInt()); + jsonWriter.writeStringField("color", this.color == null ? null : this.color.toString()); + jsonWriter.writeNumberField("unit", this.unit == null ? null : this.unit.toDouble()); + jsonWriter.writeNumberField("priorityValue", this.priorityValue == null ? null : this.priorityValue.toInt()); + jsonWriter.writeStringField("colorValue", this.colorValue == null ? null : this.colorValue.toString()); + jsonWriter.writeStringField("colorModelValue", + this.colorModelValue == null ? null : this.colorModelValue.toString()); + jsonWriter.writeNumberField("unitValue", this.unitValue == null ? null : this.unitValue.toDouble()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Operation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Operation 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 Operation. + */ + @Generated + public static Operation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationName name = null; + Priority priority = null; + ColorModel color = null; + Unit unit = null; + Unit unitValue = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = OperationName.fromString(reader.getString()); + } else if ("priority".equals(fieldName)) { + priority = Priority.fromInt(reader.getInt()); + } else if ("color".equals(fieldName)) { + color = ColorModel.fromString(reader.getString()); + } else if ("unit".equals(fieldName)) { + unit = Unit.fromDouble(reader.getDouble()); + } else if ("unitValue".equals(fieldName)) { + unitValue = Unit.fromDouble(reader.getDouble()); + } else { + reader.skipChildren(); + } + } + Operation deserializedOperation = new Operation(name, priority, color, unit); + deserializedOperation.unitValue = unitValue; + + return deserializedOperation; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/OperationName.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/OperationName.java new file mode 100644 index 000000000..0a51dedfd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/OperationName.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 com.cadl.enumservice.models; + +/** + * Defines values for OperationName. + */ +public enum OperationName { + /** + * Enum value Read. + */ + READ("Read"), + + /** + * Enum value Write. + */ + WRITE("Write"); + + /** + * The actual serialized value for a OperationName instance. + */ + private final String value; + + OperationName(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a OperationName instance. + * + * @param value the serialized value to parse. + * @return the parsed OperationName object, or null if unable to parse. + */ + public static OperationName fromString(String value) { + if (value == null) { + return null; + } + OperationName[] items = OperationName.values(); + for (OperationName item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/OperationStateValues.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/OperationStateValues.java new file mode 100644 index 000000000..4ea123af9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/OperationStateValues.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.enumservice.models; + +/** + * Defines values for OperationStateValues. + */ +public enum OperationStateValues { + /** + * Enum value Running. + */ + RUNNING("Running"), + + /** + * Enum value Completed. + */ + COMPLETED("Completed"), + + /** + * Enum value Failed. + */ + FAILED("Failed"); + + /** + * The actual serialized value for a OperationStateValues instance. + */ + private final String value; + + OperationStateValues(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a OperationStateValues instance. + * + * @param value the serialized value to parse. + * @return the parsed OperationStateValues object, or null if unable to parse. + */ + public static OperationStateValues fromString(String value) { + if (value == null) { + return null; + } + OperationStateValues[] items = OperationStateValues.values(); + for (OperationStateValues item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Priority.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Priority.java new file mode 100644 index 000000000..ee0309d72 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Priority.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.enumservice.models; + +/** + * Defines values for Priority. + */ +public enum Priority { + /** + * Enum value 100. + */ + HIGH(100), + + /** + * Enum value 0. + */ + LOW(0); + + /** + * The actual serialized value for a Priority instance. + */ + private final int value; + + Priority(int value) { + this.value = value; + } + + /** + * Parses a serialized value to a Priority instance. + * + * @param value the serialized value to parse. + * @return the parsed Priority object, or null if unable to parse. + */ + public static Priority fromInt(int value) { + Priority[] items = Priority.values(); + for (Priority item : items) { + if (item.toInt() == value) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to int value. + * + * @return the int value. + */ + public int toInt() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/PriorityModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/PriorityModel.java new file mode 100644 index 000000000..edfd13250 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/PriorityModel.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.enumservice.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for PriorityModel. + */ +public final class PriorityModel extends ExpandableStringEnum { + /** + * Static value 100 for PriorityModel. + */ + @Generated + public static final PriorityModel HIGH = fromInt(100); + + /** + * Static value 0 for PriorityModel. + */ + @Generated + public static final PriorityModel LOW = fromInt(0); + + /** + * Creates a new instance of PriorityModel value. + * + * @deprecated Use the {@link #fromInt(int)} factory method. + */ + @Generated + @Deprecated + public PriorityModel() { + } + + /** + * Creates or finds a PriorityModel from its string representation. + * + * @param name a name to look for. + * @return the corresponding PriorityModel. + */ + @Generated + public static PriorityModel fromInt(int name) { + return fromString(String.valueOf(name), PriorityModel.class); + } + + /** + * Gets known PriorityModel values. + * + * @return known PriorityModel values. + */ + @Generated + public static Collection values() { + return values(PriorityModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Unit.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Unit.java new file mode 100644 index 000000000..02352af74 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/Unit.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.enumservice.models; + +/** + * Defines values for Unit. + */ +public enum Unit { + /** + * Enum value 1. + */ + GRAMS(1.0), + + /** + * Enum value 0.001. + */ + KILO_GRAMS(0.001), + + /** + * Enum value 1000. + */ + MILLIGRAM(1000.0); + + /** + * The actual serialized value for a Unit instance. + */ + private final double value; + + Unit(double value) { + this.value = value; + } + + /** + * Parses a serialized value to a Unit instance. + * + * @param value the serialized value to parse. + * @return the parsed Unit object, or null if unable to parse. + */ + public static Unit fromDouble(double value) { + Unit[] items = Unit.values(); + for (Unit item : items) { + if (Double.doubleToLongBits(item.toDouble()) == Double.doubleToLongBits(value)) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to double value. + * + * @return the double value. + */ + public double toDouble() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/package-info.java new file mode 100644 index 000000000..5606a282c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/models/package-info.java @@ -0,0 +1,10 @@ +// 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 EnumService. + * + */ +package com.cadl.enumservice.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/package-info.java new file mode 100644 index 000000000..f42ef6f0b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/enumservice/package-info.java @@ -0,0 +1,10 @@ +// 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 EnumService. + * + */ +package com.cadl.enumservice; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/ErrorModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/ErrorModelAsyncClient.java new file mode 100644 index 000000000..602e57822 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/ErrorModelAsyncClient.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.errormodel; + +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 com.cadl.errormodel.implementation.ErrorOpsImpl; +import com.cadl.errormodel.models.Diagnostic; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ErrorModelClient type. + */ +@ServiceClient(builder = ErrorModelClientBuilder.class, isAsync = true) +public final class ErrorModelAsyncClient { + @Generated + private final ErrorOpsImpl serviceClient; + + /** + * Initializes an instance of ErrorModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ErrorModelAsyncClient(ErrorOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The read operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> readWithResponse(RequestOptions requestOptions) { + return this.serviceClient.readWithResponseAsync(requestOptions); + } + + /** + * The read 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono read() { + // Generated convenience method for readWithResponse + RequestOptions requestOptions = new RequestOptions(); + return readWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Diagnostic.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/ErrorModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/ErrorModelClient.java new file mode 100644 index 000000000..979c6a833 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/ErrorModelClient.java @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.errormodel; + +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.cadl.errormodel.implementation.ErrorOpsImpl; +import com.cadl.errormodel.models.Diagnostic; + +/** + * Initializes a new instance of the synchronous ErrorModelClient type. + */ +@ServiceClient(builder = ErrorModelClientBuilder.class) +public final class ErrorModelClient { + @Generated + private final ErrorOpsImpl serviceClient; + + /** + * Initializes an instance of ErrorModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ErrorModelClient(ErrorOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The read operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response readWithResponse(RequestOptions requestOptions) { + return this.serviceClient.readWithResponse(requestOptions); + } + + /** + * The read 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Diagnostic read() { + // Generated convenience method for readWithResponse + RequestOptions requestOptions = new RequestOptions(); + return readWithResponse(requestOptions).getValue().toObject(Diagnostic.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/ErrorModelClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/ErrorModelClientBuilder.java new file mode 100644 index 000000000..017eadb26 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/ErrorModelClientBuilder.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 com.cadl.errormodel; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.errormodel.implementation.ErrorModelClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ErrorModelClient type. + */ +@ServiceClientBuilder(serviceClients = { ErrorModelClient.class, ErrorModelAsyncClient.class }) +public final class ErrorModelClientBuilder 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("cadl-errormodel.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ErrorModelClientBuilder. + */ + @Generated + public ErrorModelClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ErrorModelClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ErrorModelClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ErrorModelClientBuilder 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 ErrorModelClientBuilder 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 ErrorModelClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ErrorModelClientBuilder 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 ErrorModelClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ErrorModelClientBuilder 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 ErrorModelClientBuilder. + */ + @Generated + public ErrorModelClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ErrorModelClientImpl with the provided parameters. + * + * @return an instance of ErrorModelClientImpl. + */ + @Generated + private ErrorModelClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ErrorModelClientImpl client + = new ErrorModelClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 ErrorModelAsyncClient class. + * + * @return an instance of ErrorModelAsyncClient. + */ + @Generated + public ErrorModelAsyncClient buildAsyncClient() { + return new ErrorModelAsyncClient(buildInnerClient().getErrorOps()); + } + + /** + * Builds an instance of ErrorModelClient class. + * + * @return an instance of ErrorModelClient. + */ + @Generated + public ErrorModelClient buildClient() { + return new ErrorModelClient(buildInnerClient().getErrorOps()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ErrorModelClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/implementation/ErrorModelClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/implementation/ErrorModelClientImpl.java new file mode 100644 index 000000000..ba7a4d34d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/implementation/ErrorModelClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.errormodel.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the ErrorModelClient type. + */ +public final class ErrorModelClientImpl { + /** + * 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; + } + + /** + * The ErrorOpsImpl object to access its operations. + */ + private final ErrorOpsImpl errorOps; + + /** + * Gets the ErrorOpsImpl object to access its operations. + * + * @return the ErrorOpsImpl object. + */ + public ErrorOpsImpl getErrorOps() { + return this.errorOps; + } + + /** + * Initializes an instance of ErrorModelClient client. + * + * @param endpoint Service host. + */ + public ErrorModelClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ErrorModelClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ErrorModelClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ErrorModelClient 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 ErrorModelClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.errorOps = new ErrorOpsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/implementation/ErrorOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/implementation/ErrorOpsImpl.java new file mode 100644 index 000000000..259b2fa4b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/implementation/ErrorOpsImpl.java @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.errormodel.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.BinaryData; +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 ErrorOps. + */ +public final class ErrorOpsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ErrorOpsService service; + + /** + * The service client containing this operation class. + */ + private final ErrorModelClientImpl client; + + /** + * Initializes an instance of ErrorOpsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ErrorOpsImpl(ErrorModelClientImpl client) { + this.service = RestProxy.create(ErrorOpsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ErrorModelClientErrorOps to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ErrorModelClientErro") + public interface ErrorOpsService { + @Get("/error") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> read(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/error") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response readSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * The read operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> readWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.read(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The read operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response readWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.readSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/implementation/package-info.java new file mode 100644 index 000000000..05d258695 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 ErrorModel. + * + */ +package com.cadl.errormodel.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/models/Diagnostic.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/models/Diagnostic.java new file mode 100644 index 000000000..51a81b39e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/models/Diagnostic.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 com.cadl.errormodel.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +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 Diagnostic model. + */ +@Immutable +public final class Diagnostic implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The error property. + */ + @Generated + private final ResponseError error; + + /** + * Creates an instance of Diagnostic class. + * + * @param name the name value to set. + * @param error the error value to set. + */ + @Generated + private Diagnostic(String name, ResponseError error) { + this.name = name; + this.error = error; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the error property: The error property. + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeJsonField("error", this.error); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Diagnostic from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Diagnostic 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 Diagnostic. + */ + @Generated + public static Diagnostic fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + ResponseError error = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("error".equals(fieldName)) { + error = ResponseError.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new Diagnostic(name, error); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/models/package-info.java new file mode 100644 index 000000000..8df6cb1de --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/models/package-info.java @@ -0,0 +1,10 @@ +// 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 ErrorModel. + * + */ +package com.cadl.errormodel.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/package-info.java new file mode 100644 index 000000000..6dc63ffe0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/errormodel/package-info.java @@ -0,0 +1,10 @@ +// 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 ErrorModel. + * + */ +package com.cadl.errormodel; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/FlattenAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/FlattenAsyncClient.java new file mode 100644 index 000000000..e3c264ec5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/FlattenAsyncClient.java @@ -0,0 +1,433 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten; + +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 com.cadl.flatten.implementation.FlattenClientImpl; +import com.cadl.flatten.implementation.JsonMergePatchHelper; +import com.cadl.flatten.implementation.MultipartFormDataHelper; +import com.cadl.flatten.implementation.models.SendLongRequest; +import com.cadl.flatten.implementation.models.SendProjectedNameRequest; +import com.cadl.flatten.implementation.models.SendRequest; +import com.cadl.flatten.implementation.models.UploadFileRequest; +import com.cadl.flatten.implementation.models.UploadTodoRequest; +import com.cadl.flatten.models.FileDataFileDetails; +import com.cadl.flatten.models.SendLongOptions; +import com.cadl.flatten.models.TodoItem; +import com.cadl.flatten.models.UpdatePatchRequest; +import com.cadl.flatten.models.UploadTodoOptions; +import com.cadl.flatten.models.User; +import java.util.Objects; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous FlattenClient type. + */ +@ServiceClient(builder = FlattenClientBuilder.class, isAsync = true) +public final class FlattenAsyncClient { + @Generated + private final FlattenClientImpl serviceClient; + + /** + * Initializes an instance of FlattenAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FlattenAsyncClient(FlattenClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: String (Required)
+     *     constant: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendRequest The sendRequest 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> sendWithResponse(String id, BinaryData sendRequest, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(id, sendRequest, requestOptions); + } + + /** + * The sendProjectedName operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     file_id: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendProjectedNameRequest The sendProjectedNameRequest 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> sendProjectedNameWithResponse(String id, BinaryData sendProjectedNameRequest, + RequestOptions requestOptions) { + return this.serviceClient.sendProjectedNameWithResponseAsync(id, sendProjectedNameRequest, requestOptions); + } + + /** + * The sendLong operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: String (Required)
+     *     dataInt: int (Required)
+     *     dataIntOptional: Integer (Optional)
+     *     dataLong: Long (Optional)
+     *     data_float: Double (Optional)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     status: String(NotStarted/InProgress/Completed) (Required)
+     *     _dummy: String (Optional)
+     *     constant: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param sendLongRequest The sendLongRequest 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> sendLongWithResponse(String name, BinaryData sendLongRequest, + RequestOptions requestOptions) { + return this.serviceClient.sendLongWithResponseAsync(name, sendLongRequest, requestOptions); + } + + /** + * The update operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     patch (Optional, Required on create): {
+     *         title: String (Optional)
+     *         description: String (Optional)
+     *         status: String(NotStarted/InProgress/Completed) (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: long (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     status: String(NotStarted/InProgress/Completed) (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     updatedAt: OffsetDateTime (Required)
+     *     completedAt: OffsetDateTime (Optional)
+     *     _dummy: String (Optional)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param updateRequest The updateRequest 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateWithResponse(long id, BinaryData updateRequest, + RequestOptions requestOptions) { + return this.serviceClient.updateWithResponseAsync(id, updateRequest, requestOptions); + } + + /** + * The uploadFile operation. + * + * @param name The name parameter. + * @param uploadFileRequest The uploadFileRequest 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) + Mono> uploadFileWithResponse(String name, BinaryData uploadFileRequest, + RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'uploadFile' is + // 'multipart/form-data' + return this.serviceClient.uploadFileWithResponseAsync(name, uploadFileRequest, requestOptions); + } + + /** + * The uploadTodo operation. + * + * @param uploadTodoRequest The uploadTodoRequest 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) + Mono> uploadTodoWithResponse(BinaryData uploadTodoRequest, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'uploadTodo' is + // 'multipart/form-data' + return this.serviceClient.uploadTodoWithResponseAsync(uploadTodoRequest, requestOptions); + } + + /** + * The send operation. + * + * @param id The id parameter. + * @param input The input parameter. + * @param user The user 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 send(String id, String input, User user) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest sendRequestObj = new SendRequest(input).setUser(user); + BinaryData sendRequest = BinaryData.fromObject(sendRequestObj); + return sendWithResponse(id, sendRequest, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The send operation. + * + * @param id The id parameter. + * @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 send(String id, String input) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest sendRequestObj = new SendRequest(input); + BinaryData sendRequest = BinaryData.fromObject(sendRequestObj); + return sendWithResponse(id, sendRequest, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The sendProjectedName operation. + * + * @param id The id parameter. + * @param fileIdentifier The fileIdentifier 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 sendProjectedName(String id, String fileIdentifier) { + // Generated convenience method for sendProjectedNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendProjectedNameRequest sendProjectedNameRequestObj = new SendProjectedNameRequest(fileIdentifier); + BinaryData sendProjectedNameRequest = BinaryData.fromObject(sendProjectedNameRequestObj); + return sendProjectedNameWithResponse(id, sendProjectedNameRequest, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The sendLong operation. + * + * @param options Options for sendLong API. + * @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 sendLong(SendLongOptions options) { + // Generated convenience method for sendLongWithResponse + RequestOptions requestOptions = new RequestOptions(); + String name = options.getName(); + String filter = options.getFilter(); + SendLongRequest sendLongRequestObj + = new SendLongRequest(options.getInput(), options.getDataInt(), options.getTitle(), options.getStatus()) + .setUser(options.getUser()) + .setDataIntOptional(options.getDataIntOptional()) + .setDataLong(options.getDataLong()) + .setDataFloat(options.getDataFloat()) + .setDescription(options.getDescription()) + .setDummy(options.getDummy()); + BinaryData sendLongRequest = BinaryData.fromObject(sendLongRequestObj); + if (filter != null) { + requestOptions.addQueryParam("filter", filter, false); + } + return sendLongWithResponse(name, sendLongRequest, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The update operation. + * + * @param id The id parameter. + * @param updateRequest The updateRequest 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono update(long id, UpdatePatchRequest updateRequest) { + // Generated convenience method for updateWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getUpdatePatchRequestAccessor().prepareModelForJsonMergePatch(updateRequest, true); + BinaryData updateRequestInBinaryData = BinaryData.fromObject(updateRequest); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + updateRequestInBinaryData.getLength(); + JsonMergePatchHelper.getUpdatePatchRequestAccessor().prepareModelForJsonMergePatch(updateRequest, false); + return updateWithResponse(id, updateRequestInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TodoItem.class)); + } + + /** + * The uploadFile operation. + * + * @param name The name parameter. + * @param fileData The fileData 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 uploadFile(String name, FileDataFileDetails fileData) { + // Generated convenience method for uploadFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + UploadFileRequest uploadFileRequestObj = new UploadFileRequest(fileData); + BinaryData uploadFileRequest = new MultipartFormDataHelper(requestOptions) + .serializeFileField("file_data", uploadFileRequestObj.getFileData().getContent(), + uploadFileRequestObj.getFileData().getContentType(), uploadFileRequestObj.getFileData().getFilename()) + .serializeTextField("constant", uploadFileRequestObj.getConstant()) + .end() + .getRequestBody(); + return uploadFileWithResponse(name, uploadFileRequest, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The uploadTodo operation. + * + * @param options Options for uploadTodo API. + * @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 uploadTodo(UploadTodoOptions options) { + // Generated convenience method for uploadTodoWithResponse + RequestOptions requestOptions = new RequestOptions(); + UploadTodoRequest uploadTodoRequestObj + = new UploadTodoRequest(options.getTitle(), options.getStatus()).setDescription(options.getDescription()) + .setDummy(options.getDummy()) + .setProp1(options.getProp1()) + .setProp2(options.getProp2()) + .setProp3(options.getProp3()); + BinaryData uploadTodoRequest + = new MultipartFormDataHelper(requestOptions).serializeTextField("title", uploadTodoRequestObj.getTitle()) + .serializeTextField("description", uploadTodoRequestObj.getDescription()) + .serializeTextField("status", Objects.toString(uploadTodoRequestObj.getStatus())) + .serializeTextField("_dummy", uploadTodoRequestObj.getDummy()) + .serializeTextField("prop1", uploadTodoRequestObj.getProp1()) + .serializeTextField("prop2", uploadTodoRequestObj.getProp2()) + .serializeTextField("prop3", uploadTodoRequestObj.getProp3()) + .end() + .getRequestBody(); + return uploadTodoWithResponse(uploadTodoRequest, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/FlattenClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/FlattenClient.java new file mode 100644 index 000000000..36a6f4af4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/FlattenClient.java @@ -0,0 +1,421 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten; + +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.cadl.flatten.implementation.FlattenClientImpl; +import com.cadl.flatten.implementation.JsonMergePatchHelper; +import com.cadl.flatten.implementation.MultipartFormDataHelper; +import com.cadl.flatten.implementation.models.SendLongRequest; +import com.cadl.flatten.implementation.models.SendProjectedNameRequest; +import com.cadl.flatten.implementation.models.SendRequest; +import com.cadl.flatten.implementation.models.UploadFileRequest; +import com.cadl.flatten.implementation.models.UploadTodoRequest; +import com.cadl.flatten.models.FileDataFileDetails; +import com.cadl.flatten.models.SendLongOptions; +import com.cadl.flatten.models.TodoItem; +import com.cadl.flatten.models.UpdatePatchRequest; +import com.cadl.flatten.models.UploadTodoOptions; +import com.cadl.flatten.models.User; +import java.util.Objects; + +/** + * Initializes a new instance of the synchronous FlattenClient type. + */ +@ServiceClient(builder = FlattenClientBuilder.class) +public final class FlattenClient { + @Generated + private final FlattenClientImpl serviceClient; + + /** + * Initializes an instance of FlattenClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FlattenClient(FlattenClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: String (Required)
+     *     constant: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendRequest The sendRequest 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 sendWithResponse(String id, BinaryData sendRequest, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(id, sendRequest, requestOptions); + } + + /** + * The sendProjectedName operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     file_id: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendProjectedNameRequest The sendProjectedNameRequest 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 sendProjectedNameWithResponse(String id, BinaryData sendProjectedNameRequest, + RequestOptions requestOptions) { + return this.serviceClient.sendProjectedNameWithResponse(id, sendProjectedNameRequest, requestOptions); + } + + /** + * The sendLong operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: String (Required)
+     *     dataInt: int (Required)
+     *     dataIntOptional: Integer (Optional)
+     *     dataLong: Long (Optional)
+     *     data_float: Double (Optional)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     status: String(NotStarted/InProgress/Completed) (Required)
+     *     _dummy: String (Optional)
+     *     constant: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param sendLongRequest The sendLongRequest 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 sendLongWithResponse(String name, BinaryData sendLongRequest, RequestOptions requestOptions) { + return this.serviceClient.sendLongWithResponse(name, sendLongRequest, requestOptions); + } + + /** + * The update operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     patch (Optional, Required on create): {
+     *         title: String (Optional)
+     *         description: String (Optional)
+     *         status: String(NotStarted/InProgress/Completed) (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: long (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     status: String(NotStarted/InProgress/Completed) (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     updatedAt: OffsetDateTime (Required)
+     *     completedAt: OffsetDateTime (Optional)
+     *     _dummy: String (Optional)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param updateRequest The updateRequest 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse(long id, BinaryData updateRequest, RequestOptions requestOptions) { + return this.serviceClient.updateWithResponse(id, updateRequest, requestOptions); + } + + /** + * The uploadFile operation. + * + * @param name The name parameter. + * @param uploadFileRequest The uploadFileRequest 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) + Response uploadFileWithResponse(String name, BinaryData uploadFileRequest, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'uploadFile' is + // 'multipart/form-data' + return this.serviceClient.uploadFileWithResponse(name, uploadFileRequest, requestOptions); + } + + /** + * The uploadTodo operation. + * + * @param uploadTodoRequest The uploadTodoRequest 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) + Response uploadTodoWithResponse(BinaryData uploadTodoRequest, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'uploadTodo' is + // 'multipart/form-data' + return this.serviceClient.uploadTodoWithResponse(uploadTodoRequest, requestOptions); + } + + /** + * The send operation. + * + * @param id The id parameter. + * @param input The input parameter. + * @param user The user 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 send(String id, String input, User user) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest sendRequestObj = new SendRequest(input).setUser(user); + BinaryData sendRequest = BinaryData.fromObject(sendRequestObj); + sendWithResponse(id, sendRequest, requestOptions).getValue(); + } + + /** + * The send operation. + * + * @param id The id parameter. + * @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 send(String id, String input) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest sendRequestObj = new SendRequest(input); + BinaryData sendRequest = BinaryData.fromObject(sendRequestObj); + sendWithResponse(id, sendRequest, requestOptions).getValue(); + } + + /** + * The sendProjectedName operation. + * + * @param id The id parameter. + * @param fileIdentifier The fileIdentifier 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 sendProjectedName(String id, String fileIdentifier) { + // Generated convenience method for sendProjectedNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendProjectedNameRequest sendProjectedNameRequestObj = new SendProjectedNameRequest(fileIdentifier); + BinaryData sendProjectedNameRequest = BinaryData.fromObject(sendProjectedNameRequestObj); + sendProjectedNameWithResponse(id, sendProjectedNameRequest, requestOptions).getValue(); + } + + /** + * The sendLong operation. + * + * @param options Options for sendLong API. + * @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 sendLong(SendLongOptions options) { + // Generated convenience method for sendLongWithResponse + RequestOptions requestOptions = new RequestOptions(); + String name = options.getName(); + String filter = options.getFilter(); + SendLongRequest sendLongRequestObj + = new SendLongRequest(options.getInput(), options.getDataInt(), options.getTitle(), options.getStatus()) + .setUser(options.getUser()) + .setDataIntOptional(options.getDataIntOptional()) + .setDataLong(options.getDataLong()) + .setDataFloat(options.getDataFloat()) + .setDescription(options.getDescription()) + .setDummy(options.getDummy()); + BinaryData sendLongRequest = BinaryData.fromObject(sendLongRequestObj); + if (filter != null) { + requestOptions.addQueryParam("filter", filter, false); + } + sendLongWithResponse(name, sendLongRequest, requestOptions).getValue(); + } + + /** + * The update operation. + * + * @param id The id parameter. + * @param updateRequest The updateRequest 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public TodoItem update(long id, UpdatePatchRequest updateRequest) { + // Generated convenience method for updateWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getUpdatePatchRequestAccessor().prepareModelForJsonMergePatch(updateRequest, true); + BinaryData updateRequestInBinaryData = BinaryData.fromObject(updateRequest); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + updateRequestInBinaryData.getLength(); + JsonMergePatchHelper.getUpdatePatchRequestAccessor().prepareModelForJsonMergePatch(updateRequest, false); + return updateWithResponse(id, updateRequestInBinaryData, requestOptions).getValue().toObject(TodoItem.class); + } + + /** + * The uploadFile operation. + * + * @param name The name parameter. + * @param fileData The fileData 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 uploadFile(String name, FileDataFileDetails fileData) { + // Generated convenience method for uploadFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + UploadFileRequest uploadFileRequestObj = new UploadFileRequest(fileData); + BinaryData uploadFileRequest = new MultipartFormDataHelper(requestOptions) + .serializeFileField("file_data", uploadFileRequestObj.getFileData().getContent(), + uploadFileRequestObj.getFileData().getContentType(), uploadFileRequestObj.getFileData().getFilename()) + .serializeTextField("constant", uploadFileRequestObj.getConstant()) + .end() + .getRequestBody(); + uploadFileWithResponse(name, uploadFileRequest, requestOptions).getValue(); + } + + /** + * The uploadTodo operation. + * + * @param options Options for uploadTodo API. + * @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 uploadTodo(UploadTodoOptions options) { + // Generated convenience method for uploadTodoWithResponse + RequestOptions requestOptions = new RequestOptions(); + UploadTodoRequest uploadTodoRequestObj + = new UploadTodoRequest(options.getTitle(), options.getStatus()).setDescription(options.getDescription()) + .setDummy(options.getDummy()) + .setProp1(options.getProp1()) + .setProp2(options.getProp2()) + .setProp3(options.getProp3()); + BinaryData uploadTodoRequest + = new MultipartFormDataHelper(requestOptions).serializeTextField("title", uploadTodoRequestObj.getTitle()) + .serializeTextField("description", uploadTodoRequestObj.getDescription()) + .serializeTextField("status", Objects.toString(uploadTodoRequestObj.getStatus())) + .serializeTextField("_dummy", uploadTodoRequestObj.getDummy()) + .serializeTextField("prop1", uploadTodoRequestObj.getProp1()) + .serializeTextField("prop2", uploadTodoRequestObj.getProp2()) + .serializeTextField("prop3", uploadTodoRequestObj.getProp3()) + .end() + .getRequestBody(); + uploadTodoWithResponse(uploadTodoRequest, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/FlattenClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/FlattenClientBuilder.java new file mode 100644 index 000000000..ec2c0ce39 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/FlattenClientBuilder.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.flatten.implementation.FlattenClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the FlattenClient type. + */ +@ServiceClientBuilder(serviceClients = { FlattenClient.class, FlattenAsyncClient.class }) +public final class FlattenClientBuilder 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("cadl-flatten.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the FlattenClientBuilder. + */ + @Generated + public FlattenClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FlattenClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FlattenClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FlattenClientBuilder 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 FlattenClientBuilder 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 FlattenClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FlattenClientBuilder 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 FlattenClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FlattenClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private FlattenServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the FlattenClientBuilder. + */ + @Generated + public FlattenClientBuilder serviceVersion(FlattenServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 FlattenClientBuilder. + */ + @Generated + public FlattenClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of FlattenClientImpl with the provided parameters. + * + * @return an instance of FlattenClientImpl. + */ + @Generated + private FlattenClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + FlattenServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : FlattenServiceVersion.getLatest(); + FlattenClientImpl client = new FlattenClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 FlattenAsyncClient class. + * + * @return an instance of FlattenAsyncClient. + */ + @Generated + public FlattenAsyncClient buildAsyncClient() { + return new FlattenAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of FlattenClient class. + * + * @return an instance of FlattenClient. + */ + @Generated + public FlattenClient buildClient() { + return new FlattenClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(FlattenClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/FlattenServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/FlattenServiceVersion.java new file mode 100644 index 000000000..3284679bb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/FlattenServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of FlattenClient. + */ +public enum FlattenServiceVersion implements ServiceVersion { + /** + * Enum value 2022-06-01-preview. + */ + V2022_06_01_PREVIEW("2022-06-01-preview"); + + private final String version; + + FlattenServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link FlattenServiceVersion}. + */ + public static FlattenServiceVersion getLatest() { + return V2022_06_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/FlattenClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/FlattenClientImpl.java new file mode 100644 index 000000000..d54baf3bb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/FlattenClientImpl.java @@ -0,0 +1,659 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.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.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +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.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 com.cadl.flatten.FlattenServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the FlattenClient type. + */ +public final class FlattenClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FlattenClientService service; + + /** + */ + private final String endpoint; + + /** + * Gets. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final FlattenServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public FlattenServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 FlattenClient client. + * + * @param endpoint + * @param serviceVersion Service version. + */ + public FlattenClientImpl(String endpoint, FlattenServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of FlattenClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint + * @param serviceVersion Service version. + */ + public FlattenClientImpl(HttpPipeline httpPipeline, String endpoint, FlattenServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of FlattenClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint + * @param serviceVersion Service version. + */ + public FlattenClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + FlattenServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(FlattenClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for FlattenClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}/openai") + @ServiceInterface(name = "FlattenClient") + public interface FlattenClientService { + @Post("/flatten/send") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, @QueryParam("id") String id, + @QueryParam("constantQueryParam") String constantQueryParam, @QueryParam("api-version") String apiVersion, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest, + RequestOptions requestOptions, Context context); + + @Post("/flatten/send") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @QueryParam("id") String id, + @QueryParam("constantQueryParam") String constantQueryParam, @QueryParam("api-version") String apiVersion, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest, + RequestOptions requestOptions, Context context); + + @Post("/flatten/send-projected-name") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> sendProjectedName(@HostParam("endpoint") String endpoint, @QueryParam("id") String id, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendProjectedNameRequest, RequestOptions requestOptions, + Context context); + + @Post("/flatten/send-projected-name") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendProjectedNameSync(@HostParam("endpoint") String endpoint, @QueryParam("id") String id, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendProjectedNameRequest, RequestOptions requestOptions, + Context context); + + @Post("/flatten/send-long") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> sendLong(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendLongRequest, RequestOptions requestOptions, Context context); + + @Post("/flatten/send-long") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendLongSync(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendLongRequest, RequestOptions requestOptions, Context context); + + @Patch("/flatten/patch/{id}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> update(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @PathParam("id") long id, + @HeaderParam("Accept") String accept, @BodyParam("application/merge-patch+json") BinaryData updateRequest, + RequestOptions requestOptions, Context context); + + @Patch("/flatten/patch/{id}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response updateSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @PathParam("id") long id, + @HeaderParam("Accept") String accept, @BodyParam("application/merge-patch+json") BinaryData updateRequest, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/flatten/upload/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadFile(@HostParam("endpoint") String endpoint, @PathParam("name") String name, + @HeaderParam("content-type") String contentType, + @BodyParam("multipart/form-data") BinaryData uploadFileRequest, RequestOptions requestOptions, + Context context); + + // @Multipart not supported by RestProxy + @Post("/flatten/upload/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadFileSync(@HostParam("endpoint") String endpoint, @PathParam("name") String name, + @HeaderParam("content-type") String contentType, + @BodyParam("multipart/form-data") BinaryData uploadFileRequest, RequestOptions requestOptions, + Context context); + + // @Multipart not supported by RestProxy + @Post("/flatten/upload-todo") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadTodo(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, + @BodyParam("multipart/form-data") BinaryData uploadTodoRequest, RequestOptions requestOptions, + Context context); + + // @Multipart not supported by RestProxy + @Post("/flatten/upload-todo") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadTodoSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, + @BodyParam("multipart/form-data") BinaryData uploadTodoRequest, RequestOptions requestOptions, + Context context); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: String (Required)
+     *     constant: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendRequest The sendRequest 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> sendWithResponseAsync(String id, BinaryData sendRequest, + RequestOptions requestOptions) { + final String constantQueryParam = "constant"; + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.send(this.getEndpoint(), id, constantQueryParam, + this.getServiceVersion().getVersion(), contentType, sendRequest, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: String (Required)
+     *     constant: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendRequest The sendRequest 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 sendWithResponse(String id, BinaryData sendRequest, RequestOptions requestOptions) { + final String constantQueryParam = "constant"; + final String contentType = "application/json"; + return service.sendSync(this.getEndpoint(), id, constantQueryParam, this.getServiceVersion().getVersion(), + contentType, sendRequest, requestOptions, Context.NONE); + } + + /** + * The sendProjectedName operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     file_id: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendProjectedNameRequest The sendProjectedNameRequest 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> sendProjectedNameWithResponseAsync(String id, BinaryData sendProjectedNameRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.sendProjectedName(this.getEndpoint(), id, contentType, + sendProjectedNameRequest, requestOptions, context)); + } + + /** + * The sendProjectedName operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     file_id: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendProjectedNameRequest The sendProjectedNameRequest 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 sendProjectedNameWithResponse(String id, BinaryData sendProjectedNameRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendProjectedNameSync(this.getEndpoint(), id, contentType, sendProjectedNameRequest, + requestOptions, Context.NONE); + } + + /** + * The sendLong operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: String (Required)
+     *     dataInt: int (Required)
+     *     dataIntOptional: Integer (Optional)
+     *     dataLong: Long (Optional)
+     *     data_float: Double (Optional)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     status: String(NotStarted/InProgress/Completed) (Required)
+     *     _dummy: String (Optional)
+     *     constant: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param sendLongRequest The sendLongRequest 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> sendLongWithResponseAsync(String name, BinaryData sendLongRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.sendLong(this.getEndpoint(), name, + this.getServiceVersion().getVersion(), contentType, sendLongRequest, requestOptions, context)); + } + + /** + * The sendLong operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: String (Required)
+     *     dataInt: int (Required)
+     *     dataIntOptional: Integer (Optional)
+     *     dataLong: Long (Optional)
+     *     data_float: Double (Optional)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     status: String(NotStarted/InProgress/Completed) (Required)
+     *     _dummy: String (Optional)
+     *     constant: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param sendLongRequest The sendLongRequest 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 sendLongWithResponse(String name, BinaryData sendLongRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendLongSync(this.getEndpoint(), name, this.getServiceVersion().getVersion(), contentType, + sendLongRequest, requestOptions, Context.NONE); + } + + /** + * The update operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     patch (Optional, Required on create): {
+     *         title: String (Optional)
+     *         description: String (Optional)
+     *         status: String(NotStarted/InProgress/Completed) (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: long (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     status: String(NotStarted/InProgress/Completed) (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     updatedAt: OffsetDateTime (Required)
+     *     completedAt: OffsetDateTime (Optional)
+     *     _dummy: String (Optional)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param updateRequest The updateRequest 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateWithResponseAsync(long id, BinaryData updateRequest, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.update(this.getEndpoint(), contentType, id, accept, + updateRequest, requestOptions, context)); + } + + /** + * The update operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     patch (Optional, Required on create): {
+     *         title: String (Optional)
+     *         description: String (Optional)
+     *         status: String(NotStarted/InProgress/Completed) (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: long (Required)
+     *     title: String (Required)
+     *     description: String (Optional)
+     *     status: String(NotStarted/InProgress/Completed) (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     updatedAt: OffsetDateTime (Required)
+     *     completedAt: OffsetDateTime (Optional)
+     *     _dummy: String (Optional)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param updateRequest The updateRequest 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse(long id, BinaryData updateRequest, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return service.updateSync(this.getEndpoint(), contentType, id, accept, updateRequest, requestOptions, + Context.NONE); + } + + /** + * The uploadFile operation. + * + * @param name The name parameter. + * @param uploadFileRequest The uploadFileRequest 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> uploadFileWithResponseAsync(String name, BinaryData uploadFileRequest, + RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext(context -> service.uploadFile(this.getEndpoint(), name, contentType, + uploadFileRequest, requestOptions, context)); + } + + /** + * The uploadFile operation. + * + * @param name The name parameter. + * @param uploadFileRequest The uploadFileRequest 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 uploadFileWithResponse(String name, BinaryData uploadFileRequest, + RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.uploadFileSync(this.getEndpoint(), name, contentType, uploadFileRequest, requestOptions, + Context.NONE); + } + + /** + * The uploadTodo operation. + * + * @param uploadTodoRequest The uploadTodoRequest 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> uploadTodoWithResponseAsync(BinaryData uploadTodoRequest, + RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext( + context -> service.uploadTodo(this.getEndpoint(), contentType, uploadTodoRequest, requestOptions, context)); + } + + /** + * The uploadTodo operation. + * + * @param uploadTodoRequest The uploadTodoRequest 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 uploadTodoWithResponse(BinaryData uploadTodoRequest, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.uploadTodoSync(this.getEndpoint(), contentType, uploadTodoRequest, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/JsonMergePatchHelper.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/JsonMergePatchHelper.java new file mode 100644 index 000000000..da6c4f93f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/JsonMergePatchHelper.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.implementation; + +import com.cadl.flatten.models.TodoItemPatch; +import com.cadl.flatten.models.UpdatePatchRequest; + +/** + * This is the Helper class to enable json merge patch serialization for a model. + */ +public class JsonMergePatchHelper { + private static UpdatePatchRequestAccessor updatePatchRequestAccessor; + + public interface UpdatePatchRequestAccessor { + UpdatePatchRequest prepareModelForJsonMergePatch(UpdatePatchRequest updatePatchRequest, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(UpdatePatchRequest updatePatchRequest); + } + + public static void setUpdatePatchRequestAccessor(UpdatePatchRequestAccessor accessor) { + updatePatchRequestAccessor = accessor; + } + + public static UpdatePatchRequestAccessor getUpdatePatchRequestAccessor() { + return updatePatchRequestAccessor; + } + + private static TodoItemPatchAccessor todoItemPatchAccessor; + + public interface TodoItemPatchAccessor { + TodoItemPatch prepareModelForJsonMergePatch(TodoItemPatch todoItemPatch, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(TodoItemPatch todoItemPatch); + } + + public static void setTodoItemPatchAccessor(TodoItemPatchAccessor accessor) { + todoItemPatchAccessor = accessor; + } + + public static TodoItemPatchAccessor getTodoItemPatchAccessor() { + return todoItemPatchAccessor; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/MultipartFormDataHelper.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/MultipartFormDataHelper.java new file mode 100644 index 000000000..fae4b0725 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/MultipartFormDataHelper.java @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.SequenceInputStream; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.UUID; + +// DO NOT modify this helper class + +public final class MultipartFormDataHelper { + /** + * Line separator for the multipart HTTP request. + */ + private static final String CRLF = "\r\n"; + + private static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + /** + * Value to be used as part of the divider for the multipart requests. + */ + private final String boundary; + + /** + * The actual part separator in the request. This is obtained by prepending "--" to the "boundary". + */ + private final String partSeparator; + + /** + * The marker for the ending of a multipart request. This is obtained by post-pending "--" to the "partSeparator". + */ + private final String endMarker; + + /** + * Charset used for encoding the multipart HTTP request. + */ + private final Charset encoderCharset = StandardCharsets.UTF_8; + + private InputStream requestDataStream = new ByteArrayInputStream(new byte[0]); + private long requestLength = 0; + + private RequestOptions requestOptions; + private BinaryData requestBody; + + /** + * Default constructor used in the code. The boundary is a random value. + * + * @param requestOptions the RequestOptions to update + */ + public MultipartFormDataHelper(RequestOptions requestOptions) { + this(requestOptions, UUID.randomUUID().toString().substring(0, 16)); + } + + private MultipartFormDataHelper(RequestOptions requestOptions, String boundary) { + this.requestOptions = requestOptions; + this.boundary = boundary; + this.partSeparator = "--" + boundary; + this.endMarker = this.partSeparator + "--"; + } + + /** + * Gets the multipart HTTP request body. + * + * @return the BinaryData of the multipart HTTP request body + */ + public BinaryData getRequestBody() { + return requestBody; + } + + // text/plain + /** + * Formats a text/plain field for a multipart HTTP request. + * + * @param fieldName the field name + * @param value the value of the text/plain field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeTextField(String fieldName, String value) { + if (value != null) { + String serialized = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + + "\"" + CRLF + CRLF + value + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + // application/json + /** + * Formats a application/json field for a multipart HTTP request. + * + * @param fieldName the field name + * @param jsonObject the object of the application/json field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeJsonField(String fieldName, Object jsonObject) { + if (jsonObject != null) { + String serialized + = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + CRLF + + "Content-Type: application/json" + CRLF + CRLF + BinaryData.fromObject(jsonObject) + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + /** + * Formats a file field for a multipart HTTP request. + * + * @param fieldName the field name + * @param file the BinaryData of the file + * @param contentType the content-type of the file + * @param filename the filename + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileField(String fieldName, BinaryData file, String contentType, + String filename) { + if (file != null) { + if (CoreUtils.isNullOrEmpty(contentType)) { + contentType = APPLICATION_OCTET_STREAM; + } + writeFileField(fieldName, file, contentType, filename); + } + return this; + } + + /** + * Formats a file field (potentially multiple files) for a multipart HTTP request. + * + * @param fieldName the field name + * @param files the List of BinaryData of the files + * @param contentTypes the List of content-type of the files + * @param filenames the List of filenames + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileFields(String fieldName, List files, + List contentTypes, List filenames) { + if (files != null) { + for (int i = 0; i < files.size(); ++i) { + BinaryData file = files.get(i); + String contentType = contentTypes.get(i); + if (CoreUtils.isNullOrEmpty(contentType)) { + contentType = APPLICATION_OCTET_STREAM; + } + String filename = filenames.get(i); + writeFileField(fieldName, file, contentType, filename); + } + } + return this; + } + + /** + * Ends the serialization of the multipart HTTP request. + * + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper end() { + byte[] data = endMarker.getBytes(encoderCharset); + appendBytes(data); + + requestBody = BinaryData.fromStream(requestDataStream, requestLength); + + requestOptions.setHeader(HttpHeaderName.CONTENT_TYPE, "multipart/form-data; boundary=" + this.boundary) + .setHeader(HttpHeaderName.CONTENT_LENGTH, String.valueOf(requestLength)); + + return this; + } + + private void writeFileField(String fieldName, BinaryData file, String contentType, String filename) { + String contentDispositionFilename = ""; + if (!CoreUtils.isNullOrEmpty(filename)) { + contentDispositionFilename = "; filename=\"" + escapeName(filename) + "\""; + } + + // Multipart preamble + String fileFieldPreamble + = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + + contentDispositionFilename + CRLF + "Content-Type: " + contentType + CRLF + CRLF; + byte[] data = fileFieldPreamble.getBytes(encoderCharset); + appendBytes(data); + + // Writing the file into the request as a byte stream + requestLength += file.getLength(); + requestDataStream = new SequenceInputStream(requestDataStream, file.toStream()); + + // CRLF + data = CRLF.getBytes(encoderCharset); + appendBytes(data); + } + + private void appendBytes(byte[] bytes) { + requestLength += bytes.length; + requestDataStream = new SequenceInputStream(requestDataStream, new ByteArrayInputStream(bytes)); + } + + private static String escapeName(String name) { + return name.replace("\n", "%0A").replace("\r", "%0D").replace("\"", "%22"); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/SendLongRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/SendLongRequest.java new file mode 100644 index 000000000..9b55f3f82 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/SendLongRequest.java @@ -0,0 +1,368 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.implementation.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 com.cadl.flatten.models.SendLongRequestStatus; +import com.cadl.flatten.models.User; +import java.io.IOException; + +/** + * The SendLongRequest model. + */ +@Fluent +public final class SendLongRequest implements JsonSerializable { + /* + * The user property. + */ + @Generated + private User user; + + /* + * The input property. + */ + @Generated + private final String input; + + /* + * The dataInt property. + */ + @Generated + private final int dataInt; + + /* + * The dataIntOptional property. + */ + @Generated + private Integer dataIntOptional; + + /* + * The dataLong property. + */ + @Generated + private Long dataLong; + + /* + * The data_float property. + */ + @Generated + private Double dataFloat; + + /* + * The item's title + */ + @Generated + private final String title; + + /* + * A longer description of the todo item in markdown format + */ + @Generated + private String description; + + /* + * The status of the todo item + */ + @Generated + private final SendLongRequestStatus status; + + /* + * The _dummy property. + */ + @Generated + private String dummy; + + /* + * The constant property. + */ + @Generated + private final String constant = "constant"; + + /** + * Creates an instance of SendLongRequest class. + * + * @param input the input value to set. + * @param dataInt the dataInt value to set. + * @param title the title value to set. + * @param status the status value to set. + */ + @Generated + public SendLongRequest(String input, int dataInt, String title, SendLongRequestStatus status) { + this.input = input; + this.dataInt = dataInt; + this.title = title; + this.status = status; + } + + /** + * Get the user property: The user property. + * + * @return the user value. + */ + @Generated + public User getUser() { + return this.user; + } + + /** + * Set the user property: The user property. + * + * @param user the user value to set. + * @return the SendLongRequest object itself. + */ + @Generated + public SendLongRequest setUser(User user) { + this.user = user; + return this; + } + + /** + * Get the input property: The input property. + * + * @return the input value. + */ + @Generated + public String getInput() { + return this.input; + } + + /** + * Get the dataInt property: The dataInt property. + * + * @return the dataInt value. + */ + @Generated + public int getDataInt() { + return this.dataInt; + } + + /** + * Get the dataIntOptional property: The dataIntOptional property. + * + * @return the dataIntOptional value. + */ + @Generated + public Integer getDataIntOptional() { + return this.dataIntOptional; + } + + /** + * Set the dataIntOptional property: The dataIntOptional property. + * + * @param dataIntOptional the dataIntOptional value to set. + * @return the SendLongRequest object itself. + */ + @Generated + public SendLongRequest setDataIntOptional(Integer dataIntOptional) { + this.dataIntOptional = dataIntOptional; + return this; + } + + /** + * Get the dataLong property: The dataLong property. + * + * @return the dataLong value. + */ + @Generated + public Long getDataLong() { + return this.dataLong; + } + + /** + * Set the dataLong property: The dataLong property. + * + * @param dataLong the dataLong value to set. + * @return the SendLongRequest object itself. + */ + @Generated + public SendLongRequest setDataLong(Long dataLong) { + this.dataLong = dataLong; + return this; + } + + /** + * Get the dataFloat property: The data_float property. + * + * @return the dataFloat value. + */ + @Generated + public Double getDataFloat() { + return this.dataFloat; + } + + /** + * Set the dataFloat property: The data_float property. + * + * @param dataFloat the dataFloat value to set. + * @return the SendLongRequest object itself. + */ + @Generated + public SendLongRequest setDataFloat(Double dataFloat) { + this.dataFloat = dataFloat; + return this; + } + + /** + * Get the title property: The item's title. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the description property: A longer description of the todo item in markdown format. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: A longer description of the todo item in markdown format. + * + * @param description the description value to set. + * @return the SendLongRequest object itself. + */ + @Generated + public SendLongRequest setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the status property: The status of the todo item. + * + * @return the status value. + */ + @Generated + public SendLongRequestStatus getStatus() { + return this.status; + } + + /** + * Get the dummy property: The _dummy property. + * + * @return the dummy value. + */ + @Generated + public String getDummy() { + return this.dummy; + } + + /** + * Set the dummy property: The _dummy property. + * + * @param dummy the dummy value to set. + * @return the SendLongRequest object itself. + */ + @Generated + public SendLongRequest setDummy(String dummy) { + this.dummy = dummy; + return this; + } + + /** + * Get the constant property: The constant property. + * + * @return the constant value. + */ + @Generated + public String getConstant() { + return this.constant; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("input", this.input); + jsonWriter.writeIntField("dataInt", this.dataInt); + jsonWriter.writeStringField("title", this.title); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeStringField("constant", this.constant); + jsonWriter.writeJsonField("user", this.user); + jsonWriter.writeNumberField("dataIntOptional", this.dataIntOptional); + jsonWriter.writeNumberField("dataLong", this.dataLong); + jsonWriter.writeNumberField("data_float", this.dataFloat); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("_dummy", this.dummy); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendLongRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendLongRequest 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 SendLongRequest. + */ + @Generated + public static SendLongRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String input = null; + int dataInt = 0; + String title = null; + SendLongRequestStatus status = null; + User user = null; + Integer dataIntOptional = null; + Long dataLong = null; + Double dataFloat = null; + String description = null; + String dummy = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("input".equals(fieldName)) { + input = reader.getString(); + } else if ("dataInt".equals(fieldName)) { + dataInt = reader.getInt(); + } else if ("title".equals(fieldName)) { + title = reader.getString(); + } else if ("status".equals(fieldName)) { + status = SendLongRequestStatus.fromString(reader.getString()); + } else if ("user".equals(fieldName)) { + user = User.fromJson(reader); + } else if ("dataIntOptional".equals(fieldName)) { + dataIntOptional = reader.getNullable(JsonReader::getInt); + } else if ("dataLong".equals(fieldName)) { + dataLong = reader.getNullable(JsonReader::getLong); + } else if ("data_float".equals(fieldName)) { + dataFloat = reader.getNullable(JsonReader::getDouble); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("_dummy".equals(fieldName)) { + dummy = reader.getString(); + } else { + reader.skipChildren(); + } + } + SendLongRequest deserializedSendLongRequest = new SendLongRequest(input, dataInt, title, status); + deserializedSendLongRequest.user = user; + deserializedSendLongRequest.dataIntOptional = dataIntOptional; + deserializedSendLongRequest.dataLong = dataLong; + deserializedSendLongRequest.dataFloat = dataFloat; + deserializedSendLongRequest.description = description; + deserializedSendLongRequest.dummy = dummy; + + return deserializedSendLongRequest; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/SendProjectedNameRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/SendProjectedNameRequest.java new file mode 100644 index 000000000..5a00e401d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/SendProjectedNameRequest.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.implementation.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; + +/** + * The SendProjectedNameRequest model. + */ +@Immutable +public final class SendProjectedNameRequest implements JsonSerializable { + /* + * The file_id property. + */ + @Generated + private final String fileIdentifier; + + /** + * Creates an instance of SendProjectedNameRequest class. + * + * @param fileIdentifier the fileIdentifier value to set. + */ + @Generated + public SendProjectedNameRequest(String fileIdentifier) { + this.fileIdentifier = fileIdentifier; + } + + /** + * Get the fileIdentifier property: The file_id property. + * + * @return the fileIdentifier value. + */ + @Generated + public String getFileIdentifier() { + return this.fileIdentifier; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("file_id", this.fileIdentifier); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendProjectedNameRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendProjectedNameRequest 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 SendProjectedNameRequest. + */ + @Generated + public static SendProjectedNameRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String fileIdentifier = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("file_id".equals(fieldName)) { + fileIdentifier = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SendProjectedNameRequest(fileIdentifier); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/SendRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/SendRequest.java new file mode 100644 index 000000000..bd4ffab24 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/SendRequest.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.implementation.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 com.cadl.flatten.models.User; +import java.io.IOException; + +/** + * The SendRequest model. + */ +@Fluent +public final class SendRequest implements JsonSerializable { + /* + * The user property. + */ + @Generated + private User user; + + /* + * The input property. + */ + @Generated + private final String input; + + /* + * The constant property. + */ + @Generated + private final String constant = "constant"; + + /** + * Creates an instance of SendRequest class. + * + * @param input the input value to set. + */ + @Generated + public SendRequest(String input) { + this.input = input; + } + + /** + * Get the user property: The user property. + * + * @return the user value. + */ + @Generated + public User getUser() { + return this.user; + } + + /** + * Set the user property: The user property. + * + * @param user the user value to set. + * @return the SendRequest object itself. + */ + @Generated + public SendRequest setUser(User user) { + this.user = user; + return this; + } + + /** + * Get the input property: The input property. + * + * @return the input value. + */ + @Generated + public String getInput() { + return this.input; + } + + /** + * Get the constant property: The constant property. + * + * @return the constant value. + */ + @Generated + public String getConstant() { + return this.constant; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("input", this.input); + jsonWriter.writeStringField("constant", this.constant); + jsonWriter.writeJsonField("user", this.user); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest 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 SendRequest. + */ + @Generated + public static SendRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String input = null; + User user = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("input".equals(fieldName)) { + input = reader.getString(); + } else if ("user".equals(fieldName)) { + user = User.fromJson(reader); + } else { + reader.skipChildren(); + } + } + SendRequest deserializedSendRequest = new SendRequest(input); + deserializedSendRequest.user = user; + + return deserializedSendRequest; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/UploadFileRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/UploadFileRequest.java new file mode 100644 index 000000000..2bbe44a1a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/UploadFileRequest.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.cadl.flatten.models.FileDataFileDetails; + +/** + * The UploadFileRequest model. + */ +@Immutable +public final class UploadFileRequest { + /* + * The file_data property. + */ + @Generated + private final FileDataFileDetails fileData; + + /* + * The constant property. + */ + @Generated + private final String constant = "constant"; + + /** + * Creates an instance of UploadFileRequest class. + * + * @param fileData the fileData value to set. + */ + @Generated + public UploadFileRequest(FileDataFileDetails fileData) { + this.fileData = fileData; + } + + /** + * Get the fileData property: The file_data property. + * + * @return the fileData value. + */ + @Generated + public FileDataFileDetails getFileData() { + return this.fileData; + } + + /** + * Get the constant property: The constant property. + * + * @return the constant value. + */ + @Generated + public String getConstant() { + return this.constant; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/UploadTodoRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/UploadTodoRequest.java new file mode 100644 index 000000000..a1b964c19 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/UploadTodoRequest.java @@ -0,0 +1,199 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.cadl.flatten.models.SendLongRequestStatus; + +/** + * The UploadTodoRequest model. + */ +@Fluent +public final class UploadTodoRequest { + /* + * The item's title + */ + @Generated + private final String title; + + /* + * A longer description of the todo item in markdown format + */ + @Generated + private String description; + + /* + * The status of the todo item + */ + @Generated + private final SendLongRequestStatus status; + + /* + * The _dummy property. + */ + @Generated + private String dummy; + + /* + * The prop1 property. + */ + @Generated + private String prop1; + + /* + * The prop2 property. + */ + @Generated + private String prop2; + + /* + * The prop3 property. + */ + @Generated + private String prop3; + + /** + * Creates an instance of UploadTodoRequest class. + * + * @param title the title value to set. + * @param status the status value to set. + */ + @Generated + public UploadTodoRequest(String title, SendLongRequestStatus status) { + this.title = title; + this.status = status; + } + + /** + * Get the title property: The item's title. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the description property: A longer description of the todo item in markdown format. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: A longer description of the todo item in markdown format. + * + * @param description the description value to set. + * @return the UploadTodoRequest object itself. + */ + @Generated + public UploadTodoRequest setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the status property: The status of the todo item. + * + * @return the status value. + */ + @Generated + public SendLongRequestStatus getStatus() { + return this.status; + } + + /** + * Get the dummy property: The _dummy property. + * + * @return the dummy value. + */ + @Generated + public String getDummy() { + return this.dummy; + } + + /** + * Set the dummy property: The _dummy property. + * + * @param dummy the dummy value to set. + * @return the UploadTodoRequest object itself. + */ + @Generated + public UploadTodoRequest setDummy(String dummy) { + this.dummy = dummy; + return this; + } + + /** + * Get the prop1 property: The prop1 property. + * + * @return the prop1 value. + */ + @Generated + public String getProp1() { + return this.prop1; + } + + /** + * Set the prop1 property: The prop1 property. + * + * @param prop1 the prop1 value to set. + * @return the UploadTodoRequest object itself. + */ + @Generated + public UploadTodoRequest setProp1(String prop1) { + this.prop1 = prop1; + return this; + } + + /** + * Get the prop2 property: The prop2 property. + * + * @return the prop2 value. + */ + @Generated + public String getProp2() { + return this.prop2; + } + + /** + * Set the prop2 property: The prop2 property. + * + * @param prop2 the prop2 value to set. + * @return the UploadTodoRequest object itself. + */ + @Generated + public UploadTodoRequest setProp2(String prop2) { + this.prop2 = prop2; + return this; + } + + /** + * Get the prop3 property: The prop3 property. + * + * @return the prop3 value. + */ + @Generated + public String getProp3() { + return this.prop3; + } + + /** + * Set the prop3 property: The prop3 property. + * + * @param prop3 the prop3 value to set. + * @return the UploadTodoRequest object itself. + */ + @Generated + public UploadTodoRequest setProp3(String prop3) { + this.prop3 = prop3; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/package-info.java new file mode 100644 index 000000000..2d74c3a2f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Flatten. + * + */ +package com.cadl.flatten.implementation.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/package-info.java new file mode 100644 index 000000000..5d96c0c91 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Flatten. + * + */ +package com.cadl.flatten.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/FileDataFileDetails.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/FileDataFileDetails.java new file mode 100644 index 000000000..ec250ada2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/FileDataFileDetails.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; + +/** + * The file details for the "file_data" field. + */ +@Fluent +public final class FileDataFileDetails { + /* + * The content of the file. + */ + @Generated + private final BinaryData content; + + /* + * The filename of the file. + */ + @Generated + private String filename; + + /* + * The content-type of the file. + */ + @Generated + private String contentType = "application/octet-stream"; + + /** + * Creates an instance of FileDataFileDetails class. + * + * @param content the content value to set. + */ + @Generated + public FileDataFileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the FileDataFileDetails object itself. + */ + @Generated + public FileDataFileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the FileDataFileDetails object itself. + */ + @Generated + public FileDataFileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/SendLongOptions.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/SendLongOptions.java new file mode 100644 index 000000000..bcf385491 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/SendLongOptions.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; + +/** + * Options for sendLong API. + */ +@Fluent +public final class SendLongOptions { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The filter property. + */ + @Generated + private String filter; + + /* + * The user property. + */ + @Generated + private User user; + + /* + * The input property. + */ + @Generated + private final String input; + + /* + * The dataInt property. + */ + @Generated + private final int dataInt; + + /* + * The dataIntOptional property. + */ + @Generated + private Integer dataIntOptional; + + /* + * The dataLong property. + */ + @Generated + private Long dataLong; + + /* + * The data_float property. + */ + @Generated + private Double dataFloat; + + /* + * The item's title + */ + @Generated + private final String title; + + /* + * A longer description of the todo item in markdown format + */ + @Generated + private String description; + + /* + * The status of the todo item + */ + @Generated + private final SendLongRequestStatus status; + + /* + * The _dummy property. + */ + @Generated + private String dummy; + + /** + * Creates an instance of SendLongOptions class. + * + * @param name the name value to set. + * @param input the input value to set. + * @param dataInt the dataInt value to set. + * @param title the title value to set. + * @param status the status value to set. + */ + @Generated + public SendLongOptions(String name, String input, int dataInt, String title, SendLongRequestStatus status) { + this.name = name; + this.input = input; + this.dataInt = dataInt; + this.title = title; + this.status = status; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the filter property: The filter property. + * + * @return the filter value. + */ + @Generated + public String getFilter() { + return this.filter; + } + + /** + * Set the filter property: The filter property. + * + * @param filter the filter value to set. + * @return the SendLongOptions object itself. + */ + @Generated + public SendLongOptions setFilter(String filter) { + this.filter = filter; + return this; + } + + /** + * Get the user property: The user property. + * + * @return the user value. + */ + @Generated + public User getUser() { + return this.user; + } + + /** + * Set the user property: The user property. + * + * @param user the user value to set. + * @return the SendLongOptions object itself. + */ + @Generated + public SendLongOptions setUser(User user) { + this.user = user; + return this; + } + + /** + * Get the input property: The input property. + * + * @return the input value. + */ + @Generated + public String getInput() { + return this.input; + } + + /** + * Get the dataInt property: The dataInt property. + * + * @return the dataInt value. + */ + @Generated + public int getDataInt() { + return this.dataInt; + } + + /** + * Get the dataIntOptional property: The dataIntOptional property. + * + * @return the dataIntOptional value. + */ + @Generated + public Integer getDataIntOptional() { + return this.dataIntOptional; + } + + /** + * Set the dataIntOptional property: The dataIntOptional property. + * + * @param dataIntOptional the dataIntOptional value to set. + * @return the SendLongOptions object itself. + */ + @Generated + public SendLongOptions setDataIntOptional(Integer dataIntOptional) { + this.dataIntOptional = dataIntOptional; + return this; + } + + /** + * Get the dataLong property: The dataLong property. + * + * @return the dataLong value. + */ + @Generated + public Long getDataLong() { + return this.dataLong; + } + + /** + * Set the dataLong property: The dataLong property. + * + * @param dataLong the dataLong value to set. + * @return the SendLongOptions object itself. + */ + @Generated + public SendLongOptions setDataLong(Long dataLong) { + this.dataLong = dataLong; + return this; + } + + /** + * Get the dataFloat property: The data_float property. + * + * @return the dataFloat value. + */ + @Generated + public Double getDataFloat() { + return this.dataFloat; + } + + /** + * Set the dataFloat property: The data_float property. + * + * @param dataFloat the dataFloat value to set. + * @return the SendLongOptions object itself. + */ + @Generated + public SendLongOptions setDataFloat(Double dataFloat) { + this.dataFloat = dataFloat; + return this; + } + + /** + * Get the title property: The item's title. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the description property: A longer description of the todo item in markdown format. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: A longer description of the todo item in markdown format. + * + * @param description the description value to set. + * @return the SendLongOptions object itself. + */ + @Generated + public SendLongOptions setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the status property: The status of the todo item. + * + * @return the status value. + */ + @Generated + public SendLongRequestStatus getStatus() { + return this.status; + } + + /** + * Get the dummy property: The _dummy property. + * + * @return the dummy value. + */ + @Generated + public String getDummy() { + return this.dummy; + } + + /** + * Set the dummy property: The _dummy property. + * + * @param dummy the dummy value to set. + * @return the SendLongOptions object itself. + */ + @Generated + public SendLongOptions setDummy(String dummy) { + this.dummy = dummy; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/SendLongRequestStatus.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/SendLongRequestStatus.java new file mode 100644 index 000000000..774868e92 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/SendLongRequestStatus.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.models; + +/** + * Defines values for SendLongRequestStatus. + */ +public enum SendLongRequestStatus { + /** + * Enum value NotStarted. + */ + NOT_STARTED("NotStarted"), + + /** + * Enum value InProgress. + */ + IN_PROGRESS("InProgress"), + + /** + * Enum value Completed. + */ + COMPLETED("Completed"); + + /** + * The actual serialized value for a SendLongRequestStatus instance. + */ + private final String value; + + SendLongRequestStatus(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a SendLongRequestStatus instance. + * + * @param value the serialized value to parse. + * @return the parsed SendLongRequestStatus object, or null if unable to parse. + */ + public static SendLongRequestStatus fromString(String value) { + if (value == null) { + return null; + } + SendLongRequestStatus[] items = SendLongRequestStatus.values(); + for (SendLongRequestStatus item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/TodoItem.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/TodoItem.java new file mode 100644 index 000000000..d3b4ec61f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/TodoItem.java @@ -0,0 +1,234 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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.time.OffsetDateTime; + +/** + * The TodoItem model. + */ +@Immutable +public final class TodoItem implements JsonSerializable { + /* + * The item's unique id + */ + @Generated + private long id; + + /* + * The item's title + */ + @Generated + private final String title; + + /* + * A longer description of the todo item in markdown format + */ + @Generated + private String description; + + /* + * The status of the todo item + */ + @Generated + private final SendLongRequestStatus status; + + /* + * When the todo item was created. + */ + @Generated + private OffsetDateTime createdAt; + + /* + * When the todo item was last updated + */ + @Generated + private OffsetDateTime updatedAt; + + /* + * When the todo item was makred as completed + */ + @Generated + private OffsetDateTime completedAt; + + /* + * The _dummy property. + */ + @Generated + private String dummy; + + /** + * Creates an instance of TodoItem class. + * + * @param title the title value to set. + * @param status the status value to set. + */ + @Generated + private TodoItem(String title, SendLongRequestStatus status) { + this.title = title; + this.status = status; + } + + /** + * Get the id property: The item's unique id. + * + * @return the id value. + */ + @Generated + public long getId() { + return this.id; + } + + /** + * Get the title property: The item's title. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the description property: A longer description of the todo item in markdown format. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Get the status property: The status of the todo item. + * + * @return the status value. + */ + @Generated + public SendLongRequestStatus getStatus() { + return this.status; + } + + /** + * Get the createdAt property: When the todo item was created. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return this.createdAt; + } + + /** + * Get the updatedAt property: When the todo item was last updated. + * + * @return the updatedAt value. + */ + @Generated + public OffsetDateTime getUpdatedAt() { + return this.updatedAt; + } + + /** + * Get the completedAt property: When the todo item was makred as completed. + * + * @return the completedAt value. + */ + @Generated + public OffsetDateTime getCompletedAt() { + return this.completedAt; + } + + /** + * Get the dummy property: The _dummy property. + * + * @return the dummy value. + */ + @Generated + public String getDummy() { + return this.dummy; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("title", this.title); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("_dummy", this.dummy); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TodoItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TodoItem 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 TodoItem. + */ + @Generated + public static TodoItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + long id = 0L; + String title = null; + SendLongRequestStatus status = null; + OffsetDateTime createdAt = null; + OffsetDateTime updatedAt = null; + String description = null; + OffsetDateTime completedAt = null; + String dummy = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getLong(); + } else if ("title".equals(fieldName)) { + title = reader.getString(); + } else if ("status".equals(fieldName)) { + status = SendLongRequestStatus.fromString(reader.getString()); + } else if ("createdAt".equals(fieldName)) { + createdAt = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("updatedAt".equals(fieldName)) { + updatedAt = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("completedAt".equals(fieldName)) { + completedAt = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("_dummy".equals(fieldName)) { + dummy = reader.getString(); + } else { + reader.skipChildren(); + } + } + TodoItem deserializedTodoItem = new TodoItem(title, status); + deserializedTodoItem.id = id; + deserializedTodoItem.createdAt = createdAt; + deserializedTodoItem.updatedAt = updatedAt; + deserializedTodoItem.description = description; + deserializedTodoItem.completedAt = completedAt; + deserializedTodoItem.dummy = dummy; + + return deserializedTodoItem; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/TodoItemPatch.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/TodoItemPatch.java new file mode 100644 index 000000000..9da1a9d7c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/TodoItemPatch.java @@ -0,0 +1,220 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.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 com.cadl.flatten.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The TodoItemPatch model. + */ +@Fluent +public final class TodoItemPatch implements JsonSerializable { + /* + * The item's title + */ + @Generated + private String title; + + /* + * A longer description of the todo item in markdown format + */ + @Generated + private String description; + + /* + * The status of the todo item + */ + @Generated + private TodoItemPatchStatus status; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setTodoItemPatchAccessor(new JsonMergePatchHelper.TodoItemPatchAccessor() { + @Override + public TodoItemPatch prepareModelForJsonMergePatch(TodoItemPatch model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(TodoItemPatch model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of TodoItemPatch class. + */ + @Generated + public TodoItemPatch() { + } + + /** + * Get the title property: The item's title. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Set the title property: The item's title. + * + * @param title the title value to set. + * @return the TodoItemPatch object itself. + */ + @Generated + public TodoItemPatch setTitle(String title) { + this.title = title; + this.updatedProperties.add("title"); + return this; + } + + /** + * Get the description property: A longer description of the todo item in markdown format. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: A longer description of the todo item in markdown format. + * + * @param description the description value to set. + * @return the TodoItemPatch object itself. + */ + @Generated + public TodoItemPatch setDescription(String description) { + this.description = description; + this.updatedProperties.add("description"); + return this; + } + + /** + * Get the status property: The status of the todo item. + * + * @return the status value. + */ + @Generated + public TodoItemPatchStatus getStatus() { + return this.status; + } + + /** + * Set the status property: The status of the todo item. + * + * @param status the status value to set. + * @return the TodoItemPatch object itself. + */ + @Generated + public TodoItemPatch setStatus(TodoItemPatchStatus status) { + this.status = status; + this.updatedProperties.add("status"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("title", this.title); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("title")) { + if (this.title == null) { + jsonWriter.writeNullField("title"); + } else { + jsonWriter.writeStringField("title", this.title); + } + } + if (updatedProperties.contains("description")) { + if (this.description == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", this.description); + } + } + if (updatedProperties.contains("status")) { + if (this.status == null) { + jsonWriter.writeNullField("status"); + } else { + jsonWriter.writeStringField("status", this.status.toString()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TodoItemPatch from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TodoItemPatch 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 TodoItemPatch. + */ + @Generated + public static TodoItemPatch fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TodoItemPatch deserializedTodoItemPatch = new TodoItemPatch(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("title".equals(fieldName)) { + deserializedTodoItemPatch.title = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedTodoItemPatch.description = reader.getString(); + } else if ("status".equals(fieldName)) { + deserializedTodoItemPatch.status = TodoItemPatchStatus.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedTodoItemPatch; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/TodoItemPatchStatus.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/TodoItemPatchStatus.java new file mode 100644 index 000000000..1ac351d62 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/TodoItemPatchStatus.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.models; + +/** + * Defines values for TodoItemPatchStatus. + */ +public enum TodoItemPatchStatus { + /** + * Enum value NotStarted. + */ + NOT_STARTED("NotStarted"), + + /** + * Enum value InProgress. + */ + IN_PROGRESS("InProgress"), + + /** + * Enum value Completed. + */ + COMPLETED("Completed"); + + /** + * The actual serialized value for a TodoItemPatchStatus instance. + */ + private final String value; + + TodoItemPatchStatus(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a TodoItemPatchStatus instance. + * + * @param value the serialized value to parse. + * @return the parsed TodoItemPatchStatus object, or null if unable to parse. + */ + public static TodoItemPatchStatus fromString(String value) { + if (value == null) { + return null; + } + TodoItemPatchStatus[] items = TodoItemPatchStatus.values(); + for (TodoItemPatchStatus item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/UpdatePatchRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/UpdatePatchRequest.java new file mode 100644 index 000000000..fc0c33a7a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/UpdatePatchRequest.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 com.cadl.flatten.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 com.cadl.flatten.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The UpdatePatchRequest model. + */ +@Fluent +public final class UpdatePatchRequest implements JsonSerializable { + /* + * The patch property. + */ + @Generated + private TodoItemPatch patch; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setUpdatePatchRequestAccessor(new JsonMergePatchHelper.UpdatePatchRequestAccessor() { + @Override + public UpdatePatchRequest prepareModelForJsonMergePatch(UpdatePatchRequest model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(UpdatePatchRequest model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of UpdatePatchRequest class. + */ + @Generated + public UpdatePatchRequest() { + } + + /** + * Get the patch property: The patch property. + * + * @return the patch value. + */ + @Generated + public TodoItemPatch getPatch() { + return this.patch; + } + + /** + * Set the patch property: The patch property. + *

Required when create the resource.

+ * + * @param patch the patch value to set. + * @return the UpdatePatchRequest object itself. + */ + @Generated + public UpdatePatchRequest setPatch(TodoItemPatch patch) { + this.patch = patch; + this.updatedProperties.add("patch"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("patch", this.patch); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("patch")) { + if (this.patch == null) { + jsonWriter.writeNullField("patch"); + } else { + JsonMergePatchHelper.getTodoItemPatchAccessor().prepareModelForJsonMergePatch(this.patch, true); + jsonWriter.writeJsonField("patch", this.patch); + JsonMergePatchHelper.getTodoItemPatchAccessor().prepareModelForJsonMergePatch(this.patch, false); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UpdatePatchRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UpdatePatchRequest 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 UpdatePatchRequest. + */ + @Generated + public static UpdatePatchRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UpdatePatchRequest deserializedUpdatePatchRequest = new UpdatePatchRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("patch".equals(fieldName)) { + deserializedUpdatePatchRequest.patch = TodoItemPatch.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedUpdatePatchRequest; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/UploadTodoOptions.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/UploadTodoOptions.java new file mode 100644 index 000000000..f05e56c24 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/UploadTodoOptions.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 com.cadl.flatten.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; + +/** + * Options for uploadTodo API. + */ +@Fluent +public final class UploadTodoOptions { + /* + * The item's title + */ + @Generated + private final String title; + + /* + * A longer description of the todo item in markdown format + */ + @Generated + private String description; + + /* + * The status of the todo item + */ + @Generated + private final SendLongRequestStatus status; + + /* + * The _dummy property. + */ + @Generated + private String dummy; + + /* + * The prop1 property. + */ + @Generated + private String prop1; + + /* + * The prop2 property. + */ + @Generated + private String prop2; + + /* + * The prop3 property. + */ + @Generated + private String prop3; + + /** + * Creates an instance of UploadTodoOptions class. + * + * @param title the title value to set. + * @param status the status value to set. + */ + @Generated + public UploadTodoOptions(String title, SendLongRequestStatus status) { + this.title = title; + this.status = status; + } + + /** + * Get the title property: The item's title. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the description property: A longer description of the todo item in markdown format. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: A longer description of the todo item in markdown format. + * + * @param description the description value to set. + * @return the UploadTodoOptions object itself. + */ + @Generated + public UploadTodoOptions setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the status property: The status of the todo item. + * + * @return the status value. + */ + @Generated + public SendLongRequestStatus getStatus() { + return this.status; + } + + /** + * Get the dummy property: The _dummy property. + * + * @return the dummy value. + */ + @Generated + public String getDummy() { + return this.dummy; + } + + /** + * Set the dummy property: The _dummy property. + * + * @param dummy the dummy value to set. + * @return the UploadTodoOptions object itself. + */ + @Generated + public UploadTodoOptions setDummy(String dummy) { + this.dummy = dummy; + return this; + } + + /** + * Get the prop1 property: The prop1 property. + * + * @return the prop1 value. + */ + @Generated + public String getProp1() { + return this.prop1; + } + + /** + * Set the prop1 property: The prop1 property. + * + * @param prop1 the prop1 value to set. + * @return the UploadTodoOptions object itself. + */ + @Generated + public UploadTodoOptions setProp1(String prop1) { + this.prop1 = prop1; + return this; + } + + /** + * Get the prop2 property: The prop2 property. + * + * @return the prop2 value. + */ + @Generated + public String getProp2() { + return this.prop2; + } + + /** + * Set the prop2 property: The prop2 property. + * + * @param prop2 the prop2 value to set. + * @return the UploadTodoOptions object itself. + */ + @Generated + public UploadTodoOptions setProp2(String prop2) { + this.prop2 = prop2; + return this; + } + + /** + * Get the prop3 property: The prop3 property. + * + * @return the prop3 value. + */ + @Generated + public String getProp3() { + return this.prop3; + } + + /** + * Set the prop3 property: The prop3 property. + * + * @param prop3 the prop3 value to set. + * @return the UploadTodoOptions object itself. + */ + @Generated + public UploadTodoOptions setProp3(String prop3) { + this.prop3 = prop3; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/User.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/User.java new file mode 100644 index 000000000..17214a4db --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/User.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.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; + +/** + * The User model. + */ +@Immutable +public final class User implements JsonSerializable { + /* + * The user property. + */ + @Generated + private final String user; + + /** + * Creates an instance of User class. + * + * @param user the user value to set. + */ + @Generated + public User(String user) { + this.user = user; + } + + /** + * Get the user property: The user property. + * + * @return the user value. + */ + @Generated + public String getUser() { + return this.user; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("user", this.user); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of User from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of User 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 User. + */ + @Generated + public static User fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String user = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("user".equals(fieldName)) { + user = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new User(user); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/package-info.java new file mode 100644 index 000000000..88a199c1c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Flatten. + * + */ +package com.cadl.flatten.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/package-info.java new file mode 100644 index 000000000..f79321557 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/flatten/package-info.java @@ -0,0 +1,10 @@ +// 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 Flatten. + * + */ +package com.cadl.flatten; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/InternalAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/InternalAsyncClient.java new file mode 100644 index 000000000..3f6993569 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/InternalAsyncClient.java @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal; + +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 com.cadl.internal.implementation.InternalOpsImpl; +import com.cadl.internal.models.ApiRequest; +import com.cadl.internal.models.ApiResponse; +import com.cadl.internal.models.ResponseInternal; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous InternalClient type. + */ +@ServiceClient(builder = InternalClientBuilder.class, isAsync = true) +public final class InternalAsyncClient { + @Generated + private final InternalOpsImpl serviceClient; + + /** + * Initializes an instance of InternalAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + InternalAsyncClient(InternalOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The postInternal operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postInternalWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postInternalWithResponseAsync(body, requestOptions); + } + + /** + * The getInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> getInternalWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getInternalWithResponseAsync(requestOptions); + } + + /** + * The postProtocalInternal operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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) + Mono> postProtocalInternalWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postProtocalInternalWithResponseAsync(body, requestOptions); + } + + /** + * The postInternal operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono postInternal(ApiRequest body) { + // Generated convenience method for postInternalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postInternalWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ResponseInternal.class)); + } + + /** + * The getInternal 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono getInternal() { + // Generated convenience method for getInternalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getInternalWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ApiResponse.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/InternalClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/InternalClient.java new file mode 100644 index 000000000..78c93dd78 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/InternalClient.java @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal; + +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.cadl.internal.implementation.InternalOpsImpl; +import com.cadl.internal.models.ApiRequest; +import com.cadl.internal.models.ApiResponse; +import com.cadl.internal.models.ResponseInternal; + +/** + * Initializes a new instance of the synchronous InternalClient type. + */ +@ServiceClient(builder = InternalClientBuilder.class) +public final class InternalClient { + @Generated + private final InternalOpsImpl serviceClient; + + /** + * Initializes an instance of InternalClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + InternalClient(InternalOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The postInternal operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postInternalWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postInternalWithResponse(body, requestOptions); + } + + /** + * The getInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response getInternalWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getInternalWithResponse(requestOptions); + } + + /** + * The postProtocalInternal operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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) + Response postProtocalInternalWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postProtocalInternalWithResponse(body, requestOptions); + } + + /** + * The postInternal operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseInternal postInternal(ApiRequest body) { + // Generated convenience method for postInternalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postInternalWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(ResponseInternal.class); + } + + /** + * The getInternal 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + ApiResponse getInternal() { + // Generated convenience method for getInternalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getInternalWithResponse(requestOptions).getValue().toObject(ApiResponse.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/InternalClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/InternalClientBuilder.java new file mode 100644 index 000000000..d0d659878 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/InternalClientBuilder.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 com.cadl.internal; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.internal.implementation.InternalClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the InternalClient type. + */ +@ServiceClientBuilder(serviceClients = { InternalClient.class, InternalAsyncClient.class }) +public final class InternalClientBuilder 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("cadl-internal.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the InternalClientBuilder. + */ + @Generated + public InternalClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public InternalClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public InternalClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public InternalClientBuilder 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 InternalClientBuilder 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 InternalClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public InternalClientBuilder 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 InternalClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public InternalClientBuilder 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 InternalClientBuilder. + */ + @Generated + public InternalClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of InternalClientImpl with the provided parameters. + * + * @return an instance of InternalClientImpl. + */ + @Generated + private InternalClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + InternalClientImpl client + = new InternalClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 InternalAsyncClient class. + * + * @return an instance of InternalAsyncClient. + */ + @Generated + public InternalAsyncClient buildAsyncClient() { + return new InternalAsyncClient(buildInnerClient().getInternalOps()); + } + + /** + * Builds an instance of InternalClient class. + * + * @return an instance of InternalClient. + */ + @Generated + public InternalClient buildClient() { + return new InternalClient(buildInnerClient().getInternalOps()); + } + + private static final ClientLogger LOGGER = new ClientLogger(InternalClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/InternalClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/InternalClientImpl.java new file mode 100644 index 000000000..d7f1cee9e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/InternalClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the InternalClient type. + */ +public final class InternalClientImpl { + /** + * 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; + } + + /** + * The InternalOpsImpl object to access its operations. + */ + private final InternalOpsImpl internalOps; + + /** + * Gets the InternalOpsImpl object to access its operations. + * + * @return the InternalOpsImpl object. + */ + public InternalOpsImpl getInternalOps() { + return this.internalOps; + } + + /** + * Initializes an instance of InternalClient client. + * + * @param endpoint Service host. + */ + public InternalClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of InternalClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public InternalClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of InternalClient 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 InternalClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.internalOps = new InternalOpsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/InternalOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/InternalOpsImpl.java new file mode 100644 index 000000000..cfa018941 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/InternalOpsImpl.java @@ -0,0 +1,293 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in InternalOps. + */ +public final class InternalOpsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final InternalOpsService service; + + /** + * The service client containing this operation class. + */ + private final InternalClientImpl client; + + /** + * Initializes an instance of InternalOpsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + InternalOpsImpl(InternalClientImpl client) { + this.service + = RestProxy.create(InternalOpsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for InternalClientInternalOps to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "InternalClientIntern") + public interface InternalOpsService { + @Post("/internal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> postInternal(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/internal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response postInternalSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Get("/internal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getInternal(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/internal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getInternalSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/internal/protocal-internal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> postProtocalInternal(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/internal/protocal-internal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response postProtocalInternalSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The postInternal operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postInternalWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.postInternal(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The postInternal operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         name: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postInternalWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.postInternalSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The getInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getInternalWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getInternal(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getInternal operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getInternalWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getInternalSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The postProtocalInternal operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> postProtocalInternalWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.postProtocalInternal(this.client.getEndpoint(), contentType, + body, requestOptions, context)); + } + + /** + * The postProtocalInternal operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 postProtocalInternalWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.postProtocalInternalSync(this.client.getEndpoint(), contentType, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/Color.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/Color.java new file mode 100644 index 000000000..a0eb56835 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/Color.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.implementation.models; + +/** + * Defines values for Color. + */ +public enum Color { + /** + * Enum value Red. + */ + RED("Red"), + + /** + * Enum value Blue. + */ + BLUE("Blue"), + + /** + * Enum value Green. + */ + GREEN("Green"); + + /** + * The actual serialized value for a Color instance. + */ + private final String value; + + Color(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a Color instance. + * + * @param value the serialized value to parse. + * @return the parsed Color object, or null if unable to parse. + */ + public static Color fromString(String value) { + if (value == null) { + return null; + } + Color[] items = Color.values(); + for (Color item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/ColorModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/ColorModel.java new file mode 100644 index 000000000..2e7063551 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/ColorModel.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for ColorModel. + */ +public final class ColorModel extends ExpandableStringEnum { + /** + * Static value Red for ColorModel. + */ + @Generated + public static final ColorModel RED = fromString("Red"); + + /** + * Static value Blue for ColorModel. + */ + @Generated + public static final ColorModel BLUE = fromString("Blue"); + + /** + * Static value Green for ColorModel. + */ + @Generated + public static final ColorModel GREEN = fromString("Green"); + + /** + * Creates a new instance of ColorModel value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ColorModel() { + } + + /** + * Creates or finds a ColorModel from its string representation. + * + * @param name a name to look for. + * @return the corresponding ColorModel. + */ + @Generated + public static ColorModel fromString(String name) { + return fromString(name, ColorModel.class); + } + + /** + * Gets known ColorModel values. + * + * @return known ColorModel values. + */ + @Generated + public static Collection values() { + return values(ColorModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/package-info.java new file mode 100644 index 000000000..4631cbb5d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Internal. + * + */ +package com.cadl.internal.implementation.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/package-info.java new file mode 100644 index 000000000..c53be017d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Internal. + * + */ +package com.cadl.internal.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/ApiRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/ApiRequest.java new file mode 100644 index 000000000..68e26a501 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/ApiRequest.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.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; + +/** + * The ApiRequest model. + */ +@Immutable +public final class ApiRequest implements JsonSerializable { + /* + * The property property. + */ + @Generated + private final RequestInner property; + + /** + * Creates an instance of ApiRequest class. + * + * @param property the property value to set. + */ + @Generated + public ApiRequest(RequestInner property) { + this.property = property; + } + + /** + * Get the property property: The property property. + * + * @return the property value. + */ + @Generated + public RequestInner getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ApiRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ApiRequest 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 ApiRequest. + */ + @Generated + public static ApiRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RequestInner property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = RequestInner.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new ApiRequest(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/ApiResponse.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/ApiResponse.java new file mode 100644 index 000000000..82819de71 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/ApiResponse.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.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; + +/** + * The ApiResponse model. + */ +@Immutable +public final class ApiResponse implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ApiResponse class. + * + * @param name the name value to set. + */ + @Generated + private ApiResponse(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ApiResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ApiResponse 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 ApiResponse. + */ + @Generated + public static ApiResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ApiResponse(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/RequestInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/RequestInner.java new file mode 100644 index 000000000..435589548 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/RequestInner.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.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; + +/** + * The RequestInner model. + */ +@Immutable +public final class RequestInner implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of RequestInner class. + * + * @param name the name value to set. + */ + @Generated + public RequestInner(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RequestInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RequestInner 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 RequestInner. + */ + @Generated + public static RequestInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new RequestInner(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/ResponseInternal.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/ResponseInternal.java new file mode 100644 index 000000000..d2a475e9f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/ResponseInternal.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.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; + +/** + * The ResponseInternal model. + */ +@Immutable +public final class ResponseInternal implements JsonSerializable { + /* + * The property property. + */ + @Generated + private final ResponseInternalInner property; + + /** + * Creates an instance of ResponseInternal class. + * + * @param property the property value to set. + */ + @Generated + private ResponseInternal(ResponseInternalInner property) { + this.property = property; + } + + /** + * Get the property property: The property property. + * + * @return the property value. + */ + @Generated + public ResponseInternalInner getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResponseInternal from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResponseInternal 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 ResponseInternal. + */ + @Generated + public static ResponseInternal fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResponseInternalInner property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = ResponseInternalInner.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new ResponseInternal(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/ResponseInternalInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/ResponseInternalInner.java new file mode 100644 index 000000000..c8ecd5640 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/ResponseInternalInner.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.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; + +/** + * The ResponseInternalInner model. + */ +@Immutable +public final class ResponseInternalInner implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ResponseInternalInner class. + * + * @param name the name value to set. + */ + @Generated + private ResponseInternalInner(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResponseInternalInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResponseInternalInner 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 ResponseInternalInner. + */ + @Generated + public static ResponseInternalInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ResponseInternalInner(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/StandAloneData.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/StandAloneData.java new file mode 100644 index 000000000..7661064c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/StandAloneData.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.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; + +/** + * The StandAloneData model. + */ +@Immutable +public final class StandAloneData implements JsonSerializable { + /* + * The property property. + */ + @Generated + private final StandAloneDataInner property; + + /** + * Creates an instance of StandAloneData class. + * + * @param property the property value to set. + */ + @Generated + private StandAloneData(StandAloneDataInner property) { + this.property = property; + } + + /** + * Get the property property: The property property. + * + * @return the property value. + */ + @Generated + public StandAloneDataInner getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StandAloneData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StandAloneData 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 StandAloneData. + */ + @Generated + public static StandAloneData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StandAloneDataInner property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = StandAloneDataInner.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new StandAloneData(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/StandAloneDataInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/StandAloneDataInner.java new file mode 100644 index 000000000..f5ff81611 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/StandAloneDataInner.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.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; + +/** + * The StandAloneDataInner model. + */ +@Immutable +public final class StandAloneDataInner implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of StandAloneDataInner class. + * + * @param name the name value to set. + */ + @Generated + public StandAloneDataInner(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StandAloneDataInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StandAloneDataInner 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 StandAloneDataInner. + */ + @Generated + public static StandAloneDataInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new StandAloneDataInner(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/UnusedEnum.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/UnusedEnum.java new file mode 100644 index 000000000..acd6e6f5a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/UnusedEnum.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for UnusedEnum. + */ +public final class UnusedEnum extends ExpandableStringEnum { + /** + * Static value Weekday for UnusedEnum. + */ + @Generated + public static final UnusedEnum WEEKDAY = fromString("Weekday"); + + /** + * Static value Weekend for UnusedEnum. + */ + @Generated + public static final UnusedEnum WEEKEND = fromString("Weekend"); + + /** + * Creates a new instance of UnusedEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public UnusedEnum() { + } + + /** + * Creates or finds a UnusedEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding UnusedEnum. + */ + @Generated + public static UnusedEnum fromString(String name) { + return fromString(name, UnusedEnum.class); + } + + /** + * Gets known UnusedEnum values. + * + * @return known UnusedEnum values. + */ + @Generated + public static Collection values() { + return values(UnusedEnum.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/package-info.java new file mode 100644 index 000000000..8e44f91d5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Internal. + * + */ +package com.cadl.internal.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/package-info.java new file mode 100644 index 000000000..dc502252c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/internal/package-info.java @@ -0,0 +1,10 @@ +// 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 Internal. + * + */ +package com.cadl.internal; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/LiteralServiceAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/LiteralServiceAsyncClient.java new file mode 100644 index 000000000..24f46a7f9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/LiteralServiceAsyncClient.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.literalservice; + +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 com.cadl.literalservice.implementation.LiteralOpsImpl; +import com.cadl.literalservice.models.Model; +import com.cadl.literalservice.models.PutRequestOptionalLiteralParam; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous LiteralServiceClient type. + */ +@ServiceClient(builder = LiteralServiceClientBuilder.class, isAsync = true) +public final class LiteralServiceAsyncClient { + @Generated + private final LiteralOpsImpl serviceClient; + + /** + * Initializes an instance of LiteralServiceAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + LiteralServiceAsyncClient(LiteralOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The put operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
optionalLiteralParamStringNoThe optionalLiteralParam parameter. Allowed + * values: "optionalLiteralParam".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     literal: String (Required)
+     *     optionalLiteral: String(optionalLiteral) (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     literal: String (Required)
+     *     optionalLiteral: String(optionalLiteral) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @param optionalLiteralParam The optionalLiteralParam 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono put(Model body, PutRequestOptionalLiteralParam optionalLiteralParam) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (optionalLiteralParam != null) { + requestOptions.addQueryParam("optionalLiteralParam", optionalLiteralParam.toString(), false); + } + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Model.class)); + } + + /** + * The put operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono put(Model body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Model.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/LiteralServiceClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/LiteralServiceClient.java new file mode 100644 index 000000000..a94905422 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/LiteralServiceClient.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.literalservice; + +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.cadl.literalservice.implementation.LiteralOpsImpl; +import com.cadl.literalservice.models.Model; +import com.cadl.literalservice.models.PutRequestOptionalLiteralParam; + +/** + * Initializes a new instance of the synchronous LiteralServiceClient type. + */ +@ServiceClient(builder = LiteralServiceClientBuilder.class) +public final class LiteralServiceClient { + @Generated + private final LiteralOpsImpl serviceClient; + + /** + * Initializes an instance of LiteralServiceClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + LiteralServiceClient(LiteralOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The put operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
optionalLiteralParamStringNoThe optionalLiteralParam parameter. Allowed + * values: "optionalLiteralParam".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     literal: String (Required)
+     *     optionalLiteral: String(optionalLiteral) (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     literal: String (Required)
+     *     optionalLiteral: String(optionalLiteral) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @param optionalLiteralParam The optionalLiteralParam 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Model put(Model body, PutRequestOptionalLiteralParam optionalLiteralParam) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (optionalLiteralParam != null) { + requestOptions.addQueryParam("optionalLiteralParam", optionalLiteralParam.toString(), false); + } + return putWithResponse(BinaryData.fromObject(body), requestOptions).getValue().toObject(Model.class); + } + + /** + * The put operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Model put(Model body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).getValue().toObject(Model.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/LiteralServiceClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/LiteralServiceClientBuilder.java new file mode 100644 index 000000000..b162dbc26 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/LiteralServiceClientBuilder.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 com.cadl.literalservice; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.literalservice.implementation.LiteralServiceClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the LiteralServiceClient type. + */ +@ServiceClientBuilder(serviceClients = { LiteralServiceClient.class, LiteralServiceAsyncClient.class }) +public final class LiteralServiceClientBuilder 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("cadl-literalservice.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the LiteralServiceClientBuilder. + */ + @Generated + public LiteralServiceClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LiteralServiceClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LiteralServiceClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LiteralServiceClientBuilder 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 LiteralServiceClientBuilder 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 LiteralServiceClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LiteralServiceClientBuilder 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 LiteralServiceClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LiteralServiceClientBuilder 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 LiteralServiceClientBuilder. + */ + @Generated + public LiteralServiceClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of LiteralServiceClientImpl with the provided parameters. + * + * @return an instance of LiteralServiceClientImpl. + */ + @Generated + private LiteralServiceClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + LiteralServiceClientImpl client = new LiteralServiceClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 LiteralServiceAsyncClient class. + * + * @return an instance of LiteralServiceAsyncClient. + */ + @Generated + public LiteralServiceAsyncClient buildAsyncClient() { + return new LiteralServiceAsyncClient(buildInnerClient().getLiteralOps()); + } + + /** + * Builds an instance of LiteralServiceClient class. + * + * @return an instance of LiteralServiceClient. + */ + @Generated + public LiteralServiceClient buildClient() { + return new LiteralServiceClient(buildInnerClient().getLiteralOps()); + } + + private static final ClientLogger LOGGER = new ClientLogger(LiteralServiceClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/implementation/LiteralOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/implementation/LiteralOpsImpl.java new file mode 100644 index 000000000..a216e21bd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/implementation/LiteralOpsImpl.java @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.literalservice.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.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.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.BinaryData; +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 LiteralOps. + */ +public final class LiteralOpsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final LiteralOpsService service; + + /** + * The service client containing this operation class. + */ + private final LiteralServiceClientImpl client; + + /** + * Initializes an instance of LiteralOpsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + LiteralOpsImpl(LiteralServiceClientImpl client) { + this.service + = RestProxy.create(LiteralOpsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for LiteralServiceClientLiteralOps to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "LiteralServiceClient") + public interface LiteralOpsService { + @Put("/literal/put") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @QueryParam("literalParam") String literalParam, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/literal/put") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, + @QueryParam("literalParam") String literalParam, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The put operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
optionalLiteralParamStringNoThe optionalLiteralParam parameter. Allowed + * values: "optionalLiteralParam".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     literal: String (Required)
+     *     optionalLiteral: String(optionalLiteral) (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     literal: String (Required)
+     *     optionalLiteral: String(optionalLiteral) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String literalParam = "literalParam"; + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.put(this.client.getEndpoint(), literalParam, contentType, accept, + body, requestOptions, context)); + } + + /** + * The put operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
optionalLiteralParamStringNoThe optionalLiteralParam parameter. Allowed + * values: "optionalLiteralParam".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     literal: String (Required)
+     *     optionalLiteral: String(optionalLiteral) (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     literal: String (Required)
+     *     optionalLiteral: String(optionalLiteral) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String literalParam = "literalParam"; + final String contentType = "application/json"; + final String accept = "application/json"; + return service.putSync(this.client.getEndpoint(), literalParam, contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/implementation/LiteralServiceClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/implementation/LiteralServiceClientImpl.java new file mode 100644 index 000000000..b0a0178bf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/implementation/LiteralServiceClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.literalservice.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the LiteralServiceClient type. + */ +public final class LiteralServiceClientImpl { + /** + * 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; + } + + /** + * The LiteralOpsImpl object to access its operations. + */ + private final LiteralOpsImpl literalOps; + + /** + * Gets the LiteralOpsImpl object to access its operations. + * + * @return the LiteralOpsImpl object. + */ + public LiteralOpsImpl getLiteralOps() { + return this.literalOps; + } + + /** + * Initializes an instance of LiteralServiceClient client. + * + * @param endpoint Service host. + */ + public LiteralServiceClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of LiteralServiceClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public LiteralServiceClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of LiteralServiceClient 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 LiteralServiceClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.literalOps = new LiteralOpsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/implementation/package-info.java new file mode 100644 index 000000000..ad4051f3d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 LiteralService. + * + */ +package com.cadl.literalservice.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/Model.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/Model.java new file mode 100644 index 000000000..d37c9708b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/Model.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.literalservice.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 Model model. + */ +@Fluent +public final class Model implements JsonSerializable { + /* + * The literal property. + */ + @Generated + private final String literal = "literal"; + + /* + * The optionalLiteral property. + */ + @Generated + private ModelOptionalLiteral optionalLiteral; + + /** + * Creates an instance of Model class. + */ + @Generated + public Model() { + } + + /** + * Get the literal property: The literal property. + * + * @return the literal value. + */ + @Generated + public String getLiteral() { + return this.literal; + } + + /** + * Get the optionalLiteral property: The optionalLiteral property. + * + * @return the optionalLiteral value. + */ + @Generated + public ModelOptionalLiteral getOptionalLiteral() { + return this.optionalLiteral; + } + + /** + * Set the optionalLiteral property: The optionalLiteral property. + * + * @param optionalLiteral the optionalLiteral value to set. + * @return the Model object itself. + */ + @Generated + public Model setOptionalLiteral(ModelOptionalLiteral optionalLiteral) { + this.optionalLiteral = optionalLiteral; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("literal", this.literal); + jsonWriter.writeStringField("optionalLiteral", + this.optionalLiteral == null ? null : this.optionalLiteral.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Model from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Model 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 Model. + */ + @Generated + public static Model fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Model deserializedModel = new Model(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("optionalLiteral".equals(fieldName)) { + deserializedModel.optionalLiteral = ModelOptionalLiteral.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/ModelOptionalLiteral.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/ModelOptionalLiteral.java new file mode 100644 index 000000000..d91cb650d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/ModelOptionalLiteral.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.literalservice.models; + +/** + * Defines values for ModelOptionalLiteral. + */ +public enum ModelOptionalLiteral { + /** + * Enum value optionalLiteral. + */ + OPTIONAL_LITERAL("optionalLiteral"); + + /** + * The actual serialized value for a ModelOptionalLiteral instance. + */ + private final String value; + + ModelOptionalLiteral(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ModelOptionalLiteral instance. + * + * @param value the serialized value to parse. + * @return the parsed ModelOptionalLiteral object, or null if unable to parse. + */ + public static ModelOptionalLiteral fromString(String value) { + if (value == null) { + return null; + } + ModelOptionalLiteral[] items = ModelOptionalLiteral.values(); + for (ModelOptionalLiteral item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/PutRequestOptionalLiteralParam.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/PutRequestOptionalLiteralParam.java new file mode 100644 index 000000000..f0141ba72 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/PutRequestOptionalLiteralParam.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.literalservice.models; + +/** + * Defines values for PutRequestOptionalLiteralParam. + */ +public enum PutRequestOptionalLiteralParam { + /** + * Enum value optionalLiteralParam. + */ + OPTIONAL_LITERAL_PARAM("optionalLiteralParam"); + + /** + * The actual serialized value for a PutRequestOptionalLiteralParam instance. + */ + private final String value; + + PutRequestOptionalLiteralParam(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a PutRequestOptionalLiteralParam instance. + * + * @param value the serialized value to parse. + * @return the parsed PutRequestOptionalLiteralParam object, or null if unable to parse. + */ + public static PutRequestOptionalLiteralParam fromString(String value) { + if (value == null) { + return null; + } + PutRequestOptionalLiteralParam[] items = PutRequestOptionalLiteralParam.values(); + for (PutRequestOptionalLiteralParam item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/package-info.java new file mode 100644 index 000000000..9898cba3b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/models/package-info.java @@ -0,0 +1,10 @@ +// 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 LiteralService. + * + */ +package com.cadl.literalservice.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/package-info.java new file mode 100644 index 000000000..6161341d6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/literalservice/package-info.java @@ -0,0 +1,10 @@ +// 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 LiteralService. + * + */ +package com.cadl.literalservice; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/LongRunningAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/LongRunningAsyncClient.java new file mode 100644 index 000000000..2149dcf05 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/LongRunningAsyncClient.java @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning; + +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 com.azure.core.util.polling.PollerFlux; +import com.cadl.longrunning.implementation.LongRunningClientImpl; +import com.cadl.longrunning.models.JobData; +import com.cadl.longrunning.models.JobResult; +import com.cadl.longrunning.models.JobResultResult; +import com.cadl.longrunning.models.PollResponse; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous LongRunningClient type. + */ +@ServiceClient(builder = LongRunningClientBuilder.class, isAsync = true) +public final class LongRunningAsyncClient { + @Generated + private final LongRunningClientImpl serviceClient; + + /** + * Initializes an instance of LongRunningAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + LongRunningAsyncClient(LongRunningClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The longRunning operation. + * + * @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 PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLongRunning(RequestOptions requestOptions) { + return this.serviceClient.beginLongRunningAsync(requestOptions); + } + + /** + * A remote procedure call (RPC) operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(notStarted/running/Succeeded/Failed/canceled) (Required)
+     *     createdDateTime: OffsetDateTime (Optional)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     lastUpdateDateTime: OffsetDateTime (Optional)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param id The id 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getJobWithResponse(String id, RequestOptions requestOptions) { + return this.serviceClient.getJobWithResponseAsync(id, requestOptions); + } + + /** + * A remote procedure call (RPC) operation. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     configuration: String (Optional)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(notStarted/running/Succeeded/Failed/canceled) (Required)
+     *     createdDateTime: OffsetDateTime (Optional)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     lastUpdateDateTime: OffsetDateTime (Optional)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateJob(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.beginCreateJobAsync(body, requestOptions); + } + + /** + * The longRunning 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 the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLongRunning() { + // Generated convenience method for beginLongRunningWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginLongRunningWithModelAsync(requestOptions); + } + + /** + * A remote procedure call (RPC) operation. + * + * @param id The id 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getJob(String id) { + // Generated convenience method for getJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getJobWithResponse(id, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(JobResult.class)); + } + + /** + * A remote procedure call (RPC) operation. + * + * @param body The body 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 the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateJob(JobData body) { + // Generated convenience method for beginCreateJobWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginCreateJobWithModelAsync(BinaryData.fromObject(body), requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/LongRunningClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/LongRunningClient.java new file mode 100644 index 000000000..7b3d921fe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/LongRunningClient.java @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning; + +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.polling.SyncPoller; +import com.cadl.longrunning.implementation.LongRunningClientImpl; +import com.cadl.longrunning.models.JobData; +import com.cadl.longrunning.models.JobResult; +import com.cadl.longrunning.models.JobResultResult; +import com.cadl.longrunning.models.PollResponse; + +/** + * Initializes a new instance of the synchronous LongRunningClient type. + */ +@ServiceClient(builder = LongRunningClientBuilder.class) +public final class LongRunningClient { + @Generated + private final LongRunningClientImpl serviceClient; + + /** + * Initializes an instance of LongRunningClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + LongRunningClient(LongRunningClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The longRunning operation. + * + * @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 SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLongRunning(RequestOptions requestOptions) { + return this.serviceClient.beginLongRunning(requestOptions); + } + + /** + * A remote procedure call (RPC) operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(notStarted/running/Succeeded/Failed/canceled) (Required)
+     *     createdDateTime: OffsetDateTime (Optional)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     lastUpdateDateTime: OffsetDateTime (Optional)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param id The id 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getJobWithResponse(String id, RequestOptions requestOptions) { + return this.serviceClient.getJobWithResponse(id, requestOptions); + } + + /** + * A remote procedure call (RPC) operation. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     configuration: String (Optional)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(notStarted/running/Succeeded/Failed/canceled) (Required)
+     *     createdDateTime: OffsetDateTime (Optional)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     lastUpdateDateTime: OffsetDateTime (Optional)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateJob(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.beginCreateJob(body, requestOptions); + } + + /** + * The longRunning 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 the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLongRunning() { + // Generated convenience method for beginLongRunningWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginLongRunningWithModel(requestOptions); + } + + /** + * A remote procedure call (RPC) operation. + * + * @param id The id 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public JobResult getJob(String id) { + // Generated convenience method for getJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getJobWithResponse(id, requestOptions).getValue().toObject(JobResult.class); + } + + /** + * A remote procedure call (RPC) operation. + * + * @param body The body 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 the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateJob(JobData body) { + // Generated convenience method for beginCreateJobWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginCreateJobWithModel(BinaryData.fromObject(body), requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/LongRunningClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/LongRunningClientBuilder.java new file mode 100644 index 000000000..a617fd947 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/LongRunningClientBuilder.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.longrunning.implementation.LongRunningClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the LongRunningClient type. + */ +@ServiceClientBuilder(serviceClients = { LongRunningClient.class, LongRunningAsyncClient.class }) +public final class LongRunningClientBuilder 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("cadl-longrunning.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the LongRunningClientBuilder. + */ + @Generated + public LongRunningClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LongRunningClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LongRunningClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LongRunningClientBuilder 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 LongRunningClientBuilder 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 LongRunningClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LongRunningClientBuilder 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 LongRunningClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public LongRunningClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private LongRunningServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the LongRunningClientBuilder. + */ + @Generated + public LongRunningClientBuilder serviceVersion(LongRunningServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 LongRunningClientBuilder. + */ + @Generated + public LongRunningClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of LongRunningClientImpl with the provided parameters. + * + * @return an instance of LongRunningClientImpl. + */ + @Generated + private LongRunningClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + LongRunningServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : LongRunningServiceVersion.getLatest(); + LongRunningClientImpl client = new LongRunningClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 LongRunningAsyncClient class. + * + * @return an instance of LongRunningAsyncClient. + */ + @Generated + public LongRunningAsyncClient buildAsyncClient() { + return new LongRunningAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of LongRunningClient class. + * + * @return an instance of LongRunningClient. + */ + @Generated + public LongRunningClient buildClient() { + return new LongRunningClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(LongRunningClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/LongRunningServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/LongRunningServiceVersion.java new file mode 100644 index 000000000..06339644e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/LongRunningServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of LongRunningClient. + */ +public enum LongRunningServiceVersion implements ServiceVersion { + /** + * Enum value 2022-06-01-preview. + */ + V2022_06_01_PREVIEW("2022-06-01-preview"); + + private final String version; + + LongRunningServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link LongRunningServiceVersion}. + */ + public static LongRunningServiceVersion getLatest() { + return V2022_06_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/LongRunningClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/LongRunningClientImpl.java new file mode 100644 index 000000000..7445d3104 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/LongRunningClientImpl.java @@ -0,0 +1,852 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +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.HttpHeaderName; +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.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.DefaultPollingStrategy; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncDefaultPollingStrategy; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.TypeReference; +import com.cadl.longrunning.LongRunningServiceVersion; +import com.cadl.longrunning.models.JobResult; +import com.cadl.longrunning.models.JobResultResult; +import com.cadl.longrunning.models.PollResponse; +import java.time.Duration; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the LongRunningClient type. + */ +public final class LongRunningClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final LongRunningClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final LongRunningServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public LongRunningServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 LongRunningClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public LongRunningClientImpl(String endpoint, LongRunningServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of LongRunningClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public LongRunningClientImpl(HttpPipeline httpPipeline, String endpoint, LongRunningServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of LongRunningClient 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. + * @param serviceVersion Service version. + */ + public LongRunningClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + LongRunningServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(LongRunningClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for LongRunningClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "LongRunningClient") + public interface LongRunningClientService { + @Post("/long-running/post") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> longRunning(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Post("/long-running/post") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response longRunningSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/long-running/jobs/{id}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getJob(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") String id, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/long-running/jobs/{id}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getJobSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("id") String id, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/long-running/jobs") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createJob(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/long-running/jobs") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createJobSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The longRunning operation. + * + * @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) + private Mono> longRunningWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.longRunning(this.getEndpoint(), requestOptions, context)); + } + + /** + * The longRunning operation. + * + * @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) + private Response longRunningWithResponse(RequestOptions requestOptions) { + return service.longRunningSync(this.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The longRunning operation. + * + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLongRunningAsync(RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.longRunningWithResponseAsync(requestOptions), + new DefaultPollingStrategy<>(new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE)), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * The longRunning operation. + * + * @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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLongRunning(RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.longRunningWithResponse(requestOptions), + new SyncDefaultPollingStrategy<>(new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE)), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * The longRunning operation. + * + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLongRunningWithModelAsync(RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.longRunningWithResponseAsync(requestOptions), + new DefaultPollingStrategy<>(new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE)), + TypeReference.createInstance(PollResponse.class), TypeReference.createInstance(Void.class)); + } + + /** + * The longRunning operation. + * + * @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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLongRunningWithModel(RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.longRunningWithResponse(requestOptions), + new SyncDefaultPollingStrategy<>(new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE)), + TypeReference.createInstance(PollResponse.class), TypeReference.createInstance(Void.class)); + } + + /** + * A remote procedure call (RPC) operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(notStarted/running/Succeeded/Failed/canceled) (Required)
+     *     createdDateTime: OffsetDateTime (Optional)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     lastUpdateDateTime: OffsetDateTime (Optional)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param id The id 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getJobWithResponseAsync(String id, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getJob(this.getEndpoint(), this.getServiceVersion().getVersion(), + id, accept, requestOptions, context)); + } + + /** + * A remote procedure call (RPC) operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(notStarted/running/Succeeded/Failed/canceled) (Required)
+     *     createdDateTime: OffsetDateTime (Optional)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     lastUpdateDateTime: OffsetDateTime (Optional)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     *     result (Optional): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param id The id 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getJobWithResponse(String id, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getJobSync(this.getEndpoint(), this.getServiceVersion().getVersion(), id, accept, requestOptions, + Context.NONE); + } + + /** + * A remote procedure call (RPC) operation. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     configuration: String (Optional)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(notStarted/running/Succeeded/Failed/canceled) (Required)
+     *     createdDateTime: OffsetDateTime (Optional)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     lastUpdateDateTime: OffsetDateTime (Optional)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createJobWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-request-id"), CoreUtils.randomUuid().toString()); + } + }); + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-first-sent")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-first-sent"), + DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); + } + }); + return FluxUtil.withContext(context -> service.createJob(this.getEndpoint(), + this.getServiceVersion().getVersion(), contentType, accept, body, requestOptionsLocal, context)); + } + + /** + * A remote procedure call (RPC) operation. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     configuration: String (Optional)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(notStarted/running/Succeeded/Failed/canceled) (Required)
+     *     createdDateTime: OffsetDateTime (Optional)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     lastUpdateDateTime: OffsetDateTime (Optional)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createJobWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-request-id"), CoreUtils.randomUuid().toString()); + } + }); + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-first-sent")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-first-sent"), + DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); + } + }); + return service.createJobSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, accept, + body, requestOptionsLocal, Context.NONE); + } + + /** + * A remote procedure call (RPC) operation. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     configuration: String (Optional)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(notStarted/running/Succeeded/Failed/canceled) (Required)
+     *     createdDateTime: OffsetDateTime (Optional)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     lastUpdateDateTime: OffsetDateTime (Optional)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateJobAsync(BinaryData body, RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.createJobWithResponseAsync(body, requestOptions), + new com.cadl.longrunning.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * A remote procedure call (RPC) operation. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     configuration: String (Optional)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(notStarted/running/Succeeded/Failed/canceled) (Required)
+     *     createdDateTime: OffsetDateTime (Optional)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     lastUpdateDateTime: OffsetDateTime (Optional)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateJob(BinaryData body, RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.createJobWithResponse(body, requestOptions), + new com.cadl.longrunning.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * A remote procedure call (RPC) operation. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     configuration: String (Optional)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(notStarted/running/Succeeded/Failed/canceled) (Required)
+     *     createdDateTime: OffsetDateTime (Optional)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     lastUpdateDateTime: OffsetDateTime (Optional)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateJobWithModelAsync(BinaryData body, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.createJobWithResponseAsync(body, requestOptions), + new com.cadl.longrunning.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(JobResult.class), TypeReference.createInstance(JobResultResult.class)); + } + + /** + * A remote procedure call (RPC) operation. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     configuration: String (Optional)
+     *     nullableFloatDict (Required): {
+     *         String: Double (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(notStarted/running/Succeeded/Failed/canceled) (Required)
+     *     createdDateTime: OffsetDateTime (Optional)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     lastUpdateDateTime: OffsetDateTime (Optional)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateJobWithModel(BinaryData body, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.createJobWithResponse(body, requestOptions), + new com.cadl.longrunning.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(JobResult.class), TypeReference.createInstance(JobResultResult.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/OperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/OperationLocationPollingStrategy.java new file mode 100644 index 000000000..a471db039 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/OperationLocationPollingStrategy.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.OperationResourcePollingStrategy; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.time.OffsetDateTime; + +// DO NOT modify this helper class + +/** + * Implements an operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class OperationLocationPollingStrategy extends OperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(OperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + final Mono> pollResponseMono + = PollingUtils.deserializeResponse((BinaryData) response.getValue(), serializer, pollResponseType) + .onErrorResume(exception -> { + LOGGER.info("Failed to parse initial response."); + return Mono.empty(); + }) + .map(value -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, value, retryAfter)); + return pollResponseMono.switchIfEmpty( + Mono.fromSupplier(() -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, null, retryAfter))); + } else { + return Mono + .error( + new AzureException(String.format( + "Operation failed or cancelled with status code %d," + + ", '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + } + + /** + * {@inheritDoc} + */ + @Override + public Mono getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + return Mono.error(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + return Mono.error(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + return PollingUtils + .deserializeResponse(latestResponseBody, serializer, PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE) + .flatMap(value -> { + if (value.get(propertyName) != null) { + return BinaryData.fromObjectAsync(value.get(propertyName)) + .flatMap(result -> PollingUtils.deserializeResponse(result, serializer, resultType)); + } else { + return Mono.error(new AzureException("Cannot get final result")); + } + }) + .switchIfEmpty(Mono.error(new AzureException("Cannot get final result"))); + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/PollingUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/PollingUtils.java new file mode 100644 index 000000000..644868390 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/PollingUtils.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.net.URI; +import java.net.URISyntaxException; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.temporal.ChronoUnit; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +// DO NOT modify this helper class + +final class PollingUtils { + + public static final TypeReference> POST_POLL_RESULT_TYPE_REFERENCE + = new TypeReference>() { + }; + + public static final HttpHeaderName OPERATION_LOCATION_HEADER = HttpHeaderName.fromString("Operation-Location"); + + public static final String HTTP_METHOD = "httpMethod"; + public static final String REQUEST_URL = "requestURL"; + public static final String POLL_RESPONSE_BODY = "pollResponseBody"; + + private static final String FORWARD_SLASH = "/"; + + public static String getAbsolutePath(String path, String endpoint, ClientLogger logger) { + try { + URI uri = new URI(path); + if (!uri.isAbsolute()) { + if (CoreUtils.isNullOrEmpty(endpoint)) { + throw logger.logExceptionAsError(new IllegalArgumentException( + "Relative path requires endpoint to be non-null and non-empty to create an absolute path.")); + } + + if (endpoint.endsWith(FORWARD_SLASH) && path.startsWith(FORWARD_SLASH)) { + return endpoint + path.substring(1); + } else if (!endpoint.endsWith(FORWARD_SLASH) && !path.startsWith(FORWARD_SLASH)) { + return endpoint + FORWARD_SLASH + path; + } else { + return endpoint + path; + } + } + } catch (URISyntaxException ex) { + throw logger.logExceptionAsWarning(new IllegalArgumentException("'path' must be a valid URI.", ex)); + } + return path; + } + + public static T deserializeResponseSync(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + T value; + if (binaryData == null) { + value = null; + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = typeReference.getJavaClass().cast(binaryData.toReplayableBinaryData()); + } else { + value = binaryData.toObject(typeReference, serializer); + } + return value; + } + + @SuppressWarnings("unchecked") + public static Mono deserializeResponse(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + Mono value; + if (binaryData == null) { + value = Mono.empty(); + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = (Mono) binaryData.toReplayableBinaryDataAsync(); + } else { + value = binaryData.toObjectAsync(typeReference, serializer); + } + return value; + } + + private static final HttpHeaderName RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("retry-after-ms"); + private static final HttpHeaderName X_MS_RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("x-ms-retry-after-ms"); + + public static Duration getRetryAfterFromHeaders(HttpHeaders headers, Supplier nowSupplier) { + // Found 'x-ms-retry-after-ms' header, use a Duration of milliseconds based on the value. + Duration retryDelay = tryGetRetryDelay(headers, X_MS_RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'retry-after-ms' header, use a Duration of milliseconds based on the value. + retryDelay = tryGetRetryDelay(headers, RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'Retry-After' header. First, attempt to resolve it as a Duration of seconds. If that fails, then + // attempt to resolve it as an HTTP date (RFC1123). + retryDelay = tryGetRetryDelay(headers, HttpHeaderName.RETRY_AFTER, + headerValue -> tryParseLongOrDateTime(headerValue, nowSupplier)); + + // Either the retry delay will have been found or it'll be null, null indicates no retry after. + return retryDelay; + } + + private static Duration tryGetRetryDelay(HttpHeaders headers, HttpHeaderName headerName, + Function delayParser) { + String headerValue = headers.getValue(headerName); + + return CoreUtils.isNullOrEmpty(headerValue) ? null : delayParser.apply(headerValue); + } + + private static Duration tryParseLongOrDateTime(String value, Supplier nowSupplier) { + long delaySeconds; + try { + OffsetDateTime retryAfter = new DateTimeRfc1123(value).getDateTime(); + + delaySeconds = nowSupplier.get().until(retryAfter, ChronoUnit.SECONDS); + } catch (DateTimeException ex) { + delaySeconds = tryParseLong(value); + } + + return (delaySeconds >= 0) ? Duration.ofSeconds(delaySeconds) : null; + } + + private static long tryParseLong(String value) { + try { + return Long.parseLong(value); + } catch (NumberFormatException ex) { + return -1; + } + } + + private static Duration tryGetDelayMillis(String value) { + long delayMillis = tryParseLong(value); + return (delayMillis >= 0) ? Duration.ofMillis(delayMillis) : null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/SyncOperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/SyncOperationLocationPollingStrategy.java new file mode 100644 index 000000000..b75f08fdd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/SyncOperationLocationPollingStrategy.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncOperationResourcePollingStrategy; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; + +import java.io.UncheckedIOException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Map; + +// DO NOT modify this helper class + +/** + * Implements a synchronous operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class SyncOperationLocationPollingStrategy extends SyncOperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(SyncOperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public PollResponse onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + T initialResponseType = null; + try { + initialResponseType = PollingUtils.deserializeResponseSync((BinaryData) response.getValue(), serializer, + pollResponseType); + } catch (UncheckedIOException e) { + LOGGER.info("Failed to parse initial response."); + } + return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, initialResponseType, retryAfter); + } + + throw LOGGER.logExceptionAsError(new AzureException( + String.format("Operation failed or cancelled with status code %d, '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + + /** + * {@inheritDoc} + */ + public U getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + Map pollResult = PollingUtils.deserializeResponseSync(latestResponseBody, serializer, + PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE); + if (pollResult != null && pollResult.get(propertyName) != null) { + return PollingUtils.deserializeResponseSync(BinaryData.fromObject(pollResult.get(propertyName)), + serializer, resultType); + } else { + throw LOGGER.logExceptionAsError(new AzureException("Cannot get final result")); + } + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/package-info.java new file mode 100644 index 000000000..f5f1c7bf0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 LongRunning. + * + */ +package com.cadl.longrunning.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/JobData.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/JobData.java new file mode 100644 index 000000000..d0acbd8b7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/JobData.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 com.cadl.longrunning.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; +import java.util.Map; + +/** + * The JobData model. + */ +@Fluent +public final class JobData implements JsonSerializable { + /* + * The configuration property. + */ + @Generated + private String configuration; + + /* + * The nullableFloatDict property. + */ + @Generated + private final Map nullableFloatDict; + + /** + * Creates an instance of JobData class. + * + * @param nullableFloatDict the nullableFloatDict value to set. + */ + @Generated + public JobData(Map nullableFloatDict) { + this.nullableFloatDict = nullableFloatDict; + } + + /** + * Get the configuration property: The configuration property. + * + * @return the configuration value. + */ + @Generated + public String getConfiguration() { + return this.configuration; + } + + /** + * Set the configuration property: The configuration property. + * + * @param configuration the configuration value to set. + * @return the JobData object itself. + */ + @Generated + public JobData setConfiguration(String configuration) { + this.configuration = configuration; + return this; + } + + /** + * Get the nullableFloatDict property: The nullableFloatDict property. + * + * @return the nullableFloatDict value. + */ + @Generated + public Map getNullableFloatDict() { + return this.nullableFloatDict; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeMapField("nullableFloatDict", this.nullableFloatDict, + (writer, element) -> writer.writeNumber(element)); + jsonWriter.writeStringField("configuration", this.configuration); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of JobData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of JobData 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 JobData. + */ + @Generated + public static JobData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Map nullableFloatDict = null; + String configuration = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("nullableFloatDict".equals(fieldName)) { + nullableFloatDict = reader.readMap(reader1 -> reader1.getNullable(JsonReader::getDouble)); + } else if ("configuration".equals(fieldName)) { + configuration = reader.getString(); + } else { + reader.skipChildren(); + } + } + JobData deserializedJobData = new JobData(nullableFloatDict); + deserializedJobData.configuration = configuration; + + return deserializedJobData; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/JobResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/JobResult.java new file mode 100644 index 000000000..2abae75fe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/JobResult.java @@ -0,0 +1,196 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +import com.azure.core.util.CoreUtils; +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.time.OffsetDateTime; + +/** + * The JobResult model. + */ +@Immutable +public final class JobResult implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The status property. + */ + @Generated + private JobStatus status; + + /* + * The createdDateTime property. + */ + @Generated + private OffsetDateTime createdDateTime; + + /* + * The expirationDateTime property. + */ + @Generated + private OffsetDateTime expirationDateTime; + + /* + * The lastUpdateDateTime property. + */ + @Generated + private OffsetDateTime lastUpdateDateTime; + + /* + * The error property. + */ + @Generated + private ResponseError error; + + /* + * The result property. + */ + @Generated + private JobResultResult result; + + /** + * Creates an instance of JobResult class. + */ + @Generated + private JobResult() { + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the status property: The status property. + * + * @return the status value. + */ + @Generated + public JobStatus getStatus() { + return this.status; + } + + /** + * Get the createdDateTime property: The createdDateTime property. + * + * @return the createdDateTime value. + */ + @Generated + public OffsetDateTime getCreatedDateTime() { + return this.createdDateTime; + } + + /** + * Get the expirationDateTime property: The expirationDateTime property. + * + * @return the expirationDateTime value. + */ + @Generated + public OffsetDateTime getExpirationDateTime() { + return this.expirationDateTime; + } + + /** + * Get the lastUpdateDateTime property: The lastUpdateDateTime property. + * + * @return the lastUpdateDateTime value. + */ + @Generated + public OffsetDateTime getLastUpdateDateTime() { + return this.lastUpdateDateTime; + } + + /** + * Get the error property: The error property. + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } + + /** + * Get the result property: The result property. + * + * @return the result value. + */ + @Generated + public JobResultResult getResult() { + return this.result; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("error", this.error); + jsonWriter.writeJsonField("result", this.result); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of JobResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of JobResult 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 JobResult. + */ + @Generated + public static JobResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + JobResult deserializedJobResult = new JobResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedJobResult.id = reader.getString(); + } else if ("status".equals(fieldName)) { + deserializedJobResult.status = JobStatus.fromString(reader.getString()); + } else if ("createdDateTime".equals(fieldName)) { + deserializedJobResult.createdDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("expirationDateTime".equals(fieldName)) { + deserializedJobResult.expirationDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("lastUpdateDateTime".equals(fieldName)) { + deserializedJobResult.lastUpdateDateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("error".equals(fieldName)) { + deserializedJobResult.error = ResponseError.fromJson(reader); + } else if ("result".equals(fieldName)) { + deserializedJobResult.result = JobResultResult.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedJobResult; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/JobResultResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/JobResultResult.java new file mode 100644 index 000000000..9980b01ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/JobResultResult.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning.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; + +/** + * The JobResultResult model. + */ +@Immutable +public final class JobResultResult implements JsonSerializable { + /* + * The data property. + */ + @Generated + private final String data; + + /** + * Creates an instance of JobResultResult class. + * + * @param data the data value to set. + */ + @Generated + private JobResultResult(String data) { + this.data = data; + } + + /** + * Get the data property: The data property. + * + * @return the data value. + */ + @Generated + public String getData() { + return this.data; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("data", this.data); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of JobResultResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of JobResultResult 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 JobResultResult. + */ + @Generated + public static JobResultResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String data = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("data".equals(fieldName)) { + data = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new JobResultResult(data); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/JobStatus.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/JobStatus.java new file mode 100644 index 000000000..79525ad90 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/JobStatus.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 com.cadl.longrunning.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for JobStatus. + */ +public final class JobStatus extends ExpandableStringEnum { + /** + * Static value notStarted for JobStatus. + */ + @Generated + public static final JobStatus NOT_STARTED = fromString("notStarted"); + + /** + * Static value running for JobStatus. + */ + @Generated + public static final JobStatus RUNNING = fromString("running"); + + /** + * Static value Succeeded for JobStatus. + */ + @Generated + public static final JobStatus SUCCEEDED = fromString("Succeeded"); + + /** + * Static value Failed for JobStatus. + */ + @Generated + public static final JobStatus FAILED = fromString("Failed"); + + /** + * Static value canceled for JobStatus. + */ + @Generated + public static final JobStatus CANCELED = fromString("canceled"); + + /** + * Creates a new instance of JobStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public JobStatus() { + } + + /** + * Creates or finds a JobStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding JobStatus. + */ + @Generated + public static JobStatus fromString(String name) { + return fromString(name, JobStatus.class); + } + + /** + * Gets known JobStatus values. + * + * @return known JobStatus values. + */ + @Generated + public static Collection values() { + return values(JobStatus.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/OperationState.java new file mode 100644 index 000000000..30784b9a2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/OperationState.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 com.cadl.longrunning.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum describing allowed operation states. + */ +public final class OperationState extends ExpandableStringEnum { + /** + * The operation has not started. + */ + @Generated + public static final OperationState NOT_STARTED = fromString("NotStarted"); + + /** + * The operation is in progress. + */ + @Generated + public static final OperationState RUNNING = fromString("Running"); + + /** + * The operation has completed successfully. + */ + @Generated + public static final OperationState SUCCEEDED = fromString("Succeeded"); + + /** + * The operation has failed. + */ + @Generated + public static final OperationState FAILED = fromString("Failed"); + + /** + * The operation has been canceled by the user. + */ + @Generated + public static final OperationState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of OperationState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OperationState() { + } + + /** + * Creates or finds a OperationState from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationState. + */ + @Generated + public static OperationState fromString(String name) { + return fromString(name, OperationState.class); + } + + /** + * Gets known OperationState values. + * + * @return known OperationState values. + */ + @Generated + public static Collection values() { + return values(OperationState.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/PollResponse.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/PollResponse.java new file mode 100644 index 000000000..9b92d12a5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/PollResponse.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning.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; + +/** + * The PollResponse model. + */ +@Immutable +public final class PollResponse implements JsonSerializable { + /* + * The operationId property. + */ + @Generated + private final String operationId; + + /* + * The status property. + */ + @Generated + private final OperationState status; + + /** + * Creates an instance of PollResponse class. + * + * @param operationId the operationId value to set. + * @param status the status value to set. + */ + @Generated + private PollResponse(String operationId, OperationState status) { + this.operationId = operationId; + this.status = status; + } + + /** + * Get the operationId property: The operationId property. + * + * @return the operationId value. + */ + @Generated + public String getOperationId() { + return this.operationId; + } + + /** + * Get the status property: The status property. + * + * @return the status value. + */ + @Generated + public OperationState getStatus() { + return this.status; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("operationId", this.operationId); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PollResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PollResponse 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 PollResponse. + */ + @Generated + public static PollResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String operationId = null; + OperationState status = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("operationId".equals(fieldName)) { + operationId = reader.getString(); + } else if ("status".equals(fieldName)) { + status = OperationState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new PollResponse(operationId, status); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/package-info.java new file mode 100644 index 000000000..151235fbd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/models/package-info.java @@ -0,0 +1,10 @@ +// 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 LongRunning. + * + */ +package com.cadl.longrunning.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/package-info.java new file mode 100644 index 000000000..cb3a0e179 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/longrunning/package-info.java @@ -0,0 +1,10 @@ +// 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 LongRunning. + * + */ +package com.cadl.longrunning; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/ModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/ModelAsyncClient.java new file mode 100644 index 000000000..3433f3f7e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/ModelAsyncClient.java @@ -0,0 +1,273 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model; + +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 com.cadl.model.implementation.ModelOpsImpl; +import com.cadl.model.models.NestedModel; +import com.cadl.model.models.Resource1; +import com.cadl.model.models.Resource2; +import com.cadl.model.models.Resource3; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ModelClient type. + */ +@ServiceClient(builder = ModelClientBuilder.class, isAsync = true) +public final class ModelAsyncClient { + @Generated + private final ModelOpsImpl serviceClient; + + /** + * Initializes an instance of ModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelAsyncClient(ModelOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The put1 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     outputData (Required): {
+     *         data: String (Required)
+     *     }
+     *     outputData2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     outputData (Required): {
+     *         data: String (Required)
+     *     }
+     *     outputData2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> put1WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.put1WithResponseAsync(body, requestOptions); + } + + /** + * The put2 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     data2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     data2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> put2WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.put2WithResponseAsync(body, requestOptions); + } + + /** + * The get3 operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     outputData3 (Required): {
+     *         data: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get3WithResponse(RequestOptions requestOptions) { + return this.serviceClient.get3WithResponseAsync(requestOptions); + } + + /** + * The putNested operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     nested1 (Required): {
+     *         nested2 (Required): {
+     *             data: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     nested1 (Required): {
+     *         nested2 (Required): {
+     *             data: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putNestedWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putNestedWithResponseAsync(body, requestOptions); + } + + /** + * The put1 operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono put1(Resource1 body) { + // Generated convenience method for put1WithResponse + RequestOptions requestOptions = new RequestOptions(); + return put1WithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource1.class)); + } + + /** + * The put2 operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono put2(Resource2 body) { + // Generated convenience method for put2WithResponse + RequestOptions requestOptions = new RequestOptions(); + return put2WithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource2.class)); + } + + /** + * The get3 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get3() { + // Generated convenience method for get3WithResponse + RequestOptions requestOptions = new RequestOptions(); + return get3WithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource3.class)); + } + + /** + * The putNested operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putNested(NestedModel body) { + // Generated convenience method for putNestedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putNestedWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(NestedModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/ModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/ModelClient.java new file mode 100644 index 000000000..f55e906a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/ModelClient.java @@ -0,0 +1,268 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model; + +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.cadl.model.implementation.ModelOpsImpl; +import com.cadl.model.models.NestedModel; +import com.cadl.model.models.Resource1; +import com.cadl.model.models.Resource2; +import com.cadl.model.models.Resource3; + +/** + * Initializes a new instance of the synchronous ModelClient type. + */ +@ServiceClient(builder = ModelClientBuilder.class) +public final class ModelClient { + @Generated + private final ModelOpsImpl serviceClient; + + /** + * Initializes an instance of ModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelClient(ModelOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The put1 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     outputData (Required): {
+     *         data: String (Required)
+     *     }
+     *     outputData2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     outputData (Required): {
+     *         data: String (Required)
+     *     }
+     *     outputData2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response put1WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.put1WithResponse(body, requestOptions); + } + + /** + * The put2 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     data2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     data2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response put2WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.put2WithResponse(body, requestOptions); + } + + /** + * The get3 operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     outputData3 (Required): {
+     *         data: String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response get3WithResponse(RequestOptions requestOptions) { + return this.serviceClient.get3WithResponse(requestOptions); + } + + /** + * The putNested operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     nested1 (Required): {
+     *         nested2 (Required): {
+     *             data: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     nested1 (Required): {
+     *         nested2 (Required): {
+     *             data: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putNestedWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putNestedWithResponse(body, requestOptions); + } + + /** + * The put1 operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource1 put1(Resource1 body) { + // Generated convenience method for put1WithResponse + RequestOptions requestOptions = new RequestOptions(); + return put1WithResponse(BinaryData.fromObject(body), requestOptions).getValue().toObject(Resource1.class); + } + + /** + * The put2 operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource2 put2(Resource2 body) { + // Generated convenience method for put2WithResponse + RequestOptions requestOptions = new RequestOptions(); + return put2WithResponse(BinaryData.fromObject(body), requestOptions).getValue().toObject(Resource2.class); + } + + /** + * The get3 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource3 get3() { + // Generated convenience method for get3WithResponse + RequestOptions requestOptions = new RequestOptions(); + return get3WithResponse(requestOptions).getValue().toObject(Resource3.class); + } + + /** + * The putNested operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public NestedModel putNested(NestedModel body) { + // Generated convenience method for putNestedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putNestedWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(NestedModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/ModelClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/ModelClientBuilder.java new file mode 100644 index 000000000..906d140c2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/ModelClientBuilder.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 com.cadl.model; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.model.implementation.ModelClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ModelClient type. + */ +@ServiceClientBuilder(serviceClients = { ModelClient.class, ModelAsyncClient.class }) +public final class ModelClientBuilder 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("cadl-model.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ModelClientBuilder. + */ + @Generated + public ModelClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder 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 ModelClientBuilder 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 ModelClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder 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 ModelClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ModelClientBuilder 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 ModelClientBuilder. + */ + @Generated + public ModelClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ModelClientImpl with the provided parameters. + * + * @return an instance of ModelClientImpl. + */ + @Generated + private ModelClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ModelClientImpl client + = new ModelClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 ModelAsyncClient class. + * + * @return an instance of ModelAsyncClient. + */ + @Generated + public ModelAsyncClient buildAsyncClient() { + return new ModelAsyncClient(buildInnerClient().getModelOps()); + } + + /** + * Builds an instance of ModelClient class. + * + * @return an instance of ModelClient. + */ + @Generated + public ModelClient buildClient() { + return new ModelClient(buildInnerClient().getModelOps()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ModelClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/implementation/ModelClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/implementation/ModelClientImpl.java new file mode 100644 index 000000000..906372402 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/implementation/ModelClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the ModelClient type. + */ +public final class ModelClientImpl { + /** + * 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; + } + + /** + * The ModelOpsImpl object to access its operations. + */ + private final ModelOpsImpl modelOps; + + /** + * Gets the ModelOpsImpl object to access its operations. + * + * @return the ModelOpsImpl object. + */ + public ModelOpsImpl getModelOps() { + return this.modelOps; + } + + /** + * Initializes an instance of ModelClient client. + * + * @param endpoint Service host. + */ + public ModelClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ModelClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ModelClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ModelClient 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 ModelClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.modelOps = new ModelOpsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/implementation/ModelOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/implementation/ModelOpsImpl.java new file mode 100644 index 000000000..a9173a6cc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/implementation/ModelOpsImpl.java @@ -0,0 +1,446 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ModelOps. + */ +public final class ModelOpsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelOpsService service; + + /** + * The service client containing this operation class. + */ + private final ModelClientImpl client; + + /** + * Initializes an instance of ModelOpsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelOpsImpl(ModelClientImpl client) { + this.service = RestProxy.create(ModelOpsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ModelClientModelOps to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ModelClientModelOps") + public interface ModelOpsService { + @Put("/model/resource1") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put1(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/model/resource1") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response put1Sync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/model/resource2") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put2(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/model/resource2") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response put2Sync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Get("/model/resource3") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get3(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/model/resource3") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response get3Sync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/model/nested") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putNested(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Get("/model/nested") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putNestedSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The put1 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     outputData (Required): {
+     *         data: String (Required)
+     *     }
+     *     outputData2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     outputData (Required): {
+     *         data: String (Required)
+     *     }
+     *     outputData2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> put1WithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.put1(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); + } + + /** + * The put1 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     outputData (Required): {
+     *         data: String (Required)
+     *     }
+     *     outputData2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     outputData (Required): {
+     *         data: String (Required)
+     *     }
+     *     outputData2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response put1WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.put1Sync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); + } + + /** + * The put2 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     data2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     data2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> put2WithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.put2(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); + } + + /** + * The put2 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     data2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     data2 (Required): {
+     *         data: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response put2WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.put2Sync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); + } + + /** + * The get3 operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     outputData3 (Required): {
+     *         data: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get3WithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get3(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get3 operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     outputData3 (Required): {
+     *         data: String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response get3WithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.get3Sync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The putNested operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     nested1 (Required): {
+     *         nested2 (Required): {
+     *             data: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     nested1 (Required): {
+     *         nested2 (Required): {
+     *             data: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putNestedWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.putNested(this.client.getEndpoint(), contentType, accept, body, + requestOptions, context)); + } + + /** + * The putNested operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     nested1 (Required): {
+     *         nested2 (Required): {
+     *             data: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     nested1 (Required): {
+     *         nested2 (Required): {
+     *             data: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putNestedWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.putNestedSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/implementation/package-info.java new file mode 100644 index 000000000..f3c25af94 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Model. + * + */ +package com.cadl.model.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/InputOutputData2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/InputOutputData2.java new file mode 100644 index 000000000..764776815 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/InputOutputData2.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.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; + +/** + * The InputOutputData2 model. + */ +@Immutable +public final class InputOutputData2 implements JsonSerializable { + /* + * The data property. + */ + @Generated + private final String data; + + /** + * Creates an instance of InputOutputData2 class. + * + * @param data the data value to set. + */ + @Generated + public InputOutputData2(String data) { + this.data = data; + } + + /** + * Get the data property: The data property. + * + * @return the data value. + */ + @Generated + public String getData() { + return this.data; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("data", this.data); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InputOutputData2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InputOutputData2 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 InputOutputData2. + */ + @Generated + public static InputOutputData2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String data = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("data".equals(fieldName)) { + data = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new InputOutputData2(data); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/NestedModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/NestedModel.java new file mode 100644 index 000000000..cb1065c87 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/NestedModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.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; + +/** + * The NestedModel model. + */ +@Immutable +public final class NestedModel implements JsonSerializable { + /* + * The nested1 property. + */ + @Generated + private final NestedModel1 nested1; + + /** + * Creates an instance of NestedModel class. + * + * @param nested1 the nested1 value to set. + */ + @Generated + public NestedModel(NestedModel1 nested1) { + this.nested1 = nested1; + } + + /** + * Get the nested1 property: The nested1 property. + * + * @return the nested1 value. + */ + @Generated + public NestedModel1 getNested1() { + return this.nested1; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("nested1", this.nested1); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NestedModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NestedModel 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 NestedModel. + */ + @Generated + public static NestedModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + NestedModel1 nested1 = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("nested1".equals(fieldName)) { + nested1 = NestedModel1.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new NestedModel(nested1); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/NestedModel1.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/NestedModel1.java new file mode 100644 index 000000000..74793939e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/NestedModel1.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.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; + +/** + * The NestedModel1 model. + */ +@Immutable +public final class NestedModel1 implements JsonSerializable { + /* + * The nested2 property. + */ + @Generated + private final NestedModel2 nested2; + + /** + * Creates an instance of NestedModel1 class. + * + * @param nested2 the nested2 value to set. + */ + @Generated + public NestedModel1(NestedModel2 nested2) { + this.nested2 = nested2; + } + + /** + * Get the nested2 property: The nested2 property. + * + * @return the nested2 value. + */ + @Generated + public NestedModel2 getNested2() { + return this.nested2; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("nested2", this.nested2); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NestedModel1 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NestedModel1 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 NestedModel1. + */ + @Generated + public static NestedModel1 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + NestedModel2 nested2 = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("nested2".equals(fieldName)) { + nested2 = NestedModel2.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new NestedModel1(nested2); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/NestedModel2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/NestedModel2.java new file mode 100644 index 000000000..ebd547cb7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/NestedModel2.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.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; + +/** + * The NestedModel2 model. + */ +@Immutable +public final class NestedModel2 implements JsonSerializable { + /* + * The data property. + */ + @Generated + private final String data; + + /** + * Creates an instance of NestedModel2 class. + * + * @param data the data value to set. + */ + @Generated + public NestedModel2(String data) { + this.data = data; + } + + /** + * Get the data property: The data property. + * + * @return the data value. + */ + @Generated + public String getData() { + return this.data; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("data", this.data); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NestedModel2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NestedModel2 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 NestedModel2. + */ + @Generated + public static NestedModel2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String data = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("data".equals(fieldName)) { + data = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new NestedModel2(data); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/OutputData.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/OutputData.java new file mode 100644 index 000000000..63cb716d5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/OutputData.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.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; + +/** + * The OutputData model. + */ +@Immutable +public final class OutputData implements JsonSerializable { + /* + * The data property. + */ + @Generated + private final String data; + + /** + * Creates an instance of OutputData class. + * + * @param data the data value to set. + */ + @Generated + private OutputData(String data) { + this.data = data; + } + + /** + * Get the data property: The data property. + * + * @return the data value. + */ + @Generated + public String getData() { + return this.data; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("data", this.data); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OutputData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OutputData 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 OutputData. + */ + @Generated + public static OutputData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String data = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("data".equals(fieldName)) { + data = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new OutputData(data); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/OutputData3.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/OutputData3.java new file mode 100644 index 000000000..b3a168e57 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/OutputData3.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.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; + +/** + * The OutputData3 model. + */ +@Immutable +public final class OutputData3 implements JsonSerializable { + /* + * The data property. + */ + @Generated + private final String data; + + /** + * Creates an instance of OutputData3 class. + * + * @param data the data value to set. + */ + @Generated + private OutputData3(String data) { + this.data = data; + } + + /** + * Get the data property: The data property. + * + * @return the data value. + */ + @Generated + public String getData() { + return this.data; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("data", this.data); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OutputData3 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OutputData3 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 OutputData3. + */ + @Generated + public static OutputData3 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String data = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("data".equals(fieldName)) { + data = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new OutputData3(data); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/Resource1.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/Resource1.java new file mode 100644 index 000000000..9b4719882 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/Resource1.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.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; + +/** + * The Resource1 model. + */ +@Immutable +public final class Resource1 implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The outputData property. + */ + @Generated + private OutputData outputData; + + /* + * The outputData2 property. + */ + @Generated + private InputOutputData2 outputData2; + + /** + * Creates an instance of Resource1 class. + * + * @param name the name value to set. + */ + @Generated + public Resource1(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the outputData property: The outputData property. + * + * @return the outputData value. + */ + @Generated + public OutputData getOutputData() { + return this.outputData; + } + + /** + * Get the outputData2 property: The outputData2 property. + * + * @return the outputData2 value. + */ + @Generated + public InputOutputData2 getOutputData2() { + return this.outputData2; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource1 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource1 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 Resource1. + */ + @Generated + public static Resource1 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + OutputData outputData = null; + InputOutputData2 outputData2 = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("outputData".equals(fieldName)) { + outputData = OutputData.fromJson(reader); + } else if ("outputData2".equals(fieldName)) { + outputData2 = InputOutputData2.fromJson(reader); + } else { + reader.skipChildren(); + } + } + Resource1 deserializedResource1 = new Resource1(name); + deserializedResource1.outputData = outputData; + deserializedResource1.outputData2 = outputData2; + + return deserializedResource1; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/Resource2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/Resource2.java new file mode 100644 index 000000000..3eea2e203 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/Resource2.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.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; + +/** + * The Resource2 model. + */ +@Immutable +public final class Resource2 implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The data2 property. + */ + @Generated + private final InputOutputData2 data2; + + /** + * Creates an instance of Resource2 class. + * + * @param name the name value to set. + * @param data2 the data2 value to set. + */ + @Generated + public Resource2(String name, InputOutputData2 data2) { + this.name = name; + this.data2 = data2; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the data2 property: The data2 property. + * + * @return the data2 value. + */ + @Generated + public InputOutputData2 getData2() { + return this.data2; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeJsonField("data2", this.data2); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource2 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 Resource2. + */ + @Generated + public static Resource2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + InputOutputData2 data2 = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("data2".equals(fieldName)) { + data2 = InputOutputData2.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new Resource2(name, data2); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/Resource3.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/Resource3.java new file mode 100644 index 000000000..1ce5cb5c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/Resource3.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.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; + +/** + * The Resource3 model. + */ +@Immutable +public final class Resource3 implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The outputData3 property. + */ + @Generated + private final OutputData3 outputData3; + + /** + * Creates an instance of Resource3 class. + * + * @param name the name value to set. + * @param outputData3 the outputData3 value to set. + */ + @Generated + private Resource3(String name, OutputData3 outputData3) { + this.name = name; + this.outputData3 = outputData3; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the outputData3 property: The outputData3 property. + * + * @return the outputData3 value. + */ + @Generated + public OutputData3 getOutputData3() { + return this.outputData3; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeJsonField("outputData3", this.outputData3); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource3 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource3 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 Resource3. + */ + @Generated + public static Resource3 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + OutputData3 outputData3 = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("outputData3".equals(fieldName)) { + outputData3 = OutputData3.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new Resource3(name, outputData3); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/package-info.java new file mode 100644 index 000000000..98ac4b7f9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Model. + * + */ +package com.cadl.model.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/package-info.java new file mode 100644 index 000000000..286c8cdf0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/model/package-info.java @@ -0,0 +1,10 @@ +// 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 Model. + * + */ +package com.cadl.model; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesAsyncClient.java new file mode 100644 index 000000000..f79c741b0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesAsyncClient.java @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes; + +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.cadl.multicontenttypes.implementation.MultiContentTypesClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous MultiContentTypesClient type. + */ +@ServiceClient(builder = MultiContentTypesClientBuilder.class, isAsync = true) +public final class MultiContentTypesAsyncClient { + @Generated + private final MultiContentTypesClientImpl serviceClient; + + /** + * Initializes an instance of MultiContentTypesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MultiContentTypesAsyncClient(MultiContentTypesClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * multiple data types map to multiple content types. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "text/plain", "application/json", + * "application/octet-stream", "image/jpeg", "image/png". + * @param data The data 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> uploadWithOverloadWithResponse(String contentType, BinaryData data, + RequestOptions requestOptions) { + // Convenience API is not generated, as operation 'uploadWithOverload' is multiple content-type + return this.serviceClient.uploadWithOverloadWithResponseAsync(contentType, data, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesClient.java new file mode 100644 index 000000000..46fccf0d9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesClient.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes; + +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.cadl.multicontenttypes.implementation.MultiContentTypesClientImpl; + +/** + * Initializes a new instance of the synchronous MultiContentTypesClient type. + */ +@ServiceClient(builder = MultiContentTypesClientBuilder.class) +public final class MultiContentTypesClient { + @Generated + private final MultiContentTypesClientImpl serviceClient; + + /** + * Initializes an instance of MultiContentTypesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MultiContentTypesClient(MultiContentTypesClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * multiple data types map to multiple content types. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "text/plain", "application/json", + * "application/octet-stream", "image/jpeg", "image/png". + * @param data The data 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 uploadWithOverloadWithResponse(String contentType, BinaryData data, + RequestOptions requestOptions) { + // Convenience API is not generated, as operation 'uploadWithOverload' is multiple content-type + return this.serviceClient.uploadWithOverloadWithResponse(contentType, data, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesClientBuilder.java new file mode 100644 index 000000000..44b14cb7e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultiContentTypesClientBuilder.java @@ -0,0 +1,334 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.multicontenttypes.implementation.MultiContentTypesClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the MultiContentTypesClient type. + */ +@ServiceClientBuilder( + serviceClients = { + MultiContentTypesClient.class, + SingleContentTypeClient.class, + MultipleContentTypesOnRequestClient.class, + MultiContentTypesAsyncClient.class, + SingleContentTypeAsyncClient.class, + MultipleContentTypesOnRequestAsyncClient.class }) +public final class MultiContentTypesClientBuilder 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("cadl-multicontenttypes.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the MultiContentTypesClientBuilder. + */ + @Generated + public MultiContentTypesClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultiContentTypesClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultiContentTypesClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultiContentTypesClientBuilder 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 MultiContentTypesClientBuilder 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 MultiContentTypesClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultiContentTypesClientBuilder 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 MultiContentTypesClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultiContentTypesClientBuilder 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 MultiContentTypesClientBuilder. + */ + @Generated + public MultiContentTypesClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of MultiContentTypesClientImpl with the provided parameters. + * + * @return an instance of MultiContentTypesClientImpl. + */ + @Generated + private MultiContentTypesClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + MultiContentTypesClientImpl client = new MultiContentTypesClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 MultiContentTypesAsyncClient class. + * + * @return an instance of MultiContentTypesAsyncClient. + */ + @Generated + public MultiContentTypesAsyncClient buildAsyncClient() { + return new MultiContentTypesAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of SingleContentTypeAsyncClient class. + * + * @return an instance of SingleContentTypeAsyncClient. + */ + @Generated + public SingleContentTypeAsyncClient buildSingleContentTypeAsyncClient() { + return new SingleContentTypeAsyncClient(buildInnerClient().getSingleContentTypes()); + } + + /** + * Builds an instance of MultipleContentTypesOnRequestAsyncClient class. + * + * @return an instance of MultipleContentTypesOnRequestAsyncClient. + */ + @Generated + public MultipleContentTypesOnRequestAsyncClient buildMultipleContentTypesOnRequestAsyncClient() { + return new MultipleContentTypesOnRequestAsyncClient(buildInnerClient().getMultipleContentTypesOnRequests()); + } + + /** + * Builds an instance of MultiContentTypesClient class. + * + * @return an instance of MultiContentTypesClient. + */ + @Generated + public MultiContentTypesClient buildClient() { + return new MultiContentTypesClient(buildInnerClient()); + } + + /** + * Builds an instance of SingleContentTypeClient class. + * + * @return an instance of SingleContentTypeClient. + */ + @Generated + public SingleContentTypeClient buildSingleContentTypeClient() { + return new SingleContentTypeClient(buildInnerClient().getSingleContentTypes()); + } + + /** + * Builds an instance of MultipleContentTypesOnRequestClient class. + * + * @return an instance of MultipleContentTypesOnRequestClient. + */ + @Generated + public MultipleContentTypesOnRequestClient buildMultipleContentTypesOnRequestClient() { + return new MultipleContentTypesOnRequestClient(buildInnerClient().getMultipleContentTypesOnRequests()); + } + + private static final ClientLogger LOGGER = new ClientLogger(MultiContentTypesClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java new file mode 100644 index 000000000..f31fd83d5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestAsyncClient.java @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes; + +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 com.cadl.multicontenttypes.implementation.MultipleContentTypesOnRequestsImpl; +import com.cadl.multicontenttypes.models.Resource; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous MultiContentTypesClient type. + */ +@ServiceClient(builder = MultiContentTypesClientBuilder.class, isAsync = true) +public final class MultipleContentTypesOnRequestAsyncClient { + @Generated + private final MultipleContentTypesOnRequestsImpl serviceClient; + + /** + * Initializes an instance of MultipleContentTypesOnRequestAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MultipleContentTypesOnRequestAsyncClient(MultipleContentTypesOnRequestsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * one data type maps to multiple content types. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "application/octet-stream", "image/jpeg", + * "image/png", "application/json-patch+json". + * @param data The data 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> uploadBytesWithSingleBodyTypeForMultiContentTypesWithResponse(String contentType, + BinaryData data, RequestOptions requestOptions) { + // Convenience API is not generated, as operation 'uploadBytesWithSingleBodyTypeForMultiContentTypes' is + // multiple content-type + return this.serviceClient.uploadBytesWithSingleBodyTypeForMultiContentTypesWithResponseAsync(contentType, data, + requestOptions); + } + + /** + * multiple data types map to multiple content types using shared route. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "application/octet-stream", "image/jpeg", + * "image/png". + * @param data The data 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> uploadBytesWithMultiBodyTypesForMultiContentTypesWithResponse(String contentType, + BinaryData data, RequestOptions requestOptions) { + // Convenience API is not generated, as operation 'uploadBytesWithMultiBodyTypesForMultiContentTypes' is + // multiple content-type + return this.serviceClient.uploadBytesWithMultiBodyTypesForMultiContentTypesWithResponseAsync(contentType, data, + requestOptions); + } + + /** + * multiple data types map to multiple content types using shared route. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param data The data 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> uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse(BinaryData data, + RequestOptions requestOptions) { + return this.serviceClient.uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponseAsync(data, + requestOptions); + } + + /** + * multiple data types map to multiple content types using shared route. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "application/json", "application/octet-stream", + * "image/jpeg", "image/png". + * @param data The data 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> uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponse(String contentType, + BinaryData data, RequestOptions requestOptions) { + // Convenience API is not generated, as operation 'uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes' is + // multiple content-type + return this.serviceClient.uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponseAsync(contentType, + data, requestOptions); + } + + /** + * multiple data types map to multiple content types using shared route. + * + * @param data The data 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 uploadJsonWithMultiBodyTypesForMultiContentTypes(Resource data) { + // Generated convenience method for uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse(BinaryData.fromObject(data), requestOptions) + .flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestClient.java new file mode 100644 index 000000000..a80a640c1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/MultipleContentTypesOnRequestClient.java @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes; + +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.cadl.multicontenttypes.implementation.MultipleContentTypesOnRequestsImpl; +import com.cadl.multicontenttypes.models.Resource; + +/** + * Initializes a new instance of the synchronous MultiContentTypesClient type. + */ +@ServiceClient(builder = MultiContentTypesClientBuilder.class) +public final class MultipleContentTypesOnRequestClient { + @Generated + private final MultipleContentTypesOnRequestsImpl serviceClient; + + /** + * Initializes an instance of MultipleContentTypesOnRequestClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MultipleContentTypesOnRequestClient(MultipleContentTypesOnRequestsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * one data type maps to multiple content types. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "application/octet-stream", "image/jpeg", + * "image/png", "application/json-patch+json". + * @param data The data 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 uploadBytesWithSingleBodyTypeForMultiContentTypesWithResponse(String contentType, + BinaryData data, RequestOptions requestOptions) { + // Convenience API is not generated, as operation 'uploadBytesWithSingleBodyTypeForMultiContentTypes' is + // multiple content-type + return this.serviceClient.uploadBytesWithSingleBodyTypeForMultiContentTypesWithResponse(contentType, data, + requestOptions); + } + + /** + * multiple data types map to multiple content types using shared route. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "application/octet-stream", "image/jpeg", + * "image/png". + * @param data The data 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 uploadBytesWithMultiBodyTypesForMultiContentTypesWithResponse(String contentType, + BinaryData data, RequestOptions requestOptions) { + // Convenience API is not generated, as operation 'uploadBytesWithMultiBodyTypesForMultiContentTypes' is + // multiple content-type + return this.serviceClient.uploadBytesWithMultiBodyTypesForMultiContentTypesWithResponse(contentType, data, + requestOptions); + } + + /** + * multiple data types map to multiple content types using shared route. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param data The data 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 uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse(BinaryData data, + RequestOptions requestOptions) { + return this.serviceClient.uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse(data, requestOptions); + } + + /** + * multiple data types map to multiple content types using shared route. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "application/json", "application/octet-stream", + * "image/jpeg", "image/png". + * @param data The data 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 uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponse(String contentType, + BinaryData data, RequestOptions requestOptions) { + // Convenience API is not generated, as operation 'uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes' is + // multiple content-type + return this.serviceClient.uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponse(contentType, data, + requestOptions); + } + + /** + * multiple data types map to multiple content types using shared route. + * + * @param data The data 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 uploadJsonWithMultiBodyTypesForMultiContentTypes(Resource data) { + // Generated convenience method for uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse(BinaryData.fromObject(data), requestOptions) + .getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/SingleContentTypeAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/SingleContentTypeAsyncClient.java new file mode 100644 index 000000000..75e5b8c9a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/SingleContentTypeAsyncClient.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes; + +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 com.cadl.multicontenttypes.implementation.SingleContentTypesImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous MultiContentTypesClient type. + */ +@ServiceClient(builder = MultiContentTypesClientBuilder.class, isAsync = true) +public final class SingleContentTypeAsyncClient { + @Generated + private final SingleContentTypesImpl serviceClient; + + /** + * Initializes an instance of SingleContentTypeAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SingleContentTypeAsyncClient(SingleContentTypesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * response is binary. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> downloadImageForSingleContentTypeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.downloadImageForSingleContentTypeWithResponseAsync(requestOptions); + } + + /** + * request is binary. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param data The data 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> uploadImageForSingleContentTypeWithResponse(BinaryData data, + RequestOptions requestOptions) { + return this.serviceClient.uploadImageForSingleContentTypeWithResponseAsync(data, requestOptions); + } + + /** + * response is binary. + * + * @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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono downloadImageForSingleContentType() { + // Generated convenience method for downloadImageForSingleContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadImageForSingleContentTypeWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * request is binary. + * + * @param data The data 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 uploadImageForSingleContentType(BinaryData data) { + // Generated convenience method for uploadImageForSingleContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadImageForSingleContentTypeWithResponse(data, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/SingleContentTypeClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/SingleContentTypeClient.java new file mode 100644 index 000000000..d1eb7fd33 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/SingleContentTypeClient.java @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes; + +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.cadl.multicontenttypes.implementation.SingleContentTypesImpl; + +/** + * Initializes a new instance of the synchronous MultiContentTypesClient type. + */ +@ServiceClient(builder = MultiContentTypesClientBuilder.class) +public final class SingleContentTypeClient { + @Generated + private final SingleContentTypesImpl serviceClient; + + /** + * Initializes an instance of SingleContentTypeClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SingleContentTypeClient(SingleContentTypesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * response is binary. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response downloadImageForSingleContentTypeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.downloadImageForSingleContentTypeWithResponse(requestOptions); + } + + /** + * request is binary. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param data The data 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 uploadImageForSingleContentTypeWithResponse(BinaryData data, RequestOptions requestOptions) { + return this.serviceClient.uploadImageForSingleContentTypeWithResponse(data, requestOptions); + } + + /** + * response is binary. + * + * @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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData downloadImageForSingleContentType() { + // Generated convenience method for downloadImageForSingleContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadImageForSingleContentTypeWithResponse(requestOptions).getValue(); + } + + /** + * request is binary. + * + * @param data The data 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 uploadImageForSingleContentType(BinaryData data) { + // Generated convenience method for uploadImageForSingleContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadImageForSingleContentTypeWithResponse(data, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/implementation/MultiContentTypesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/implementation/MultiContentTypesClientImpl.java new file mode 100644 index 000000000..cf7ce9bb3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/implementation/MultiContentTypesClientImpl.java @@ -0,0 +1,228 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes.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 MultiContentTypesClient type. + */ +public final class MultiContentTypesClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MultiContentTypesClientService 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; + } + + /** + * The SingleContentTypesImpl object to access its operations. + */ + private final SingleContentTypesImpl singleContentTypes; + + /** + * Gets the SingleContentTypesImpl object to access its operations. + * + * @return the SingleContentTypesImpl object. + */ + public SingleContentTypesImpl getSingleContentTypes() { + return this.singleContentTypes; + } + + /** + * The MultipleContentTypesOnRequestsImpl object to access its operations. + */ + private final MultipleContentTypesOnRequestsImpl multipleContentTypesOnRequests; + + /** + * Gets the MultipleContentTypesOnRequestsImpl object to access its operations. + * + * @return the MultipleContentTypesOnRequestsImpl object. + */ + public MultipleContentTypesOnRequestsImpl getMultipleContentTypesOnRequests() { + return this.multipleContentTypesOnRequests; + } + + /** + * Initializes an instance of MultiContentTypesClient client. + * + * @param endpoint Service host. + */ + public MultiContentTypesClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of MultiContentTypesClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public MultiContentTypesClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of MultiContentTypesClient 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 MultiContentTypesClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.singleContentTypes = new SingleContentTypesImpl(this); + this.multipleContentTypesOnRequests = new MultipleContentTypesOnRequestsImpl(this); + this.service + = RestProxy.create(MultiContentTypesClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for MultiContentTypesClient to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "MultiContentTypesCli") + public interface MultiContentTypesClientService { + @Post("/upload/overload/multi-body-types") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadWithOverload(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); + + @Post("/upload/overload/multi-body-types") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadWithOverloadSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); + } + + /** + * multiple data types map to multiple content types. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "text/plain", "application/json", + * "application/octet-stream", "image/jpeg", "image/png". + * @param data The data 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> uploadWithOverloadWithResponseAsync(String contentType, BinaryData data, + RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.uploadWithOverload(this.getEndpoint(), contentType, data, requestOptions, context)); + } + + /** + * multiple data types map to multiple content types. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "text/plain", "application/json", + * "application/octet-stream", "image/jpeg", "image/png". + * @param data The data 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 uploadWithOverloadWithResponse(String contentType, BinaryData data, + RequestOptions requestOptions) { + return service.uploadWithOverloadSync(this.getEndpoint(), contentType, data, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/implementation/MultipleContentTypesOnRequestsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/implementation/MultipleContentTypesOnRequestsImpl.java new file mode 100644 index 000000000..ddbc56d4d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/implementation/MultipleContentTypesOnRequestsImpl.java @@ -0,0 +1,348 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in MultipleContentTypesOnRequests. + */ +public final class MultipleContentTypesOnRequestsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MultipleContentTypesOnRequestsService service; + + /** + * The service client containing this operation class. + */ + private final MultiContentTypesClientImpl client; + + /** + * Initializes an instance of MultipleContentTypesOnRequestsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + MultipleContentTypesOnRequestsImpl(MultiContentTypesClientImpl client) { + this.service = RestProxy.create(MultipleContentTypesOnRequestsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MultiContentTypesClientMultipleContentTypesOnRequests to be used by + * the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "MultiContentTypesCli") + public interface MultipleContentTypesOnRequestsService { + @Post("/multiple/sharedroute/request/upload/single-body-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadBytesWithSingleBodyTypeForMultiContentTypes(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); + + @Post("/multiple/sharedroute/request/upload/single-body-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadBytesWithSingleBodyTypeForMultiContentTypesSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); + + @Post("/multiple/sharedroute/request/upload/multi-body-types") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadBytesWithMultiBodyTypesForMultiContentTypes(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); + + @Post("/multiple/sharedroute/request/upload/multi-body-types") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadBytesWithMultiBodyTypesForMultiContentTypesSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); + + @Post("/multiple/sharedroute/request/upload/multi-body-types") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadJsonWithMultiBodyTypesForMultiContentTypes(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); + + @Post("/multiple/sharedroute/request/upload/multi-body-types") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadJsonWithMultiBodyTypesForMultiContentTypesSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData data, + RequestOptions requestOptions, Context context); + + @Post("/multiple/sharedroute/request/upload/multi-body-types") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes( + @HostParam("endpoint") String endpoint, @HeaderParam("content-type") String contentType, + @BodyParam("application/json") BinaryData data, RequestOptions requestOptions, Context context); + + @Post("/multiple/sharedroute/request/upload/multi-body-types") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesSync( + @HostParam("endpoint") String endpoint, @HeaderParam("content-type") String contentType, + @BodyParam("application/json") BinaryData data, RequestOptions requestOptions, Context context); + } + + /** + * one data type maps to multiple content types. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "application/octet-stream", "image/jpeg", + * "image/png", "application/json-patch+json". + * @param data The data 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> uploadBytesWithSingleBodyTypeForMultiContentTypesWithResponseAsync(String contentType, + BinaryData data, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.uploadBytesWithSingleBodyTypeForMultiContentTypes(this.client.getEndpoint(), + contentType, data, requestOptions, context)); + } + + /** + * one data type maps to multiple content types. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "application/octet-stream", "image/jpeg", + * "image/png", "application/json-patch+json". + * @param data The data 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 uploadBytesWithSingleBodyTypeForMultiContentTypesWithResponse(String contentType, + BinaryData data, RequestOptions requestOptions) { + return service.uploadBytesWithSingleBodyTypeForMultiContentTypesSync(this.client.getEndpoint(), contentType, + data, requestOptions, Context.NONE); + } + + /** + * multiple data types map to multiple content types using shared route. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "application/octet-stream", "image/jpeg", + * "image/png". + * @param data The data 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> uploadBytesWithMultiBodyTypesForMultiContentTypesWithResponseAsync(String contentType, + BinaryData data, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.uploadBytesWithMultiBodyTypesForMultiContentTypes(this.client.getEndpoint(), + contentType, data, requestOptions, context)); + } + + /** + * multiple data types map to multiple content types using shared route. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "application/octet-stream", "image/jpeg", + * "image/png". + * @param data The data 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 uploadBytesWithMultiBodyTypesForMultiContentTypesWithResponse(String contentType, + BinaryData data, RequestOptions requestOptions) { + return service.uploadBytesWithMultiBodyTypesForMultiContentTypesSync(this.client.getEndpoint(), contentType, + data, requestOptions, Context.NONE); + } + + /** + * multiple data types map to multiple content types using shared route. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param data The data 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> uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponseAsync(BinaryData data, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.uploadJsonWithMultiBodyTypesForMultiContentTypes(this.client.getEndpoint(), + contentType, data, requestOptions, context)); + } + + /** + * multiple data types map to multiple content types using shared route. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param data The data 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 uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse(BinaryData data, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.uploadJsonWithMultiBodyTypesForMultiContentTypesSync(this.client.getEndpoint(), contentType, + data, requestOptions, Context.NONE); + } + + /** + * multiple data types map to multiple content types using shared route. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "application/json", "application/octet-stream", + * "image/jpeg", "image/png". + * @param data The data 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> uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponseAsync( + String contentType, BinaryData data, RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes( + this.client.getEndpoint(), contentType, data, requestOptions, context)); + } + + /** + * multiple data types map to multiple content types using shared route. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param contentType The contentType parameter. Allowed values: "application/json", "application/octet-stream", + * "image/jpeg", "image/png". + * @param data The data 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 uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesWithResponse(String contentType, + BinaryData data, RequestOptions requestOptions) { + return service.uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypesSync(this.client.getEndpoint(), + contentType, data, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/implementation/SingleContentTypesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/implementation/SingleContentTypesImpl.java new file mode 100644 index 000000000..5ed3adbc9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/implementation/SingleContentTypesImpl.java @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in SingleContentTypes. + */ +public final class SingleContentTypesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SingleContentTypesService service; + + /** + * The service client containing this operation class. + */ + private final MultiContentTypesClientImpl client; + + /** + * Initializes an instance of SingleContentTypesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SingleContentTypesImpl(MultiContentTypesClientImpl client) { + this.service = RestProxy.create(SingleContentTypesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MultiContentTypesClientSingleContentTypes to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "MultiContentTypesCli") + public interface SingleContentTypesService { + @Get("/single/request/download/image") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> downloadImageForSingleContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/single/request/download/image") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response downloadImageForSingleContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/single/request/upload/image") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadImageForSingleContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("image/png") BinaryData data, + RequestOptions requestOptions, Context context); + + @Post("/single/request/upload/image") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadImageForSingleContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("image/png") BinaryData data, + RequestOptions requestOptions, Context context); + } + + /** + * response is binary. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> + downloadImageForSingleContentTypeWithResponseAsync(RequestOptions requestOptions) { + final String accept = "image/png"; + return FluxUtil.withContext(context -> service.downloadImageForSingleContentType(this.client.getEndpoint(), + accept, requestOptions, context)); + } + + /** + * response is binary. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response downloadImageForSingleContentTypeWithResponse(RequestOptions requestOptions) { + final String accept = "image/png"; + return service.downloadImageForSingleContentTypeSync(this.client.getEndpoint(), accept, requestOptions, + Context.NONE); + } + + /** + * request is binary. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param data The data 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> uploadImageForSingleContentTypeWithResponseAsync(BinaryData data, + RequestOptions requestOptions) { + final String contentType = "image/png"; + return FluxUtil.withContext(context -> service.uploadImageForSingleContentType(this.client.getEndpoint(), + contentType, data, requestOptions, context)); + } + + /** + * request is binary. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param data The data 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 uploadImageForSingleContentTypeWithResponse(BinaryData data, RequestOptions requestOptions) { + final String contentType = "image/png"; + return service.uploadImageForSingleContentTypeSync(this.client.getEndpoint(), contentType, data, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/implementation/package-info.java new file mode 100644 index 000000000..ddb26762e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 MultiContentTypes. + * + */ +package com.cadl.multicontenttypes.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/Resource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/Resource.java new file mode 100644 index 000000000..3a3afa107 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/Resource.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 com.cadl.multicontenttypes.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; + +/** + * The Resource model. + */ +@Immutable +public final class Resource implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private String name; + + /** + * Creates an instance of Resource class. + */ + @Generated + public Resource() { + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource 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 Resource. + */ + @Generated + public static Resource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Resource deserializedResource = new Resource(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedResource.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedResource.name = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedResource; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/package-info.java new file mode 100644 index 000000000..dfcd5b656 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/models/package-info.java @@ -0,0 +1,10 @@ +// 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 MultiContentTypes. + * + */ +package com.cadl.multicontenttypes.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/package-info.java new file mode 100644 index 000000000..513e267ca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multicontenttypes/package-info.java @@ -0,0 +1,10 @@ +// 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 MultiContentTypes. + * + */ +package com.cadl.multicontenttypes; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/MultipartAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/MultipartAsyncClient.java new file mode 100644 index 000000000..64bf5d3ae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/MultipartAsyncClient.java @@ -0,0 +1,245 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipart; + +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 com.cadl.multipart.implementation.MultipartClientImpl; +import com.cadl.multipart.implementation.MultipartFormDataHelper; +import com.cadl.multipart.models.FileDataFileDetails; +import com.cadl.multipart.models.FormData; +import com.cadl.multipart.models.UploadHttpPartRequest; +import java.util.Objects; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous MultipartClient type. + */ +@ServiceClient(builder = MultipartClientBuilder.class, isAsync = true) +public final class MultipartAsyncClient { + @Generated + private final MultipartClientImpl serviceClient; + + /** + * Initializes an instance of MultipartAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MultipartAsyncClient(MultipartClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The upload operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
compressBooleanNoThe compress parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param name The name parameter. + * @param data The data 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) + Mono> uploadWithResponse(String name, BinaryData data, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'upload' is + // 'multipart/form-data' + return this.serviceClient.uploadWithResponseAsync(name, data, requestOptions); + } + + /** + * The uploadHttpPart operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
compressBooleanNoThe compress parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param name The name parameter. + * @param body The body 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) + Mono> uploadHttpPartWithResponse(String name, BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'uploadHttpPart' + // is 'multipart/form-data' + return this.serviceClient.uploadHttpPartWithResponseAsync(name, body, requestOptions); + } + + /** + * The upload operation. + * + * @param name The name parameter. + * @param data The data parameter. + * @param compress The compress 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 upload(String name, FormData data, Boolean compress) { + // Generated convenience method for uploadWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (compress != null) { + requestOptions.addQueryParam("compress", String.valueOf(compress), false); + } + return uploadWithResponse(name, new MultipartFormDataHelper(requestOptions) + .serializeTextField("name", data.getName()) + .serializeTextField("resolution", String.valueOf(data.getResolution())) + .serializeTextField("type", Objects.toString(data.getType())) + .serializeJsonField("size", data.getSize()) + .serializeFileField("image", data.getImage().getContent(), data.getImage().getContentType(), + data.getImage().getFilename()) + .serializeFileFields("fileData", + data.getFileData() == null + ? null + : data.getFileData().stream().map(FileDataFileDetails::getContent).collect(Collectors.toList()), + data.getFileData() == null + ? null + : data.getFileData().stream().map(FileDataFileDetails::getContentType).collect(Collectors.toList()), + data.getFileData() == null + ? null + : data.getFileData().stream().map(FileDataFileDetails::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The upload operation. + * + * @param name The name parameter. + * @param data The data 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 upload(String name, FormData data) { + // Generated convenience method for uploadWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadWithResponse(name, new MultipartFormDataHelper(requestOptions) + .serializeTextField("name", data.getName()) + .serializeTextField("resolution", String.valueOf(data.getResolution())) + .serializeTextField("type", Objects.toString(data.getType())) + .serializeJsonField("size", data.getSize()) + .serializeFileField("image", data.getImage().getContent(), data.getImage().getContentType(), + data.getImage().getFilename()) + .serializeFileFields("fileData", + data.getFileData() == null + ? null + : data.getFileData().stream().map(FileDataFileDetails::getContent).collect(Collectors.toList()), + data.getFileData() == null + ? null + : data.getFileData().stream().map(FileDataFileDetails::getContentType).collect(Collectors.toList()), + data.getFileData() == null + ? null + : data.getFileData().stream().map(FileDataFileDetails::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The uploadHttpPart operation. + * + * @param name The name parameter. + * @param body The body parameter. + * @param compress The compress 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 uploadHttpPart(String name, UploadHttpPartRequest body, Boolean compress) { + // Generated convenience method for uploadHttpPartWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (compress != null) { + requestOptions.addQueryParam("compress", String.valueOf(compress), false); + } + return uploadHttpPartWithResponse(name, + new MultipartFormDataHelper(requestOptions) + .serializeFileField("fileData1", body.getFileData1().getContent(), body.getFileData1().getContentType(), + body.getFileData1().getFilename()) + .serializeFileField("fileData2", body.getFileData2().getContent(), body.getFileData2().getContentType(), + body.getFileData2().getFilename()) + .serializeJsonField("size", body.getSize()) + .end() + .getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The uploadHttpPart operation. + * + * @param name The name parameter. + * @param body The body 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 uploadHttpPart(String name, UploadHttpPartRequest body) { + // Generated convenience method for uploadHttpPartWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadHttpPartWithResponse(name, + new MultipartFormDataHelper(requestOptions) + .serializeFileField("fileData1", body.getFileData1().getContent(), body.getFileData1().getContentType(), + body.getFileData1().getFilename()) + .serializeFileField("fileData2", body.getFileData2().getContent(), body.getFileData2().getContentType(), + body.getFileData2().getFilename()) + .serializeJsonField("size", body.getSize()) + .end() + .getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/MultipartClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/MultipartClient.java new file mode 100644 index 000000000..ec7a4b1b0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/MultipartClient.java @@ -0,0 +1,237 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipart; + +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.cadl.multipart.implementation.MultipartClientImpl; +import com.cadl.multipart.implementation.MultipartFormDataHelper; +import com.cadl.multipart.models.FileDataFileDetails; +import com.cadl.multipart.models.FormData; +import com.cadl.multipart.models.UploadHttpPartRequest; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Initializes a new instance of the synchronous MultipartClient type. + */ +@ServiceClient(builder = MultipartClientBuilder.class) +public final class MultipartClient { + @Generated + private final MultipartClientImpl serviceClient; + + /** + * Initializes an instance of MultipartClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MultipartClient(MultipartClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The upload operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
compressBooleanNoThe compress parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param name The name parameter. + * @param data The data 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) + Response uploadWithResponse(String name, BinaryData data, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'upload' is + // 'multipart/form-data' + return this.serviceClient.uploadWithResponse(name, data, requestOptions); + } + + /** + * The uploadHttpPart operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
compressBooleanNoThe compress parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param name The name parameter. + * @param body The body 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) + Response uploadHttpPartWithResponse(String name, BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'uploadHttpPart' + // is 'multipart/form-data' + return this.serviceClient.uploadHttpPartWithResponse(name, body, requestOptions); + } + + /** + * The upload operation. + * + * @param name The name parameter. + * @param data The data parameter. + * @param compress The compress 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 upload(String name, FormData data, Boolean compress) { + // Generated convenience method for uploadWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (compress != null) { + requestOptions.addQueryParam("compress", String.valueOf(compress), false); + } + uploadWithResponse(name, new MultipartFormDataHelper(requestOptions).serializeTextField("name", data.getName()) + .serializeTextField("resolution", String.valueOf(data.getResolution())) + .serializeTextField("type", Objects.toString(data.getType())) + .serializeJsonField("size", data.getSize()) + .serializeFileField("image", data.getImage().getContent(), data.getImage().getContentType(), + data.getImage().getFilename()) + .serializeFileFields("fileData", + data.getFileData() == null + ? null + : data.getFileData().stream().map(FileDataFileDetails::getContent).collect(Collectors.toList()), + data.getFileData() == null + ? null + : data.getFileData().stream().map(FileDataFileDetails::getContentType).collect(Collectors.toList()), + data.getFileData() == null + ? null + : data.getFileData().stream().map(FileDataFileDetails::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), requestOptions).getValue(); + } + + /** + * The upload operation. + * + * @param name The name parameter. + * @param data The data 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 upload(String name, FormData data) { + // Generated convenience method for uploadWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadWithResponse(name, new MultipartFormDataHelper(requestOptions).serializeTextField("name", data.getName()) + .serializeTextField("resolution", String.valueOf(data.getResolution())) + .serializeTextField("type", Objects.toString(data.getType())) + .serializeJsonField("size", data.getSize()) + .serializeFileField("image", data.getImage().getContent(), data.getImage().getContentType(), + data.getImage().getFilename()) + .serializeFileFields("fileData", + data.getFileData() == null + ? null + : data.getFileData().stream().map(FileDataFileDetails::getContent).collect(Collectors.toList()), + data.getFileData() == null + ? null + : data.getFileData().stream().map(FileDataFileDetails::getContentType).collect(Collectors.toList()), + data.getFileData() == null + ? null + : data.getFileData().stream().map(FileDataFileDetails::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), requestOptions).getValue(); + } + + /** + * The uploadHttpPart operation. + * + * @param name The name parameter. + * @param body The body parameter. + * @param compress The compress 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 uploadHttpPart(String name, UploadHttpPartRequest body, Boolean compress) { + // Generated convenience method for uploadHttpPartWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (compress != null) { + requestOptions.addQueryParam("compress", String.valueOf(compress), false); + } + uploadHttpPartWithResponse(name, + new MultipartFormDataHelper(requestOptions) + .serializeFileField("fileData1", body.getFileData1().getContent(), body.getFileData1().getContentType(), + body.getFileData1().getFilename()) + .serializeFileField("fileData2", body.getFileData2().getContent(), body.getFileData2().getContentType(), + body.getFileData2().getFilename()) + .serializeJsonField("size", body.getSize()) + .end() + .getRequestBody(), + requestOptions).getValue(); + } + + /** + * The uploadHttpPart operation. + * + * @param name The name parameter. + * @param body The body 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 uploadHttpPart(String name, UploadHttpPartRequest body) { + // Generated convenience method for uploadHttpPartWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadHttpPartWithResponse(name, + new MultipartFormDataHelper(requestOptions) + .serializeFileField("fileData1", body.getFileData1().getContent(), body.getFileData1().getContentType(), + body.getFileData1().getFilename()) + .serializeFileField("fileData2", body.getFileData2().getContent(), body.getFileData2().getContentType(), + body.getFileData2().getFilename()) + .serializeJsonField("size", body.getSize()) + .end() + .getRequestBody(), + requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/MultipartClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/MultipartClientBuilder.java new file mode 100644 index 000000000..fee41a53d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/MultipartClientBuilder.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 com.cadl.multipart; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.multipart.implementation.MultipartClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the MultipartClient type. + */ +@ServiceClientBuilder(serviceClients = { MultipartClient.class, MultipartAsyncClient.class }) +public final class MultipartClientBuilder 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("cadl-multipart.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the MultipartClientBuilder. + */ + @Generated + public MultipartClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultipartClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultipartClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultipartClientBuilder 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 MultipartClientBuilder 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 MultipartClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultipartClientBuilder 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 MultipartClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultipartClientBuilder 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 MultipartClientBuilder. + */ + @Generated + public MultipartClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of MultipartClientImpl with the provided parameters. + * + * @return an instance of MultipartClientImpl. + */ + @Generated + private MultipartClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + MultipartClientImpl client + = new MultipartClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 MultipartAsyncClient class. + * + * @return an instance of MultipartAsyncClient. + */ + @Generated + public MultipartAsyncClient buildAsyncClient() { + return new MultipartAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of MultipartClient class. + * + * @return an instance of MultipartClient. + */ + @Generated + public MultipartClient buildClient() { + return new MultipartClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(MultipartClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/implementation/MultipartClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/implementation/MultipartClientImpl.java new file mode 100644 index 000000000..c0b1c8753 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/implementation/MultipartClientImpl.java @@ -0,0 +1,275 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipart.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.PathParam; +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 MultipartClient type. + */ +public final class MultipartClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MultipartClientService 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 MultipartClient client. + * + * @param endpoint Service host. + */ + public MultipartClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of MultipartClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public MultipartClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of MultipartClient 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 MultipartClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(MultipartClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for MultipartClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "MultipartClient") + public interface MultipartClientService { + // @Multipart not supported by RestProxy + @Post("/upload/images/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> upload(@HostParam("endpoint") String endpoint, @PathParam("name") String name, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData data, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/upload/images/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadSync(@HostParam("endpoint") String endpoint, @PathParam("name") String name, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData data, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/uploadHttpPart/images/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadHttpPart(@HostParam("endpoint") String endpoint, @PathParam("name") String name, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/uploadHttpPart/images/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadHttpPartSync(@HostParam("endpoint") String endpoint, @PathParam("name") String name, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The upload operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
compressBooleanNoThe compress parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param name The name parameter. + * @param data The data 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> uploadWithResponseAsync(String name, BinaryData data, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext( + context -> service.upload(this.getEndpoint(), name, contentType, data, requestOptions, context)); + } + + /** + * The upload operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
compressBooleanNoThe compress parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param name The name parameter. + * @param data The data 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 uploadWithResponse(String name, BinaryData data, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.uploadSync(this.getEndpoint(), name, contentType, data, requestOptions, Context.NONE); + } + + /** + * The uploadHttpPart operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
compressBooleanNoThe compress parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param name The name parameter. + * @param body The body 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> uploadHttpPartWithResponseAsync(String name, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext( + context -> service.uploadHttpPart(this.getEndpoint(), name, contentType, body, requestOptions, context)); + } + + /** + * The uploadHttpPart operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
compressBooleanNoThe compress parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param name The name parameter. + * @param body The body 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 uploadHttpPartWithResponse(String name, BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.uploadHttpPartSync(this.getEndpoint(), name, contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/implementation/MultipartFormDataHelper.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/implementation/MultipartFormDataHelper.java new file mode 100644 index 000000000..8f7d7e597 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/implementation/MultipartFormDataHelper.java @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipart.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.SequenceInputStream; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.UUID; + +// DO NOT modify this helper class + +public final class MultipartFormDataHelper { + /** + * Line separator for the multipart HTTP request. + */ + private static final String CRLF = "\r\n"; + + private static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + /** + * Value to be used as part of the divider for the multipart requests. + */ + private final String boundary; + + /** + * The actual part separator in the request. This is obtained by prepending "--" to the "boundary". + */ + private final String partSeparator; + + /** + * The marker for the ending of a multipart request. This is obtained by post-pending "--" to the "partSeparator". + */ + private final String endMarker; + + /** + * Charset used for encoding the multipart HTTP request. + */ + private final Charset encoderCharset = StandardCharsets.UTF_8; + + private InputStream requestDataStream = new ByteArrayInputStream(new byte[0]); + private long requestLength = 0; + + private RequestOptions requestOptions; + private BinaryData requestBody; + + /** + * Default constructor used in the code. The boundary is a random value. + * + * @param requestOptions the RequestOptions to update + */ + public MultipartFormDataHelper(RequestOptions requestOptions) { + this(requestOptions, UUID.randomUUID().toString().substring(0, 16)); + } + + private MultipartFormDataHelper(RequestOptions requestOptions, String boundary) { + this.requestOptions = requestOptions; + this.boundary = boundary; + this.partSeparator = "--" + boundary; + this.endMarker = this.partSeparator + "--"; + } + + /** + * Gets the multipart HTTP request body. + * + * @return the BinaryData of the multipart HTTP request body + */ + public BinaryData getRequestBody() { + return requestBody; + } + + // text/plain + /** + * Formats a text/plain field for a multipart HTTP request. + * + * @param fieldName the field name + * @param value the value of the text/plain field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeTextField(String fieldName, String value) { + if (value != null) { + String serialized = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + + "\"" + CRLF + CRLF + value + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + // application/json + /** + * Formats a application/json field for a multipart HTTP request. + * + * @param fieldName the field name + * @param jsonObject the object of the application/json field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeJsonField(String fieldName, Object jsonObject) { + if (jsonObject != null) { + String serialized + = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + CRLF + + "Content-Type: application/json" + CRLF + CRLF + BinaryData.fromObject(jsonObject) + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + /** + * Formats a file field for a multipart HTTP request. + * + * @param fieldName the field name + * @param file the BinaryData of the file + * @param contentType the content-type of the file + * @param filename the filename + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileField(String fieldName, BinaryData file, String contentType, + String filename) { + if (file != null) { + if (CoreUtils.isNullOrEmpty(contentType)) { + contentType = APPLICATION_OCTET_STREAM; + } + writeFileField(fieldName, file, contentType, filename); + } + return this; + } + + /** + * Formats a file field (potentially multiple files) for a multipart HTTP request. + * + * @param fieldName the field name + * @param files the List of BinaryData of the files + * @param contentTypes the List of content-type of the files + * @param filenames the List of filenames + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileFields(String fieldName, List files, + List contentTypes, List filenames) { + if (files != null) { + for (int i = 0; i < files.size(); ++i) { + BinaryData file = files.get(i); + String contentType = contentTypes.get(i); + if (CoreUtils.isNullOrEmpty(contentType)) { + contentType = APPLICATION_OCTET_STREAM; + } + String filename = filenames.get(i); + writeFileField(fieldName, file, contentType, filename); + } + } + return this; + } + + /** + * Ends the serialization of the multipart HTTP request. + * + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper end() { + byte[] data = endMarker.getBytes(encoderCharset); + appendBytes(data); + + requestBody = BinaryData.fromStream(requestDataStream, requestLength); + + requestOptions.setHeader(HttpHeaderName.CONTENT_TYPE, "multipart/form-data; boundary=" + this.boundary) + .setHeader(HttpHeaderName.CONTENT_LENGTH, String.valueOf(requestLength)); + + return this; + } + + private void writeFileField(String fieldName, BinaryData file, String contentType, String filename) { + String contentDispositionFilename = ""; + if (!CoreUtils.isNullOrEmpty(filename)) { + contentDispositionFilename = "; filename=\"" + escapeName(filename) + "\""; + } + + // Multipart preamble + String fileFieldPreamble + = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + + contentDispositionFilename + CRLF + "Content-Type: " + contentType + CRLF + CRLF; + byte[] data = fileFieldPreamble.getBytes(encoderCharset); + appendBytes(data); + + // Writing the file into the request as a byte stream + requestLength += file.getLength(); + requestDataStream = new SequenceInputStream(requestDataStream, file.toStream()); + + // CRLF + data = CRLF.getBytes(encoderCharset); + appendBytes(data); + } + + private void appendBytes(byte[] bytes) { + requestLength += bytes.length; + requestDataStream = new SequenceInputStream(requestDataStream, new ByteArrayInputStream(bytes)); + } + + private static String escapeName(String name) { + return name.replace("\n", "%0A").replace("\r", "%0D").replace("\"", "%22"); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/implementation/package-info.java new file mode 100644 index 000000000..4afc28185 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Multipart. + * + */ +package com.cadl.multipart.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/FileDataFileDetails.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/FileDataFileDetails.java new file mode 100644 index 000000000..780bbbd80 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/FileDataFileDetails.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipart.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; + +/** + * The file details for the "fileData" field. + */ +@Fluent +public final class FileDataFileDetails { + /* + * The content of the file. + */ + @Generated + private final BinaryData content; + + /* + * The filename of the file. + */ + @Generated + private String filename; + + /* + * The content-type of the file. + */ + @Generated + private String contentType = "application/octet-stream"; + + /** + * Creates an instance of FileDataFileDetails class. + * + * @param content the content value to set. + */ + @Generated + public FileDataFileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the FileDataFileDetails object itself. + */ + @Generated + public FileDataFileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the FileDataFileDetails object itself. + */ + @Generated + public FileDataFileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/FileDetails.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/FileDetails.java new file mode 100644 index 000000000..74568ac22 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/FileDetails.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipart.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; + +/** + * The file details for the "fileData2" field. + */ +@Fluent +public final class FileDetails { + /* + * The content of the file. + */ + @Generated + private final BinaryData content; + + /* + * The filename of the file. + */ + @Generated + private String filename; + + /* + * The content-type of the file. + */ + @Generated + private String contentType = "application/octet-stream"; + + /** + * Creates an instance of FileDetails class. + * + * @param content the content value to set. + */ + @Generated + public FileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the FileDetails object itself. + */ + @Generated + public FileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the FileDetails object itself. + */ + @Generated + public FileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/FormData.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/FormData.java new file mode 100644 index 000000000..376d1c0d8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/FormData.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipart.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import java.util.List; + +/** + * The FormData model. + */ +@Fluent +public final class FormData { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The resolution property. + */ + @Generated + private final int resolution; + + /* + * The type property. + */ + @Generated + private final ImageType type; + + /* + * The size property. + */ + @Generated + private final Size size; + + /* + * The image property. + */ + @Generated + private final ImageFileDetails image; + + /* + * The fileData property. + */ + @Generated + private List fileData; + + /** + * Creates an instance of FormData class. + * + * @param name the name value to set. + * @param resolution the resolution value to set. + * @param type the type value to set. + * @param size the size value to set. + * @param image the image value to set. + */ + @Generated + public FormData(String name, int resolution, ImageType type, Size size, ImageFileDetails image) { + this.name = name; + this.resolution = resolution; + this.type = type; + this.size = size; + this.image = image; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the resolution property: The resolution property. + * + * @return the resolution value. + */ + @Generated + public int getResolution() { + return this.resolution; + } + + /** + * Get the type property: The type property. + * + * @return the type value. + */ + @Generated + public ImageType getType() { + return this.type; + } + + /** + * Get the size property: The size property. + * + * @return the size value. + */ + @Generated + public Size getSize() { + return this.size; + } + + /** + * Get the image property: The image property. + * + * @return the image value. + */ + @Generated + public ImageFileDetails getImage() { + return this.image; + } + + /** + * Get the fileData property: The fileData property. + * + * @return the fileData value. + */ + @Generated + public List getFileData() { + return this.fileData; + } + + /** + * Set the fileData property: The fileData property. + * + * @param fileData the fileData value to set. + * @return the FormData object itself. + */ + @Generated + public FormData setFileData(List fileData) { + this.fileData = fileData; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/ImageFileDetails.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/ImageFileDetails.java new file mode 100644 index 000000000..57a0cfcca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/ImageFileDetails.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipart.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; + +/** + * The file details for the "image" field. + */ +@Fluent +public final class ImageFileDetails { + /* + * The content of the file. + */ + @Generated + private final BinaryData content; + + /* + * The filename of the file. + */ + @Generated + private String filename; + + /* + * The content-type of the file. + */ + @Generated + private String contentType = "application/octet-stream"; + + /** + * Creates an instance of ImageFileDetails class. + * + * @param content the content value to set. + */ + @Generated + public ImageFileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the ImageFileDetails object itself. + */ + @Generated + public ImageFileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the ImageFileDetails object itself. + */ + @Generated + public ImageFileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/ImageType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/ImageType.java new file mode 100644 index 000000000..e0d7b7819 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/ImageType.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipart.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for ImageType. + */ +public final class ImageType extends ExpandableStringEnum { + /** + * Static value JPEG for ImageType. + */ + @Generated + public static final ImageType JPEG = fromString("JPEG"); + + /** + * Static value PNG for ImageType. + */ + @Generated + public static final ImageType PNG = fromString("PNG"); + + /** + * Creates a new instance of ImageType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ImageType() { + } + + /** + * Creates or finds a ImageType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ImageType. + */ + @Generated + public static ImageType fromString(String name) { + return fromString(name, ImageType.class); + } + + /** + * Gets known ImageType values. + * + * @return known ImageType values. + */ + @Generated + public static Collection values() { + return values(ImageType.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/InheritFileData.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/InheritFileData.java new file mode 100644 index 000000000..61f32493c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/InheritFileData.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 com.cadl.multipart.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.BinaryData; + +/** + * Image file of content-type "image/jpeg" + * + * The file details for the "fileData1" field. + */ +@Immutable +public final class InheritFileData { + /* + * The content of the file. + */ + @Generated + private final BinaryData content; + + /* + * The filename of the file. + */ + @Generated + private final String filename; + + /* + * The content-type of the file. + */ + @Generated + private final String contentType = "image/jpeg"; + + /** + * Creates an instance of InheritFileData class. + * + * @param content the content value to set. + * @param filename the filename value to set. + */ + @Generated + public InheritFileData(BinaryData content, String filename) { + this.content = content; + this.filename = filename; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/Size.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/Size.java new file mode 100644 index 000000000..e5d7ae3ad --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/Size.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipart.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; + +/** + * The Size model. + */ +@Immutable +public final class Size implements JsonSerializable { + /* + * The width property. + */ + @Generated + private final int width; + + /* + * The height property. + */ + @Generated + private final int height; + + /** + * Creates an instance of Size class. + * + * @param width the width value to set. + * @param height the height value to set. + */ + @Generated + public Size(int width, int height) { + this.width = width; + this.height = height; + } + + /** + * Get the width property: The width property. + * + * @return the width value. + */ + @Generated + public int getWidth() { + return this.width; + } + + /** + * Get the height property: The height property. + * + * @return the height value. + */ + @Generated + public int getHeight() { + return this.height; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("width", this.width); + jsonWriter.writeIntField("height", this.height); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Size from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Size 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 Size. + */ + @Generated + public static Size fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int width = 0; + int height = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("width".equals(fieldName)) { + width = reader.getInt(); + } else if ("height".equals(fieldName)) { + height = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new Size(width, height); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/UploadHttpPartRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/UploadHttpPartRequest.java new file mode 100644 index 000000000..e7a84cf54 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/UploadHttpPartRequest.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 com.cadl.multipart.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; + +/** + * The UploadHttpPartRequest model. + */ +@Immutable +public final class UploadHttpPartRequest { + /* + * The fileData1 property. + */ + @Generated + private final InheritFileData fileData1; + + /* + * The fileData2 property. + */ + @Generated + private final FileDetails fileData2; + + /* + * The size property. + */ + @Generated + private final Size size; + + /** + * Creates an instance of UploadHttpPartRequest class. + * + * @param fileData1 the fileData1 value to set. + * @param fileData2 the fileData2 value to set. + * @param size the size value to set. + */ + @Generated + public UploadHttpPartRequest(InheritFileData fileData1, FileDetails fileData2, Size size) { + this.fileData1 = fileData1; + this.fileData2 = fileData2; + this.size = size; + } + + /** + * Get the fileData1 property: The fileData1 property. + * + * @return the fileData1 value. + */ + @Generated + public InheritFileData getFileData1() { + return this.fileData1; + } + + /** + * Get the fileData2 property: The fileData2 property. + * + * @return the fileData2 value. + */ + @Generated + public FileDetails getFileData2() { + return this.fileData2; + } + + /** + * Get the size property: The size property. + * + * @return the size value. + */ + @Generated + public Size getSize() { + return this.size; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/package-info.java new file mode 100644 index 000000000..bc5fa550b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Multipart. + * + */ +package com.cadl.multipart.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/package-info.java new file mode 100644 index 000000000..1dc212a2a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipart/package-info.java @@ -0,0 +1,10 @@ +// 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 Multipart. + * + */ +package com.cadl.multipart; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/FirstAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/FirstAsyncClient.java new file mode 100644 index 000000000..767e682e6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/FirstAsyncClient.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion; + +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 com.cadl.multipleapiversion.implementation.FirstClientImpl; +import com.cadl.multipleapiversion.models.Resource; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous FirstClient type. + */ +@ServiceClient(builder = FirstClientBuilder.class, isAsync = true) +public final class FirstAsyncClient { + @Generated + private final FirstClientImpl serviceClient; + + /** + * Initializes an instance of FirstAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FirstAsyncClient(FirstClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Resource read operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(name, requestOptions); + } + + /** + * Resource read operation template. + * + * @param name The name 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get(String name) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/FirstClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/FirstClient.java new file mode 100644 index 000000000..d69ad98e7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/FirstClient.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion; + +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.cadl.multipleapiversion.implementation.FirstClientImpl; +import com.cadl.multipleapiversion.models.Resource; + +/** + * Initializes a new instance of the synchronous FirstClient type. + */ +@ServiceClient(builder = FirstClientBuilder.class) +public final class FirstClient { + @Generated + private final FirstClientImpl serviceClient; + + /** + * Initializes an instance of FirstClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FirstClient(FirstClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Resource read operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(name, requestOptions); + } + + /** + * Resource read operation template. + * + * @param name The name 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource get(String name) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, requestOptions).getValue().toObject(Resource.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/FirstClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/FirstClientBuilder.java new file mode 100644 index 000000000..d95184ae8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/FirstClientBuilder.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.multipleapiversion.implementation.FirstClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the FirstClient type. + */ +@ServiceClientBuilder(serviceClients = { FirstClient.class, FirstAsyncClient.class }) +public final class FirstClientBuilder 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("cadl-multipleapiversion.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the FirstClientBuilder. + */ + @Generated + public FirstClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FirstClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FirstClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FirstClientBuilder 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 FirstClientBuilder 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 FirstClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FirstClientBuilder 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 FirstClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FirstClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private FirstServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the FirstClientBuilder. + */ + @Generated + public FirstClientBuilder serviceVersion(FirstServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 FirstClientBuilder. + */ + @Generated + public FirstClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of FirstClientImpl with the provided parameters. + * + * @return an instance of FirstClientImpl. + */ + @Generated + private FirstClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + FirstServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : FirstServiceVersion.getLatest(); + FirstClientImpl client = new FirstClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 FirstAsyncClient class. + * + * @return an instance of FirstAsyncClient. + */ + @Generated + public FirstAsyncClient buildAsyncClient() { + return new FirstAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of FirstClient class. + * + * @return an instance of FirstClient. + */ + @Generated + public FirstClient buildClient() { + return new FirstClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(FirstClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/FirstServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/FirstServiceVersion.java new file mode 100644 index 000000000..8e81a5653 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/FirstServiceVersion.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of FirstClient. + */ +public enum FirstServiceVersion implements ServiceVersion { + /** + * Enum value 2022-06-01-preview. + */ + V2022_06_01_PREVIEW("2022-06-01-preview"), + + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + FirstServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link FirstServiceVersion}. + */ + public static FirstServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/NoApiVersionAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/NoApiVersionAsyncClient.java new file mode 100644 index 000000000..bf2245002 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/NoApiVersionAsyncClient.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion; + +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 com.cadl.multipleapiversion.implementation.NoApiVersionClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NoApiVersionClient type. + */ +@ServiceClient(builder = NoApiVersionClientBuilder.class, isAsync = true) +public final class NoApiVersionAsyncClient { + @Generated + private final NoApiVersionClientImpl serviceClient; + + /** + * Initializes an instance of NoApiVersionAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NoApiVersionAsyncClient(NoApiVersionClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The action operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
param1StringNoThe param1 parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> actionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.actionWithResponseAsync(requestOptions); + } + + /** + * The action operation. + * + * @param param1 The param1 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 action(String param1) { + // Generated convenience method for actionWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (param1 != null) { + requestOptions.addQueryParam("param1", param1, false); + } + return actionWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The action 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono action() { + // Generated convenience method for actionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return actionWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/NoApiVersionClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/NoApiVersionClient.java new file mode 100644 index 000000000..8ab00ba55 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/NoApiVersionClient.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 com.cadl.multipleapiversion; + +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.cadl.multipleapiversion.implementation.NoApiVersionClientImpl; + +/** + * Initializes a new instance of the synchronous NoApiVersionClient type. + */ +@ServiceClient(builder = NoApiVersionClientBuilder.class) +public final class NoApiVersionClient { + @Generated + private final NoApiVersionClientImpl serviceClient; + + /** + * Initializes an instance of NoApiVersionClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NoApiVersionClient(NoApiVersionClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The action operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
param1StringNoThe param1 parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 actionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.actionWithResponse(requestOptions); + } + + /** + * The action operation. + * + * @param param1 The param1 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 action(String param1) { + // Generated convenience method for actionWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (param1 != null) { + requestOptions.addQueryParam("param1", param1, false); + } + actionWithResponse(requestOptions).getValue(); + } + + /** + * The action 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void action() { + // Generated convenience method for actionWithResponse + RequestOptions requestOptions = new RequestOptions(); + actionWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/NoApiVersionClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/NoApiVersionClientBuilder.java new file mode 100644 index 000000000..8cce8ffe0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/NoApiVersionClientBuilder.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.multipleapiversion.implementation.NoApiVersionClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the NoApiVersionClient type. + */ +@ServiceClientBuilder(serviceClients = { NoApiVersionClient.class, NoApiVersionAsyncClient.class }) +public final class NoApiVersionClientBuilder 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("cadl-multipleapiversion.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the NoApiVersionClientBuilder. + */ + @Generated + public NoApiVersionClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NoApiVersionClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NoApiVersionClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NoApiVersionClientBuilder 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 NoApiVersionClientBuilder 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 NoApiVersionClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NoApiVersionClientBuilder 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 NoApiVersionClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NoApiVersionClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private NoApiVersionServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the NoApiVersionClientBuilder. + */ + @Generated + public NoApiVersionClientBuilder serviceVersion(NoApiVersionServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 NoApiVersionClientBuilder. + */ + @Generated + public NoApiVersionClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of NoApiVersionClientImpl with the provided parameters. + * + * @return an instance of NoApiVersionClientImpl. + */ + @Generated + private NoApiVersionClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + NoApiVersionServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : NoApiVersionServiceVersion.getLatest(); + NoApiVersionClientImpl client = new NoApiVersionClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 NoApiVersionAsyncClient class. + * + * @return an instance of NoApiVersionAsyncClient. + */ + @Generated + public NoApiVersionAsyncClient buildAsyncClient() { + return new NoApiVersionAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of NoApiVersionClient class. + * + * @return an instance of NoApiVersionClient. + */ + @Generated + public NoApiVersionClient buildClient() { + return new NoApiVersionClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NoApiVersionClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/NoApiVersionServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/NoApiVersionServiceVersion.java new file mode 100644 index 000000000..b01cda2ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/NoApiVersionServiceVersion.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of NoApiVersionClient. + */ +public enum NoApiVersionServiceVersion implements ServiceVersion { + /** + * Enum value 2022-10-01-preview. + */ + V2022_10_01_PREVIEW("2022-10-01-preview"), + + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + NoApiVersionServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link NoApiVersionServiceVersion}. + */ + public static NoApiVersionServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/SecondAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/SecondAsyncClient.java new file mode 100644 index 000000000..14083b48a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/SecondAsyncClient.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion; + +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 com.cadl.multipleapiversion.implementation.SecondClientImpl; +import com.cadl.multipleapiversion.models.Resource2; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SecondClient type. + */ +@ServiceClient(builder = SecondClientBuilder.class, isAsync = true) +public final class SecondAsyncClient { + @Generated + private final SecondClientImpl serviceClient; + + /** + * Initializes an instance of SecondAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SecondAsyncClient(SecondClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Resource read operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(name, requestOptions); + } + + /** + * Resource read operation template. + * + * @param name The name 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get(String name) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource2.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/SecondClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/SecondClient.java new file mode 100644 index 000000000..2a71ef331 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/SecondClient.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion; + +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.cadl.multipleapiversion.implementation.SecondClientImpl; +import com.cadl.multipleapiversion.models.Resource2; + +/** + * Initializes a new instance of the synchronous SecondClient type. + */ +@ServiceClient(builder = SecondClientBuilder.class) +public final class SecondClient { + @Generated + private final SecondClientImpl serviceClient; + + /** + * Initializes an instance of SecondClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SecondClient(SecondClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Resource read operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(name, requestOptions); + } + + /** + * Resource read operation template. + * + * @param name The name 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource2 get(String name) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, requestOptions).getValue().toObject(Resource2.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/SecondClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/SecondClientBuilder.java new file mode 100644 index 000000000..787f3bb96 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/SecondClientBuilder.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.multipleapiversion.implementation.SecondClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the SecondClient type. + */ +@ServiceClientBuilder(serviceClients = { SecondClient.class, SecondAsyncClient.class }) +public final class SecondClientBuilder 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("cadl-multipleapiversion.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the SecondClientBuilder. + */ + @Generated + public SecondClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SecondClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SecondClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SecondClientBuilder 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 SecondClientBuilder 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 SecondClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SecondClientBuilder 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 SecondClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SecondClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private SecondServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the SecondClientBuilder. + */ + @Generated + public SecondClientBuilder serviceVersion(SecondServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 SecondClientBuilder. + */ + @Generated + public SecondClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of SecondClientImpl with the provided parameters. + * + * @return an instance of SecondClientImpl. + */ + @Generated + private SecondClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + SecondServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : SecondServiceVersion.getLatest(); + SecondClientImpl client = new SecondClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 SecondAsyncClient class. + * + * @return an instance of SecondAsyncClient. + */ + @Generated + public SecondAsyncClient buildAsyncClient() { + return new SecondAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of SecondClient class. + * + * @return an instance of SecondClient. + */ + @Generated + public SecondClient buildClient() { + return new SecondClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SecondClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/SecondServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/SecondServiceVersion.java new file mode 100644 index 000000000..93a4cfb69 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/SecondServiceVersion.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of SecondClient. + */ +public enum SecondServiceVersion implements ServiceVersion { + /** + * Enum value 2022-10-01-preview. + */ + V2022_10_01_PREVIEW("2022-10-01-preview"), + + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + SecondServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link SecondServiceVersion}. + */ + public static SecondServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/implementation/FirstClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/implementation/FirstClientImpl.java new file mode 100644 index 000000000..72350c4d9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/implementation/FirstClientImpl.java @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +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.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 com.cadl.multipleapiversion.FirstServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the FirstClient type. + */ +public final class FirstClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FirstClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final FirstServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public FirstServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 FirstClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public FirstClientImpl(String endpoint, FirstServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of FirstClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public FirstClientImpl(HttpPipeline httpPipeline, String endpoint, FirstServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of FirstClient 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. + * @param serviceVersion Service version. + */ + public FirstClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + FirstServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(FirstClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for FirstClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "FirstClient") + public interface FirstClientService { + @Get("/client1/resources/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/client1/resources/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Resource read operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.getEndpoint(), this.getServiceVersion().getVersion(), + name, accept, requestOptions, context)); + } + + /** + * Resource read operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, accept, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/implementation/NoApiVersionClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/implementation/NoApiVersionClientImpl.java new file mode 100644 index 000000000..bd0eb8a1b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/implementation/NoApiVersionClientImpl.java @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.cadl.multipleapiversion.NoApiVersionServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the NoApiVersionClient type. + */ +public final class NoApiVersionClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NoApiVersionClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final NoApiVersionServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public NoApiVersionServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 NoApiVersionClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public NoApiVersionClientImpl(String endpoint, NoApiVersionServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of NoApiVersionClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public NoApiVersionClientImpl(HttpPipeline httpPipeline, String endpoint, + NoApiVersionServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of NoApiVersionClient 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. + * @param serviceVersion Service version. + */ + public NoApiVersionClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + NoApiVersionServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service + = RestProxy.create(NoApiVersionClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for NoApiVersionClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NoApiVersionClient") + public interface NoApiVersionClientService { + @Post("/client3") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> action(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Post("/client3") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response actionSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + } + + /** + * The action operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
param1StringNoThe param1 parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> actionWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.action(this.getEndpoint(), requestOptions, context)); + } + + /** + * The action operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
param1StringNoThe param1 parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 actionWithResponse(RequestOptions requestOptions) { + return service.actionSync(this.getEndpoint(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/implementation/SecondClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/implementation/SecondClientImpl.java new file mode 100644 index 000000000..0e29c7149 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/implementation/SecondClientImpl.java @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +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.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 com.cadl.multipleapiversion.SecondServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the SecondClient type. + */ +public final class SecondClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SecondClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final SecondServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public SecondServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 SecondClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public SecondClientImpl(String endpoint, SecondServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of SecondClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public SecondClientImpl(HttpPipeline httpPipeline, String endpoint, SecondServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of SecondClient 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. + * @param serviceVersion Service version. + */ + public SecondClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + SecondServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(SecondClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for SecondClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SecondClient") + public interface SecondClientService { + @Get("/client2/resources/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/client2/resources/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Resource read operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.getEndpoint(), this.getServiceVersion().getVersion(), + name, accept, requestOptions, context)); + } + + /** + * Resource read operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, accept, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/implementation/package-info.java new file mode 100644 index 000000000..ebd3f681e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 MultipleApiVersion. + * + */ +package com.cadl.multipleapiversion.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/models/Resource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/models/Resource.java new file mode 100644 index 000000000..ac1472cd6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/models/Resource.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion.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; + +/** + * The Resource model. + */ +@Immutable +public final class Resource implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private String name; + + /* + * The type property. + */ + @Generated + private final String type; + + /** + * Creates an instance of Resource class. + * + * @param type the type value to set. + */ + @Generated + private Resource(String type) { + this.type = type; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the type property: The type property. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource 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 Resource. + */ + @Generated + public static Resource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + Resource deserializedResource = new Resource(type); + deserializedResource.id = id; + deserializedResource.name = name; + + return deserializedResource; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/models/Resource2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/models/Resource2.java new file mode 100644 index 000000000..7bc2ab87d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/models/Resource2.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion.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; + +/** + * The Resource2 model. + */ +@Immutable +public final class Resource2 implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private String name; + + /* + * The type property. + */ + @Generated + private final String type; + + /** + * Creates an instance of Resource2 class. + * + * @param type the type value to set. + */ + @Generated + private Resource2(String type) { + this.type = type; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the type property: The type property. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource2 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 Resource2. + */ + @Generated + public static Resource2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + Resource2 deserializedResource2 = new Resource2(type); + deserializedResource2.id = id; + deserializedResource2.name = name; + + return deserializedResource2; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/models/package-info.java new file mode 100644 index 000000000..50dca0d75 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/models/package-info.java @@ -0,0 +1,10 @@ +// 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 MultipleApiVersion. + * + */ +package com.cadl.multipleapiversion.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/package-info.java new file mode 100644 index 000000000..a4473dbd1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/multipleapiversion/package-info.java @@ -0,0 +1,10 @@ +// 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 MultipleApiVersion. + * + */ +package com.cadl.multipleapiversion; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/NamingAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/NamingAsyncClient.java new file mode 100644 index 000000000..53cdb56fe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/NamingAsyncClient.java @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming; + +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.HttpHeaderName; +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 com.cadl.naming.implementation.NamingOpsImpl; +import com.cadl.naming.models.DataRequest; +import com.cadl.naming.models.DataResponse; +import com.cadl.naming.models.GetAnonymousResponse; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NamingClient type. + */ +@ServiceClient(builder = NamingClientBuilder.class, isAsync = true) +public final class NamingAsyncClient { + @Generated + private final NamingOpsImpl serviceClient; + + /** + * Initializes an instance of NamingAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NamingAsyncClient(NamingOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * summary of POST op + * + * description of POST op. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
etagStringNosummary of etag header parameter + * + * description of etag header parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     parameters (Optional): {
+     *         type: String(Type1/Type2) (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     data (Required): {
+     *         data (Required): {
+     *             @data.kind: String (Required)
+     *         }
+     *     }
+     *     type: String(Blob/File) (Required)
+     *     status: String(Running/Completed/Failed) (Required)
+     *     anonymous (Required): {
+     *         last_error (Required): {
+     *             code: String(server_error/rate_limit_exceeded/invalid_prompt) (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param name summary of name query parameter + * + * description of name query parameter. + * @param body The body 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 summary of Response along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postWithResponse(String name, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postWithResponseAsync(name, body, requestOptions); + } + + /** + * The getAnonymous operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAnonymousWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAnonymousWithResponseAsync(requestOptions); + } + + /** + * summary of POST op + * + * description of POST op. + * + * @param name summary of name query parameter + * + * description of name query parameter. + * @param body The body parameter. + * @param etag summary of etag header parameter + * + * description of etag header 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 summary of Response on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono post(String name, DataRequest body, String etag) { + // Generated convenience method for postWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (etag != null) { + requestOptions.setHeader(HttpHeaderName.ETAG, etag); + } + return postWithResponse(name, BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DataResponse.class)); + } + + /** + * summary of POST op + * + * description of POST op. + * + * @param name summary of name query parameter + * + * description of name query parameter. + * @param body The body 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 summary of Response on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono post(String name, DataRequest body) { + // Generated convenience method for postWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postWithResponse(name, BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DataResponse.class)); + } + + /** + * The getAnonymous 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAnonymous() { + // Generated convenience method for getAnonymousWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAnonymousWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetAnonymousResponse.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/NamingClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/NamingClient.java new file mode 100644 index 000000000..2c435a757 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/NamingClient.java @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming; + +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.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.cadl.naming.implementation.NamingOpsImpl; +import com.cadl.naming.models.DataRequest; +import com.cadl.naming.models.DataResponse; +import com.cadl.naming.models.GetAnonymousResponse; + +/** + * Initializes a new instance of the synchronous NamingClient type. + */ +@ServiceClient(builder = NamingClientBuilder.class) +public final class NamingClient { + @Generated + private final NamingOpsImpl serviceClient; + + /** + * Initializes an instance of NamingClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NamingClient(NamingOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Protocol method for POST operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @param body The body parameter. + * @param name summary of name query parameter + * @return summary of Response along with {@link Response}. + * @throws ResourceModifiedException ResourceModifiedException thrown if the request is rejected by server on status + * code 409. + * @throws ResourceNotFoundException ResourceNotFoundException thrown if the request is rejected by server on status + * code 404. + * @throws ClientAuthenticationException ClientAuthenticationException thrown if the request is rejected by server + * on status code 401. + * @throws HttpResponseException HttpResponseException thrown if the request is rejected by server. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postWithResponse(String name, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postWithResponse(name, body, requestOptions); + } + + /** + * The getAnonymous operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAnonymousWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAnonymousWithResponse(requestOptions); + } + + /** + * summary of POST op + * + * description of POST op. + * + * @param name summary of name query parameter + * + * description of name query parameter. + * @param body The body parameter. + * @param etag summary of etag header parameter + * + * description of etag header 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 summary of Response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DataResponse post(String name, DataRequest body, String etag) { + // Generated convenience method for postWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (etag != null) { + requestOptions.setHeader(HttpHeaderName.ETAG, etag); + } + return postWithResponse(name, BinaryData.fromObject(body), requestOptions).getValue() + .toObject(DataResponse.class); + } + + /** + * summary of POST op + * + * description of POST op. + * + * @param name summary of name query parameter + * + * description of name query parameter. + * @param body The body 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 summary of Response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DataResponse post(String name, DataRequest body) { + // Generated convenience method for postWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postWithResponse(name, BinaryData.fromObject(body), requestOptions).getValue() + .toObject(DataResponse.class); + } + + /** + * The getAnonymous 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public GetAnonymousResponse getAnonymous() { + // Generated convenience method for getAnonymousWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAnonymousWithResponse(requestOptions).getValue().toObject(GetAnonymousResponse.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/NamingClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/NamingClientBuilder.java new file mode 100644 index 000000000..f1c45ce59 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/NamingClientBuilder.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 com.cadl.naming; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.naming.implementation.NamingClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the NamingClient type. + */ +@ServiceClientBuilder(serviceClients = { NamingClient.class, NamingAsyncClient.class }) +public final class NamingClientBuilder 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("cadl-naming.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the NamingClientBuilder. + */ + @Generated + public NamingClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NamingClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NamingClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NamingClientBuilder 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 NamingClientBuilder 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 NamingClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NamingClientBuilder 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 NamingClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NamingClientBuilder 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 NamingClientBuilder. + */ + @Generated + public NamingClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of NamingClientImpl with the provided parameters. + * + * @return an instance of NamingClientImpl. + */ + @Generated + private NamingClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + NamingClientImpl client + = new NamingClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 NamingAsyncClient class. + * + * @return an instance of NamingAsyncClient. + */ + @Generated + public NamingAsyncClient buildAsyncClient() { + return new NamingAsyncClient(buildInnerClient().getNamingOps()); + } + + /** + * Builds an instance of NamingClient class. + * + * @return an instance of NamingClient. + */ + @Generated + public NamingClient buildClient() { + return new NamingClient(buildInnerClient().getNamingOps()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NamingClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/NamingClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/NamingClientImpl.java new file mode 100644 index 000000000..e45bea2ae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/NamingClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the NamingClient type. + */ +public final class NamingClientImpl { + /** + * 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; + } + + /** + * The NamingOpsImpl object to access its operations. + */ + private final NamingOpsImpl namingOps; + + /** + * Gets the NamingOpsImpl object to access its operations. + * + * @return the NamingOpsImpl object. + */ + public NamingOpsImpl getNamingOps() { + return this.namingOps; + } + + /** + * Initializes an instance of NamingClient client. + * + * @param endpoint Service host. + */ + public NamingClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NamingClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public NamingClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NamingClient 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 NamingClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.namingOps = new NamingOpsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java new file mode 100644 index 000000000..5ec21c69f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java @@ -0,0 +1,273 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +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.BinaryData; +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 NamingOps. + */ +public final class NamingOpsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NamingOpsService service; + + /** + * The service client containing this operation class. + */ + private final NamingClientImpl client; + + /** + * Initializes an instance of NamingOpsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NamingOpsImpl(NamingClientImpl client) { + this.service + = RestProxy.create(NamingOpsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for NamingClientNamingOps to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NamingClientNamingOp") + public interface NamingOpsService { + @Post("/naming") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> post(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/naming") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response postSync(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Get("/naming") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAnonymous(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/naming") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAnonymousSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * summary of POST op + * + * description of POST op. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
etagStringNosummary of etag header parameter + * + * description of etag header parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     parameters (Optional): {
+     *         type: String(Type1/Type2) (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     data (Required): {
+     *         data (Required): {
+     *             @data.kind: String (Required)
+     *         }
+     *     }
+     *     type: String(Blob/File) (Required)
+     *     status: String(Running/Completed/Failed) (Required)
+     *     anonymous (Required): {
+     *         last_error (Required): {
+     *             code: String(server_error/rate_limit_exceeded/invalid_prompt) (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param name summary of name query parameter + * + * description of name query parameter. + * @param body The body 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 summary of Response along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postWithResponseAsync(String name, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.post(this.client.getEndpoint(), name, contentType, accept, body, + requestOptions, context)); + } + + /** + * summary of POST op + * + * description of POST op. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
etagStringNosummary of etag header parameter + * + * description of etag header parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     parameters (Optional): {
+     *         type: String(Type1/Type2) (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     data (Required): {
+     *         data (Required): {
+     *             @data.kind: String (Required)
+     *         }
+     *     }
+     *     type: String(Blob/File) (Required)
+     *     status: String(Running/Completed/Failed) (Required)
+     *     anonymous (Required): {
+     *         last_error (Required): {
+     *             code: String(server_error/rate_limit_exceeded/invalid_prompt) (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param name summary of name query parameter + * + * description of name query parameter. + * @param body The body 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 summary of Response along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postWithResponse(String name, BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.postSync(this.client.getEndpoint(), name, contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The getAnonymous operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAnonymousWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAnonymous(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getAnonymous operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAnonymousWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAnonymousSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/package-info.java new file mode 100644 index 000000000..e39e9cae6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/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 Naming. + * description of Naming. + * + */ +package com.cadl.naming.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/BinaryData.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/BinaryData.java new file mode 100644 index 000000000..dcc3c9b52 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/BinaryData.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.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; + +/** + * summary of Data + * + * description of Data. + */ +@Immutable +public final class BinaryData implements JsonSerializable { + /* + * summary of data property + * + * description of data property + */ + @Generated + private final Data data; + + /** + * Creates an instance of BinaryData class. + * + * @param data the data value to set. + */ + @Generated + private BinaryData(Data data) { + this.data = data; + } + + /** + * Get the data property: summary of data property + * + * description of data property. + * + * @return the data value. + */ + @Generated + public Data getData() { + return this.data; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("data", this.data); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BinaryData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BinaryData 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 BinaryData. + */ + @Generated + public static BinaryData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Data data = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("data".equals(fieldName)) { + data = Data.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new BinaryData(data); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/BytesData.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/BytesData.java new file mode 100644 index 000000000..bbe0c7965 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/BytesData.java @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The BytesData model. + */ +@Immutable +public final class BytesData extends Data { + /* + * Data as {@code byte[]} + */ + @Generated + private final byte[] dataAsBytes; + + /** + * Creates an instance of BytesData class. + * + * @param dataAsBytes the dataAsBytes value to set. + */ + @Generated + private BytesData(byte[] dataAsBytes) { + this.dataAsBytes = dataAsBytes; + this.type = "bytes"; + } + + /** + * Get the dataAsBytes property: Data as {@code byte[]}. + * + * @return the dataAsBytes value. + */ + @Generated + public byte[] getDataAsBytes() { + return CoreUtils.clone(this.dataAsBytes); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + jsonWriter.writeBinaryField("data_bytes", this.dataAsBytes); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BytesData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BytesData 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 BytesData. + */ + @Generated + public static BytesData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + byte[] dataAsBytes = null; + String type = "bytes"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("data_bytes".equals(fieldName)) { + dataAsBytes = reader.getBinary(); + } else if ("@data.kind".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + BytesData deserializedBytesData = new BytesData(dataAsBytes); + deserializedBytesData.type = type; + + return deserializedBytesData; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/Data.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/Data.java new file mode 100644 index 000000000..e2b92b159 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/Data.java @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.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; + +/** + * Dummy doc to make the javadoc break at the 'at' symbol. The type of the Data depends on + * @data.kind.letusmakeitlongsoitwouldbreakbeforethis field. + */ +@Immutable +public class Data implements JsonSerializable { + /* + * The @data.kind property. + */ + @Generated + String type; + + /** + * Creates an instance of Data class. + */ + @Generated + protected Data() { + this.type = "Data"; + } + + /** + * Get the type property: The @data.kind property. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + void toJsonShared(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStringField("@data.kind", this.type); + } + + /** + * Reads an instance of Data from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Data 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 Data. + */ + @Generated + public static Data fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("@data.kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("bytes".equals(discriminatorValue)) { + return BytesData.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Data fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Data deserializedData = new Data(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if (!Data.fromJsonShared(reader, fieldName, deserializedData)) { + reader.skipChildren(); + } + } + + return deserializedData; + }); + } + + @Generated + static boolean fromJsonShared(JsonReader reader, String fieldName, Data deserializedData) throws IOException { + if ("@data.kind".equals(fieldName)) { + deserializedData.type = reader.getString(); + return true; + } + return false; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/DataRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/DataRequest.java new file mode 100644 index 000000000..7bd569a7f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/DataRequest.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.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; + +/** + * summary of Request + * + * description of Request. + */ +@Fluent +public final class DataRequest implements JsonSerializable { + /* + * The parameters property. + */ + @Generated + private RequestParameters parameters; + + /** + * Creates an instance of DataRequest class. + */ + @Generated + public DataRequest() { + } + + /** + * Get the parameters property: The parameters property. + * + * @return the parameters value. + */ + @Generated + public RequestParameters getParameters() { + return this.parameters; + } + + /** + * Set the parameters property: The parameters property. + * + * @param parameters the parameters value to set. + * @return the DataRequest object itself. + */ + @Generated + public DataRequest setParameters(RequestParameters parameters) { + this.parameters = parameters; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("parameters", this.parameters); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DataRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DataRequest 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 DataRequest. + */ + @Generated + public static DataRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DataRequest deserializedDataRequest = new DataRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("parameters".equals(fieldName)) { + deserializedDataRequest.parameters = RequestParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedDataRequest; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/DataResponse.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/DataResponse.java new file mode 100644 index 000000000..b108d7fa1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/DataResponse.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 com.cadl.naming.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; + +/** + * summary of Response + * + * description of Response. Include tab ' ' in doc. + */ +@Immutable +public final class DataResponse implements JsonSerializable { + /* + * summary of name property + * + * description of name property + */ + @Generated + private final String name; + + /* + * summary of data property + * + * description of data property + */ + @Generated + private final BinaryData data; + + /* + * summary of type property + * + * description of type property + */ + @Generated + private final TypesModel dataType; + + /* + * summary of status property + * + * description of status property + */ + @Generated + private final DataStatus status; + + /* + * The anonymous property. + */ + @Generated + private final RunObject anonymous; + + /** + * Creates an instance of DataResponse class. + * + * @param name the name value to set. + * @param data the data value to set. + * @param dataType the dataType value to set. + * @param status the status value to set. + * @param anonymous the anonymous value to set. + */ + @Generated + private DataResponse(String name, BinaryData data, TypesModel dataType, DataStatus status, RunObject anonymous) { + this.name = name; + this.data = data; + this.dataType = dataType; + this.status = status; + this.anonymous = anonymous; + } + + /** + * Get the name property: summary of name property + * + * description of name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the data property: summary of data property + * + * description of data property. + * + * @return the data value. + */ + @Generated + public BinaryData getData() { + return this.data; + } + + /** + * Get the dataType property: summary of type property + * + * description of type property. + * + * @return the dataType value. + */ + @Generated + public TypesModel getDataType() { + return this.dataType; + } + + /** + * Get the status property: summary of status property + * + * description of status property. + * + * @return the status value. + */ + @Generated + public DataStatus getStatus() { + return this.status; + } + + /** + * Get the anonymous property: The anonymous property. + * + * @return the anonymous value. + */ + @Generated + public RunObject getAnonymous() { + return this.anonymous; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeJsonField("data", this.data); + jsonWriter.writeStringField("type", this.dataType == null ? null : this.dataType.toString()); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("anonymous", this.anonymous); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DataResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DataResponse 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 DataResponse. + */ + @Generated + public static DataResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + BinaryData data = null; + TypesModel dataType = null; + DataStatus status = null; + RunObject anonymous = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("data".equals(fieldName)) { + data = BinaryData.fromJson(reader); + } else if ("type".equals(fieldName)) { + dataType = TypesModel.fromString(reader.getString()); + } else if ("status".equals(fieldName)) { + status = DataStatus.fromString(reader.getString()); + } else if ("anonymous".equals(fieldName)) { + anonymous = RunObject.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new DataResponse(name, data, dataType, status, anonymous); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/DataStatus.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/DataStatus.java new file mode 100644 index 000000000..7bedc2628 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/DataStatus.java @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * summary of Statuses + * + * description of Statuses. + */ +public final class DataStatus extends ExpandableStringEnum { + /** + * Static value Running for DataStatus. + */ + @Generated + public static final DataStatus LRO_RUNNING = fromString("Running"); + + /** + * Static value Completed for DataStatus. + */ + @Generated + public static final DataStatus COMPLETED = fromString("Completed"); + + /** + * Static value Failed for DataStatus. + */ + @Generated + public static final DataStatus FAILED = fromString("Failed"); + + /** + * Creates a new instance of DataStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DataStatus() { + } + + /** + * Creates or finds a DataStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding DataStatus. + */ + @Generated + public static DataStatus fromString(String name) { + return fromString(name, DataStatus.class); + } + + /** + * Gets known DataStatus values. + * + * @return known DataStatus values. + */ + @Generated + public static Collection values() { + return values(DataStatus.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/GetAnonymousResponse.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/GetAnonymousResponse.java new file mode 100644 index 000000000..a976740fb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/GetAnonymousResponse.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.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; + +/** + * The GetAnonymousResponse model. + */ +@Immutable +public final class GetAnonymousResponse implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of GetAnonymousResponse class. + * + * @param name the name value to set. + */ + @Generated + private GetAnonymousResponse(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetAnonymousResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetAnonymousResponse 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 GetAnonymousResponse. + */ + @Generated + public static GetAnonymousResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new GetAnonymousResponse(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RequestParameters.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RequestParameters.java new file mode 100644 index 000000000..893c82569 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RequestParameters.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.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; + +/** + * The RequestParameters model. + */ +@Immutable +public final class RequestParameters implements JsonSerializable { + /* + * The type property. + */ + @Generated + private final RequestParametersType type; + + /** + * Creates an instance of RequestParameters class. + * + * @param type the type value to set. + */ + @Generated + public RequestParameters(RequestParametersType type) { + this.type = type; + } + + /** + * Get the type property: The type property. + * + * @return the type value. + */ + @Generated + public RequestParametersType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RequestParameters from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RequestParameters 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 RequestParameters. + */ + @Generated + public static RequestParameters fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RequestParametersType type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + type = RequestParametersType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new RequestParameters(type); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RequestParametersType.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RequestParametersType.java new file mode 100644 index 000000000..64727e83a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RequestParametersType.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 com.cadl.naming.models; + +/** + * Defines values for RequestParametersType. + */ +public enum RequestParametersType { + /** + * Enum value Type1. + */ + TYPE1("Type1"), + + /** + * Enum value Type2. + */ + TYPE2("Type2"); + + /** + * The actual serialized value for a RequestParametersType instance. + */ + private final String value; + + RequestParametersType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a RequestParametersType instance. + * + * @param value the serialized value to parse. + * @return the parsed RequestParametersType object, or null if unable to parse. + */ + public static RequestParametersType fromString(String value) { + if (value == null) { + return null; + } + RequestParametersType[] items = RequestParametersType.values(); + for (RequestParametersType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RunObject.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RunObject.java new file mode 100644 index 000000000..2ea2601b7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RunObject.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.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; + +/** + * The RunObject model. + */ +@Immutable +public final class RunObject implements JsonSerializable { + /* + * The last_error property. + */ + @Generated + private final RunObjectLastError lastError; + + /** + * Creates an instance of RunObject class. + * + * @param lastError the lastError value to set. + */ + @Generated + private RunObject(RunObjectLastError lastError) { + this.lastError = lastError; + } + + /** + * Get the lastError property: The last_error property. + * + * @return the lastError value. + */ + @Generated + public RunObjectLastError getLastError() { + return this.lastError; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("last_error", this.lastError); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunObject from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunObject 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 RunObject. + */ + @Generated + public static RunObject fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunObjectLastError lastError = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("last_error".equals(fieldName)) { + lastError = RunObjectLastError.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new RunObject(lastError); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RunObjectLastError.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RunObjectLastError.java new file mode 100644 index 000000000..f86625f4a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RunObjectLastError.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.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; + +/** + * The RunObjectLastError model. + */ +@Immutable +public final class RunObjectLastError implements JsonSerializable { + /* + * The code property. + */ + @Generated + private final RunObjectLastErrorCode code; + + /** + * Creates an instance of RunObjectLastError class. + * + * @param code the code value to set. + */ + @Generated + private RunObjectLastError(RunObjectLastErrorCode code) { + this.code = code; + } + + /** + * Get the code property: The code property. + * + * @return the code value. + */ + @Generated + public RunObjectLastErrorCode getCode() { + return this.code; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("code", this.code == null ? null : this.code.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunObjectLastError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunObjectLastError 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 RunObjectLastError. + */ + @Generated + public static RunObjectLastError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunObjectLastErrorCode code = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("code".equals(fieldName)) { + code = RunObjectLastErrorCode.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new RunObjectLastError(code); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RunObjectLastErrorCode.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RunObjectLastErrorCode.java new file mode 100644 index 000000000..ba3acb47a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/RunObjectLastErrorCode.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.models; + +/** + * Defines values for RunObjectLastErrorCode. + */ +public enum RunObjectLastErrorCode { + /** + * Enum value server_error. + */ + SERVER_ERROR("server_error"), + + /** + * Enum value rate_limit_exceeded. + */ + RATE_LIMIT_EXCEEDED("rate_limit_exceeded"), + + /** + * Enum value invalid_prompt. + */ + INVALID_PROMPT("invalid_prompt"); + + /** + * The actual serialized value for a RunObjectLastErrorCode instance. + */ + private final String value; + + RunObjectLastErrorCode(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a RunObjectLastErrorCode instance. + * + * @param value the serialized value to parse. + * @return the parsed RunObjectLastErrorCode object, or null if unable to parse. + */ + public static RunObjectLastErrorCode fromString(String value) { + if (value == null) { + return null; + } + RunObjectLastErrorCode[] items = RunObjectLastErrorCode.values(); + for (RunObjectLastErrorCode item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/TypesModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/TypesModel.java new file mode 100644 index 000000000..8d41bdd85 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/TypesModel.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.models; + +/** + * summary of Types + * + * description of Types. + */ +public enum TypesModel { + /** + * Enum value Blob. + */ + BLOB("Blob"), + + /** + * Enum value File. + */ + FILE("File"); + + /** + * The actual serialized value for a TypesModel instance. + */ + private final String value; + + TypesModel(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a TypesModel instance. + * + * @param value the serialized value to parse. + * @return the parsed TypesModel object, or null if unable to parse. + */ + public static TypesModel fromString(String value) { + if (value == null) { + return null; + } + TypesModel[] items = TypesModel.values(); + for (TypesModel item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/package-info.java new file mode 100644 index 000000000..41c730326 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/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 Naming. + * description of Naming. + * + */ +package com.cadl.naming.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/package-info.java new file mode 100644 index 000000000..12cf7f737 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/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 Naming. + * description of Naming. + * + */ +package com.cadl.naming; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/OptionalAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/OptionalAsyncClient.java new file mode 100644 index 000000000..882eeeed2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/OptionalAsyncClient.java @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.optional; + +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.HttpHeaderName; +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 com.cadl.optional.implementation.OptionalOpsImpl; +import com.cadl.optional.models.AllPropertiesOptional; +import com.cadl.optional.models.Optional; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class OptionalAsyncClient { + @Generated + private final OptionalOpsImpl serviceClient; + + /** + * Initializes an instance of OptionalAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + OptionalAsyncClient(OptionalOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The put operation. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
booleanNullableBooleanNoThe booleanNullable parameter
stringStringNoThe string parameter
stringNullableStringNoThe stringNullable parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
request-header-optionalStringNoThe requestHeaderOptional parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     boolean: Boolean (Optional)
+     *     booleanNullable: Boolean (Optional)
+     *     booleanRequired: boolean (Required)
+     *     booleanRequiredNullable: Boolean (Required)
+     *     string: String (Optional)
+     *     stringNullable: String (Optional)
+     *     stringRequired: String (Required)
+     *     stringRequiredNullable: String (Required)
+     *     bytes: byte[] (Optional)
+     *     int: Integer (Optional)
+     *     long: Long (Optional)
+     *     float: Double (Optional)
+     *     double: Double (Optional)
+     *     duration: Duration (Optional)
+     *     dateTime: OffsetDateTime (Optional)
+     *     stringList (Optional): [
+     *         String (Optional)
+     *     ]
+     *     bytesDict (Optional): {
+     *         String: byte[] (Required)
+     *     }
+     *     epochDateTimeRequiredNullable: Long (Required)
+     *     epochDateTimeNullable: Long (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: Boolean (Optional)
+     *     booleanNullable: Boolean (Optional)
+     *     booleanRequired: Boolean (Optional)
+     *     booleanRequiredNullable: Boolean (Optional)
+     *     string: String (Optional)
+     *     stringNullable: String (Optional)
+     *     stringRequired: String (Optional)
+     *     stringRequiredNullable: String (Optional)
+     *     bytes: byte[] (Optional)
+     *     int: Integer (Optional)
+     *     long: Long (Optional)
+     *     float: Double (Optional)
+     *     double: Double (Optional)
+     *     duration: Duration (Optional)
+     *     dateTime: OffsetDateTime (Optional)
+     *     stringList (Optional): [
+     *         String (Optional)
+     *     ]
+     *     bytesDict (Optional): {
+     *         String: byte[] (Required)
+     *     }
+     *     epochDateTimeRequiredNullable: Long (Optional)
+     *     epochDateTimeNullable: Long (Optional)
+     *     immutable (Optional): {
+     *         stringReadWriteRequired: String (Required)
+     *         stringReadOnlyOptional: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param requestHeaderRequired The requestHeaderRequired parameter. + * @param booleanRequired The booleanRequired parameter. + * @param booleanRequiredNullable The booleanRequiredNullable parameter. + * @param stringRequired The stringRequired parameter. + * @param stringRequiredNullable The stringRequiredNullable 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putWithResponse(String requestHeaderRequired, boolean booleanRequired, + Boolean booleanRequiredNullable, String stringRequired, String stringRequiredNullable, + RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(requestHeaderRequired, booleanRequired, booleanRequiredNullable, + stringRequired, stringRequiredNullable, requestOptions); + } + + /** + * The put operation. + * + * @param requestHeaderRequired The requestHeaderRequired parameter. + * @param booleanRequired The booleanRequired parameter. + * @param booleanRequiredNullable The booleanRequiredNullable parameter. + * @param stringRequired The stringRequired parameter. + * @param stringRequiredNullable The stringRequiredNullable parameter. + * @param requestHeaderOptional The requestHeaderOptional parameter. + * @param booleanNullable The booleanNullable parameter. + * @param string The string parameter. + * @param stringNullable The stringNullable parameter. + * @param optional The optional 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono put(String requestHeaderRequired, boolean booleanRequired, + Boolean booleanRequiredNullable, String stringRequired, String stringRequiredNullable, + String requestHeaderOptional, Boolean booleanNullable, String string, String stringNullable, + Optional optional) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (requestHeaderOptional != null) { + requestOptions.setHeader(HttpHeaderName.fromString("request-header-optional"), requestHeaderOptional); + } + if (booleanNullable != null) { + requestOptions.addQueryParam("booleanNullable", String.valueOf(booleanNullable), false); + } + if (string != null) { + requestOptions.addQueryParam("string", string, false); + } + if (stringNullable != null) { + requestOptions.addQueryParam("stringNullable", stringNullable, false); + } + if (optional != null) { + requestOptions.setBody(BinaryData.fromObject(optional)); + } + return putWithResponse(requestHeaderRequired, booleanRequired, booleanRequiredNullable, stringRequired, + stringRequiredNullable, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AllPropertiesOptional.class)); + } + + /** + * The put operation. + * + * @param requestHeaderRequired The requestHeaderRequired parameter. + * @param booleanRequired The booleanRequired parameter. + * @param booleanRequiredNullable The booleanRequiredNullable parameter. + * @param stringRequired The stringRequired parameter. + * @param stringRequiredNullable The stringRequiredNullable 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono put(String requestHeaderRequired, boolean booleanRequired, + Boolean booleanRequiredNullable, String stringRequired, String stringRequiredNullable) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(requestHeaderRequired, booleanRequired, booleanRequiredNullable, stringRequired, + stringRequiredNullable, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AllPropertiesOptional.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/OptionalClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/OptionalClient.java new file mode 100644 index 000000000..96ecb5df5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/OptionalClient.java @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.optional; + +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.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.cadl.optional.implementation.OptionalOpsImpl; +import com.cadl.optional.models.AllPropertiesOptional; +import com.cadl.optional.models.Optional; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class OptionalClient { + @Generated + private final OptionalOpsImpl serviceClient; + + /** + * Initializes an instance of OptionalClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + OptionalClient(OptionalOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The put operation. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
booleanNullableBooleanNoThe booleanNullable parameter
stringStringNoThe string parameter
stringNullableStringNoThe stringNullable parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
request-header-optionalStringNoThe requestHeaderOptional parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     boolean: Boolean (Optional)
+     *     booleanNullable: Boolean (Optional)
+     *     booleanRequired: boolean (Required)
+     *     booleanRequiredNullable: Boolean (Required)
+     *     string: String (Optional)
+     *     stringNullable: String (Optional)
+     *     stringRequired: String (Required)
+     *     stringRequiredNullable: String (Required)
+     *     bytes: byte[] (Optional)
+     *     int: Integer (Optional)
+     *     long: Long (Optional)
+     *     float: Double (Optional)
+     *     double: Double (Optional)
+     *     duration: Duration (Optional)
+     *     dateTime: OffsetDateTime (Optional)
+     *     stringList (Optional): [
+     *         String (Optional)
+     *     ]
+     *     bytesDict (Optional): {
+     *         String: byte[] (Required)
+     *     }
+     *     epochDateTimeRequiredNullable: Long (Required)
+     *     epochDateTimeNullable: Long (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: Boolean (Optional)
+     *     booleanNullable: Boolean (Optional)
+     *     booleanRequired: Boolean (Optional)
+     *     booleanRequiredNullable: Boolean (Optional)
+     *     string: String (Optional)
+     *     stringNullable: String (Optional)
+     *     stringRequired: String (Optional)
+     *     stringRequiredNullable: String (Optional)
+     *     bytes: byte[] (Optional)
+     *     int: Integer (Optional)
+     *     long: Long (Optional)
+     *     float: Double (Optional)
+     *     double: Double (Optional)
+     *     duration: Duration (Optional)
+     *     dateTime: OffsetDateTime (Optional)
+     *     stringList (Optional): [
+     *         String (Optional)
+     *     ]
+     *     bytesDict (Optional): {
+     *         String: byte[] (Required)
+     *     }
+     *     epochDateTimeRequiredNullable: Long (Optional)
+     *     epochDateTimeNullable: Long (Optional)
+     *     immutable (Optional): {
+     *         stringReadWriteRequired: String (Required)
+     *         stringReadOnlyOptional: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param requestHeaderRequired The requestHeaderRequired parameter. + * @param booleanRequired The booleanRequired parameter. + * @param booleanRequiredNullable The booleanRequiredNullable parameter. + * @param stringRequired The stringRequired parameter. + * @param stringRequiredNullable The stringRequiredNullable 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putWithResponse(String requestHeaderRequired, boolean booleanRequired, + Boolean booleanRequiredNullable, String stringRequired, String stringRequiredNullable, + RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(requestHeaderRequired, booleanRequired, booleanRequiredNullable, + stringRequired, stringRequiredNullable, requestOptions); + } + + /** + * The put operation. + * + * @param requestHeaderRequired The requestHeaderRequired parameter. + * @param booleanRequired The booleanRequired parameter. + * @param booleanRequiredNullable The booleanRequiredNullable parameter. + * @param stringRequired The stringRequired parameter. + * @param stringRequiredNullable The stringRequiredNullable parameter. + * @param requestHeaderOptional The requestHeaderOptional parameter. + * @param booleanNullable The booleanNullable parameter. + * @param string The string parameter. + * @param stringNullable The stringNullable parameter. + * @param optional The optional 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AllPropertiesOptional put(String requestHeaderRequired, boolean booleanRequired, + Boolean booleanRequiredNullable, String stringRequired, String stringRequiredNullable, + String requestHeaderOptional, Boolean booleanNullable, String string, String stringNullable, + Optional optional) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (requestHeaderOptional != null) { + requestOptions.setHeader(HttpHeaderName.fromString("request-header-optional"), requestHeaderOptional); + } + if (booleanNullable != null) { + requestOptions.addQueryParam("booleanNullable", String.valueOf(booleanNullable), false); + } + if (string != null) { + requestOptions.addQueryParam("string", string, false); + } + if (stringNullable != null) { + requestOptions.addQueryParam("stringNullable", stringNullable, false); + } + if (optional != null) { + requestOptions.setBody(BinaryData.fromObject(optional)); + } + return putWithResponse(requestHeaderRequired, booleanRequired, booleanRequiredNullable, stringRequired, + stringRequiredNullable, requestOptions).getValue().toObject(AllPropertiesOptional.class); + } + + /** + * The put operation. + * + * @param requestHeaderRequired The requestHeaderRequired parameter. + * @param booleanRequired The booleanRequired parameter. + * @param booleanRequiredNullable The booleanRequiredNullable parameter. + * @param stringRequired The stringRequired parameter. + * @param stringRequiredNullable The stringRequiredNullable 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AllPropertiesOptional put(String requestHeaderRequired, boolean booleanRequired, + Boolean booleanRequiredNullable, String stringRequired, String stringRequiredNullable) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(requestHeaderRequired, booleanRequired, booleanRequiredNullable, stringRequired, + stringRequiredNullable, requestOptions).getValue().toObject(AllPropertiesOptional.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/OptionalClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/OptionalClientBuilder.java new file mode 100644 index 000000000..509a7e7ae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/OptionalClientBuilder.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 com.cadl.optional; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.optional.implementation.OptionalClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the OptionalClient type. + */ +@ServiceClientBuilder(serviceClients = { OptionalClient.class, OptionalAsyncClient.class }) +public final class OptionalClientBuilder 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("cadl-optional.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the OptionalClientBuilder. + */ + @Generated + public OptionalClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OptionalClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OptionalClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OptionalClientBuilder 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 OptionalClientBuilder 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 OptionalClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OptionalClientBuilder 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 OptionalClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OptionalClientBuilder 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 OptionalClientBuilder. + */ + @Generated + public OptionalClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of OptionalClientImpl with the provided parameters. + * + * @return an instance of OptionalClientImpl. + */ + @Generated + private OptionalClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + OptionalClientImpl client + = new OptionalClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 OptionalAsyncClient class. + * + * @return an instance of OptionalAsyncClient. + */ + @Generated + public OptionalAsyncClient buildAsyncClient() { + return new OptionalAsyncClient(buildInnerClient().getOptionalOps()); + } + + /** + * Builds an instance of OptionalClient class. + * + * @return an instance of OptionalClient. + */ + @Generated + public OptionalClient buildClient() { + return new OptionalClient(buildInnerClient().getOptionalOps()); + } + + private static final ClientLogger LOGGER = new ClientLogger(OptionalClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/implementation/OptionalClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/implementation/OptionalClientImpl.java new file mode 100644 index 000000000..9d1063ffa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/implementation/OptionalClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.optional.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the OptionalClient type. + */ +public final class OptionalClientImpl { + /** + * 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; + } + + /** + * The OptionalOpsImpl object to access its operations. + */ + private final OptionalOpsImpl optionalOps; + + /** + * Gets the OptionalOpsImpl object to access its operations. + * + * @return the OptionalOpsImpl object. + */ + public OptionalOpsImpl getOptionalOps() { + return this.optionalOps; + } + + /** + * Initializes an instance of OptionalClient client. + * + * @param endpoint Service host. + */ + public OptionalClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of OptionalClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public OptionalClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of OptionalClient 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 OptionalClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.optionalOps = new OptionalOpsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/implementation/OptionalOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/implementation/OptionalOpsImpl.java new file mode 100644 index 000000000..df25fa882 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/implementation/OptionalOpsImpl.java @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.optional.implementation; + +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.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.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.HttpHeaderName; +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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in OptionalOps. + */ +public final class OptionalOpsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final OptionalOpsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of OptionalOpsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OptionalOpsImpl(OptionalClientImpl client) { + this.service + = RestProxy.create(OptionalOpsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientOptionalOps to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientOption") + public interface OptionalOpsService { + @Put("/optional/put") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("request-header-required") String requestHeaderRequired, + @QueryParam("booleanRequired") boolean booleanRequired, + @QueryParam("booleanRequiredNullable") Boolean booleanRequiredNullable, + @QueryParam("stringRequired") String stringRequired, + @QueryParam("stringRequiredNullable") String stringRequiredNullable, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/optional/put") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, + @HeaderParam("request-header-required") String requestHeaderRequired, + @QueryParam("booleanRequired") boolean booleanRequired, + @QueryParam("booleanRequiredNullable") Boolean booleanRequiredNullable, + @QueryParam("stringRequired") String stringRequired, + @QueryParam("stringRequiredNullable") String stringRequiredNullable, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * The put operation. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
booleanNullableBooleanNoThe booleanNullable parameter
stringStringNoThe string parameter
stringNullableStringNoThe stringNullable parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
request-header-optionalStringNoThe requestHeaderOptional parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     boolean: Boolean (Optional)
+     *     booleanNullable: Boolean (Optional)
+     *     booleanRequired: boolean (Required)
+     *     booleanRequiredNullable: Boolean (Required)
+     *     string: String (Optional)
+     *     stringNullable: String (Optional)
+     *     stringRequired: String (Required)
+     *     stringRequiredNullable: String (Required)
+     *     bytes: byte[] (Optional)
+     *     int: Integer (Optional)
+     *     long: Long (Optional)
+     *     float: Double (Optional)
+     *     double: Double (Optional)
+     *     duration: Duration (Optional)
+     *     dateTime: OffsetDateTime (Optional)
+     *     stringList (Optional): [
+     *         String (Optional)
+     *     ]
+     *     bytesDict (Optional): {
+     *         String: byte[] (Required)
+     *     }
+     *     epochDateTimeRequiredNullable: Long (Required)
+     *     epochDateTimeNullable: Long (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: Boolean (Optional)
+     *     booleanNullable: Boolean (Optional)
+     *     booleanRequired: Boolean (Optional)
+     *     booleanRequiredNullable: Boolean (Optional)
+     *     string: String (Optional)
+     *     stringNullable: String (Optional)
+     *     stringRequired: String (Optional)
+     *     stringRequiredNullable: String (Optional)
+     *     bytes: byte[] (Optional)
+     *     int: Integer (Optional)
+     *     long: Long (Optional)
+     *     float: Double (Optional)
+     *     double: Double (Optional)
+     *     duration: Duration (Optional)
+     *     dateTime: OffsetDateTime (Optional)
+     *     stringList (Optional): [
+     *         String (Optional)
+     *     ]
+     *     bytesDict (Optional): {
+     *         String: byte[] (Required)
+     *     }
+     *     epochDateTimeRequiredNullable: Long (Optional)
+     *     epochDateTimeNullable: Long (Optional)
+     *     immutable (Optional): {
+     *         stringReadWriteRequired: String (Required)
+     *         stringReadOnlyOptional: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param requestHeaderRequired The requestHeaderRequired parameter. + * @param booleanRequired The booleanRequired parameter. + * @param booleanRequiredNullable The booleanRequiredNullable parameter. + * @param stringRequired The stringRequired parameter. + * @param stringRequiredNullable The stringRequiredNullable 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putWithResponseAsync(String requestHeaderRequired, boolean booleanRequired, + Boolean booleanRequiredNullable, String stringRequired, String stringRequiredNullable, + RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), requestHeaderRequired, booleanRequired, + booleanRequiredNullable, stringRequired, stringRequiredNullable, accept, requestOptionsLocal, context)); + } + + /** + * The put operation. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
booleanNullableBooleanNoThe booleanNullable parameter
stringStringNoThe string parameter
stringNullableStringNoThe stringNullable parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
request-header-optionalStringNoThe requestHeaderOptional parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     boolean: Boolean (Optional)
+     *     booleanNullable: Boolean (Optional)
+     *     booleanRequired: boolean (Required)
+     *     booleanRequiredNullable: Boolean (Required)
+     *     string: String (Optional)
+     *     stringNullable: String (Optional)
+     *     stringRequired: String (Required)
+     *     stringRequiredNullable: String (Required)
+     *     bytes: byte[] (Optional)
+     *     int: Integer (Optional)
+     *     long: Long (Optional)
+     *     float: Double (Optional)
+     *     double: Double (Optional)
+     *     duration: Duration (Optional)
+     *     dateTime: OffsetDateTime (Optional)
+     *     stringList (Optional): [
+     *         String (Optional)
+     *     ]
+     *     bytesDict (Optional): {
+     *         String: byte[] (Required)
+     *     }
+     *     epochDateTimeRequiredNullable: Long (Required)
+     *     epochDateTimeNullable: Long (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: Boolean (Optional)
+     *     booleanNullable: Boolean (Optional)
+     *     booleanRequired: Boolean (Optional)
+     *     booleanRequiredNullable: Boolean (Optional)
+     *     string: String (Optional)
+     *     stringNullable: String (Optional)
+     *     stringRequired: String (Optional)
+     *     stringRequiredNullable: String (Optional)
+     *     bytes: byte[] (Optional)
+     *     int: Integer (Optional)
+     *     long: Long (Optional)
+     *     float: Double (Optional)
+     *     double: Double (Optional)
+     *     duration: Duration (Optional)
+     *     dateTime: OffsetDateTime (Optional)
+     *     stringList (Optional): [
+     *         String (Optional)
+     *     ]
+     *     bytesDict (Optional): {
+     *         String: byte[] (Required)
+     *     }
+     *     epochDateTimeRequiredNullable: Long (Optional)
+     *     epochDateTimeNullable: Long (Optional)
+     *     immutable (Optional): {
+     *         stringReadWriteRequired: String (Required)
+     *         stringReadOnlyOptional: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param requestHeaderRequired The requestHeaderRequired parameter. + * @param booleanRequired The booleanRequired parameter. + * @param booleanRequiredNullable The booleanRequiredNullable parameter. + * @param stringRequired The stringRequired parameter. + * @param stringRequiredNullable The stringRequiredNullable 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putWithResponse(String requestHeaderRequired, boolean booleanRequired, + Boolean booleanRequiredNullable, String stringRequired, String stringRequiredNullable, + RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return service.putSync(this.client.getEndpoint(), requestHeaderRequired, booleanRequired, + booleanRequiredNullable, stringRequired, stringRequiredNullable, accept, requestOptionsLocal, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/implementation/package-info.java new file mode 100644 index 000000000..57b1a7bda --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Optional. + * + */ +package com.cadl.optional.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/models/AllPropertiesOptional.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/models/AllPropertiesOptional.java new file mode 100644 index 000000000..b8a309e2c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/models/AllPropertiesOptional.java @@ -0,0 +1,462 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.optional.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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.time.Duration; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Map; + +/** + * The AllPropertiesOptional model. + */ +@Immutable +public final class AllPropertiesOptional implements JsonSerializable { + /* + * The boolean property. + */ + @Generated + private Boolean booleanProperty; + + /* + * The booleanNullable property. + */ + @Generated + private Boolean booleanNullable; + + /* + * The booleanRequired property. + */ + @Generated + private Boolean booleanRequired; + + /* + * The booleanRequiredNullable property. + */ + @Generated + private Boolean booleanRequiredNullable; + + /* + * The string property. + */ + @Generated + private String string; + + /* + * The stringNullable property. + */ + @Generated + private String stringNullable; + + /* + * The stringRequired property. + */ + @Generated + private String stringRequired; + + /* + * The stringRequiredNullable property. + */ + @Generated + private String stringRequiredNullable; + + /* + * The bytes property. + */ + @Generated + private byte[] bytes; + + /* + * The int property. + */ + @Generated + private Integer intProperty; + + /* + * The long property. + */ + @Generated + private Long longProperty; + + /* + * The float property. + */ + @Generated + private Double floatProperty; + + /* + * The double property. + */ + @Generated + private Double doubleProperty; + + /* + * The duration property. + */ + @Generated + private Duration duration; + + /* + * The dateTime property. + */ + @Generated + private OffsetDateTime dateTime; + + /* + * The stringList property. + */ + @Generated + private List stringList; + + /* + * The bytesDict property. + */ + @Generated + private Map bytesDict; + + /* + * The epochDateTimeRequiredNullable property. + */ + @Generated + private Long epochDateTimeRequiredNullable; + + /* + * The epochDateTimeNullable property. + */ + @Generated + private Long epochDateTimeNullable; + + /* + * The immutable property. + */ + @Generated + private ImmutableModel immutable; + + /** + * Creates an instance of AllPropertiesOptional class. + */ + @Generated + private AllPropertiesOptional() { + } + + /** + * Get the booleanProperty property: The boolean property. + * + * @return the booleanProperty value. + */ + @Generated + public Boolean isBooleanProperty() { + return this.booleanProperty; + } + + /** + * Get the booleanNullable property: The booleanNullable property. + * + * @return the booleanNullable value. + */ + @Generated + public Boolean isBooleanNullable() { + return this.booleanNullable; + } + + /** + * Get the booleanRequired property: The booleanRequired property. + * + * @return the booleanRequired value. + */ + @Generated + public Boolean isBooleanRequired() { + return this.booleanRequired; + } + + /** + * Get the booleanRequiredNullable property: The booleanRequiredNullable property. + * + * @return the booleanRequiredNullable value. + */ + @Generated + public Boolean isBooleanRequiredNullable() { + return this.booleanRequiredNullable; + } + + /** + * Get the string property: The string property. + * + * @return the string value. + */ + @Generated + public String getString() { + return this.string; + } + + /** + * Get the stringNullable property: The stringNullable property. + * + * @return the stringNullable value. + */ + @Generated + public String getStringNullable() { + return this.stringNullable; + } + + /** + * Get the stringRequired property: The stringRequired property. + * + * @return the stringRequired value. + */ + @Generated + public String getStringRequired() { + return this.stringRequired; + } + + /** + * Get the stringRequiredNullable property: The stringRequiredNullable property. + * + * @return the stringRequiredNullable value. + */ + @Generated + public String getStringRequiredNullable() { + return this.stringRequiredNullable; + } + + /** + * Get the bytes property: The bytes property. + * + * @return the bytes value. + */ + @Generated + public byte[] getBytes() { + return CoreUtils.clone(this.bytes); + } + + /** + * Get the intProperty property: The int property. + * + * @return the intProperty value. + */ + @Generated + public Integer getIntProperty() { + return this.intProperty; + } + + /** + * Get the longProperty property: The long property. + * + * @return the longProperty value. + */ + @Generated + public Long getLongProperty() { + return this.longProperty; + } + + /** + * Get the floatProperty property: The float property. + * + * @return the floatProperty value. + */ + @Generated + public Double getFloatProperty() { + return this.floatProperty; + } + + /** + * Get the doubleProperty property: The double property. + * + * @return the doubleProperty value. + */ + @Generated + public Double getDoubleProperty() { + return this.doubleProperty; + } + + /** + * Get the duration property: The duration property. + * + * @return the duration value. + */ + @Generated + public Duration getDuration() { + return this.duration; + } + + /** + * Get the dateTime property: The dateTime property. + * + * @return the dateTime value. + */ + @Generated + public OffsetDateTime getDateTime() { + return this.dateTime; + } + + /** + * Get the stringList property: The stringList property. + * + * @return the stringList value. + */ + @Generated + public List getStringList() { + return this.stringList; + } + + /** + * Get the bytesDict property: The bytesDict property. + * + * @return the bytesDict value. + */ + @Generated + public Map getBytesDict() { + return this.bytesDict; + } + + /** + * Get the epochDateTimeRequiredNullable property: The epochDateTimeRequiredNullable property. + * + * @return the epochDateTimeRequiredNullable value. + */ + @Generated + public OffsetDateTime getEpochDateTimeRequiredNullable() { + if (this.epochDateTimeRequiredNullable == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.epochDateTimeRequiredNullable), ZoneOffset.UTC); + } + + /** + * Get the epochDateTimeNullable property: The epochDateTimeNullable property. + * + * @return the epochDateTimeNullable value. + */ + @Generated + public OffsetDateTime getEpochDateTimeNullable() { + if (this.epochDateTimeNullable == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.epochDateTimeNullable), ZoneOffset.UTC); + } + + /** + * Get the immutable property: The immutable property. + * + * @return the immutable value. + */ + @Generated + public ImmutableModel getImmutable() { + return this.immutable; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("boolean", this.booleanProperty); + jsonWriter.writeBooleanField("booleanNullable", this.booleanNullable); + jsonWriter.writeBooleanField("booleanRequired", this.booleanRequired); + jsonWriter.writeBooleanField("booleanRequiredNullable", this.booleanRequiredNullable); + jsonWriter.writeStringField("string", this.string); + jsonWriter.writeStringField("stringNullable", this.stringNullable); + jsonWriter.writeStringField("stringRequired", this.stringRequired); + jsonWriter.writeStringField("stringRequiredNullable", this.stringRequiredNullable); + jsonWriter.writeBinaryField("bytes", this.bytes); + jsonWriter.writeNumberField("int", this.intProperty); + jsonWriter.writeNumberField("long", this.longProperty); + jsonWriter.writeNumberField("float", this.floatProperty); + jsonWriter.writeNumberField("double", this.doubleProperty); + jsonWriter.writeStringField("duration", CoreUtils.durationToStringWithDays(this.duration)); + jsonWriter.writeStringField("dateTime", + this.dateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.dateTime)); + jsonWriter.writeArrayField("stringList", this.stringList, (writer, element) -> writer.writeString(element)); + jsonWriter.writeMapField("bytesDict", this.bytesDict, (writer, element) -> writer.writeBinary(element)); + jsonWriter.writeNumberField("epochDateTimeRequiredNullable", this.epochDateTimeRequiredNullable); + jsonWriter.writeNumberField("epochDateTimeNullable", this.epochDateTimeNullable); + jsonWriter.writeJsonField("immutable", this.immutable); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AllPropertiesOptional from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AllPropertiesOptional 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 AllPropertiesOptional. + */ + @Generated + public static AllPropertiesOptional fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AllPropertiesOptional deserializedAllPropertiesOptional = new AllPropertiesOptional(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("boolean".equals(fieldName)) { + deserializedAllPropertiesOptional.booleanProperty = reader.getNullable(JsonReader::getBoolean); + } else if ("booleanNullable".equals(fieldName)) { + deserializedAllPropertiesOptional.booleanNullable = reader.getNullable(JsonReader::getBoolean); + } else if ("booleanRequired".equals(fieldName)) { + deserializedAllPropertiesOptional.booleanRequired = reader.getNullable(JsonReader::getBoolean); + } else if ("booleanRequiredNullable".equals(fieldName)) { + deserializedAllPropertiesOptional.booleanRequiredNullable + = reader.getNullable(JsonReader::getBoolean); + } else if ("string".equals(fieldName)) { + deserializedAllPropertiesOptional.string = reader.getString(); + } else if ("stringNullable".equals(fieldName)) { + deserializedAllPropertiesOptional.stringNullable = reader.getString(); + } else if ("stringRequired".equals(fieldName)) { + deserializedAllPropertiesOptional.stringRequired = reader.getString(); + } else if ("stringRequiredNullable".equals(fieldName)) { + deserializedAllPropertiesOptional.stringRequiredNullable = reader.getString(); + } else if ("bytes".equals(fieldName)) { + deserializedAllPropertiesOptional.bytes = reader.getBinary(); + } else if ("int".equals(fieldName)) { + deserializedAllPropertiesOptional.intProperty = reader.getNullable(JsonReader::getInt); + } else if ("long".equals(fieldName)) { + deserializedAllPropertiesOptional.longProperty = reader.getNullable(JsonReader::getLong); + } else if ("float".equals(fieldName)) { + deserializedAllPropertiesOptional.floatProperty = reader.getNullable(JsonReader::getDouble); + } else if ("double".equals(fieldName)) { + deserializedAllPropertiesOptional.doubleProperty = reader.getNullable(JsonReader::getDouble); + } else if ("duration".equals(fieldName)) { + deserializedAllPropertiesOptional.duration + = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else if ("dateTime".equals(fieldName)) { + deserializedAllPropertiesOptional.dateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("stringList".equals(fieldName)) { + List stringList = reader.readArray(reader1 -> reader1.getString()); + deserializedAllPropertiesOptional.stringList = stringList; + } else if ("bytesDict".equals(fieldName)) { + Map bytesDict = reader.readMap(reader1 -> reader1.getBinary()); + deserializedAllPropertiesOptional.bytesDict = bytesDict; + } else if ("epochDateTimeRequiredNullable".equals(fieldName)) { + deserializedAllPropertiesOptional.epochDateTimeRequiredNullable + = reader.getNullable(JsonReader::getLong); + } else if ("epochDateTimeNullable".equals(fieldName)) { + deserializedAllPropertiesOptional.epochDateTimeNullable = reader.getNullable(JsonReader::getLong); + } else if ("immutable".equals(fieldName)) { + deserializedAllPropertiesOptional.immutable = ImmutableModel.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedAllPropertiesOptional; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/models/ImmutableModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/models/ImmutableModel.java new file mode 100644 index 000000000..6494cc895 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/models/ImmutableModel.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.optional.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; + +/** + * The ImmutableModel model. + */ +@Immutable +public final class ImmutableModel implements JsonSerializable { + /* + * The stringReadWriteRequired property. + */ + @Generated + private final String stringReadWriteRequired; + + /* + * The stringReadOnlyOptional property. + */ + @Generated + private String stringReadOnlyOptional; + + /** + * Creates an instance of ImmutableModel class. + * + * @param stringReadWriteRequired the stringReadWriteRequired value to set. + */ + @Generated + private ImmutableModel(String stringReadWriteRequired) { + this.stringReadWriteRequired = stringReadWriteRequired; + } + + /** + * Get the stringReadWriteRequired property: The stringReadWriteRequired property. + * + * @return the stringReadWriteRequired value. + */ + @Generated + public String getStringReadWriteRequired() { + return this.stringReadWriteRequired; + } + + /** + * Get the stringReadOnlyOptional property: The stringReadOnlyOptional property. + * + * @return the stringReadOnlyOptional value. + */ + @Generated + public String getStringReadOnlyOptional() { + return this.stringReadOnlyOptional; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("stringReadWriteRequired", this.stringReadWriteRequired); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ImmutableModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ImmutableModel 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 ImmutableModel. + */ + @Generated + public static ImmutableModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String stringReadWriteRequired = null; + String stringReadOnlyOptional = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("stringReadWriteRequired".equals(fieldName)) { + stringReadWriteRequired = reader.getString(); + } else if ("stringReadOnlyOptional".equals(fieldName)) { + stringReadOnlyOptional = reader.getString(); + } else { + reader.skipChildren(); + } + } + ImmutableModel deserializedImmutableModel = new ImmutableModel(stringReadWriteRequired); + deserializedImmutableModel.stringReadOnlyOptional = stringReadOnlyOptional; + + return deserializedImmutableModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/models/Optional.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/models/Optional.java new file mode 100644 index 000000000..ed01145a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/models/Optional.java @@ -0,0 +1,665 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.optional.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +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.time.Duration; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Map; + +/** + * The Optional model. + */ +@Fluent +public final class Optional implements JsonSerializable { + /* + * The boolean property. + */ + @Generated + private Boolean booleanProperty; + + /* + * The booleanNullable property. + */ + @Generated + private Boolean booleanNullable; + + /* + * The booleanRequired property. + */ + @Generated + private final boolean booleanRequired; + + /* + * The booleanRequiredNullable property. + */ + @Generated + private final Boolean booleanRequiredNullable; + + /* + * The string property. + */ + @Generated + private String string; + + /* + * The stringNullable property. + */ + @Generated + private String stringNullable; + + /* + * The stringRequired property. + */ + @Generated + private final String stringRequired; + + /* + * The stringRequiredNullable property. + */ + @Generated + private final String stringRequiredNullable; + + /* + * The bytes property. + */ + @Generated + private byte[] bytes; + + /* + * The int property. + */ + @Generated + private Integer intProperty; + + /* + * The long property. + */ + @Generated + private Long longProperty; + + /* + * The float property. + */ + @Generated + private Double floatProperty; + + /* + * The double property. + */ + @Generated + private Double doubleProperty; + + /* + * The duration property. + */ + @Generated + private Duration duration; + + /* + * The dateTime property. + */ + @Generated + private OffsetDateTime dateTime; + + /* + * The stringList property. + */ + @Generated + private List stringList; + + /* + * The bytesDict property. + */ + @Generated + private Map bytesDict; + + /* + * The epochDateTimeRequiredNullable property. + */ + @Generated + private final Long epochDateTimeRequiredNullable; + + /* + * The epochDateTimeNullable property. + */ + @Generated + private Long epochDateTimeNullable; + + /** + * Creates an instance of Optional class. + * + * @param booleanRequired the booleanRequired value to set. + * @param booleanRequiredNullable the booleanRequiredNullable value to set. + * @param stringRequired the stringRequired value to set. + * @param stringRequiredNullable the stringRequiredNullable value to set. + * @param epochDateTimeRequiredNullable the epochDateTimeRequiredNullable value to set. + */ + @Generated + public Optional(boolean booleanRequired, Boolean booleanRequiredNullable, String stringRequired, + String stringRequiredNullable, OffsetDateTime epochDateTimeRequiredNullable) { + this.booleanRequired = booleanRequired; + this.booleanRequiredNullable = booleanRequiredNullable; + this.stringRequired = stringRequired; + this.stringRequiredNullable = stringRequiredNullable; + if (epochDateTimeRequiredNullable == null) { + this.epochDateTimeRequiredNullable = null; + } else { + this.epochDateTimeRequiredNullable = epochDateTimeRequiredNullable.toEpochSecond(); + } + } + + /** + * Get the booleanProperty property: The boolean property. + * + * @return the booleanProperty value. + */ + @Generated + public Boolean isBooleanProperty() { + return this.booleanProperty; + } + + /** + * Set the booleanProperty property: The boolean property. + * + * @param booleanProperty the booleanProperty value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setBooleanProperty(Boolean booleanProperty) { + this.booleanProperty = booleanProperty; + return this; + } + + /** + * Get the booleanNullable property: The booleanNullable property. + * + * @return the booleanNullable value. + */ + @Generated + public Boolean isBooleanNullable() { + return this.booleanNullable; + } + + /** + * Set the booleanNullable property: The booleanNullable property. + * + * @param booleanNullable the booleanNullable value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setBooleanNullable(Boolean booleanNullable) { + this.booleanNullable = booleanNullable; + return this; + } + + /** + * Get the booleanRequired property: The booleanRequired property. + * + * @return the booleanRequired value. + */ + @Generated + public boolean isBooleanRequired() { + return this.booleanRequired; + } + + /** + * Get the booleanRequiredNullable property: The booleanRequiredNullable property. + * + * @return the booleanRequiredNullable value. + */ + @Generated + public Boolean isBooleanRequiredNullable() { + return this.booleanRequiredNullable; + } + + /** + * Get the string property: The string property. + * + * @return the string value. + */ + @Generated + public String getString() { + return this.string; + } + + /** + * Set the string property: The string property. + * + * @param string the string value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setString(String string) { + this.string = string; + return this; + } + + /** + * Get the stringNullable property: The stringNullable property. + * + * @return the stringNullable value. + */ + @Generated + public String getStringNullable() { + return this.stringNullable; + } + + /** + * Set the stringNullable property: The stringNullable property. + * + * @param stringNullable the stringNullable value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setStringNullable(String stringNullable) { + this.stringNullable = stringNullable; + return this; + } + + /** + * Get the stringRequired property: The stringRequired property. + * + * @return the stringRequired value. + */ + @Generated + public String getStringRequired() { + return this.stringRequired; + } + + /** + * Get the stringRequiredNullable property: The stringRequiredNullable property. + * + * @return the stringRequiredNullable value. + */ + @Generated + public String getStringRequiredNullable() { + return this.stringRequiredNullable; + } + + /** + * Get the bytes property: The bytes property. + * + * @return the bytes value. + */ + @Generated + public byte[] getBytes() { + return CoreUtils.clone(this.bytes); + } + + /** + * Set the bytes property: The bytes property. + * + * @param bytes the bytes value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setBytes(byte[] bytes) { + this.bytes = CoreUtils.clone(bytes); + return this; + } + + /** + * Get the intProperty property: The int property. + * + * @return the intProperty value. + */ + @Generated + public Integer getIntProperty() { + return this.intProperty; + } + + /** + * Set the intProperty property: The int property. + * + * @param intProperty the intProperty value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setIntProperty(Integer intProperty) { + this.intProperty = intProperty; + return this; + } + + /** + * Get the longProperty property: The long property. + * + * @return the longProperty value. + */ + @Generated + public Long getLongProperty() { + return this.longProperty; + } + + /** + * Set the longProperty property: The long property. + * + * @param longProperty the longProperty value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setLongProperty(Long longProperty) { + this.longProperty = longProperty; + return this; + } + + /** + * Get the floatProperty property: The float property. + * + * @return the floatProperty value. + */ + @Generated + public Double getFloatProperty() { + return this.floatProperty; + } + + /** + * Set the floatProperty property: The float property. + * + * @param floatProperty the floatProperty value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setFloatProperty(Double floatProperty) { + this.floatProperty = floatProperty; + return this; + } + + /** + * Get the doubleProperty property: The double property. + * + * @return the doubleProperty value. + */ + @Generated + public Double getDoubleProperty() { + return this.doubleProperty; + } + + /** + * Set the doubleProperty property: The double property. + * + * @param doubleProperty the doubleProperty value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setDoubleProperty(Double doubleProperty) { + this.doubleProperty = doubleProperty; + return this; + } + + /** + * Get the duration property: The duration property. + * + * @return the duration value. + */ + @Generated + public Duration getDuration() { + return this.duration; + } + + /** + * Set the duration property: The duration property. + * + * @param duration the duration value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setDuration(Duration duration) { + this.duration = duration; + return this; + } + + /** + * Get the dateTime property: The dateTime property. + * + * @return the dateTime value. + */ + @Generated + public OffsetDateTime getDateTime() { + return this.dateTime; + } + + /** + * Set the dateTime property: The dateTime property. + * + * @param dateTime the dateTime value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setDateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get the stringList property: The stringList property. + * + * @return the stringList value. + */ + @Generated + public List getStringList() { + return this.stringList; + } + + /** + * Set the stringList property: The stringList property. + * + * @param stringList the stringList value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setStringList(List stringList) { + this.stringList = stringList; + return this; + } + + /** + * Get the bytesDict property: The bytesDict property. + * + * @return the bytesDict value. + */ + @Generated + public Map getBytesDict() { + return this.bytesDict; + } + + /** + * Set the bytesDict property: The bytesDict property. + * + * @param bytesDict the bytesDict value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setBytesDict(Map bytesDict) { + this.bytesDict = bytesDict; + return this; + } + + /** + * Get the epochDateTimeRequiredNullable property: The epochDateTimeRequiredNullable property. + * + * @return the epochDateTimeRequiredNullable value. + */ + @Generated + public OffsetDateTime getEpochDateTimeRequiredNullable() { + if (this.epochDateTimeRequiredNullable == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.epochDateTimeRequiredNullable), ZoneOffset.UTC); + } + + /** + * Get the epochDateTimeNullable property: The epochDateTimeNullable property. + * + * @return the epochDateTimeNullable value. + */ + @Generated + public OffsetDateTime getEpochDateTimeNullable() { + if (this.epochDateTimeNullable == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.epochDateTimeNullable), ZoneOffset.UTC); + } + + /** + * Set the epochDateTimeNullable property: The epochDateTimeNullable property. + * + * @param epochDateTimeNullable the epochDateTimeNullable value to set. + * @return the Optional object itself. + */ + @Generated + public Optional setEpochDateTimeNullable(OffsetDateTime epochDateTimeNullable) { + if (epochDateTimeNullable == null) { + this.epochDateTimeNullable = null; + } else { + this.epochDateTimeNullable = epochDateTimeNullable.toEpochSecond(); + } + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("booleanRequired", this.booleanRequired); + jsonWriter.writeBooleanField("booleanRequiredNullable", this.booleanRequiredNullable); + jsonWriter.writeStringField("stringRequired", this.stringRequired); + jsonWriter.writeStringField("stringRequiredNullable", this.stringRequiredNullable); + jsonWriter.writeNumberField("epochDateTimeRequiredNullable", this.epochDateTimeRequiredNullable); + jsonWriter.writeBooleanField("boolean", this.booleanProperty); + jsonWriter.writeBooleanField("booleanNullable", this.booleanNullable); + jsonWriter.writeStringField("string", this.string); + jsonWriter.writeStringField("stringNullable", this.stringNullable); + jsonWriter.writeBinaryField("bytes", this.bytes); + jsonWriter.writeNumberField("int", this.intProperty); + jsonWriter.writeNumberField("long", this.longProperty); + jsonWriter.writeNumberField("float", this.floatProperty); + jsonWriter.writeNumberField("double", this.doubleProperty); + jsonWriter.writeStringField("duration", CoreUtils.durationToStringWithDays(this.duration)); + jsonWriter.writeStringField("dateTime", + this.dateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.dateTime)); + jsonWriter.writeArrayField("stringList", this.stringList, (writer, element) -> writer.writeString(element)); + jsonWriter.writeMapField("bytesDict", this.bytesDict, (writer, element) -> writer.writeBinary(element)); + jsonWriter.writeNumberField("epochDateTimeNullable", this.epochDateTimeNullable); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Optional from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Optional 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 Optional. + */ + @Generated + public static Optional fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean booleanRequired = false; + Boolean booleanRequiredNullable = null; + String stringRequired = null; + String stringRequiredNullable = null; + OffsetDateTime epochDateTimeRequiredNullable = null; + Boolean booleanProperty = null; + Boolean booleanNullable = null; + String string = null; + String stringNullable = null; + byte[] bytes = null; + Integer intProperty = null; + Long longProperty = null; + Double floatProperty = null; + Double doubleProperty = null; + Duration duration = null; + OffsetDateTime dateTime = null; + List stringList = null; + Map bytesDict = null; + Long epochDateTimeNullable = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("booleanRequired".equals(fieldName)) { + booleanRequired = reader.getBoolean(); + } else if ("booleanRequiredNullable".equals(fieldName)) { + booleanRequiredNullable = reader.getNullable(JsonReader::getBoolean); + } else if ("stringRequired".equals(fieldName)) { + stringRequired = reader.getString(); + } else if ("stringRequiredNullable".equals(fieldName)) { + stringRequiredNullable = reader.getString(); + } else if ("epochDateTimeRequiredNullable".equals(fieldName)) { + Long epochDateTimeRequiredNullableHolder = reader.getNullable(JsonReader::getLong); + if (epochDateTimeRequiredNullableHolder != null) { + epochDateTimeRequiredNullable = OffsetDateTime + .ofInstant(Instant.ofEpochSecond(epochDateTimeRequiredNullableHolder), ZoneOffset.UTC); + } + } else if ("boolean".equals(fieldName)) { + booleanProperty = reader.getNullable(JsonReader::getBoolean); + } else if ("booleanNullable".equals(fieldName)) { + booleanNullable = reader.getNullable(JsonReader::getBoolean); + } else if ("string".equals(fieldName)) { + string = reader.getString(); + } else if ("stringNullable".equals(fieldName)) { + stringNullable = reader.getString(); + } else if ("bytes".equals(fieldName)) { + bytes = reader.getBinary(); + } else if ("int".equals(fieldName)) { + intProperty = reader.getNullable(JsonReader::getInt); + } else if ("long".equals(fieldName)) { + longProperty = reader.getNullable(JsonReader::getLong); + } else if ("float".equals(fieldName)) { + floatProperty = reader.getNullable(JsonReader::getDouble); + } else if ("double".equals(fieldName)) { + doubleProperty = reader.getNullable(JsonReader::getDouble); + } else if ("duration".equals(fieldName)) { + duration = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else if ("dateTime".equals(fieldName)) { + dateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("stringList".equals(fieldName)) { + stringList = reader.readArray(reader1 -> reader1.getString()); + } else if ("bytesDict".equals(fieldName)) { + bytesDict = reader.readMap(reader1 -> reader1.getBinary()); + } else if ("epochDateTimeNullable".equals(fieldName)) { + epochDateTimeNullable = reader.getNullable(JsonReader::getLong); + } else { + reader.skipChildren(); + } + } + Optional deserializedOptional = new Optional(booleanRequired, booleanRequiredNullable, stringRequired, + stringRequiredNullable, epochDateTimeRequiredNullable); + deserializedOptional.booleanProperty = booleanProperty; + deserializedOptional.booleanNullable = booleanNullable; + deserializedOptional.string = string; + deserializedOptional.stringNullable = stringNullable; + deserializedOptional.bytes = bytes; + deserializedOptional.intProperty = intProperty; + deserializedOptional.longProperty = longProperty; + deserializedOptional.floatProperty = floatProperty; + deserializedOptional.doubleProperty = doubleProperty; + deserializedOptional.duration = duration; + deserializedOptional.dateTime = dateTime; + deserializedOptional.stringList = stringList; + deserializedOptional.bytesDict = bytesDict; + deserializedOptional.epochDateTimeNullable = epochDateTimeNullable; + + return deserializedOptional; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/models/package-info.java new file mode 100644 index 000000000..6b32eea60 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Optional. + * + */ +package com.cadl.optional.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/package-info.java new file mode 100644 index 000000000..928b2f690 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/optional/package-info.java @@ -0,0 +1,10 @@ +// 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 Optional. + * + */ +package com.cadl.optional; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/PartialUpdateAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/PartialUpdateAsyncClient.java new file mode 100644 index 000000000..281c3da7e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/PartialUpdateAsyncClient.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 com.cadl.partialupdate; + +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 com.cadl.partialupdate.implementation.PartialUpdateClientImpl; +import com.cadl.partialupdate.models.PartialUpdateModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PartialUpdateClient type. + */ +@ServiceClient(builder = PartialUpdateClientBuilder.class, isAsync = true) +public final class PartialUpdateAsyncClient { + + @Generated + private final PartialUpdateClientImpl serviceClient; + + /** + * Initializes an instance of PartialUpdateAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PartialUpdateAsyncClient(PartialUpdateClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The read operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     aggregate: String (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> readWithResponse(RequestOptions requestOptions) { + return this.serviceClient.readWithResponseAsync(requestOptions); + } + + /** + * The read 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono read() { + // Generated convenience method for readWithResponse + RequestOptions requestOptions = new RequestOptions(); + return readWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PartialUpdateModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/PartialUpdateClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/PartialUpdateClient.java new file mode 100644 index 000000000..880a6ef5c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/PartialUpdateClient.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.cadl.partialupdate; + +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.cadl.partialupdate.implementation.PartialUpdateClientImpl; +import com.cadl.partialupdate.models.PartialUpdateModel; + +/** + * Initializes a new instance of the synchronous PartialUpdateClient type. + */ +@ServiceClient(builder = PartialUpdateClientBuilder.class) +public final class PartialUpdateClient { + + @Generated + private final PartialUpdateClientImpl serviceClient; + + /** + * Initializes an instance of PartialUpdateClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PartialUpdateClient(PartialUpdateClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The read operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     aggregate: String (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response readWithResponse(RequestOptions requestOptions) { + return this.serviceClient.readWithResponse(requestOptions); + } + + /** + * The read 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PartialUpdateModel read() { + // Generated convenience method for readWithResponse + RequestOptions requestOptions = new RequestOptions(); + return readWithResponse(requestOptions).getValue().toObject(PartialUpdateModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/PartialUpdateClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/PartialUpdateClientBuilder.java new file mode 100644 index 000000000..04c87f3af --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/PartialUpdateClientBuilder.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 com.cadl.partialupdate; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.partialupdate.implementation.PartialUpdateClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the PartialUpdateClient type. + */ +@ServiceClientBuilder(serviceClients = { PartialUpdateClient.class, PartialUpdateAsyncClient.class }) +public final class PartialUpdateClientBuilder 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("cadl-partialupdate.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the PartialUpdateClientBuilder. + */ + @Generated + public PartialUpdateClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PartialUpdateClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PartialUpdateClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PartialUpdateClientBuilder 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 PartialUpdateClientBuilder 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 PartialUpdateClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PartialUpdateClientBuilder 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 PartialUpdateClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PartialUpdateClientBuilder 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 PartialUpdateClientBuilder. + */ + @Generated + public PartialUpdateClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of PartialUpdateClientImpl with the provided parameters. + * + * @return an instance of PartialUpdateClientImpl. + */ + @Generated + private PartialUpdateClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + PartialUpdateClientImpl client = new PartialUpdateClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 PartialUpdateAsyncClient class. + * + * @return an instance of PartialUpdateAsyncClient. + */ + @Generated + public PartialUpdateAsyncClient buildAsyncClient() { + return new PartialUpdateAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of PartialUpdateClient class. + * + * @return an instance of PartialUpdateClient. + */ + @Generated + public PartialUpdateClient buildClient() { + return new PartialUpdateClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(PartialUpdateClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/implementation/PartialUpdateClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/implementation/PartialUpdateClientImpl.java new file mode 100644 index 000000000..b845d53aa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/implementation/PartialUpdateClientImpl.java @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.partialupdate.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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 PartialUpdateClient type. + */ +public final class PartialUpdateClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PartialUpdateClientService 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 PartialUpdateClient client. + * + * @param endpoint Service host. + */ + public PartialUpdateClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of PartialUpdateClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public PartialUpdateClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of PartialUpdateClient 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 PartialUpdateClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service + = RestProxy.create(PartialUpdateClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for PartialUpdateClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PartialUpdateClient") + public interface PartialUpdateClientService { + @Get("/partialupdate") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> read(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/partialupdate") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response readSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * The read operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     aggregate: String (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> readWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.read(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The read operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     aggregate: String (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response readWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.readSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/implementation/package-info.java new file mode 100644 index 000000000..8fb2ddadb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/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 PartialUpdate. + * + */ +package com.cadl.partialupdate.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/models/PartialUpdateModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/models/PartialUpdateModel.java new file mode 100644 index 000000000..76ccfdc9a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/models/PartialUpdateModel.java @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.cadl.partialupdate.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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 PartialUpdateModel model. + */ +@Immutable +public final class PartialUpdateModel implements JsonSerializable { + + /* + * The boolean property. + */ + @Generated + private final boolean booleanProperty; + + /* + * The string property. + */ + @Generated + private final String string; + + /* + * The bytes property. + */ + @Generated + private final byte[] bytes; + + /* + * The aggregation function to be applied on the client metric. Allowed functions + * - ‘percentage’ - for error metric , ‘avg’, ‘p50’, ‘p90’, ‘p95’, ‘p99’, ‘min’, + * ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + * ‘count’ - for requests + */ + @Generated + private String aggregate; + + /** + * Creates an instance of PartialUpdateModel class. + * + * @param booleanProperty the booleanProperty value to set. + * @param string the string value to set. + * @param bytes the bytes value to set. + */ + @Generated + private PartialUpdateModel(boolean booleanProperty, String string, byte[] bytes) { + this.booleanProperty = booleanProperty; + this.string = string; + this.bytes = bytes; + } + + /** + * Get the booleanProperty property: The boolean property. + * + * @return the booleanProperty value. + */ + @Generated + public boolean isBooleanProperty() { + return this.booleanProperty; + } + + /** + * Get the string property: The string property. + * + * @return the string value. + */ + @Generated + public String getString() { + return this.string; + } + + /** + * Get the bytes property: The bytes property. + * + * @return the bytes value. + */ + @Generated + public byte[] getBytes() { + return CoreUtils.clone(this.bytes); + } + + /** + * Get the aggregate property: The aggregation function to be applied on the client metric. Allowed functions + * - ‘percentage’ - for error metric , ‘avg’, ‘p50’, ‘p90’, ‘p95’, ‘p99’, ‘min’, + * ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + * ‘count’ - for requests. + * + * @return the aggregate value. + */ + @Generated + public String getAggregate() { + return this.aggregate; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("boolean", this.booleanProperty); + jsonWriter.writeStringField("string", this.string); + jsonWriter.writeBinaryField("bytes", this.bytes); + jsonWriter.writeStringField("aggregate", this.aggregate); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PartialUpdateModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PartialUpdateModel 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 PartialUpdateModel. + */ + @Generated + public static PartialUpdateModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean booleanProperty = false; + String string = null; + byte[] bytes = null; + String aggregate = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("boolean".equals(fieldName)) { + booleanProperty = reader.getBoolean(); + } else if ("string".equals(fieldName)) { + string = reader.getString(); + } else if ("bytes".equals(fieldName)) { + bytes = reader.getBinary(); + } else if ("aggregate".equals(fieldName)) { + aggregate = reader.getString(); + } else { + reader.skipChildren(); + } + } + PartialUpdateModel deserializedPartialUpdateModel = new PartialUpdateModel(booleanProperty, string, bytes); + deserializedPartialUpdateModel.aggregate = aggregate; + return deserializedPartialUpdateModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/models/package-info.java new file mode 100644 index 000000000..b606f3432 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/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 PartialUpdate. + * + */ +package com.cadl.partialupdate.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/package-info.java new file mode 100644 index 000000000..b5c14556f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/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 PartialUpdate. + * + */ +package com.cadl.partialupdate; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/PartialUpdateAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/PartialUpdateAsyncClient.java new file mode 100644 index 000000000..281c3da7e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/PartialUpdateAsyncClient.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 com.cadl.partialupdate; + +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 com.cadl.partialupdate.implementation.PartialUpdateClientImpl; +import com.cadl.partialupdate.models.PartialUpdateModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PartialUpdateClient type. + */ +@ServiceClient(builder = PartialUpdateClientBuilder.class, isAsync = true) +public final class PartialUpdateAsyncClient { + + @Generated + private final PartialUpdateClientImpl serviceClient; + + /** + * Initializes an instance of PartialUpdateAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PartialUpdateAsyncClient(PartialUpdateClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The read operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     aggregate: String (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> readWithResponse(RequestOptions requestOptions) { + return this.serviceClient.readWithResponseAsync(requestOptions); + } + + /** + * The read 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono read() { + // Generated convenience method for readWithResponse + RequestOptions requestOptions = new RequestOptions(); + return readWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PartialUpdateModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/PartialUpdateClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/PartialUpdateClient.java new file mode 100644 index 000000000..880a6ef5c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/PartialUpdateClient.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.cadl.partialupdate; + +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.cadl.partialupdate.implementation.PartialUpdateClientImpl; +import com.cadl.partialupdate.models.PartialUpdateModel; + +/** + * Initializes a new instance of the synchronous PartialUpdateClient type. + */ +@ServiceClient(builder = PartialUpdateClientBuilder.class) +public final class PartialUpdateClient { + + @Generated + private final PartialUpdateClientImpl serviceClient; + + /** + * Initializes an instance of PartialUpdateClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PartialUpdateClient(PartialUpdateClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The read operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     aggregate: String (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response readWithResponse(RequestOptions requestOptions) { + return this.serviceClient.readWithResponse(requestOptions); + } + + /** + * The read 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PartialUpdateModel read() { + // Generated convenience method for readWithResponse + RequestOptions requestOptions = new RequestOptions(); + return readWithResponse(requestOptions).getValue().toObject(PartialUpdateModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/PartialUpdateClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/PartialUpdateClientBuilder.java new file mode 100644 index 000000000..04c87f3af --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/PartialUpdateClientBuilder.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 com.cadl.partialupdate; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.partialupdate.implementation.PartialUpdateClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the PartialUpdateClient type. + */ +@ServiceClientBuilder(serviceClients = { PartialUpdateClient.class, PartialUpdateAsyncClient.class }) +public final class PartialUpdateClientBuilder 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("cadl-partialupdate.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the PartialUpdateClientBuilder. + */ + @Generated + public PartialUpdateClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PartialUpdateClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PartialUpdateClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PartialUpdateClientBuilder 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 PartialUpdateClientBuilder 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 PartialUpdateClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PartialUpdateClientBuilder 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 PartialUpdateClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PartialUpdateClientBuilder 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 PartialUpdateClientBuilder. + */ + @Generated + public PartialUpdateClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of PartialUpdateClientImpl with the provided parameters. + * + * @return an instance of PartialUpdateClientImpl. + */ + @Generated + private PartialUpdateClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + PartialUpdateClientImpl client = new PartialUpdateClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 PartialUpdateAsyncClient class. + * + * @return an instance of PartialUpdateAsyncClient. + */ + @Generated + public PartialUpdateAsyncClient buildAsyncClient() { + return new PartialUpdateAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of PartialUpdateClient class. + * + * @return an instance of PartialUpdateClient. + */ + @Generated + public PartialUpdateClient buildClient() { + return new PartialUpdateClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(PartialUpdateClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/implementation/PartialUpdateClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/implementation/PartialUpdateClientImpl.java new file mode 100644 index 000000000..b845d53aa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/implementation/PartialUpdateClientImpl.java @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.partialupdate.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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 PartialUpdateClient type. + */ +public final class PartialUpdateClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PartialUpdateClientService 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 PartialUpdateClient client. + * + * @param endpoint Service host. + */ + public PartialUpdateClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of PartialUpdateClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public PartialUpdateClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of PartialUpdateClient 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 PartialUpdateClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service + = RestProxy.create(PartialUpdateClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for PartialUpdateClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PartialUpdateClient") + public interface PartialUpdateClientService { + @Get("/partialupdate") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> read(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/partialupdate") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response readSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * The read operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     aggregate: String (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> readWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.read(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The read operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     boolean: boolean (Required)
+     *     string: String (Required)
+     *     bytes: byte[] (Required)
+     *     aggregate: String (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response readWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.readSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/implementation/package-info.java new file mode 100644 index 000000000..8fb2ddadb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/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 PartialUpdate. + * + */ +package com.cadl.partialupdate.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/models/PartialUpdateModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/models/PartialUpdateModel.java new file mode 100644 index 000000000..76ccfdc9a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/models/PartialUpdateModel.java @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.cadl.partialupdate.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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 PartialUpdateModel model. + */ +@Immutable +public final class PartialUpdateModel implements JsonSerializable { + + /* + * The boolean property. + */ + @Generated + private final boolean booleanProperty; + + /* + * The string property. + */ + @Generated + private final String string; + + /* + * The bytes property. + */ + @Generated + private final byte[] bytes; + + /* + * The aggregation function to be applied on the client metric. Allowed functions + * - ‘percentage’ - for error metric , ‘avg’, ‘p50’, ‘p90’, ‘p95’, ‘p99’, ‘min’, + * ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + * ‘count’ - for requests + */ + @Generated + private String aggregate; + + /** + * Creates an instance of PartialUpdateModel class. + * + * @param booleanProperty the booleanProperty value to set. + * @param string the string value to set. + * @param bytes the bytes value to set. + */ + @Generated + private PartialUpdateModel(boolean booleanProperty, String string, byte[] bytes) { + this.booleanProperty = booleanProperty; + this.string = string; + this.bytes = bytes; + } + + /** + * Get the booleanProperty property: The boolean property. + * + * @return the booleanProperty value. + */ + @Generated + public boolean isBooleanProperty() { + return this.booleanProperty; + } + + /** + * Get the string property: The string property. + * + * @return the string value. + */ + @Generated + public String getString() { + return this.string; + } + + /** + * Get the bytes property: The bytes property. + * + * @return the bytes value. + */ + @Generated + public byte[] getBytes() { + return CoreUtils.clone(this.bytes); + } + + /** + * Get the aggregate property: The aggregation function to be applied on the client metric. Allowed functions + * - ‘percentage’ - for error metric , ‘avg’, ‘p50’, ‘p90’, ‘p95’, ‘p99’, ‘min’, + * ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + * ‘count’ - for requests. + * + * @return the aggregate value. + */ + @Generated + public String getAggregate() { + return this.aggregate; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("boolean", this.booleanProperty); + jsonWriter.writeStringField("string", this.string); + jsonWriter.writeBinaryField("bytes", this.bytes); + jsonWriter.writeStringField("aggregate", this.aggregate); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PartialUpdateModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PartialUpdateModel 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 PartialUpdateModel. + */ + @Generated + public static PartialUpdateModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean booleanProperty = false; + String string = null; + byte[] bytes = null; + String aggregate = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("boolean".equals(fieldName)) { + booleanProperty = reader.getBoolean(); + } else if ("string".equals(fieldName)) { + string = reader.getString(); + } else if ("bytes".equals(fieldName)) { + bytes = reader.getBinary(); + } else if ("aggregate".equals(fieldName)) { + aggregate = reader.getString(); + } else { + reader.skipChildren(); + } + } + PartialUpdateModel deserializedPartialUpdateModel = new PartialUpdateModel(booleanProperty, string, bytes); + deserializedPartialUpdateModel.aggregate = aggregate; + return deserializedPartialUpdateModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/models/package-info.java new file mode 100644 index 000000000..b606f3432 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/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 PartialUpdate. + * + */ +package com.cadl.partialupdate.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/package-info.java new file mode 100644 index 000000000..b5c14556f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/partialupdate/partialupdate/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 PartialUpdate. + * + */ +package com.cadl.partialupdate; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/PatchAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/PatchAsyncClient.java new file mode 100644 index 000000000..4dea94aaf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/PatchAsyncClient.java @@ -0,0 +1,344 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.patch; + +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 com.cadl.patch.implementation.JsonMergePatchHelper; +import com.cadl.patch.implementation.PatchesImpl; +import com.cadl.patch.models.Fish; +import com.cadl.patch.models.Resource; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PatchClient type. + */ +@ServiceClient(builder = PatchClientBuilder.class, isAsync = true) +public final class PatchAsyncClient { + @Generated + private final PatchesImpl serviceClient; + + /** + * Initializes an instance of PatchAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PatchAsyncClient(PatchesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The createOrUpdateResource operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param resource The resource 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateResourceWithResponse(BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateResourceWithResponseAsync(resource, requestOptions); + } + + /** + * The createOrUpdateOptionalResource operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/merge-patch+json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateOptionalResourceWithResponse(RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateOptionalResourceWithResponseAsync(requestOptions); + } + + /** + * The createOrUpdateFish operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     id: String (Required)
+     *     name: String (Required)
+     *     age: int (Optional, Required on create)
+     *     color: String (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     id: String (Required)
+     *     name: String (Required)
+     *     age: int (Optional, Required on create)
+     *     color: String (Optional)
+     * }
+     * }
+ * + * @param fish The fish 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateFishWithResponse(BinaryData fish, RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateFishWithResponseAsync(fish, requestOptions); + } + + /** + * The createOrUpdateResource operation. + * + * @param resource The resource 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrUpdateResource(Resource resource) { + // Generated convenience method for createOrUpdateResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, false); + return createOrUpdateResourceWithResponse(resourceInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * The createOrUpdateOptionalResource operation. + * + * @param resource The resource 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrUpdateOptionalResource(Resource resource) { + // Generated convenience method for createOrUpdateOptionalResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (resource != null) { + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, false); + requestOptions.setBody(resourceInBinaryData); + } + return createOrUpdateOptionalResourceWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * The createOrUpdateOptionalResource 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrUpdateOptionalResource() { + // Generated convenience method for createOrUpdateOptionalResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createOrUpdateOptionalResourceWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * The createOrUpdateFish operation. + * + * @param fish The fish 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 this is base model for polymorphic multiple levels inheritance with a discriminator on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrUpdateFish(Fish fish) { + // Generated convenience method for createOrUpdateFishWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getFishAccessor().prepareModelForJsonMergePatch(fish, true); + BinaryData fishInBinaryData = BinaryData.fromObject(fish); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + fishInBinaryData.getLength(); + JsonMergePatchHelper.getFishAccessor().prepareModelForJsonMergePatch(fish, false); + return createOrUpdateFishWithResponse(fishInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Fish.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/PatchClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/PatchClient.java new file mode 100644 index 000000000..05d644605 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/PatchClient.java @@ -0,0 +1,337 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.patch; + +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.cadl.patch.implementation.JsonMergePatchHelper; +import com.cadl.patch.implementation.PatchesImpl; +import com.cadl.patch.models.Fish; +import com.cadl.patch.models.Resource; + +/** + * Initializes a new instance of the synchronous PatchClient type. + */ +@ServiceClient(builder = PatchClientBuilder.class) +public final class PatchClient { + @Generated + private final PatchesImpl serviceClient; + + /** + * Initializes an instance of PatchClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PatchClient(PatchesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The createOrUpdateResource operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param resource The resource 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateResourceWithResponse(BinaryData resource, RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateResourceWithResponse(resource, requestOptions); + } + + /** + * The createOrUpdateOptionalResource operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/merge-patch+json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateOptionalResourceWithResponse(RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateOptionalResourceWithResponse(requestOptions); + } + + /** + * The createOrUpdateFish operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     id: String (Required)
+     *     name: String (Required)
+     *     age: int (Optional, Required on create)
+     *     color: String (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     id: String (Required)
+     *     name: String (Required)
+     *     age: int (Optional, Required on create)
+     *     color: String (Optional)
+     * }
+     * }
+ * + * @param fish The fish 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateFishWithResponse(BinaryData fish, RequestOptions requestOptions) { + return this.serviceClient.createOrUpdateFishWithResponse(fish, requestOptions); + } + + /** + * The createOrUpdateResource operation. + * + * @param resource The resource 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource createOrUpdateResource(Resource resource) { + // Generated convenience method for createOrUpdateResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, false); + return createOrUpdateResourceWithResponse(resourceInBinaryData, requestOptions).getValue() + .toObject(Resource.class); + } + + /** + * The createOrUpdateOptionalResource operation. + * + * @param resource The resource 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource createOrUpdateOptionalResource(Resource resource) { + // Generated convenience method for createOrUpdateOptionalResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (resource != null) { + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, false); + requestOptions.setBody(resourceInBinaryData); + } + return createOrUpdateOptionalResourceWithResponse(requestOptions).getValue().toObject(Resource.class); + } + + /** + * The createOrUpdateOptionalResource 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource createOrUpdateOptionalResource() { + // Generated convenience method for createOrUpdateOptionalResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createOrUpdateOptionalResourceWithResponse(requestOptions).getValue().toObject(Resource.class); + } + + /** + * The createOrUpdateFish operation. + * + * @param fish The fish 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 this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish createOrUpdateFish(Fish fish) { + // Generated convenience method for createOrUpdateFishWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getFishAccessor().prepareModelForJsonMergePatch(fish, true); + BinaryData fishInBinaryData = BinaryData.fromObject(fish); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + fishInBinaryData.getLength(); + JsonMergePatchHelper.getFishAccessor().prepareModelForJsonMergePatch(fish, false); + return createOrUpdateFishWithResponse(fishInBinaryData, requestOptions).getValue().toObject(Fish.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/PatchClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/PatchClientBuilder.java new file mode 100644 index 000000000..2601d785d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/PatchClientBuilder.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 com.cadl.patch; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.patch.implementation.PatchClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the PatchClient type. + */ +@ServiceClientBuilder(serviceClients = { PatchClient.class, PatchAsyncClient.class }) +public final class PatchClientBuilder 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("cadl-patch.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the PatchClientBuilder. + */ + @Generated + public PatchClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PatchClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PatchClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PatchClientBuilder 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 PatchClientBuilder 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 PatchClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PatchClientBuilder 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 PatchClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PatchClientBuilder 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 PatchClientBuilder. + */ + @Generated + public PatchClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of PatchClientImpl with the provided parameters. + * + * @return an instance of PatchClientImpl. + */ + @Generated + private PatchClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + PatchClientImpl client + = new PatchClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 PatchAsyncClient class. + * + * @return an instance of PatchAsyncClient. + */ + @Generated + public PatchAsyncClient buildAsyncClient() { + return new PatchAsyncClient(buildInnerClient().getPatches()); + } + + /** + * Builds an instance of PatchClient class. + * + * @return an instance of PatchClient. + */ + @Generated + public PatchClient buildClient() { + return new PatchClient(buildInnerClient().getPatches()); + } + + private static final ClientLogger LOGGER = new ClientLogger(PatchClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/implementation/JsonMergePatchHelper.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/implementation/JsonMergePatchHelper.java new file mode 100644 index 000000000..2c2d5f223 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/implementation/JsonMergePatchHelper.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 com.cadl.patch.implementation; + +import com.cadl.patch.models.Fish; +import com.cadl.patch.models.InnerModel; +import com.cadl.patch.models.Resource; +import com.cadl.patch.models.Shark; + +/** + * This is the Helper class to enable json merge patch serialization for a model. + */ +public class JsonMergePatchHelper { + private static ResourceAccessor resourceAccessor; + + public interface ResourceAccessor { + Resource prepareModelForJsonMergePatch(Resource resource, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(Resource resource); + } + + public static void setResourceAccessor(ResourceAccessor accessor) { + resourceAccessor = accessor; + } + + public static ResourceAccessor getResourceAccessor() { + return resourceAccessor; + } + + private static InnerModelAccessor innerModelAccessor; + + public interface InnerModelAccessor { + InnerModel prepareModelForJsonMergePatch(InnerModel innerModel, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(InnerModel innerModel); + } + + public static void setInnerModelAccessor(InnerModelAccessor accessor) { + innerModelAccessor = accessor; + } + + public static InnerModelAccessor getInnerModelAccessor() { + return innerModelAccessor; + } + + private static FishAccessor fishAccessor; + + public interface FishAccessor { + Fish prepareModelForJsonMergePatch(Fish fish, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(Fish fish); + + void setId(Fish fish, String id); + + void setName(Fish fish, String name); + + void setAge(Fish fish, int age); + + void setColor(Fish fish, String color); + } + + public static void setFishAccessor(FishAccessor accessor) { + fishAccessor = accessor; + } + + public static FishAccessor getFishAccessor() { + return fishAccessor; + } + + private static SharkAccessor sharkAccessor; + + public interface SharkAccessor { + void setWeight(Shark shark, Integer weight); + } + + public static void setSharkAccessor(SharkAccessor accessor) { + sharkAccessor = accessor; + } + + public static SharkAccessor getSharkAccessor() { + return sharkAccessor; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/implementation/PatchClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/implementation/PatchClientImpl.java new file mode 100644 index 000000000..e6cdd0a91 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/implementation/PatchClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.patch.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the PatchClient type. + */ +public final class PatchClientImpl { + /** + * 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; + } + + /** + * The PatchesImpl object to access its operations. + */ + private final PatchesImpl patches; + + /** + * Gets the PatchesImpl object to access its operations. + * + * @return the PatchesImpl object. + */ + public PatchesImpl getPatches() { + return this.patches; + } + + /** + * Initializes an instance of PatchClient client. + * + * @param endpoint Service host. + */ + public PatchClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of PatchClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public PatchClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of PatchClient 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 PatchClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.patches = new PatchesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/implementation/PatchesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/implementation/PatchesImpl.java new file mode 100644 index 000000000..4c05f57d8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/implementation/PatchesImpl.java @@ -0,0 +1,545 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.patch.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.Patch; +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.HttpHeaderName; +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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Patches. + */ +public final class PatchesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PatchesService service; + + /** + * The service client containing this operation class. + */ + private final PatchClientImpl client; + + /** + * Initializes an instance of PatchesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PatchesImpl(PatchClientImpl client) { + this.service = RestProxy.create(PatchesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for PatchClientPatches to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PatchClientPatches") + public interface PatchesService { + @Patch("/patch/resource") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrUpdateResource(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + Context context); + + @Patch("/patch/resource") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createOrUpdateResourceSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + Context context); + + @Patch("/patch/resource/optional") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrUpdateOptionalResource(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Patch("/patch/resource/optional") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createOrUpdateOptionalResourceSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Patch("/patch/fish") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrUpdateFish(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData fish, RequestOptions requestOptions, Context context); + + @Patch("/patch/fish") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createOrUpdateFishSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData fish, RequestOptions requestOptions, Context context); + } + + /** + * The createOrUpdateResource operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param resource The resource 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateResourceWithResponseAsync(BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createOrUpdateResource(this.client.getEndpoint(), contentType, + accept, resource, requestOptions, context)); + } + + /** + * The createOrUpdateResource operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param resource The resource 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateResourceWithResponse(BinaryData resource, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return service.createOrUpdateResourceSync(this.client.getEndpoint(), contentType, accept, resource, + requestOptions, Context.NONE); + } + + /** + * The createOrUpdateOptionalResource operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/merge-patch+json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateOptionalResourceWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/merge-patch+json"); + } + }); + return FluxUtil.withContext(context -> service.createOrUpdateOptionalResource(this.client.getEndpoint(), accept, + requestOptionsLocal, context)); + } + + /** + * The createOrUpdateOptionalResource operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/merge-patch+json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional, Required on create): {
+     *         String (Required): {
+     *             name: String (Optional, Required on create)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     longValue: Long (Optional)
+     *     intValue: Integer (Optional)
+     *     enumValue: String(a/b/c) (Optional)
+     *     wireNameForInnerModelProperty (Optional): (recursive schema, see wireNameForInnerModelProperty above)
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     fish (Optional): {
+     *         kind: String (Required)
+     *         id: String (Required)
+     *         name: String (Required)
+     *         age: int (Optional, Required on create)
+     *         color: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateOptionalResourceWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/merge-patch+json"); + } + }); + return service.createOrUpdateOptionalResourceSync(this.client.getEndpoint(), accept, requestOptionsLocal, + Context.NONE); + } + + /** + * The createOrUpdateFish operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     id: String (Required)
+     *     name: String (Required)
+     *     age: int (Optional, Required on create)
+     *     color: String (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     id: String (Required)
+     *     name: String (Required)
+     *     age: int (Optional, Required on create)
+     *     color: String (Optional)
+     * }
+     * }
+ * + * @param fish The fish 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrUpdateFishWithResponseAsync(BinaryData fish, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createOrUpdateFish(this.client.getEndpoint(), contentType, + accept, fish, requestOptions, context)); + } + + /** + * The createOrUpdateFish operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     id: String (Required)
+     *     name: String (Required)
+     *     age: int (Optional, Required on create)
+     *     color: String (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     id: String (Required)
+     *     name: String (Required)
+     *     age: int (Optional, Required on create)
+     *     color: String (Optional)
+     * }
+     * }
+ * + * @param fish The fish 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateFishWithResponse(BinaryData fish, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return service.createOrUpdateFishSync(this.client.getEndpoint(), contentType, accept, fish, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/implementation/package-info.java new file mode 100644 index 000000000..e038d0c6e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 PatchModel. + * + */ +package com.cadl.patch.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/Fish.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/Fish.java new file mode 100644 index 000000000..86f0597e4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/Fish.java @@ -0,0 +1,295 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.patch.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 com.cadl.patch.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * This is base model for polymorphic multiple levels inheritance with a discriminator. + */ +@Fluent +public class Fish implements JsonSerializable { + /* + * Discriminator property for Fish. + */ + @Generated + String kind; + + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private String name; + + /* + * The age property. + */ + @Generated + private int age; + + /* + * The color property. + */ + @Generated + private String color; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setFishAccessor(new JsonMergePatchHelper.FishAccessor() { + @Override + public Fish prepareModelForJsonMergePatch(Fish model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(Fish model) { + return model.jsonMergePatch; + } + + @Override + public void setId(Fish model, String id) { + model.id = id; + } + + @Override + public void setName(Fish model, String name) { + model.name = name; + } + + @Override + public void setAge(Fish model, int age) { + model.age = age; + } + + @Override + public void setColor(Fish model, String color) { + model.color = color; + } + }); + } + + /** + * Creates an instance of Fish class. + */ + @Generated + public Fish() { + this.kind = "Fish"; + } + + /** + * Get the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + @Generated + public String getKind() { + return this.kind; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Generated + public int getAge() { + return this.age; + } + + /** + * Set the age property: The age property. + *

Required when create the resource.

+ * + * @param age the age value to set. + * @return the Fish object itself. + */ + @Generated + public Fish setAge(int age) { + this.age = age; + this.updatedProperties.add("age"); + return this; + } + + /** + * Get the color property: The color property. + * + * @return the color value. + */ + @Generated + public String getColor() { + return this.color; + } + + /** + * Set the color property: The color property. + * + * @param color the color value to set. + * @return the Fish object itself. + */ + @Generated + public Fish setColor(String color) { + this.color = color; + this.updatedProperties.add("color"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeIntField("age", this.age); + jsonWriter.writeStringField("color", this.color); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + if (updatedProperties.contains("age")) { + jsonWriter.writeIntField("age", this.age); + } + if (updatedProperties.contains("color")) { + if (this.color == null) { + jsonWriter.writeNullField("color"); + } else { + jsonWriter.writeStringField("color", this.color); + } + } + 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 -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("shark".equals(discriminatorValue)) { + return Shark.fromJson(readerToUse.reset()); + } else if ("salmon".equals(discriminatorValue)) { + return Salmon.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Fish fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Fish deserializedFish = new Fish(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if (!Fish.fromJsonShared(reader, fieldName, deserializedFish)) { + reader.skipChildren(); + } + } + + return deserializedFish; + }); + } + + @Generated + static boolean fromJsonShared(JsonReader reader, String fieldName, Fish deserializedFish) throws IOException { + if ("id".equals(fieldName)) { + deserializedFish.id = reader.getString(); + return true; + } else if ("name".equals(fieldName)) { + deserializedFish.name = reader.getString(); + return true; + } else if ("kind".equals(fieldName)) { + deserializedFish.kind = reader.getString(); + return true; + } else if ("age".equals(fieldName)) { + deserializedFish.age = reader.getInt(); + return true; + } else if ("color".equals(fieldName)) { + deserializedFish.color = reader.getString(); + return true; + } + return false; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/InnerModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/InnerModel.java new file mode 100644 index 000000000..0be134f8d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/InnerModel.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.patch.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 com.cadl.patch.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The InnerModel model. + */ +@Fluent +public final class InnerModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private String name; + + /* + * The description property. + */ + @Generated + private String description; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setInnerModelAccessor(new JsonMergePatchHelper.InnerModelAccessor() { + @Override + public InnerModel prepareModelForJsonMergePatch(InnerModel model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(InnerModel model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of InnerModel class. + */ + @Generated + public InnerModel() { + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The name property. + *

Required when create the resource.

+ * + * @param name the name value to set. + * @return the InnerModel object itself. + */ + @Generated + public InnerModel setName(String name) { + this.name = name; + this.updatedProperties.add("name"); + return this; + } + + /** + * Get the description property: The description property. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The description property. + * + * @param description the description value to set. + * @return the InnerModel object itself. + */ + @Generated + public InnerModel setDescription(String description) { + this.description = description; + this.updatedProperties.add("description"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("name")) { + if (this.name == null) { + jsonWriter.writeNullField("name"); + } else { + jsonWriter.writeStringField("name", this.name); + } + } + if (updatedProperties.contains("description")) { + if (this.description == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", this.description); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerModel 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 InnerModel. + */ + @Generated + public static InnerModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + InnerModel deserializedInnerModel = new InnerModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedInnerModel.name = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedInnerModel.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedInnerModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/Resource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/Resource.java new file mode 100644 index 000000000..0255285d6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/Resource.java @@ -0,0 +1,471 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.patch.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 com.cadl.patch.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * The Resource model. + */ +@Fluent +public final class Resource implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private String name; + + /* + * The description property. + */ + @Generated + private String description; + + /* + * The map property. + */ + @Generated + private Map map; + + /* + * The longValue property. + */ + @Generated + private Long longValue; + + /* + * The intValue property. + */ + @Generated + private Integer intValue; + + /* + * The enumValue property. + */ + @Generated + private ResourceEnumValue enumValue; + + /* + * The wireNameForInnerModelProperty property. + */ + @Generated + private InnerModel innerModelProperty; + + /* + * The array property. + */ + @Generated + private List array; + + /* + * The fish property. + */ + @Generated + private Fish fish; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setResourceAccessor(new JsonMergePatchHelper.ResourceAccessor() { + @Override + public Resource prepareModelForJsonMergePatch(Resource model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(Resource model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of Resource class. + */ + @Generated + public Resource() { + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the description property: The description property. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The description property. + * + * @param description the description value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setDescription(String description) { + this.description = description; + this.updatedProperties.add("description"); + return this; + } + + /** + * Get the map property: The map property. + * + * @return the map value. + */ + @Generated + public Map getMap() { + return this.map; + } + + /** + * Set the map property: The map property. + *

Required when create the resource.

+ * + * @param map the map value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setMap(Map map) { + this.map = map; + this.updatedProperties.add("map"); + return this; + } + + /** + * Get the longValue property: The longValue property. + * + * @return the longValue value. + */ + @Generated + public Long getLongValue() { + return this.longValue; + } + + /** + * Set the longValue property: The longValue property. + * + * @param longValue the longValue value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setLongValue(Long longValue) { + this.longValue = longValue; + this.updatedProperties.add("longValue"); + return this; + } + + /** + * Get the intValue property: The intValue property. + * + * @return the intValue value. + */ + @Generated + public Integer getIntValue() { + return this.intValue; + } + + /** + * Set the intValue property: The intValue property. + * + * @param intValue the intValue value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setIntValue(Integer intValue) { + this.intValue = intValue; + this.updatedProperties.add("intValue"); + return this; + } + + /** + * Get the enumValue property: The enumValue property. + * + * @return the enumValue value. + */ + @Generated + public ResourceEnumValue getEnumValue() { + return this.enumValue; + } + + /** + * Set the enumValue property: The enumValue property. + * + * @param enumValue the enumValue value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setEnumValue(ResourceEnumValue enumValue) { + this.enumValue = enumValue; + this.updatedProperties.add("enumValue"); + return this; + } + + /** + * Get the innerModelProperty property: The wireNameForInnerModelProperty property. + * + * @return the innerModelProperty value. + */ + @Generated + public InnerModel getInnerModelProperty() { + return this.innerModelProperty; + } + + /** + * Set the innerModelProperty property: The wireNameForInnerModelProperty property. + * + * @param innerModelProperty the innerModelProperty value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setInnerModelProperty(InnerModel innerModelProperty) { + this.innerModelProperty = innerModelProperty; + this.updatedProperties.add("innerModelProperty"); + return this; + } + + /** + * Get the array property: The array property. + * + * @return the array value. + */ + @Generated + public List getArray() { + return this.array; + } + + /** + * Set the array property: The array property. + * + * @param array the array value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setArray(List array) { + this.array = array; + this.updatedProperties.add("array"); + return this; + } + + /** + * Get the fish property: The fish property. + * + * @return the fish value. + */ + @Generated + public Fish getFish() { + return this.fish; + } + + /** + * Set the fish property: The fish property. + * + * @param fish the fish value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setFish(Fish fish) { + this.fish = fish; + this.updatedProperties.add("fish"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeMapField("map", this.map, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeNumberField("longValue", this.longValue); + jsonWriter.writeNumberField("intValue", this.intValue); + jsonWriter.writeStringField("enumValue", this.enumValue == null ? null : this.enumValue.toString()); + jsonWriter.writeJsonField("wireNameForInnerModelProperty", this.innerModelProperty); + jsonWriter.writeArrayField("array", this.array, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("fish", this.fish); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("description")) { + if (this.description == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", this.description); + } + } + if (updatedProperties.contains("map")) { + if (this.map == null) { + jsonWriter.writeNullField("map"); + } else { + jsonWriter.writeMapField("map", this.map, (writer, element) -> { + if (element != null) { + JsonMergePatchHelper.getInnerModelAccessor().prepareModelForJsonMergePatch(element, true); + writer.writeJson(element); + JsonMergePatchHelper.getInnerModelAccessor().prepareModelForJsonMergePatch(element, false); + } else { + writer.writeNull(); + } + }); + } + } + if (updatedProperties.contains("longValue")) { + if (this.longValue == null) { + jsonWriter.writeNullField("longValue"); + } else { + jsonWriter.writeNumberField("longValue", this.longValue); + } + } + if (updatedProperties.contains("intValue")) { + if (this.intValue == null) { + jsonWriter.writeNullField("intValue"); + } else { + jsonWriter.writeNumberField("intValue", this.intValue); + } + } + if (updatedProperties.contains("enumValue")) { + if (this.enumValue == null) { + jsonWriter.writeNullField("enumValue"); + } else { + jsonWriter.writeStringField("enumValue", this.enumValue.toString()); + } + } + if (updatedProperties.contains("innerModelProperty")) { + if (this.innerModelProperty == null) { + jsonWriter.writeNullField("wireNameForInnerModelProperty"); + } else { + JsonMergePatchHelper.getInnerModelAccessor() + .prepareModelForJsonMergePatch(this.innerModelProperty, true); + jsonWriter.writeJsonField("wireNameForInnerModelProperty", this.innerModelProperty); + JsonMergePatchHelper.getInnerModelAccessor() + .prepareModelForJsonMergePatch(this.innerModelProperty, false); + } + } + if (updatedProperties.contains("array")) { + if (this.array == null) { + jsonWriter.writeNullField("array"); + } else { + jsonWriter.writeArrayField("array", this.array, (writer, element) -> writer.writeJson(element)); + } + } + if (updatedProperties.contains("fish")) { + if (this.fish == null) { + jsonWriter.writeNullField("fish"); + } else { + JsonMergePatchHelper.getFishAccessor().prepareModelForJsonMergePatch(this.fish, true); + jsonWriter.writeJsonField("fish", this.fish); + JsonMergePatchHelper.getFishAccessor().prepareModelForJsonMergePatch(this.fish, false); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource 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 Resource. + */ + @Generated + public static Resource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Resource deserializedResource = new Resource(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedResource.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedResource.name = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedResource.description = reader.getString(); + } else if ("map".equals(fieldName)) { + Map map = reader.readMap(reader1 -> InnerModel.fromJson(reader1)); + deserializedResource.map = map; + } else if ("longValue".equals(fieldName)) { + deserializedResource.longValue = reader.getNullable(JsonReader::getLong); + } else if ("intValue".equals(fieldName)) { + deserializedResource.intValue = reader.getNullable(JsonReader::getInt); + } else if ("enumValue".equals(fieldName)) { + deserializedResource.enumValue = ResourceEnumValue.fromString(reader.getString()); + } else if ("wireNameForInnerModelProperty".equals(fieldName)) { + deserializedResource.innerModelProperty = InnerModel.fromJson(reader); + } else if ("array".equals(fieldName)) { + List array = reader.readArray(reader1 -> InnerModel.fromJson(reader1)); + deserializedResource.array = array; + } else if ("fish".equals(fieldName)) { + deserializedResource.fish = Fish.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedResource; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/ResourceEnumValue.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/ResourceEnumValue.java new file mode 100644 index 000000000..3645916d7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/ResourceEnumValue.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.patch.models; + +/** + * Defines values for ResourceEnumValue. + */ +public enum ResourceEnumValue { + /** + * Enum value a. + */ + A("a"), + + /** + * Enum value b. + */ + B("b"), + + /** + * Enum value c. + */ + C("c"); + + /** + * The actual serialized value for a ResourceEnumValue instance. + */ + private final String value; + + ResourceEnumValue(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ResourceEnumValue instance. + * + * @param value the serialized value to parse. + * @return the parsed ResourceEnumValue object, or null if unable to parse. + */ + public static ResourceEnumValue fromString(String value) { + if (value == null) { + return null; + } + ResourceEnumValue[] items = ResourceEnumValue.values(); + for (ResourceEnumValue item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/Salmon.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/Salmon.java new file mode 100644 index 000000000..339026314 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/Salmon.java @@ -0,0 +1,251 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.patch.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.patch.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * The second level model in polymorphic multiple levels inheritance which contains references to other polymorphic + * instances. + */ +@Fluent +public final class Salmon extends Fish { + /* + * The friends property. + */ + @Generated + private List friends; + + /* + * The hate property. + */ + @Generated + private Map hate; + + /* + * The partner property. + */ + @Generated + private Fish partner; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of Salmon class. + */ + @Generated + public Salmon() { + this.kind = "salmon"; + } + + /** + * Get the friends property: The friends property. + * + * @return the friends value. + */ + @Generated + public List getFriends() { + return this.friends; + } + + /** + * Set the friends property: The friends property. + * + * @param friends the friends value to set. + * @return the Salmon object itself. + */ + @Generated + public Salmon setFriends(List friends) { + this.friends = friends; + this.updatedProperties.add("friends"); + return this; + } + + /** + * Get the hate property: The hate property. + * + * @return the hate value. + */ + @Generated + public Map getHate() { + return this.hate; + } + + /** + * Set the hate property: The hate property. + * + * @param hate the hate value to set. + * @return the Salmon object itself. + */ + @Generated + public Salmon setHate(Map hate) { + this.hate = hate; + this.updatedProperties.add("hate"); + return this; + } + + /** + * Get the partner property: The partner property. + * + * @return the partner value. + */ + @Generated + public Fish getPartner() { + return this.partner; + } + + /** + * Set the partner property: The partner property. + * + * @param partner the partner value to set. + * @return the Salmon object itself. + */ + @Generated + public Salmon setPartner(Fish partner) { + this.partner = partner; + this.updatedProperties.add("partner"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Salmon setAge(int age) { + super.setAge(age); + this.updatedProperties.add("age"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Salmon setColor(String color) { + super.setColor(color); + this.updatedProperties.add("color"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getFishAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("age", getAge()); + jsonWriter.writeStringField("color", getColor()); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeArrayField("friends", this.friends, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeMapField("hate", this.hate, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("partner", this.partner); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("age")) { + jsonWriter.writeIntField("age", getAge()); + } + if (updatedProperties.contains("color")) { + if (getColor() == null) { + jsonWriter.writeNullField("color"); + } else { + jsonWriter.writeStringField("color", getColor()); + } + } + jsonWriter.writeStringField("kind", this.kind); + if (updatedProperties.contains("friends")) { + if (this.friends == null) { + jsonWriter.writeNullField("friends"); + } else { + jsonWriter.writeArrayField("friends", this.friends, (writer, element) -> writer.writeJson(element)); + } + } + if (updatedProperties.contains("hate")) { + if (this.hate == null) { + jsonWriter.writeNullField("hate"); + } else { + jsonWriter.writeMapField("hate", this.hate, (writer, element) -> { + if (element != null) { + JsonMergePatchHelper.getFishAccessor().prepareModelForJsonMergePatch(element, true); + writer.writeJson(element); + JsonMergePatchHelper.getFishAccessor().prepareModelForJsonMergePatch(element, false); + } else { + writer.writeNull(); + } + }); + } + } + if (updatedProperties.contains("partner")) { + if (this.partner == null) { + jsonWriter.writeNullField("partner"); + } else { + JsonMergePatchHelper.getFishAccessor().prepareModelForJsonMergePatch(this.partner, true); + jsonWriter.writeJsonField("partner", this.partner); + JsonMergePatchHelper.getFishAccessor().prepareModelForJsonMergePatch(this.partner, false); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Salmon from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Salmon 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 Salmon. + */ + @Generated + public static Salmon fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Salmon deserializedSalmon = new Salmon(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if (Fish.fromJsonShared(reader, fieldName, deserializedSalmon)) { + continue; + } else if ("friends".equals(fieldName)) { + List friends = reader.readArray(reader1 -> Fish.fromJson(reader1)); + deserializedSalmon.friends = friends; + } else if ("hate".equals(fieldName)) { + Map hate = reader.readMap(reader1 -> Fish.fromJson(reader1)); + deserializedSalmon.hate = hate; + } else if ("partner".equals(fieldName)) { + deserializedSalmon.partner = Fish.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSalmon; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/SawShark.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/SawShark.java new file mode 100644 index 000000000..9be54bb8b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/SawShark.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.patch.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.patch.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The third level model SawShark in polymorphic multiple levels inheritance. + */ +@Fluent +public final class SawShark extends Shark { + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + /** + * Creates an instance of SawShark class. + */ + @Generated + public SawShark() { + this.kind = "shark"; + this.sharktype = "saw"; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public SawShark setWeight(Integer weight) { + super.setWeight(weight); + this.updatedProperties.add("weight"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public SawShark setAge(int age) { + super.setAge(age); + this.updatedProperties.add("age"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public SawShark setColor(String color) { + super.setColor(color); + this.updatedProperties.add("color"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getFishAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeIntField("age", getAge()); + jsonWriter.writeStringField("color", getColor()); + jsonWriter.writeNumberField("weight", getWeight()); + jsonWriter.writeStringField("sharktype", this.sharktype); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + if (updatedProperties.contains("age")) { + jsonWriter.writeIntField("age", getAge()); + } + if (updatedProperties.contains("color")) { + if (getColor() == null) { + jsonWriter.writeNullField("color"); + } else { + jsonWriter.writeStringField("color", getColor()); + } + } + if (updatedProperties.contains("weight")) { + if (getWeight() == null) { + jsonWriter.writeNullField("weight"); + } else { + jsonWriter.writeNumberField("weight", getWeight()); + } + } + jsonWriter.writeStringField("sharktype", this.sharktype); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SawShark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SawShark 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 SawShark. + */ + @Generated + public static SawShark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SawShark deserializedSawShark = new SawShark(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if (Shark.fromJsonShared(reader, fieldName, deserializedSawShark)) { + continue; + } else { + reader.skipChildren(); + } + } + + return deserializedSawShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/Shark.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/Shark.java new file mode 100644 index 000000000..0e383f40a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/Shark.java @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.patch.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.patch.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The second level model in polymorphic multiple levels inheritance and it defines a new discriminator. + */ +@Fluent +public class Shark extends Fish { + /* + * The sharktype property. + */ + @Generated + String sharktype; + + /* + * The weight property. + */ + @Generated + private Integer weight; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + static { + JsonMergePatchHelper.setSharkAccessor(new JsonMergePatchHelper.SharkAccessor() { + @Override + public void setWeight(Shark model, Integer weight) { + model.weight = weight; + } + }); + } + + /** + * Creates an instance of Shark class. + */ + @Generated + public Shark() { + this.kind = "shark"; + this.sharktype = "shark"; + } + + /** + * Get the sharktype property: The sharktype property. + * + * @return the sharktype value. + */ + @Generated + public String getSharktype() { + return this.sharktype; + } + + /** + * Get the weight property: The weight property. + * + * @return the weight value. + */ + @Generated + public Integer getWeight() { + return this.weight; + } + + /** + * Set the weight property: The weight property. + * + * @param weight the weight value to set. + * @return the Shark object itself. + */ + @Generated + public Shark setWeight(Integer weight) { + this.weight = weight; + this.updatedProperties.add("weight"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Shark setAge(int age) { + super.setAge(age); + this.updatedProperties.add("age"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Shark setColor(String color) { + super.setColor(color); + this.updatedProperties.add("color"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (JsonMergePatchHelper.getFishAccessor().isJsonMergePatch(this)) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeIntField("age", getAge()); + jsonWriter.writeStringField("color", getColor()); + jsonWriter.writeStringField("sharktype", this.sharktype); + jsonWriter.writeNumberField("weight", this.weight); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + if (updatedProperties.contains("age")) { + jsonWriter.writeIntField("age", getAge()); + } + if (updatedProperties.contains("color")) { + if (getColor() == null) { + jsonWriter.writeNullField("color"); + } else { + jsonWriter.writeStringField("color", getColor()); + } + } + jsonWriter.writeStringField("sharktype", this.sharktype); + if (updatedProperties.contains("weight")) { + if (this.weight == null) { + jsonWriter.writeNullField("weight"); + } else { + jsonWriter.writeNumberField("weight", this.weight); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Shark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Shark 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 Shark. + */ + @Generated + public static Shark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("sharktype".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("saw".equals(discriminatorValue)) { + return SawShark.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Shark fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Shark deserializedShark = new Shark(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if (!Shark.fromJsonShared(reader, fieldName, deserializedShark)) { + reader.skipChildren(); + } + } + + return deserializedShark; + }); + } + + @Generated + static boolean fromJsonShared(JsonReader reader, String fieldName, Shark deserializedShark) throws IOException { + if (Fish.fromJsonShared(reader, fieldName, deserializedShark)) { + return true; + } else if ("sharktype".equals(fieldName)) { + deserializedShark.sharktype = reader.getString(); + return true; + } else if ("weight".equals(fieldName)) { + deserializedShark.weight = reader.getNullable(JsonReader::getInt); + return true; + } + return false; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/package-info.java new file mode 100644 index 000000000..9863a70a1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/models/package-info.java @@ -0,0 +1,10 @@ +// 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 PatchModel. + * + */ +package com.cadl.patch.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/package-info.java new file mode 100644 index 000000000..60084d511 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/patch/package-info.java @@ -0,0 +1,10 @@ +// 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 PatchModel. + * + */ +package com.cadl.patch; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/ProtocolAndConvenientAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/ProtocolAndConvenientAsyncClient.java new file mode 100644 index 000000000..52ed37be7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/ProtocolAndConvenientAsyncClient.java @@ -0,0 +1,354 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient; + +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.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +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 com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollOperationDetails; +import com.cadl.protocolandconvenient.implementation.ProtocolAndConvenienceOpsImpl; +import com.cadl.protocolandconvenient.models.ResourceA; +import com.cadl.protocolandconvenient.models.ResourceB; +import com.cadl.protocolandconvenient.models.ResourceE; +import com.cadl.protocolandconvenient.models.ResourceF; +import com.cadl.protocolandconvenient.models.ResourceI; +import com.cadl.protocolandconvenient.models.ResourceJ; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ProtocolAndConvenientClient type. + */ +@ServiceClient(builder = ProtocolAndConvenientClientBuilder.class, isAsync = true) +public final class ProtocolAndConvenientAsyncClient { + @Generated + private final ProtocolAndConvenienceOpsImpl serviceClient; + + /** + * Initializes an instance of ProtocolAndConvenientAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ProtocolAndConvenientAsyncClient(ProtocolAndConvenienceOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * When set protocol false and convenient true, then the protocol method should be package private. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> onlyConvenientWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.onlyConvenientWithResponseAsync(body, requestOptions); + } + + /** + * When set protocol true and convenient false, only the protocol method should be generated, ResourceC and + * ResourceD should not be generated. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> onlyProtocolWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.onlyProtocolWithResponseAsync(body, requestOptions); + } + + /** + * Setting protocol true and convenient true, both convenient and protocol methods will be generated. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> bothConvenientAndProtocolWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.bothConvenientAndProtocolWithResponseAsync(body, requestOptions); + } + + /** + * When set protocol false and convenient false. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> errorSettingWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.errorSettingWithResponseAsync(body, requestOptions); + } + + /** + * Long running operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + PollerFlux beginCreateOrReplace(String name, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.beginCreateOrReplaceAsync(name, resource, requestOptions); + } + + /** + * Paging operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsLongNoThe maxPageSize parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (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 paged collection of ResourceJ items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedFlux list(RequestOptions requestOptions) { + return this.serviceClient.listAsync(requestOptions); + } + + /** + * When set protocol false and convenient true, then the protocol method should be package private. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono onlyConvenient(ResourceA body) { + // Generated convenience method for onlyConvenientWithResponse + RequestOptions requestOptions = new RequestOptions(); + return onlyConvenientWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ResourceB.class)); + } + + /** + * Setting protocol true and convenient true, both convenient and protocol methods will be generated. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono bothConvenientAndProtocol(ResourceE body) { + // Generated convenience method for bothConvenientAndProtocolWithResponse + RequestOptions requestOptions = new RequestOptions(); + return bothConvenientAndProtocolWithResponse(BinaryData.fromObject(body), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ResourceF.class)); + } + + /** + * Long running operation. + * + * @param name The name parameter. + * @param resource The resource instance. + * @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 the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateOrReplace(String name, ResourceI resource) { + // Generated convenience method for beginCreateOrReplaceWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginCreateOrReplaceWithModelAsync(name, BinaryData.fromObject(resource), requestOptions); + } + + /** + * Paging 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 paged collection of ResourceJ items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = list(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ResourceJ.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/ProtocolAndConvenientClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/ProtocolAndConvenientClient.java new file mode 100644 index 000000000..af12d28f8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/ProtocolAndConvenientClient.java @@ -0,0 +1,334 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient; + +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.PagedIterable; +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.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; +import com.cadl.protocolandconvenient.implementation.ProtocolAndConvenienceOpsImpl; +import com.cadl.protocolandconvenient.models.ResourceA; +import com.cadl.protocolandconvenient.models.ResourceB; +import com.cadl.protocolandconvenient.models.ResourceE; +import com.cadl.protocolandconvenient.models.ResourceF; +import com.cadl.protocolandconvenient.models.ResourceI; +import com.cadl.protocolandconvenient.models.ResourceJ; + +/** + * Initializes a new instance of the synchronous ProtocolAndConvenientClient type. + */ +@ServiceClient(builder = ProtocolAndConvenientClientBuilder.class) +public final class ProtocolAndConvenientClient { + @Generated + private final ProtocolAndConvenienceOpsImpl serviceClient; + + /** + * Initializes an instance of ProtocolAndConvenientClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ProtocolAndConvenientClient(ProtocolAndConvenienceOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * When set protocol false and convenient true, then the protocol method should be package private. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response onlyConvenientWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.onlyConvenientWithResponse(body, requestOptions); + } + + /** + * When set protocol true and convenient false, only the protocol method should be generated, ResourceC and + * ResourceD should not be generated. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response onlyProtocolWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.onlyProtocolWithResponse(body, requestOptions); + } + + /** + * Setting protocol true and convenient true, both convenient and protocol methods will be generated. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response bothConvenientAndProtocolWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.bothConvenientAndProtocolWithResponse(body, requestOptions); + } + + /** + * When set protocol false and convenient false. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response errorSettingWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.errorSettingWithResponse(body, requestOptions); + } + + /** + * Long running operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller beginCreateOrReplace(String name, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.beginCreateOrReplace(name, resource, requestOptions); + } + + /** + * Paging operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsLongNoThe maxPageSize parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (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 paged collection of ResourceJ items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(RequestOptions requestOptions) { + return this.serviceClient.list(requestOptions); + } + + /** + * When set protocol false and convenient true, then the protocol method should be package private. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResourceB onlyConvenient(ResourceA body) { + // Generated convenience method for onlyConvenientWithResponse + RequestOptions requestOptions = new RequestOptions(); + return onlyConvenientWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(ResourceB.class); + } + + /** + * Setting protocol true and convenient true, both convenient and protocol methods will be generated. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResourceF bothConvenientAndProtocol(ResourceE body) { + // Generated convenience method for bothConvenientAndProtocolWithResponse + RequestOptions requestOptions = new RequestOptions(); + return bothConvenientAndProtocolWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(ResourceF.class); + } + + /** + * Long running operation. + * + * @param name The name parameter. + * @param resource The resource instance. + * @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 the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateOrReplace(String name, ResourceI resource) { + // Generated convenience method for beginCreateOrReplaceWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginCreateOrReplaceWithModel(name, BinaryData.fromObject(resource), requestOptions); + } + + /** + * Paging 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 paged collection of ResourceJ items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.list(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(ResourceJ.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/ProtocolAndConvenientClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/ProtocolAndConvenientClientBuilder.java new file mode 100644 index 000000000..4c7d9b6ae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/ProtocolAndConvenientClientBuilder.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.protocolandconvenient.implementation.ProtocolAndConvenientClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ProtocolAndConvenientClient type. + */ +@ServiceClientBuilder(serviceClients = { ProtocolAndConvenientClient.class, ProtocolAndConvenientAsyncClient.class }) +public final class ProtocolAndConvenientClientBuilder 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("cadl-protocolandconvenient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ProtocolAndConvenientClientBuilder. + */ + @Generated + public ProtocolAndConvenientClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ProtocolAndConvenientClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ProtocolAndConvenientClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ProtocolAndConvenientClientBuilder 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 ProtocolAndConvenientClientBuilder 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 ProtocolAndConvenientClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ProtocolAndConvenientClientBuilder 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 ProtocolAndConvenientClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ProtocolAndConvenientClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private ProtocolAndConvenientServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the ProtocolAndConvenientClientBuilder. + */ + @Generated + public ProtocolAndConvenientClientBuilder serviceVersion(ProtocolAndConvenientServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 ProtocolAndConvenientClientBuilder. + */ + @Generated + public ProtocolAndConvenientClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ProtocolAndConvenientClientImpl with the provided parameters. + * + * @return an instance of ProtocolAndConvenientClientImpl. + */ + @Generated + private ProtocolAndConvenientClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ProtocolAndConvenientServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ProtocolAndConvenientServiceVersion.getLatest(); + ProtocolAndConvenientClientImpl client = new ProtocolAndConvenientClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 ProtocolAndConvenientAsyncClient class. + * + * @return an instance of ProtocolAndConvenientAsyncClient. + */ + @Generated + public ProtocolAndConvenientAsyncClient buildAsyncClient() { + return new ProtocolAndConvenientAsyncClient(buildInnerClient().getProtocolAndConvenienceOps()); + } + + /** + * Builds an instance of ProtocolAndConvenientClient class. + * + * @return an instance of ProtocolAndConvenientClient. + */ + @Generated + public ProtocolAndConvenientClient buildClient() { + return new ProtocolAndConvenientClient(buildInnerClient().getProtocolAndConvenienceOps()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ProtocolAndConvenientClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/ProtocolAndConvenientServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/ProtocolAndConvenientServiceVersion.java new file mode 100644 index 000000000..aab5ce85f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/ProtocolAndConvenientServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of ProtocolAndConvenientClient. + */ +public enum ProtocolAndConvenientServiceVersion implements ServiceVersion { + /** + * Enum value 2022-06-01-preview. + */ + V2022_06_01_PREVIEW("2022-06-01-preview"); + + private final String version; + + ProtocolAndConvenientServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link ProtocolAndConvenientServiceVersion}. + */ + public static ProtocolAndConvenientServiceVersion getLatest() { + return V2022_06_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/OperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/OperationLocationPollingStrategy.java new file mode 100644 index 000000000..01fa64753 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/OperationLocationPollingStrategy.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.OperationResourcePollingStrategy; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.time.OffsetDateTime; + +// DO NOT modify this helper class + +/** + * Implements an operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class OperationLocationPollingStrategy extends OperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(OperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + final Mono> pollResponseMono + = PollingUtils.deserializeResponse((BinaryData) response.getValue(), serializer, pollResponseType) + .onErrorResume(exception -> { + LOGGER.info("Failed to parse initial response."); + return Mono.empty(); + }) + .map(value -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, value, retryAfter)); + return pollResponseMono.switchIfEmpty( + Mono.fromSupplier(() -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, null, retryAfter))); + } else { + return Mono + .error( + new AzureException(String.format( + "Operation failed or cancelled with status code %d," + + ", '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + } + + /** + * {@inheritDoc} + */ + @Override + public Mono getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + return Mono.error(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + return Mono.error(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + return PollingUtils + .deserializeResponse(latestResponseBody, serializer, PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE) + .flatMap(value -> { + if (value.get(propertyName) != null) { + return BinaryData.fromObjectAsync(value.get(propertyName)) + .flatMap(result -> PollingUtils.deserializeResponse(result, serializer, resultType)); + } else { + return Mono.error(new AzureException("Cannot get final result")); + } + }) + .switchIfEmpty(Mono.error(new AzureException("Cannot get final result"))); + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/PollingUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/PollingUtils.java new file mode 100644 index 000000000..9b88a3994 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/PollingUtils.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.net.URI; +import java.net.URISyntaxException; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.temporal.ChronoUnit; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +// DO NOT modify this helper class + +final class PollingUtils { + + public static final TypeReference> POST_POLL_RESULT_TYPE_REFERENCE + = new TypeReference>() { + }; + + public static final HttpHeaderName OPERATION_LOCATION_HEADER = HttpHeaderName.fromString("Operation-Location"); + + public static final String HTTP_METHOD = "httpMethod"; + public static final String REQUEST_URL = "requestURL"; + public static final String POLL_RESPONSE_BODY = "pollResponseBody"; + + private static final String FORWARD_SLASH = "/"; + + public static String getAbsolutePath(String path, String endpoint, ClientLogger logger) { + try { + URI uri = new URI(path); + if (!uri.isAbsolute()) { + if (CoreUtils.isNullOrEmpty(endpoint)) { + throw logger.logExceptionAsError(new IllegalArgumentException( + "Relative path requires endpoint to be non-null and non-empty to create an absolute path.")); + } + + if (endpoint.endsWith(FORWARD_SLASH) && path.startsWith(FORWARD_SLASH)) { + return endpoint + path.substring(1); + } else if (!endpoint.endsWith(FORWARD_SLASH) && !path.startsWith(FORWARD_SLASH)) { + return endpoint + FORWARD_SLASH + path; + } else { + return endpoint + path; + } + } + } catch (URISyntaxException ex) { + throw logger.logExceptionAsWarning(new IllegalArgumentException("'path' must be a valid URI.", ex)); + } + return path; + } + + public static T deserializeResponseSync(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + T value; + if (binaryData == null) { + value = null; + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = typeReference.getJavaClass().cast(binaryData.toReplayableBinaryData()); + } else { + value = binaryData.toObject(typeReference, serializer); + } + return value; + } + + @SuppressWarnings("unchecked") + public static Mono deserializeResponse(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + Mono value; + if (binaryData == null) { + value = Mono.empty(); + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = (Mono) binaryData.toReplayableBinaryDataAsync(); + } else { + value = binaryData.toObjectAsync(typeReference, serializer); + } + return value; + } + + private static final HttpHeaderName RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("retry-after-ms"); + private static final HttpHeaderName X_MS_RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("x-ms-retry-after-ms"); + + public static Duration getRetryAfterFromHeaders(HttpHeaders headers, Supplier nowSupplier) { + // Found 'x-ms-retry-after-ms' header, use a Duration of milliseconds based on the value. + Duration retryDelay = tryGetRetryDelay(headers, X_MS_RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'retry-after-ms' header, use a Duration of milliseconds based on the value. + retryDelay = tryGetRetryDelay(headers, RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'Retry-After' header. First, attempt to resolve it as a Duration of seconds. If that fails, then + // attempt to resolve it as an HTTP date (RFC1123). + retryDelay = tryGetRetryDelay(headers, HttpHeaderName.RETRY_AFTER, + headerValue -> tryParseLongOrDateTime(headerValue, nowSupplier)); + + // Either the retry delay will have been found or it'll be null, null indicates no retry after. + return retryDelay; + } + + private static Duration tryGetRetryDelay(HttpHeaders headers, HttpHeaderName headerName, + Function delayParser) { + String headerValue = headers.getValue(headerName); + + return CoreUtils.isNullOrEmpty(headerValue) ? null : delayParser.apply(headerValue); + } + + private static Duration tryParseLongOrDateTime(String value, Supplier nowSupplier) { + long delaySeconds; + try { + OffsetDateTime retryAfter = new DateTimeRfc1123(value).getDateTime(); + + delaySeconds = nowSupplier.get().until(retryAfter, ChronoUnit.SECONDS); + } catch (DateTimeException ex) { + delaySeconds = tryParseLong(value); + } + + return (delaySeconds >= 0) ? Duration.ofSeconds(delaySeconds) : null; + } + + private static long tryParseLong(String value) { + try { + return Long.parseLong(value); + } catch (NumberFormatException ex) { + return -1; + } + } + + private static Duration tryGetDelayMillis(String value) { + long delayMillis = tryParseLong(value); + return (delayMillis >= 0) ? Duration.ofMillis(delayMillis) : null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenienceOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenienceOpsImpl.java new file mode 100644 index 000000000..2e3b98433 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenienceOpsImpl.java @@ -0,0 +1,1053 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +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.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.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.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.UrlBuilder; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.TypeReference; +import com.cadl.protocolandconvenient.ProtocolAndConvenientServiceVersion; +import com.cadl.protocolandconvenient.models.ResourceI; +import java.time.Duration; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ProtocolAndConvenienceOps. + */ +public final class ProtocolAndConvenienceOpsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ProtocolAndConvenienceOpsService service; + + /** + * The service client containing this operation class. + */ + private final ProtocolAndConvenientClientImpl client; + + /** + * Initializes an instance of ProtocolAndConvenienceOpsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ProtocolAndConvenienceOpsImpl(ProtocolAndConvenientClientImpl client) { + this.service = RestProxy.create(ProtocolAndConvenienceOpsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ProtocolAndConvenientServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for ProtocolAndConvenientClientProtocolAndConvenienceOps to be used by + * the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ProtocolAndConvenien") + public interface ProtocolAndConvenienceOpsService { + @Post("/protocolandconvenient/onlyConvenient") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> onlyConvenient(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/protocolandconvenient/onlyConvenient") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response onlyConvenientSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/protocolandconvenient/onlyProtocol") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> onlyProtocol(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/protocolandconvenient/onlyProtocol") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response onlyProtocolSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/protocolandconvenient/bothConvenientAndProtocol") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> bothConvenientAndProtocol(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/protocolandconvenient/bothConvenientAndProtocol") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response bothConvenientAndProtocolSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/protocolandconvenient/errorSetting") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> errorSetting(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/protocolandconvenient/errorSetting") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response errorSettingSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/protocolandconvenient/resources/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrReplace(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Put("/protocolandconvenient/resources/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createOrReplaceSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Get("/protocolandconvenient/resources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/protocolandconvenient/resources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * When set protocol false and convenient true, then the protocol method should be package private. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> onlyConvenientWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.onlyConvenient(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * When set protocol false and convenient true, then the protocol method should be package private. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response onlyConvenientWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.onlyConvenientSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * When set protocol true and convenient false, only the protocol method should be generated, ResourceC and + * ResourceD should not be generated. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> onlyProtocolWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.onlyProtocol(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * When set protocol true and convenient false, only the protocol method should be generated, ResourceC and + * ResourceD should not be generated. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response onlyProtocolWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.onlyProtocolSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * Setting protocol true and convenient true, both convenient and protocol methods will be generated. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> bothConvenientAndProtocolWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.bothConvenientAndProtocol(this.client.getEndpoint(), contentType, + accept, body, requestOptions, context)); + } + + /** + * Setting protocol true and convenient true, both convenient and protocol methods will be generated. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response bothConvenientAndProtocolWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.bothConvenientAndProtocolSync(this.client.getEndpoint(), contentType, accept, body, + requestOptions, Context.NONE); + } + + /** + * When set protocol false and convenient false. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> errorSettingWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.errorSetting(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * When set protocol false and convenient false. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response errorSettingWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.errorSettingSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * Long running operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrReplaceWithResponseAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createOrReplace(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + name, contentType, accept, resource, requestOptions, context)); + } + + /** + * Long running operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrReplaceWithResponse(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrReplaceSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + name, contentType, accept, resource, requestOptions, Context.NONE); + } + + /** + * Long running operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateOrReplaceAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.createOrReplaceWithResponseAsync(name, resource, requestOptions), + new com.cadl.protocolandconvenient.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Long running operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateOrReplace(String name, BinaryData resource, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.createOrReplaceWithResponse(name, resource, requestOptions), + new com.cadl.protocolandconvenient.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Long running operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateOrReplaceWithModelAsync(String name, + BinaryData resource, RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.createOrReplaceWithResponseAsync(name, resource, requestOptions), + new com.cadl.protocolandconvenient.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion())), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(ResourceI.class)); + } + + /** + * Long running operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateOrReplaceWithModel(String name, BinaryData resource, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.createOrReplaceWithResponse(name, resource, requestOptions), + new com.cadl.protocolandconvenient.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion())), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(ResourceI.class)); + } + + /** + * Paging operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsLongNoThe maxPageSize parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (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 paged collection of ResourceJ items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Paging operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsLongNoThe maxPageSize parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (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 paged collection of ResourceJ items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxresults", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePageAsync(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxresults", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * Paging operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsLongNoThe maxPageSize parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (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 paged collection of ResourceJ items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Paging operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxresultsLongNoThe maxPageSize parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (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 paged collection of ResourceJ items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxresults", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePage(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxresults", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * Paging operation + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of ResourceJ items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listNext(nextLink, this.client.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Paging operation + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of ResourceJ items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listNextSync(nextLink, this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenientClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenientClientImpl.java new file mode 100644 index 000000000..8c75e79e3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/ProtocolAndConvenientClientImpl.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.cadl.protocolandconvenient.ProtocolAndConvenientServiceVersion; + +/** + * Initializes a new instance of the ProtocolAndConvenientClient type. + */ +public final class ProtocolAndConvenientClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final ProtocolAndConvenientServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ProtocolAndConvenientServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * The ProtocolAndConvenienceOpsImpl object to access its operations. + */ + private final ProtocolAndConvenienceOpsImpl protocolAndConvenienceOps; + + /** + * Gets the ProtocolAndConvenienceOpsImpl object to access its operations. + * + * @return the ProtocolAndConvenienceOpsImpl object. + */ + public ProtocolAndConvenienceOpsImpl getProtocolAndConvenienceOps() { + return this.protocolAndConvenienceOps; + } + + /** + * Initializes an instance of ProtocolAndConvenientClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public ProtocolAndConvenientClientImpl(String endpoint, ProtocolAndConvenientServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of ProtocolAndConvenientClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public ProtocolAndConvenientClientImpl(HttpPipeline httpPipeline, String endpoint, + ProtocolAndConvenientServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of ProtocolAndConvenientClient 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. + * @param serviceVersion Service version. + */ + public ProtocolAndConvenientClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, ProtocolAndConvenientServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.protocolAndConvenienceOps = new ProtocolAndConvenienceOpsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/SyncOperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/SyncOperationLocationPollingStrategy.java new file mode 100644 index 000000000..eabd365d4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/SyncOperationLocationPollingStrategy.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncOperationResourcePollingStrategy; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; + +import java.io.UncheckedIOException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Map; + +// DO NOT modify this helper class + +/** + * Implements a synchronous operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class SyncOperationLocationPollingStrategy extends SyncOperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(SyncOperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public PollResponse onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + T initialResponseType = null; + try { + initialResponseType = PollingUtils.deserializeResponseSync((BinaryData) response.getValue(), serializer, + pollResponseType); + } catch (UncheckedIOException e) { + LOGGER.info("Failed to parse initial response."); + } + return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, initialResponseType, retryAfter); + } + + throw LOGGER.logExceptionAsError(new AzureException( + String.format("Operation failed or cancelled with status code %d, '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + + /** + * {@inheritDoc} + */ + public U getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + Map pollResult = PollingUtils.deserializeResponseSync(latestResponseBody, serializer, + PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE); + if (pollResult != null && pollResult.get(propertyName) != null) { + return PollingUtils.deserializeResponseSync(BinaryData.fromObject(pollResult.get(propertyName)), + serializer, resultType); + } else { + throw LOGGER.logExceptionAsError(new AzureException("Cannot get final result")); + } + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/package-info.java new file mode 100644 index 000000000..20a55a624 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 ProtocolAndConvenient. + * + */ +package com.cadl.protocolandconvenient.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceA.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceA.java new file mode 100644 index 000000000..458cc5470 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceA.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.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; + +/** + * The ResourceA model. + */ +@Immutable +public final class ResourceA implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ResourceA class. + * + * @param name the name value to set. + */ + @Generated + public ResourceA(String name) { + this.name = name; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceA from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceA 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 ResourceA. + */ + @Generated + public static ResourceA fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + ResourceA deserializedResourceA = new ResourceA(name); + deserializedResourceA.id = id; + + return deserializedResourceA; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceB.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceB.java new file mode 100644 index 000000000..3b110fb40 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceB.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.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; + +/** + * The ResourceB model. + */ +@Immutable +public final class ResourceB implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ResourceB class. + * + * @param name the name value to set. + */ + @Generated + private ResourceB(String name) { + this.name = name; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceB from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceB 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 ResourceB. + */ + @Generated + public static ResourceB fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + ResourceB deserializedResourceB = new ResourceB(name); + deserializedResourceB.id = id; + + return deserializedResourceB; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceE.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceE.java new file mode 100644 index 000000000..6072f07cb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceE.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.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; + +/** + * The ResourceE model. + */ +@Immutable +public final class ResourceE implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ResourceE class. + * + * @param name the name value to set. + */ + @Generated + public ResourceE(String name) { + this.name = name; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceE from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceE 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 ResourceE. + */ + @Generated + public static ResourceE fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + ResourceE deserializedResourceE = new ResourceE(name); + deserializedResourceE.id = id; + + return deserializedResourceE; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceF.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceF.java new file mode 100644 index 000000000..b64e97d54 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceF.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.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; + +/** + * The ResourceF model. + */ +@Immutable +public final class ResourceF implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ResourceF class. + * + * @param name the name value to set. + */ + @Generated + private ResourceF(String name) { + this.name = name; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceF from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceF 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 ResourceF. + */ + @Generated + public static ResourceF fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + ResourceF deserializedResourceF = new ResourceF(name); + deserializedResourceF.id = id; + + return deserializedResourceF; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceI.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceI.java new file mode 100644 index 000000000..27a288070 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceI.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.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; + +/** + * The ResourceI model. + */ +@Immutable +public final class ResourceI implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private String name; + + /* + * The type property. + */ + @Generated + private final String type; + + /** + * Creates an instance of ResourceI class. + * + * @param type the type value to set. + */ + @Generated + public ResourceI(String type) { + this.type = type; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the type property: The type property. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceI from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceI 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 ResourceI. + */ + @Generated + public static ResourceI fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + ResourceI deserializedResourceI = new ResourceI(type); + deserializedResourceI.id = id; + deserializedResourceI.name = name; + + return deserializedResourceI; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceJ.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceJ.java new file mode 100644 index 000000000..a7acda88f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/ResourceJ.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.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; + +/** + * The ResourceJ model. + */ +@Immutable +public final class ResourceJ implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private String name; + + /* + * The type property. + */ + @Generated + private final String type; + + /** + * Creates an instance of ResourceJ class. + * + * @param type the type value to set. + */ + @Generated + private ResourceJ(String type) { + this.type = type; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the type property: The type property. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceJ from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceJ 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 ResourceJ. + */ + @Generated + public static ResourceJ fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + ResourceJ deserializedResourceJ = new ResourceJ(type); + deserializedResourceJ.id = id; + deserializedResourceJ.name = name; + + return deserializedResourceJ; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/package-info.java new file mode 100644 index 000000000..fc5f731f8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/models/package-info.java @@ -0,0 +1,10 @@ +// 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 ProtocolAndConvenient. + * + */ +package com.cadl.protocolandconvenient.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/package-info.java new file mode 100644 index 000000000..e15659735 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/protocolandconvenient/package-info.java @@ -0,0 +1,10 @@ +// 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 ProtocolAndConvenient. + * + */ +package com.cadl.protocolandconvenient; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/ResponseAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/ResponseAsyncClient.java new file mode 100644 index 000000000..317cfbc61 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/ResponseAsyncClient.java @@ -0,0 +1,591 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response; + +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.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +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 com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.TypeReference; +import com.cadl.response.implementation.ResponseClientImpl; +import com.cadl.response.models.OperationDetails1; +import com.cadl.response.models.OperationDetails2; +import com.cadl.response.models.Resource; +import java.util.List; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ResponseClient type. + */ +@ServiceClient(builder = ResponseClientBuilder.class, isAsync = true) +public final class ResponseAsyncClient { + @Generated + private final ResponseClientImpl serviceClient; + + /** + * Initializes an instance of ResponseAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ResponseAsyncClient(ResponseClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getBinary operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getBinaryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getBinaryWithResponseAsync(requestOptions); + } + + /** + * The getArray operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         name: String (Required)
+     *         description: String (Optional)
+     *         type: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getArrayWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getArrayWithResponseAsync(requestOptions); + } + + /** + * The getAnotherArray operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         name: String (Required)
+     *         description: String (Optional)
+     *         type: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAnotherArrayWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAnotherArrayWithResponseAsync(requestOptions); + } + + /** + * The createWithHeaders operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createWithHeadersWithResponse(RequestOptions requestOptions) { + return this.serviceClient.createWithHeadersWithResponseAsync(requestOptions); + } + + /** + * The deleteWithHeaders operation. + * + * @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> deleteWithHeadersWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteWithHeadersWithResponseAsync(requestOptions); + } + + /** + * The most basic operation. + *

Response Body Schema

+ * + *
{@code
+     * boolean
+     * }
+ * + * @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 ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return whether resource exists along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> existsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.existsWithResponseAsync(requestOptions); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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 PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLroInvalidPollResponse(BinaryData request, + RequestOptions requestOptions) { + return this.serviceClient.beginLroInvalidPollResponseAsync(request, requestOptions); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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 PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLroInvalidResult(BinaryData request, RequestOptions requestOptions) { + return this.serviceClient.beginLroInvalidResultAsync(request, requestOptions); + } + + /** + * The listStrings operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listStrings(RequestOptions requestOptions) { + return this.serviceClient.listStringsAsync(requestOptions); + } + + /** + * The listIntegers operation. + *

Response Body Schema

+ * + *
{@code
+     * int
+     * }
+ * + * @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 paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listIntegers(RequestOptions requestOptions) { + return this.serviceClient.listIntegersAsync(requestOptions); + } + + /** + * The getJsonUtf8Response operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getJsonUtf8ResponseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getJsonUtf8ResponseWithResponseAsync(requestOptions); + } + + /** + * The getPlusJsonResponse operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPlusJsonResponseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getPlusJsonResponseWithResponseAsync(requestOptions); + } + + /** + * The getBinary 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getBinary() { + // Generated convenience method for getBinaryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getBinaryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getArray 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getArray() { + // Generated convenience method for getArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getArrayWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_RESOURCE)); + } + + /** + * The getAnotherArray 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAnotherArray() { + // Generated convenience method for getAnotherArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAnotherArrayWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_RESOURCE)); + } + + /** + * The createWithHeaders 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createWithHeaders() { + // Generated convenience method for createWithHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createWithHeadersWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * The deleteWithHeaders 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteWithHeaders() { + // Generated convenience method for deleteWithHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteWithHeadersWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The most basic 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 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 whether resource exists on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono exists() { + // Generated convenience method for existsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return existsWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The most basic operation. + * + * @param request The request 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 the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLroInvalidPollResponse(Resource request) { + // Generated convenience method for beginLroInvalidPollResponseWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginLroInvalidPollResponseWithModelAsync(BinaryData.fromObject(request), requestOptions); + } + + /** + * The most basic operation. + * + * @param request The request 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 the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLroInvalidResult(Resource request) { + // Generated convenience method for beginLroInvalidResultWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginLroInvalidResultWithModelAsync(BinaryData.fromObject(request), requestOptions); + } + + /** + * The listStrings 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 the paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listStrings() { + // Generated convenience method for listStrings + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listStrings(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(String.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * The listIntegers 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 the paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listIntegers() { + // Generated convenience method for listIntegers + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listIntegers(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Integer.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * The getJsonUtf8Response 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getJsonUtf8Response() { + // Generated convenience method for getJsonUtf8ResponseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getJsonUtf8ResponseWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * The getPlusJsonResponse 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPlusJsonResponse() { + // Generated convenience method for getPlusJsonResponseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getPlusJsonResponseWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_RESOURCE + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/ResponseClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/ResponseClient.java new file mode 100644 index 000000000..92823b8e9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/ResponseClient.java @@ -0,0 +1,556 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response; + +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.PagedIterable; +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.polling.SyncPoller; +import com.azure.core.util.serializer.TypeReference; +import com.cadl.response.implementation.ResponseClientImpl; +import com.cadl.response.models.OperationDetails1; +import com.cadl.response.models.OperationDetails2; +import com.cadl.response.models.Resource; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ResponseClient type. + */ +@ServiceClient(builder = ResponseClientBuilder.class) +public final class ResponseClient { + @Generated + private final ResponseClientImpl serviceClient; + + /** + * Initializes an instance of ResponseClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ResponseClient(ResponseClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getBinary operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getBinaryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getBinaryWithResponse(requestOptions); + } + + /** + * The getArray operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         name: String (Required)
+     *         description: String (Optional)
+     *         type: String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getArrayWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getArrayWithResponse(requestOptions); + } + + /** + * The getAnotherArray operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         name: String (Required)
+     *         description: String (Optional)
+     *         type: String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAnotherArrayWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAnotherArrayWithResponse(requestOptions); + } + + /** + * The createWithHeaders operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createWithHeadersWithResponse(RequestOptions requestOptions) { + return this.serviceClient.createWithHeadersWithResponse(requestOptions); + } + + /** + * The deleteWithHeaders operation. + * + * @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 deleteWithHeadersWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteWithHeadersWithResponse(requestOptions); + } + + /** + * The most basic operation. + *

Response Body Schema

+ * + *
{@code
+     * boolean
+     * }
+ * + * @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 ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return whether resource exists along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response existsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.existsWithResponse(requestOptions); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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 SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLroInvalidPollResponse(BinaryData request, + RequestOptions requestOptions) { + return this.serviceClient.beginLroInvalidPollResponse(request, requestOptions); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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 SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLroInvalidResult(BinaryData request, RequestOptions requestOptions) { + return this.serviceClient.beginLroInvalidResult(request, requestOptions); + } + + /** + * The listStrings operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listStrings(RequestOptions requestOptions) { + return this.serviceClient.listStrings(requestOptions); + } + + /** + * The listIntegers operation. + *

Response Body Schema

+ * + *
{@code
+     * int
+     * }
+ * + * @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 paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listIntegers(RequestOptions requestOptions) { + return this.serviceClient.listIntegers(requestOptions); + } + + /** + * The getJsonUtf8Response operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getJsonUtf8ResponseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getJsonUtf8ResponseWithResponse(requestOptions); + } + + /** + * The getPlusJsonResponse operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPlusJsonResponseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getPlusJsonResponseWithResponse(requestOptions); + } + + /** + * The getBinary 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData getBinary() { + // Generated convenience method for getBinaryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getBinaryWithResponse(requestOptions).getValue(); + } + + /** + * The getArray 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List getArray() { + // Generated convenience method for getArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getArrayWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_RESOURCE); + } + + /** + * The getAnotherArray 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List getAnotherArray() { + // Generated convenience method for getAnotherArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAnotherArrayWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_RESOURCE); + } + + /** + * The createWithHeaders 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource createWithHeaders() { + // Generated convenience method for createWithHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createWithHeadersWithResponse(requestOptions).getValue().toObject(Resource.class); + } + + /** + * The deleteWithHeaders 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteWithHeaders() { + // Generated convenience method for deleteWithHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteWithHeadersWithResponse(requestOptions).getValue(); + } + + /** + * The most basic 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 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 whether resource exists. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public boolean exists() { + // Generated convenience method for existsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return existsWithResponse(requestOptions).getValue(); + } + + /** + * The most basic operation. + * + * @param request The request 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 the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLroInvalidPollResponse(Resource request) { + // Generated convenience method for beginLroInvalidPollResponseWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginLroInvalidPollResponseWithModel(BinaryData.fromObject(request), requestOptions); + } + + /** + * The most basic operation. + * + * @param request The request 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 the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLroInvalidResult(Resource request) { + // Generated convenience method for beginLroInvalidResultWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginLroInvalidResultWithModel(BinaryData.fromObject(request), requestOptions); + } + + /** + * The listStrings 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 the paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listStrings() { + // Generated convenience method for listStrings + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listStrings(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(String.class)); + } + + /** + * The listIntegers 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 the paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listIntegers() { + // Generated convenience method for listIntegers + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listIntegers(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(Integer.class)); + } + + /** + * The getJsonUtf8Response 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource getJsonUtf8Response() { + // Generated convenience method for getJsonUtf8ResponseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getJsonUtf8ResponseWithResponse(requestOptions).getValue().toObject(Resource.class); + } + + /** + * The getPlusJsonResponse 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource getPlusJsonResponse() { + // Generated convenience method for getPlusJsonResponseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getPlusJsonResponseWithResponse(requestOptions).getValue().toObject(Resource.class); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_RESOURCE + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/ResponseClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/ResponseClientBuilder.java new file mode 100644 index 000000000..b25ef5a92 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/ResponseClientBuilder.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.response.implementation.ResponseClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ResponseClient type. + */ +@ServiceClientBuilder(serviceClients = { ResponseClient.class, ResponseAsyncClient.class }) +public final class ResponseClientBuilder 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("cadl-response.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ResponseClientBuilder. + */ + @Generated + public ResponseClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResponseClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResponseClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResponseClientBuilder 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 ResponseClientBuilder 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 ResponseClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResponseClientBuilder 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 ResponseClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResponseClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private ResponseServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the ResponseClientBuilder. + */ + @Generated + public ResponseClientBuilder serviceVersion(ResponseServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 ResponseClientBuilder. + */ + @Generated + public ResponseClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ResponseClientImpl with the provided parameters. + * + * @return an instance of ResponseClientImpl. + */ + @Generated + private ResponseClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ResponseServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ResponseServiceVersion.getLatest(); + ResponseClientImpl client = new ResponseClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 ResponseAsyncClient class. + * + * @return an instance of ResponseAsyncClient. + */ + @Generated + public ResponseAsyncClient buildAsyncClient() { + return new ResponseAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ResponseClient class. + * + * @return an instance of ResponseClient. + */ + @Generated + public ResponseClient buildClient() { + return new ResponseClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ResponseClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/ResponseServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/ResponseServiceVersion.java new file mode 100644 index 000000000..e876fae77 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/ResponseServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of ResponseClient. + */ +public enum ResponseServiceVersion implements ServiceVersion { + /** + * Enum value 2022-06-01-preview. + */ + V2022_06_01_PREVIEW("2022-06-01-preview"); + + private final String version; + + ResponseServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link ResponseServiceVersion}. + */ + public static ResponseServiceVersion getLatest() { + return V2022_06_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/OperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/OperationLocationPollingStrategy.java new file mode 100644 index 000000000..71de5c33d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/OperationLocationPollingStrategy.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.OperationResourcePollingStrategy; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.time.OffsetDateTime; + +// DO NOT modify this helper class + +/** + * Implements an operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class OperationLocationPollingStrategy extends OperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(OperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + final Mono> pollResponseMono + = PollingUtils.deserializeResponse((BinaryData) response.getValue(), serializer, pollResponseType) + .onErrorResume(exception -> { + LOGGER.info("Failed to parse initial response."); + return Mono.empty(); + }) + .map(value -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, value, retryAfter)); + return pollResponseMono.switchIfEmpty( + Mono.fromSupplier(() -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, null, retryAfter))); + } else { + return Mono + .error( + new AzureException(String.format( + "Operation failed or cancelled with status code %d," + + ", '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + } + + /** + * {@inheritDoc} + */ + @Override + public Mono getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + return Mono.error(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + return Mono.error(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + return PollingUtils + .deserializeResponse(latestResponseBody, serializer, PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE) + .flatMap(value -> { + if (value.get(propertyName) != null) { + return BinaryData.fromObjectAsync(value.get(propertyName)) + .flatMap(result -> PollingUtils.deserializeResponse(result, serializer, resultType)); + } else { + return Mono.error(new AzureException("Cannot get final result")); + } + }) + .switchIfEmpty(Mono.error(new AzureException("Cannot get final result"))); + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/PollingUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/PollingUtils.java new file mode 100644 index 000000000..3762e95a6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/PollingUtils.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.net.URI; +import java.net.URISyntaxException; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.temporal.ChronoUnit; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +// DO NOT modify this helper class + +final class PollingUtils { + + public static final TypeReference> POST_POLL_RESULT_TYPE_REFERENCE + = new TypeReference>() { + }; + + public static final HttpHeaderName OPERATION_LOCATION_HEADER = HttpHeaderName.fromString("Operation-Location"); + + public static final String HTTP_METHOD = "httpMethod"; + public static final String REQUEST_URL = "requestURL"; + public static final String POLL_RESPONSE_BODY = "pollResponseBody"; + + private static final String FORWARD_SLASH = "/"; + + public static String getAbsolutePath(String path, String endpoint, ClientLogger logger) { + try { + URI uri = new URI(path); + if (!uri.isAbsolute()) { + if (CoreUtils.isNullOrEmpty(endpoint)) { + throw logger.logExceptionAsError(new IllegalArgumentException( + "Relative path requires endpoint to be non-null and non-empty to create an absolute path.")); + } + + if (endpoint.endsWith(FORWARD_SLASH) && path.startsWith(FORWARD_SLASH)) { + return endpoint + path.substring(1); + } else if (!endpoint.endsWith(FORWARD_SLASH) && !path.startsWith(FORWARD_SLASH)) { + return endpoint + FORWARD_SLASH + path; + } else { + return endpoint + path; + } + } + } catch (URISyntaxException ex) { + throw logger.logExceptionAsWarning(new IllegalArgumentException("'path' must be a valid URI.", ex)); + } + return path; + } + + public static T deserializeResponseSync(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + T value; + if (binaryData == null) { + value = null; + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = typeReference.getJavaClass().cast(binaryData.toReplayableBinaryData()); + } else { + value = binaryData.toObject(typeReference, serializer); + } + return value; + } + + @SuppressWarnings("unchecked") + public static Mono deserializeResponse(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + Mono value; + if (binaryData == null) { + value = Mono.empty(); + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = (Mono) binaryData.toReplayableBinaryDataAsync(); + } else { + value = binaryData.toObjectAsync(typeReference, serializer); + } + return value; + } + + private static final HttpHeaderName RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("retry-after-ms"); + private static final HttpHeaderName X_MS_RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("x-ms-retry-after-ms"); + + public static Duration getRetryAfterFromHeaders(HttpHeaders headers, Supplier nowSupplier) { + // Found 'x-ms-retry-after-ms' header, use a Duration of milliseconds based on the value. + Duration retryDelay = tryGetRetryDelay(headers, X_MS_RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'retry-after-ms' header, use a Duration of milliseconds based on the value. + retryDelay = tryGetRetryDelay(headers, RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'Retry-After' header. First, attempt to resolve it as a Duration of seconds. If that fails, then + // attempt to resolve it as an HTTP date (RFC1123). + retryDelay = tryGetRetryDelay(headers, HttpHeaderName.RETRY_AFTER, + headerValue -> tryParseLongOrDateTime(headerValue, nowSupplier)); + + // Either the retry delay will have been found or it'll be null, null indicates no retry after. + return retryDelay; + } + + private static Duration tryGetRetryDelay(HttpHeaders headers, HttpHeaderName headerName, + Function delayParser) { + String headerValue = headers.getValue(headerName); + + return CoreUtils.isNullOrEmpty(headerValue) ? null : delayParser.apply(headerValue); + } + + private static Duration tryParseLongOrDateTime(String value, Supplier nowSupplier) { + long delaySeconds; + try { + OffsetDateTime retryAfter = new DateTimeRfc1123(value).getDateTime(); + + delaySeconds = nowSupplier.get().until(retryAfter, ChronoUnit.SECONDS); + } catch (DateTimeException ex) { + delaySeconds = tryParseLong(value); + } + + return (delaySeconds >= 0) ? Duration.ofSeconds(delaySeconds) : null; + } + + private static long tryParseLong(String value) { + try { + return Long.parseLong(value); + } catch (NumberFormatException ex) { + return -1; + } + } + + private static Duration tryGetDelayMillis(String value) { + long delayMillis = tryParseLong(value); + return (delayMillis >= 0) ? Duration.ofMillis(delayMillis) : null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/ResponseClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/ResponseClientImpl.java new file mode 100644 index 000000000..e9bd3194c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/ResponseClientImpl.java @@ -0,0 +1,1541 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response.implementation; + +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.Head; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +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.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.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.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.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.TypeReference; +import com.cadl.response.ResponseServiceVersion; +import com.cadl.response.models.OperationDetails1; +import com.cadl.response.models.OperationDetails2; +import com.cadl.response.models.Resource; +import java.time.Duration; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the ResponseClient type. + */ +public final class ResponseClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ResponseClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final ResponseServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ResponseServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 ResponseClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public ResponseClientImpl(String endpoint, ResponseServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of ResponseClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public ResponseClientImpl(HttpPipeline httpPipeline, String endpoint, ResponseServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of ResponseClient 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. + * @param serviceVersion Service version. + */ + public ResponseClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + ResponseServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(ResponseClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for ResponseClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ResponseClient") + public interface ResponseClientService { + @Get("/response/get-binary") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getBinary(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/response/get-binary") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getBinarySync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/response/get-array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getArray(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/response/get-array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getArraySync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/response/get-another-array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAnotherArray(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/response/get-another-array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAnotherArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/response/create-with-headers") + @ExpectedResponses({ 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createWithHeaders(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/response/create-with-headers") + @ExpectedResponses({ 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createWithHeadersSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/response/delete-with-headers") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteWithHeaders(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Delete("/response/delete-with-headers") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteWithHeadersSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Head("/response/exists") + @ExpectedResponses({ 200, 404 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> exists(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Head("/response/exists") + @ExpectedResponses({ 200, 404 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response existsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/response/lro-invalid-poll-response") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> lroInvalidPollResponse(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData request, + RequestOptions requestOptions, Context context); + + @Post("/response/lro-invalid-poll-response") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response lroInvalidPollResponseSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData request, + RequestOptions requestOptions, Context context); + + @Post("/response/lro-invalid-result") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> lroInvalidResult(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData request, + RequestOptions requestOptions, Context context); + + @Post("/response/lro-invalid-result") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response lroInvalidResultSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData request, + RequestOptions requestOptions, Context context); + + @Get("/response/paged-string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listStrings(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/response/paged-string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listStringsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/response/paged-int32") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listIntegers(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/response/paged-int32") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listIntegersSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/response/json-utf8-response") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getJsonUtf8Response(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/response/json-utf8-response") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getJsonUtf8ResponseSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/response/plus-json-response") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getPlusJsonResponse(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/response/plus-json-response") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getPlusJsonResponseSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listStringsNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listStringsNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listIntegersNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listIntegersNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * The getBinary operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getBinaryWithResponseAsync(RequestOptions requestOptions) { + final String accept = "image/png"; + return FluxUtil.withContext(context -> service.getBinary(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getBinary operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getBinaryWithResponse(RequestOptions requestOptions) { + final String accept = "image/png"; + return service.getBinarySync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The getArray operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         name: String (Required)
+     *         description: String (Optional)
+     *         type: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getArrayWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getArray(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getArray operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         name: String (Required)
+     *         description: String (Optional)
+     *         type: String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getArrayWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getArraySync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The getAnotherArray operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         name: String (Required)
+     *         description: String (Optional)
+     *         type: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAnotherArrayWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAnotherArray(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getAnotherArray operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         id: String (Required)
+     *         name: String (Required)
+     *         description: String (Optional)
+     *         type: String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAnotherArrayWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAnotherArraySync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The createWithHeaders operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createWithHeadersWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createWithHeaders(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The createWithHeaders operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createWithHeadersWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.createWithHeadersSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The deleteWithHeaders operation. + * + * @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> deleteWithHeadersWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.deleteWithHeaders(this.getEndpoint(), requestOptions, context)); + } + + /** + * The deleteWithHeaders operation. + * + * @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 deleteWithHeadersWithResponse(RequestOptions requestOptions) { + return service.deleteWithHeadersSync(this.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The most basic operation. + *

Response Body Schema

+ * + *
{@code
+     * boolean
+     * }
+ * + * @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 ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return whether resource exists along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> existsWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.exists(this.getEndpoint(), this.getServiceVersion().getVersion(), + accept, requestOptions, context)); + } + + /** + * The most basic operation. + *

Response Body Schema

+ * + *
{@code
+     * boolean
+     * }
+ * + * @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 ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return whether resource exists along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response existsWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.existsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), accept, requestOptions, + Context.NONE); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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) + private Mono> lroInvalidPollResponseWithResponseAsync(BinaryData request, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.lroInvalidPollResponse(this.getEndpoint(), + this.getServiceVersion().getVersion(), contentType, accept, request, requestOptions, context)); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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) + private Response lroInvalidPollResponseWithResponse(BinaryData request, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.lroInvalidPollResponseSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + contentType, accept, request, requestOptions, Context.NONE); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLroInvalidPollResponseAsync(BinaryData request, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.lroInvalidPollResponseWithResponseAsync(request, requestOptions), + new com.cadl.response.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLroInvalidPollResponse(BinaryData request, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.lroInvalidPollResponseWithResponse(request, requestOptions), + new com.cadl.response.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLroInvalidPollResponseWithModelAsync(BinaryData request, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.lroInvalidPollResponseWithResponseAsync(request, requestOptions), + new com.cadl.response.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(OperationDetails1.class), TypeReference.createInstance(Resource.class)); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLroInvalidPollResponseWithModel(BinaryData request, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.lroInvalidPollResponseWithResponse(request, requestOptions), + new com.cadl.response.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(OperationDetails1.class), TypeReference.createInstance(Resource.class)); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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) + private Mono> lroInvalidResultWithResponseAsync(BinaryData request, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.lroInvalidResult(this.getEndpoint(), + this.getServiceVersion().getVersion(), contentType, accept, request, requestOptions, context)); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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) + private Response lroInvalidResultWithResponse(BinaryData request, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.lroInvalidResultSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, + accept, request, requestOptions, Context.NONE); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLroInvalidResultAsync(BinaryData request, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.lroInvalidResultWithResponseAsync(request, requestOptions), + new com.cadl.response.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "lroResult"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLroInvalidResult(BinaryData request, RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.lroInvalidResultWithResponse(request, requestOptions), + new com.cadl.response.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "lroResult"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginLroInvalidResultWithModelAsync(BinaryData request, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.lroInvalidResultWithResponseAsync(request, requestOptions), + new com.cadl.response.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "lroResult"), + TypeReference.createInstance(OperationDetails2.class), TypeReference.createInstance(Resource.class)); + } + + /** + * The most basic operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param request The request 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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginLroInvalidResultWithModel(BinaryData request, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.lroInvalidResultWithResponse(request, requestOptions), + new com.cadl.response.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion()), + "lroResult"), + TypeReference.createInstance(OperationDetails2.class), TypeReference.createInstance(Resource.class)); + } + + /** + * The listStrings operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listStringsSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.listStrings(this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * The listStrings operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listStringsAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listStringsSinglePageAsync(requestOptions), + nextLink -> listStringsNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * The listStrings operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 response body along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listStringsSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listStringsSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * The listStrings operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listStrings(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listStringsSinglePage(requestOptions), + nextLink -> listStringsNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * The listIntegers operation. + *

Response Body Schema

+ * + *
{@code
+     * int
+     * }
+ * + * @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 response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listIntegersSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listIntegers(this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * The listIntegers operation. + *

Response Body Schema

+ * + *
{@code
+     * int
+     * }
+ * + * @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 paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listIntegersAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listIntegersSinglePageAsync(requestOptions), + nextLink -> listIntegersNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * The listIntegers operation. + *

Response Body Schema

+ * + *
{@code
+     * int
+     * }
+ * + * @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 response body along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listIntegersSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listIntegersSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * The listIntegers operation. + *

Response Body Schema

+ * + *
{@code
+     * int
+     * }
+ * + * @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 paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listIntegers(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listIntegersSinglePage(requestOptions), + nextLink -> listIntegersNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * The getJsonUtf8Response operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getJsonUtf8ResponseWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json;charset=utf-8"; + return FluxUtil + .withContext(context -> service.getJsonUtf8Response(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getJsonUtf8Response operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getJsonUtf8ResponseWithResponse(RequestOptions requestOptions) { + final String accept = "application/json;charset=utf-8"; + return service.getJsonUtf8ResponseSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The getPlusJsonResponse operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPlusJsonResponseWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/vnd.microsoft.appconfig.kv+json"; + return FluxUtil + .withContext(context -> service.getPlusJsonResponse(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getPlusJsonResponse operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPlusJsonResponseWithResponse(RequestOptions requestOptions) { + final String accept = "application/vnd.microsoft.appconfig.kv+json"; + return service.getPlusJsonResponseSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listStringsNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listStringsNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 response body along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listStringsNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listStringsNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * int
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listIntegersNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listIntegersNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * int
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 response body along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listIntegersNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listIntegersNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/SyncOperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/SyncOperationLocationPollingStrategy.java new file mode 100644 index 000000000..fdc8eaeea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/SyncOperationLocationPollingStrategy.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncOperationResourcePollingStrategy; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; + +import java.io.UncheckedIOException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Map; + +// DO NOT modify this helper class + +/** + * Implements a synchronous operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class SyncOperationLocationPollingStrategy extends SyncOperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(SyncOperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public PollResponse onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + T initialResponseType = null; + try { + initialResponseType = PollingUtils.deserializeResponseSync((BinaryData) response.getValue(), serializer, + pollResponseType); + } catch (UncheckedIOException e) { + LOGGER.info("Failed to parse initial response."); + } + return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, initialResponseType, retryAfter); + } + + throw LOGGER.logExceptionAsError(new AzureException( + String.format("Operation failed or cancelled with status code %d, '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + + /** + * {@inheritDoc} + */ + public U getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + Map pollResult = PollingUtils.deserializeResponseSync(latestResponseBody, serializer, + PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE); + if (pollResult != null && pollResult.get(propertyName) != null) { + return PollingUtils.deserializeResponseSync(BinaryData.fromObject(pollResult.get(propertyName)), + serializer, resultType); + } else { + throw LOGGER.logExceptionAsError(new AzureException("Cannot get final result")); + } + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/package-info.java new file mode 100644 index 000000000..e5f7eb14f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Response. + * + */ +package com.cadl.response.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/OperationDetails1.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/OperationDetails1.java new file mode 100644 index 000000000..ecffe912a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/OperationDetails1.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 com.cadl.response.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +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 OperationDetails1 model. + */ +@Immutable +public final class OperationDetails1 implements JsonSerializable { + /* + * Operation ID + */ + @Generated + private final String operationId; + + /* + * The status property. + */ + @Generated + private final OperationState status; + + /* + * The error property. + */ + @Generated + private ResponseError error; + + /* + * The result property. + */ + @Generated + private Resource result; + + /** + * Creates an instance of OperationDetails1 class. + * + * @param operationId the operationId value to set. + * @param status the status value to set. + */ + @Generated + private OperationDetails1(String operationId, OperationState status) { + this.operationId = operationId; + this.status = status; + } + + /** + * Get the operationId property: Operation ID. + * + * @return the operationId value. + */ + @Generated + public String getOperationId() { + return this.operationId; + } + + /** + * Get the status property: The status property. + * + * @return the status value. + */ + @Generated + public OperationState getStatus() { + return this.status; + } + + /** + * Get the error property: The error property. + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } + + /** + * Get the result property: The result property. + * + * @return the result value. + */ + @Generated + public Resource getResult() { + return this.result; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("operationId", this.operationId); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("error", this.error); + jsonWriter.writeJsonField("result", this.result); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationDetails1 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationDetails1 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 OperationDetails1. + */ + @Generated + public static OperationDetails1 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String operationId = null; + OperationState status = null; + ResponseError error = null; + Resource result = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("operationId".equals(fieldName)) { + operationId = reader.getString(); + } else if ("status".equals(fieldName)) { + status = OperationState.fromString(reader.getString()); + } else if ("error".equals(fieldName)) { + error = ResponseError.fromJson(reader); + } else if ("result".equals(fieldName)) { + result = Resource.fromJson(reader); + } else { + reader.skipChildren(); + } + } + OperationDetails1 deserializedOperationDetails1 = new OperationDetails1(operationId, status); + deserializedOperationDetails1.error = error; + deserializedOperationDetails1.result = result; + + return deserializedOperationDetails1; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/OperationDetails2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/OperationDetails2.java new file mode 100644 index 000000000..268f74a73 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/OperationDetails2.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 com.cadl.response.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +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 OperationDetails2 model. + */ +@Immutable +public final class OperationDetails2 implements JsonSerializable { + /* + * Operation ID + */ + @Generated + private final String id; + + /* + * The status property. + */ + @Generated + private final OperationState status; + + /* + * The error property. + */ + @Generated + private ResponseError error; + + /* + * The lroResult property. + */ + @Generated + private Resource lroResult; + + /** + * Creates an instance of OperationDetails2 class. + * + * @param id the id value to set. + * @param status the status value to set. + */ + @Generated + private OperationDetails2(String id, OperationState status) { + this.id = id; + this.status = status; + } + + /** + * Get the id property: Operation ID. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the status property: The status property. + * + * @return the status value. + */ + @Generated + public OperationState getStatus() { + return this.status; + } + + /** + * Get the error property: The error property. + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } + + /** + * Get the lroResult property: The lroResult property. + * + * @return the lroResult value. + */ + @Generated + public Resource getLroResult() { + return this.lroResult; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("error", this.error); + jsonWriter.writeJsonField("lroResult", this.lroResult); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationDetails2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationDetails2 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 OperationDetails2. + */ + @Generated + public static OperationDetails2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OperationState status = null; + ResponseError error = null; + Resource lroResult = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("status".equals(fieldName)) { + status = OperationState.fromString(reader.getString()); + } else if ("error".equals(fieldName)) { + error = ResponseError.fromJson(reader); + } else if ("lroResult".equals(fieldName)) { + lroResult = Resource.fromJson(reader); + } else { + reader.skipChildren(); + } + } + OperationDetails2 deserializedOperationDetails2 = new OperationDetails2(id, status); + deserializedOperationDetails2.error = error; + deserializedOperationDetails2.lroResult = lroResult; + + return deserializedOperationDetails2; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/OperationState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/OperationState.java new file mode 100644 index 000000000..ce23be521 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/OperationState.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 com.cadl.response.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum describing allowed operation states. + */ +public final class OperationState extends ExpandableStringEnum { + /** + * The operation has not started. + */ + @Generated + public static final OperationState NOT_STARTED = fromString("NotStarted"); + + /** + * The operation is in progress. + */ + @Generated + public static final OperationState RUNNING = fromString("Running"); + + /** + * The operation has completed successfully. + */ + @Generated + public static final OperationState SUCCEEDED = fromString("Succeeded"); + + /** + * The operation has failed. + */ + @Generated + public static final OperationState FAILED = fromString("Failed"); + + /** + * The operation has been canceled by the user. + */ + @Generated + public static final OperationState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of OperationState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OperationState() { + } + + /** + * Creates or finds a OperationState from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationState. + */ + @Generated + public static OperationState fromString(String name) { + return fromString(name, OperationState.class); + } + + /** + * Gets known OperationState values. + * + * @return known OperationState values. + */ + @Generated + public static Collection values() { + return values(OperationState.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/Resource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/Resource.java new file mode 100644 index 000000000..ca71710eb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/Resource.java @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response.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 Resource model. + */ +@Fluent +public final class Resource implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private String name; + + /* + * The description property. + */ + @Generated + private String description; + + /* + * The type property. + */ + @Generated + private final String type; + + /** + * Creates an instance of Resource class. + * + * @param type the type value to set. + */ + @Generated + public Resource(String type) { + this.type = type; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the description property: The description property. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The description property. + * + * @param description the description value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the type property: The type property. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource 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 Resource. + */ + @Generated + public static Resource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + String type = null; + String description = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else { + reader.skipChildren(); + } + } + Resource deserializedResource = new Resource(type); + deserializedResource.id = id; + deserializedResource.name = name; + deserializedResource.description = description; + + return deserializedResource; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/package-info.java new file mode 100644 index 000000000..02f67e488 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Response. + * + */ +package com.cadl.response.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/package-info.java new file mode 100644 index 000000000..0ca0b43b6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/response/package-info.java @@ -0,0 +1,10 @@ +// 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 Response. + * + */ +package com.cadl.response; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/ContosoServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/ContosoServiceVersion.java new file mode 100644 index 000000000..43bc42743 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/ContosoServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.server; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of ContosoClient. + */ +public enum ContosoServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"); + + private final String version; + + ContosoServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link ContosoServiceVersion}. + */ + public static ContosoServiceVersion getLatest() { + return V1; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/HttpbinAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/HttpbinAsyncClient.java new file mode 100644 index 000000000..41a954aa3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/HttpbinAsyncClient.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 com.cadl.server; + +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 com.cadl.server.implementation.HttpbinClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous HttpbinClient type. + */ +@ServiceClient(builder = HttpbinClientBuilder.class, isAsync = true) +public final class HttpbinAsyncClient { + @Generated + private final HttpbinClientImpl serviceClient; + + /** + * Initializes an instance of HttpbinAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + HttpbinAsyncClient(HttpbinClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The status operation. + * + * @param code The code 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> statusWithResponse(int code, RequestOptions requestOptions) { + return this.serviceClient.statusWithResponseAsync(code, requestOptions); + } + + /** + * The status operation. + * + * @param code The code 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 status(int code) { + // Generated convenience method for statusWithResponse + RequestOptions requestOptions = new RequestOptions(); + return statusWithResponse(code, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/HttpbinClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/HttpbinClient.java new file mode 100644 index 000000000..27908f794 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/HttpbinClient.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 com.cadl.server; + +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.cadl.server.implementation.HttpbinClientImpl; + +/** + * Initializes a new instance of the synchronous HttpbinClient type. + */ +@ServiceClient(builder = HttpbinClientBuilder.class) +public final class HttpbinClient { + @Generated + private final HttpbinClientImpl serviceClient; + + /** + * Initializes an instance of HttpbinClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + HttpbinClient(HttpbinClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The status operation. + * + * @param code The code 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 statusWithResponse(int code, RequestOptions requestOptions) { + return this.serviceClient.statusWithResponse(code, requestOptions); + } + + /** + * The status operation. + * + * @param code The code 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 status(int code) { + // Generated convenience method for statusWithResponse + RequestOptions requestOptions = new RequestOptions(); + statusWithResponse(code, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/HttpbinClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/HttpbinClientBuilder.java new file mode 100644 index 000000000..dae54e3b3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/HttpbinClientBuilder.java @@ -0,0 +1,326 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.server; + +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.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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.server.implementation.HttpbinClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the HttpbinClient type. + */ +@ServiceClientBuilder(serviceClients = { HttpbinClient.class, HttpbinAsyncClient.class }) +public final class HttpbinClientBuilder + implements HttpTrait, ConfigurationTrait { + @Generated + private static final String SDK_NAME = "name"; + + @Generated + private static final String SDK_VERSION = "version"; + + @Generated + private static final Map PROPERTIES = CoreUtils.getProperties("cadl-server.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the HttpbinClientBuilder. + */ + @Generated + public HttpbinClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public HttpbinClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public HttpbinClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public HttpbinClientBuilder 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 HttpbinClientBuilder 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 HttpbinClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public HttpbinClientBuilder 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 HttpbinClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * second-level domain, use httpbin + */ + @Generated + private String domain; + + /** + * Sets second-level domain, use httpbin. + * + * @param domain the domain value. + * @return the HttpbinClientBuilder. + */ + @Generated + public HttpbinClientBuilder domain(String domain) { + this.domain = domain; + return this; + } + + /* + * top-level domain, use org + */ + @Generated + private String tld; + + /** + * Sets top-level domain, use org. + * + * @param tld the tld value. + * @return the HttpbinClientBuilder. + */ + @Generated + public HttpbinClientBuilder tld(String tld) { + this.tld = tld; + return this; + } + + /* + * relative path segment, can be empty + */ + @Generated + private String relativePath; + + /** + * Sets relative path segment, can be empty. + * + * @param relativePath the relativePath value. + * @return the HttpbinClientBuilder. + */ + @Generated + public HttpbinClientBuilder relativePath(String relativePath) { + this.relativePath = relativePath; + 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 HttpbinClientBuilder. + */ + @Generated + public HttpbinClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of HttpbinClientImpl with the provided parameters. + * + * @return an instance of HttpbinClientImpl. + */ + @Generated + private HttpbinClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localDomain = (domain != null) ? domain : "httpbin"; + String localTld = (tld != null) ? tld : "org"; + HttpbinClientImpl client = new HttpbinClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localDomain, localTld, this.relativePath); + 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. + Objects.requireNonNull(relativePath, "'relativePath' cannot be null."); + } + + @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 HttpbinAsyncClient class. + * + * @return an instance of HttpbinAsyncClient. + */ + @Generated + public HttpbinAsyncClient buildAsyncClient() { + return new HttpbinAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of HttpbinClient class. + * + * @return an instance of HttpbinClient. + */ + @Generated + public HttpbinClient buildClient() { + return new HttpbinClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(HttpbinClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/contoso/sub/ContosoAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/contoso/sub/ContosoAsyncClient.java new file mode 100644 index 000000000..971043aae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/contoso/sub/ContosoAsyncClient.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 com.cadl.server.contoso.sub; + +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 com.cadl.server.implementation.ContosoClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ContosoClient type. + */ +@ServiceClient(builder = ContosoClientBuilder.class, isAsync = true) +public final class ContosoAsyncClient { + @Generated + private final ContosoClientImpl serviceClient; + + /** + * Initializes an instance of ContosoAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ContosoAsyncClient(ContosoClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + * + * @param group The group 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> getWithResponse(String group, RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(group, requestOptions); + } + + /** + * The get operation. + * + * @param group The group 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 get(String group) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(group, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/contoso/sub/ContosoClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/contoso/sub/ContosoClient.java new file mode 100644 index 000000000..d824ad708 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/contoso/sub/ContosoClient.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 com.cadl.server.contoso.sub; + +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.cadl.server.implementation.ContosoClientImpl; + +/** + * Initializes a new instance of the synchronous ContosoClient type. + */ +@ServiceClient(builder = ContosoClientBuilder.class) +public final class ContosoClient { + @Generated + private final ContosoClientImpl serviceClient; + + /** + * Initializes an instance of ContosoClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ContosoClient(ContosoClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + * + * @param group The group 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 getWithResponse(String group, RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(group, requestOptions); + } + + /** + * The get operation. + * + * @param group The group 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 get(String group) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + getWithResponse(group, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/contoso/sub/ContosoClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/contoso/sub/ContosoClientBuilder.java new file mode 100644 index 000000000..d00e6513d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/contoso/sub/ContosoClientBuilder.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.server.contoso.sub; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.server.ContosoServiceVersion; +import com.cadl.server.implementation.ContosoClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ContosoClient type. + */ +@ServiceClientBuilder(serviceClients = { ContosoClient.class, ContosoAsyncClient.class }) +public final class ContosoClientBuilder 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("cadl-server.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ContosoClientBuilder. + */ + @Generated + public ContosoClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContosoClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContosoClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContosoClientBuilder 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 ContosoClientBuilder 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 ContosoClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContosoClientBuilder 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 ContosoClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContosoClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private ContosoServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the ContosoClientBuilder. + */ + @Generated + public ContosoClientBuilder serviceVersion(ContosoServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 ContosoClientBuilder. + */ + @Generated + public ContosoClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ContosoClientImpl with the provided parameters. + * + * @return an instance of ContosoClientImpl. + */ + @Generated + private ContosoClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ContosoServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ContosoServiceVersion.getLatest(); + ContosoClientImpl client = new ContosoClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 ContosoAsyncClient class. + * + * @return an instance of ContosoAsyncClient. + */ + @Generated + public ContosoAsyncClient buildAsyncClient() { + return new ContosoAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ContosoClient class. + * + * @return an instance of ContosoClient. + */ + @Generated + public ContosoClient buildClient() { + return new ContosoClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ContosoClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/contoso/sub/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/contoso/sub/package-info.java new file mode 100644 index 000000000..3bc5dce16 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/contoso/sub/package-info.java @@ -0,0 +1,10 @@ +// 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 ContosoClient. + * + */ +package com.cadl.server.contoso.sub; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/implementation/ContosoClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/implementation/ContosoClientImpl.java new file mode 100644 index 000000000..10740ce1d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/implementation/ContosoClientImpl.java @@ -0,0 +1,196 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.server.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.PathParam; +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.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.cadl.server.ContosoServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the ContosoClient type. + */ +public final class ContosoClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ContosoClientService service; + + /** + * Service endpoint. + */ + private final String endpoint; + + /** + * Gets Service endpoint. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final ContosoServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ContosoServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 ContosoClient client. + * + * @param endpoint Service endpoint. + * @param serviceVersion Service version. + */ + public ContosoClientImpl(String endpoint, ContosoServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of ContosoClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service endpoint. + * @param serviceVersion Service version. + */ + public ContosoClientImpl(HttpPipeline httpPipeline, String endpoint, ContosoServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of ContosoClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Service endpoint. + * @param serviceVersion Service version. + */ + public ContosoClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + ContosoServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(ContosoClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for ContosoClient to be used by the proxy service to perform REST calls. + */ + @Host("{Endpoint}/contoso/{ApiVersion}") + @ServiceInterface(name = "ContosoClient") + public interface ContosoClientService { + @Get("/contoso/{group}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("Endpoint") String endpoint, @HostParam("ApiVersion") String apiVersion, + @PathParam(value = "group", encoded = true) String group, RequestOptions requestOptions, Context context); + + @Get("/contoso/{group}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("Endpoint") String endpoint, @HostParam("ApiVersion") String apiVersion, + @PathParam(value = "group", encoded = true) String group, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + * + * @param group The group 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> getWithResponseAsync(String group, RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.get(this.getEndpoint(), this.getServiceVersion().getVersion(), + group, requestOptions, context)); + } + + /** + * The get operation. + * + * @param group The group 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 getWithResponse(String group, RequestOptions requestOptions) { + return service.getSync(this.getEndpoint(), this.getServiceVersion().getVersion(), group, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/implementation/HttpbinClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/implementation/HttpbinClientImpl.java new file mode 100644 index 000000000..20c3a71dc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/implementation/HttpbinClientImpl.java @@ -0,0 +1,215 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.server.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.PathParam; +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.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 HttpbinClient type. + */ +public final class HttpbinClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final HttpbinClientService service; + + /** + * second-level domain, use httpbin. + */ + private final String domain; + + /** + * Gets second-level domain, use httpbin. + * + * @return the domain value. + */ + public String getDomain() { + return this.domain; + } + + /** + * top-level domain, use org. + */ + private final String tld; + + /** + * Gets top-level domain, use org. + * + * @return the tld value. + */ + public String getTld() { + return this.tld; + } + + /** + * relative path segment, can be empty. + */ + private final String relativePath; + + /** + * Gets relative path segment, can be empty. + * + * @return the relativePath value. + */ + public String getRelativePath() { + return this.relativePath; + } + + /** + * 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 HttpbinClient client. + * + * @param domain second-level domain, use httpbin. + * @param tld top-level domain, use org. + * @param relativePath relative path segment, can be empty. + */ + public HttpbinClientImpl(String domain, String tld, String relativePath) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), domain, tld, relativePath); + } + + /** + * Initializes an instance of HttpbinClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param domain second-level domain, use httpbin. + * @param tld top-level domain, use org. + * @param relativePath relative path segment, can be empty. + */ + public HttpbinClientImpl(HttpPipeline httpPipeline, String domain, String tld, String relativePath) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), domain, tld, relativePath); + } + + /** + * Initializes an instance of HttpbinClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param domain second-level domain, use httpbin. + * @param tld top-level domain, use org. + * @param relativePath relative path segment, can be empty. + */ + public HttpbinClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String domain, String tld, + String relativePath) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.domain = domain; + this.tld = tld; + this.relativePath = relativePath; + this.service = RestProxy.create(HttpbinClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for HttpbinClient to be used by the proxy service to perform REST calls. + */ + @Host("https://{domain}.{tld}{relative-path}") + @ServiceInterface(name = "HttpbinClient") + public interface HttpbinClientService { + @Get("/status/{code}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> status(@HostParam("domain") String domain, @HostParam("tld") String tld, + @HostParam("relative-path") String relativePath, @PathParam("code") int code, RequestOptions requestOptions, + Context context); + + @Get("/status/{code}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response statusSync(@HostParam("domain") String domain, @HostParam("tld") String tld, + @HostParam("relative-path") String relativePath, @PathParam("code") int code, RequestOptions requestOptions, + Context context); + } + + /** + * The status operation. + * + * @param code The code 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> statusWithResponseAsync(int code, RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.status(this.getDomain(), this.getTld(), this.getRelativePath(), + code, requestOptions, context)); + } + + /** + * The status operation. + * + * @param code The code 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 statusWithResponse(int code, RequestOptions requestOptions) { + return service.statusSync(this.getDomain(), this.getTld(), this.getRelativePath(), code, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/implementation/package-info.java new file mode 100644 index 000000000..56f04ad8e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Server. + * + */ +package com.cadl.server.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/package-info.java new file mode 100644 index 000000000..93a63e815 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/server/package-info.java @@ -0,0 +1,10 @@ +// 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 Server. + * + */ +package com.cadl.server; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/SpecialCharsAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/SpecialCharsAsyncClient.java new file mode 100644 index 000000000..102014414 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/SpecialCharsAsyncClient.java @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialchars; + +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 com.cadl.specialchars.implementation.BuiltinOpsImpl; +import com.cadl.specialchars.implementation.models.ReadRequest; +import com.cadl.specialchars.models.Resource; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SpecialCharsClient type. + */ +@ServiceClient(builder = SpecialCharsClientBuilder.class, isAsync = true) +public final class SpecialCharsAsyncClient { + @Generated + private final BuiltinOpsImpl serviceClient; + + /** + * Initializes an instance of SpecialCharsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpecialCharsAsyncClient(BuiltinOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The read operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     aggregate: String (Optional)
+     *     condition: String (Optional)
+     *     requestName: String (Optional)
+     *     value: Double (Optional)
+     * }
+     * }
+ * + * @param readRequest The readRequest 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> readWithResponse(BinaryData readRequest, RequestOptions requestOptions) { + return this.serviceClient.readWithResponseAsync(readRequest, requestOptions); + } + + /** + * The read operation. + * + * @param id The id 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono read(String id) { + // Generated convenience method for readWithResponse + RequestOptions requestOptions = new RequestOptions(); + ReadRequest readRequestObj = new ReadRequest(id); + BinaryData readRequest = BinaryData.fromObject(readRequestObj); + return readWithResponse(readRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/SpecialCharsClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/SpecialCharsClient.java new file mode 100644 index 000000000..c04954982 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/SpecialCharsClient.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialchars; + +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.cadl.specialchars.implementation.BuiltinOpsImpl; +import com.cadl.specialchars.implementation.models.ReadRequest; +import com.cadl.specialchars.models.Resource; + +/** + * Initializes a new instance of the synchronous SpecialCharsClient type. + */ +@ServiceClient(builder = SpecialCharsClientBuilder.class) +public final class SpecialCharsClient { + @Generated + private final BuiltinOpsImpl serviceClient; + + /** + * Initializes an instance of SpecialCharsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpecialCharsClient(BuiltinOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The read operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     aggregate: String (Optional)
+     *     condition: String (Optional)
+     *     requestName: String (Optional)
+     *     value: Double (Optional)
+     * }
+     * }
+ * + * @param readRequest The readRequest 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response readWithResponse(BinaryData readRequest, RequestOptions requestOptions) { + return this.serviceClient.readWithResponse(readRequest, requestOptions); + } + + /** + * The read operation. + * + * @param id The id 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource read(String id) { + // Generated convenience method for readWithResponse + RequestOptions requestOptions = new RequestOptions(); + ReadRequest readRequestObj = new ReadRequest(id); + BinaryData readRequest = BinaryData.fromObject(readRequestObj); + return readWithResponse(readRequest, requestOptions).getValue().toObject(Resource.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/SpecialCharsClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/SpecialCharsClientBuilder.java new file mode 100644 index 000000000..c17bceb24 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/SpecialCharsClientBuilder.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 com.cadl.specialchars; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.specialchars.implementation.SpecialCharsClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the SpecialCharsClient type. + */ +@ServiceClientBuilder(serviceClients = { SpecialCharsClient.class, SpecialCharsAsyncClient.class }) +public final class SpecialCharsClientBuilder 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("cadl-specialchars.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the SpecialCharsClientBuilder. + */ + @Generated + public SpecialCharsClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialCharsClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialCharsClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialCharsClientBuilder 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 SpecialCharsClientBuilder 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 SpecialCharsClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialCharsClientBuilder 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 SpecialCharsClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialCharsClientBuilder 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 SpecialCharsClientBuilder. + */ + @Generated + public SpecialCharsClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of SpecialCharsClientImpl with the provided parameters. + * + * @return an instance of SpecialCharsClientImpl. + */ + @Generated + private SpecialCharsClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + SpecialCharsClientImpl client + = new SpecialCharsClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 SpecialCharsAsyncClient class. + * + * @return an instance of SpecialCharsAsyncClient. + */ + @Generated + public SpecialCharsAsyncClient buildAsyncClient() { + return new SpecialCharsAsyncClient(buildInnerClient().getBuiltinOps()); + } + + /** + * Builds an instance of SpecialCharsClient class. + * + * @return an instance of SpecialCharsClient. + */ + @Generated + public SpecialCharsClient buildClient() { + return new SpecialCharsClient(buildInnerClient().getBuiltinOps()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SpecialCharsClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/BuiltinOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/BuiltinOpsImpl.java new file mode 100644 index 000000000..95933ed80 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/BuiltinOpsImpl.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 com.cadl.specialchars.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in BuiltinOps. + */ +public final class BuiltinOpsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BuiltinOpsService service; + + /** + * The service client containing this operation class. + */ + private final SpecialCharsClientImpl client; + + /** + * Initializes an instance of BuiltinOpsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BuiltinOpsImpl(SpecialCharsClientImpl client) { + this.service + = RestProxy.create(BuiltinOpsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SpecialCharsClientBuiltinOps to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SpecialCharsClientBu") + public interface BuiltinOpsService { + @Post("/specialchars") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> read(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData readRequest, RequestOptions requestOptions, Context context); + + @Post("/specialchars") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response readSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData readRequest, RequestOptions requestOptions, Context context); + } + + /** + * The read operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     aggregate: String (Optional)
+     *     condition: String (Optional)
+     *     requestName: String (Optional)
+     *     value: Double (Optional)
+     * }
+     * }
+ * + * @param readRequest The readRequest 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> readWithResponseAsync(BinaryData readRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.read(this.client.getEndpoint(), contentType, accept, readRequest, + requestOptions, context)); + } + + /** + * The read operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     aggregate: String (Optional)
+     *     condition: String (Optional)
+     *     requestName: String (Optional)
+     *     value: Double (Optional)
+     * }
+     * }
+ * + * @param readRequest The readRequest 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response readWithResponse(BinaryData readRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.readSync(this.client.getEndpoint(), contentType, accept, readRequest, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/SpecialCharsClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/SpecialCharsClientImpl.java new file mode 100644 index 000000000..a451aefaa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/SpecialCharsClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialchars.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the SpecialCharsClient type. + */ +public final class SpecialCharsClientImpl { + /** + * 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; + } + + /** + * The BuiltinOpsImpl object to access its operations. + */ + private final BuiltinOpsImpl builtinOps; + + /** + * Gets the BuiltinOpsImpl object to access its operations. + * + * @return the BuiltinOpsImpl object. + */ + public BuiltinOpsImpl getBuiltinOps() { + return this.builtinOps; + } + + /** + * Initializes an instance of SpecialCharsClient client. + * + * @param endpoint Service host. + */ + public SpecialCharsClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of SpecialCharsClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public SpecialCharsClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of SpecialCharsClient 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 SpecialCharsClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.builtinOps = new BuiltinOpsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/models/ReadRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/models/ReadRequest.java new file mode 100644 index 000000000..dd3307721 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/models/ReadRequest.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialchars.implementation.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; + +/** + * The ReadRequest model. + */ +@Immutable +public final class ReadRequest implements JsonSerializable { + /* + * The id property. + */ + @Generated + private final String id; + + /** + * Creates an instance of ReadRequest class. + * + * @param id the id value to set. + */ + @Generated + public ReadRequest(String id) { + this.id = id; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ReadRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ReadRequest 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 ReadRequest. + */ + @Generated + public static ReadRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ReadRequest(id); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/models/package-info.java new file mode 100644 index 000000000..78fabf09b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/models/package-info.java @@ -0,0 +1,10 @@ +// 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 SpecialChars. + * + */ +package com.cadl.specialchars.implementation.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/package-info.java new file mode 100644 index 000000000..466fa64dd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 SpecialChars. + * + */ +package com.cadl.specialchars.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/models/Resource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/models/Resource.java new file mode 100644 index 000000000..854c9c34a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/models/Resource.java @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialchars.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; + +/** + * The Resource model. + */ +@Immutable +public final class Resource implements JsonSerializable { + /* + * id + */ + @Generated + private final String id; + + /* + * The aggregation function to be applied on the client metric. Allowed functions + * - ‘percentage’ - for error metric , ‘avg’, ‘p50’, ‘p90’, ‘p95’, ‘p99’, ‘min’, + * ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + * ‘count’ - for requests + */ + @Generated + private String aggregate; + + /* + * The comparison operator. Supported types ‘>’, ‘<’ + */ + @Generated + private String condition; + + /* + * Request name for which the Pass fail criteria has to be applied + */ + @Generated + private String requestName; + + /* + * The value to compare with the client metric. Allowed values - ‘error : [0.0 , + * 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. + */ + @Generated + private Double value; + + /** + * Creates an instance of Resource class. + * + * @param id the id value to set. + */ + @Generated + private Resource(String id) { + this.id = id; + } + + /** + * Get the id property: id. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the aggregate property: The aggregation function to be applied on the client metric. Allowed functions + * - ‘percentage’ - for error metric , ‘avg’, ‘p50’, ‘p90’, ‘p95’, ‘p99’, ‘min’, + * ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + * ‘count’ - for requests. + * + * @return the aggregate value. + */ + @Generated + public String getAggregate() { + return this.aggregate; + } + + /** + * Get the condition property: The comparison operator. Supported types ‘>’, ‘<’. + * + * @return the condition value. + */ + @Generated + public String getCondition() { + return this.condition; + } + + /** + * Get the requestName property: Request name for which the Pass fail criteria has to be applied. + * + * @return the requestName value. + */ + @Generated + public String getRequestName() { + return this.requestName; + } + + /** + * Get the value property: The value to compare with the client metric. Allowed values - ‘error : [0.0 , + * 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. + * + * @return the value value. + */ + @Generated + public Double getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("aggregate", this.aggregate); + jsonWriter.writeStringField("condition", this.condition); + jsonWriter.writeStringField("requestName", this.requestName); + jsonWriter.writeNumberField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource 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 Resource. + */ + @Generated + public static Resource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String aggregate = null; + String condition = null; + String requestName = null; + Double value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("aggregate".equals(fieldName)) { + aggregate = reader.getString(); + } else if ("condition".equals(fieldName)) { + condition = reader.getString(); + } else if ("requestName".equals(fieldName)) { + requestName = reader.getString(); + } else if ("value".equals(fieldName)) { + value = reader.getNullable(JsonReader::getDouble); + } else { + reader.skipChildren(); + } + } + Resource deserializedResource = new Resource(id); + deserializedResource.aggregate = aggregate; + deserializedResource.condition = condition; + deserializedResource.requestName = requestName; + deserializedResource.value = value; + + return deserializedResource; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/models/package-info.java new file mode 100644 index 000000000..f6376b751 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/models/package-info.java @@ -0,0 +1,10 @@ +// 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 SpecialChars. + * + */ +package com.cadl.specialchars.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/package-info.java new file mode 100644 index 000000000..f09d3d3ee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialchars/package-info.java @@ -0,0 +1,10 @@ +// 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 SpecialChars. + * + */ +package com.cadl.specialchars; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/EtagHeadersAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/EtagHeadersAsyncClient.java new file mode 100644 index 000000000..df0a0267d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/EtagHeadersAsyncClient.java @@ -0,0 +1,339 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders; + +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.HttpHeaderName; +import com.azure.core.http.MatchConditions; +import com.azure.core.http.RequestConditions; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +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.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.cadl.specialheaders.implementation.EtagHeadersImpl; +import com.cadl.specialheaders.implementation.JsonMergePatchHelper; +import com.cadl.specialheaders.models.Resource; +import java.time.OffsetDateTime; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SpecialHeadersClient type. + */ +@ServiceClient(builder = SpecialHeadersClientBuilder.class, isAsync = true) +public final class EtagHeadersAsyncClient { + @Generated + private final EtagHeadersImpl serviceClient; + + /** + * Initializes an instance of EtagHeadersAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EtagHeadersAsyncClient(EtagHeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Create or replace operation template. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putWithRequestHeadersWithResponse(String name, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.putWithRequestHeadersWithResponseAsync(name, resource, requestOptions); + } + + /** + * Create or update operation template. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> patchWithMatchHeadersWithResponse(String name, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.patchWithMatchHeadersWithResponseAsync(name, resource, requestOptions); + } + + /** + * Resource list operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 paged collection of Resource items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithEtag(RequestOptions requestOptions) { + return this.serviceClient.listWithEtagAsync(requestOptions); + } + + /** + * Create or replace operation template. + * + * @param name The name parameter. + * @param resource The resource instance. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putWithRequestHeaders(String name, Resource resource, RequestConditions requestConditions) { + // Generated convenience method for putWithRequestHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return putWithRequestHeadersWithResponse(name, BinaryData.fromObject(resource), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * Create or replace operation template. + * + * @param name The name parameter. + * @param resource The resource instance. + * @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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putWithRequestHeaders(String name, Resource resource) { + // Generated convenience method for putWithRequestHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithRequestHeadersWithResponse(name, BinaryData.fromObject(resource), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * Create or update operation template. + * + * @param name The name parameter. + * @param resource The resource instance. + * @param matchConditions Specifies HTTP options for conditional requests. + * @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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono patchWithMatchHeaders(String name, Resource resource, MatchConditions matchConditions) { + // Generated convenience method for patchWithMatchHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); + String ifNoneMatch = matchConditions == null ? null : matchConditions.getIfNoneMatch(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, false); + return patchWithMatchHeadersWithResponse(name, resourceInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * Create or update operation template. + * + * @param name The name parameter. + * @param resource The resource instance. + * @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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono patchWithMatchHeaders(String name, Resource resource) { + // Generated convenience method for patchWithMatchHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, false); + return patchWithMatchHeadersWithResponse(name, resourceInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * Resource list operation template. + * + * @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 paged collection of Resource items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithEtag() { + // Generated convenience method for listWithEtag + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listWithEtag(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/EtagHeadersClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/EtagHeadersClient.java new file mode 100644 index 000000000..e713ac62d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/EtagHeadersClient.java @@ -0,0 +1,320 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders; + +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.HttpHeaderName; +import com.azure.core.http.MatchConditions; +import com.azure.core.http.RequestConditions; +import com.azure.core.http.rest.PagedIterable; +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.DateTimeRfc1123; +import com.cadl.specialheaders.implementation.EtagHeadersImpl; +import com.cadl.specialheaders.implementation.JsonMergePatchHelper; +import com.cadl.specialheaders.models.Resource; +import java.time.OffsetDateTime; + +/** + * Initializes a new instance of the synchronous SpecialHeadersClient type. + */ +@ServiceClient(builder = SpecialHeadersClientBuilder.class) +public final class EtagHeadersClient { + @Generated + private final EtagHeadersImpl serviceClient; + + /** + * Initializes an instance of EtagHeadersClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EtagHeadersClient(EtagHeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Create or replace operation template. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putWithRequestHeadersWithResponse(String name, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.putWithRequestHeadersWithResponse(name, resource, requestOptions); + } + + /** + * Create or update operation template. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response patchWithMatchHeadersWithResponse(String name, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.patchWithMatchHeadersWithResponse(name, resource, requestOptions); + } + + /** + * Resource list operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 paged collection of Resource items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithEtag(RequestOptions requestOptions) { + return this.serviceClient.listWithEtag(requestOptions); + } + + /** + * Create or replace operation template. + * + * @param name The name parameter. + * @param resource The resource instance. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource putWithRequestHeaders(String name, Resource resource, RequestConditions requestConditions) { + // Generated convenience method for putWithRequestHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return putWithRequestHeadersWithResponse(name, BinaryData.fromObject(resource), requestOptions).getValue() + .toObject(Resource.class); + } + + /** + * Create or replace operation template. + * + * @param name The name parameter. + * @param resource The resource instance. + * @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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource putWithRequestHeaders(String name, Resource resource) { + // Generated convenience method for putWithRequestHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithRequestHeadersWithResponse(name, BinaryData.fromObject(resource), requestOptions).getValue() + .toObject(Resource.class); + } + + /** + * Create or update operation template. + * + * @param name The name parameter. + * @param resource The resource instance. + * @param matchConditions Specifies HTTP options for conditional requests. + * @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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource patchWithMatchHeaders(String name, Resource resource, MatchConditions matchConditions) { + // Generated convenience method for patchWithMatchHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); + String ifNoneMatch = matchConditions == null ? null : matchConditions.getIfNoneMatch(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, false); + return patchWithMatchHeadersWithResponse(name, resourceInBinaryData, requestOptions).getValue() + .toObject(Resource.class); + } + + /** + * Create or update operation template. + * + * @param name The name parameter. + * @param resource The resource instance. + * @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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource patchWithMatchHeaders(String name, Resource resource) { + // Generated convenience method for patchWithMatchHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, false); + return patchWithMatchHeadersWithResponse(name, resourceInBinaryData, requestOptions).getValue() + .toObject(Resource.class); + } + + /** + * Resource list operation template. + * + * @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 paged collection of Resource items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithEtag() { + // Generated convenience method for listWithEtag + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listWithEtag(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(Resource.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/EtagHeadersOptionalBodyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/EtagHeadersOptionalBodyAsyncClient.java new file mode 100644 index 000000000..5db8ba085 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/EtagHeadersOptionalBodyAsyncClient.java @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders; + +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.HttpHeaderName; +import com.azure.core.http.RequestConditions; +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.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.cadl.specialheaders.implementation.EtagHeadersOptionalBodiesImpl; +import com.cadl.specialheaders.models.Resource; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SpecialHeadersClient type. + */ +@ServiceClient(builder = SpecialHeadersClientBuilder.class, isAsync = true) +public final class EtagHeadersOptionalBodyAsyncClient { + @Generated + private final EtagHeadersOptionalBodiesImpl serviceClient; + + /** + * Initializes an instance of EtagHeadersOptionalBodyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EtagHeadersOptionalBodyAsyncClient(EtagHeadersOptionalBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * etag headers among other optional query/header/body parameters. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
timestampOffsetDateTimeNoThe timestamp parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param format The format 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putWithOptionalBodyWithResponse(String format, RequestOptions requestOptions) { + return this.serviceClient.putWithOptionalBodyWithResponseAsync(format, requestOptions); + } + + /** + * etag headers among other optional query/header/body parameters. + * + * @param format The format parameter. + * @param filter The filter parameter. + * @param timestamp The timestamp parameter. + * @param body The body parameter. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putWithOptionalBody(String format, String filter, OffsetDateTime timestamp, Resource body, + RequestConditions requestConditions) { + // Generated convenience method for putWithOptionalBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (filter != null) { + requestOptions.addQueryParam("filter", filter, false); + } + if (timestamp != null) { + requestOptions.setHeader(HttpHeaderName.fromString("timestamp"), String.valueOf(timestamp.toEpochSecond())); + } + if (body != null) { + requestOptions.setBody(BinaryData.fromObject(body)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return putWithOptionalBodyWithResponse(format, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * etag headers among other optional query/header/body parameters. + * + * @param format The format 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putWithOptionalBody(String format) { + // Generated convenience method for putWithOptionalBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithOptionalBodyWithResponse(format, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/EtagHeadersOptionalBodyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/EtagHeadersOptionalBodyClient.java new file mode 100644 index 000000000..dd54c1264 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/EtagHeadersOptionalBodyClient.java @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders; + +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.HttpHeaderName; +import com.azure.core.http.RequestConditions; +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.DateTimeRfc1123; +import com.cadl.specialheaders.implementation.EtagHeadersOptionalBodiesImpl; +import com.cadl.specialheaders.models.Resource; +import java.time.OffsetDateTime; + +/** + * Initializes a new instance of the synchronous SpecialHeadersClient type. + */ +@ServiceClient(builder = SpecialHeadersClientBuilder.class) +public final class EtagHeadersOptionalBodyClient { + @Generated + private final EtagHeadersOptionalBodiesImpl serviceClient; + + /** + * Initializes an instance of EtagHeadersOptionalBodyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EtagHeadersOptionalBodyClient(EtagHeadersOptionalBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * etag headers among other optional query/header/body parameters. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
timestampOffsetDateTimeNoThe timestamp parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param format The format 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putWithOptionalBodyWithResponse(String format, RequestOptions requestOptions) { + return this.serviceClient.putWithOptionalBodyWithResponse(format, requestOptions); + } + + /** + * etag headers among other optional query/header/body parameters. + * + * @param format The format parameter. + * @param filter The filter parameter. + * @param timestamp The timestamp parameter. + * @param body The body parameter. + * @param requestConditions Specifies HTTP options for conditional requests based on modification time. + * @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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource putWithOptionalBody(String format, String filter, OffsetDateTime timestamp, Resource body, + RequestConditions requestConditions) { + // Generated convenience method for putWithOptionalBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = requestConditions == null ? null : requestConditions.getIfMatch(); + String ifNoneMatch = requestConditions == null ? null : requestConditions.getIfNoneMatch(); + OffsetDateTime ifUnmodifiedSince = requestConditions == null ? null : requestConditions.getIfUnmodifiedSince(); + OffsetDateTime ifModifiedSince = requestConditions == null ? null : requestConditions.getIfModifiedSince(); + if (filter != null) { + requestOptions.addQueryParam("filter", filter, false); + } + if (timestamp != null) { + requestOptions.setHeader(HttpHeaderName.fromString("timestamp"), String.valueOf(timestamp.toEpochSecond())); + } + if (body != null) { + requestOptions.setBody(BinaryData.fromObject(body)); + } + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + if (ifUnmodifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_UNMODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifUnmodifiedSince))); + } + if (ifModifiedSince != null) { + requestOptions.setHeader(HttpHeaderName.IF_MODIFIED_SINCE, + String.valueOf(new DateTimeRfc1123(ifModifiedSince))); + } + return putWithOptionalBodyWithResponse(format, requestOptions).getValue().toObject(Resource.class); + } + + /** + * etag headers among other optional query/header/body parameters. + * + * @param format The format 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource putWithOptionalBody(String format) { + // Generated convenience method for putWithOptionalBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithOptionalBodyWithResponse(format, requestOptions).getValue().toObject(Resource.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/RepeatabilityHeadersAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/RepeatabilityHeadersAsyncClient.java new file mode 100644 index 000000000..2a36d561e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/RepeatabilityHeadersAsyncClient.java @@ -0,0 +1,293 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders; + +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 com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollOperationDetails; +import com.cadl.specialheaders.implementation.JsonMergePatchHelper; +import com.cadl.specialheaders.implementation.RepeatabilityHeadersImpl; +import com.cadl.specialheaders.models.Resource; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SpecialHeadersClient type. + */ +@ServiceClient(builder = SpecialHeadersClientBuilder.class, isAsync = true) +public final class RepeatabilityHeadersAsyncClient { + @Generated + private final RepeatabilityHeadersImpl serviceClient; + + /** + * Initializes an instance of RepeatabilityHeadersAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RepeatabilityHeadersAsyncClient(RepeatabilityHeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Resource read operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(name, requestOptions); + } + + /** + * Send a put request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putWithResponse(String name, BinaryData resource, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(name, resource, requestOptions); + } + + /** + * Send a post request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.postWithResponseAsync(name, requestOptions); + } + + /** + * Send a LRO request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateLro(String name, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.beginCreateLroAsync(name, resource, requestOptions); + } + + /** + * Resource read operation template. + * + * @param name The name 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get(String name) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * Send a put request with header Repeatability-Request-ID and Repeatability-First-Sent. + * + * @param name The name parameter. + * @param resource The resource instance. + * @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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono put(String name, Resource resource) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(name, BinaryData.fromObject(resource), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * Send a post request with header Repeatability-Request-ID and Repeatability-First-Sent. + * + * @param name The name 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono post(String name) { + // Generated convenience method for postWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * Send a LRO request with header Repeatability-Request-ID and Repeatability-First-Sent. + * + * @param name The name parameter. + * @param resource The resource instance. + * @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 the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateLro(String name, Resource resource) { + // Generated convenience method for beginCreateLroWithModel + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, false); + return serviceClient.beginCreateLroWithModelAsync(name, resourceInBinaryData, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/RepeatabilityHeadersClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/RepeatabilityHeadersClient.java new file mode 100644 index 000000000..2c29ffb7a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/RepeatabilityHeadersClient.java @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders; + +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.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; +import com.cadl.specialheaders.implementation.JsonMergePatchHelper; +import com.cadl.specialheaders.implementation.RepeatabilityHeadersImpl; +import com.cadl.specialheaders.models.Resource; + +/** + * Initializes a new instance of the synchronous SpecialHeadersClient type. + */ +@ServiceClient(builder = SpecialHeadersClientBuilder.class) +public final class RepeatabilityHeadersClient { + @Generated + private final RepeatabilityHeadersImpl serviceClient; + + /** + * Initializes an instance of RepeatabilityHeadersClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RepeatabilityHeadersClient(RepeatabilityHeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Resource read operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(name, requestOptions); + } + + /** + * Send a put request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putWithResponse(String name, BinaryData resource, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(name, resource, requestOptions); + } + + /** + * Send a post request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postWithResponse(String name, RequestOptions requestOptions) { + return this.serviceClient.postWithResponse(name, requestOptions); + } + + /** + * Send a LRO request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateLro(String name, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.beginCreateLro(name, resource, requestOptions); + } + + /** + * Resource read operation template. + * + * @param name The name 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource get(String name) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(name, requestOptions).getValue().toObject(Resource.class); + } + + /** + * Send a put request with header Repeatability-Request-ID and Repeatability-First-Sent. + * + * @param name The name parameter. + * @param resource The resource instance. + * @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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource put(String name, Resource resource) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(name, BinaryData.fromObject(resource), requestOptions).getValue() + .toObject(Resource.class); + } + + /** + * Send a post request with header Repeatability-Request-ID and Repeatability-First-Sent. + * + * @param name The name 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource post(String name) { + // Generated convenience method for postWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postWithResponse(name, requestOptions).getValue().toObject(Resource.class); + } + + /** + * Send a LRO request with header Repeatability-Request-ID and Repeatability-First-Sent. + * + * @param name The name parameter. + * @param resource The resource instance. + * @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 the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateLro(String name, Resource resource) { + // Generated convenience method for beginCreateLroWithModel + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getResourceAccessor().prepareModelForJsonMergePatch(resource, false); + return serviceClient.beginCreateLroWithModel(name, resourceInBinaryData, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/SkipSpecialHeadersAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/SkipSpecialHeadersAsyncClient.java new file mode 100644 index 000000000..aac583b74 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/SkipSpecialHeadersAsyncClient.java @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders; + +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 com.cadl.specialheaders.implementation.SkipSpecialHeadersImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SpecialHeadersClient type. + */ +@ServiceClient(builder = SpecialHeadersClientBuilder.class, isAsync = true) +public final class SkipSpecialHeadersAsyncClient { + @Generated + private final SkipSpecialHeadersImpl serviceClient; + + /** + * Initializes an instance of SkipSpecialHeadersAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SkipSpecialHeadersAsyncClient(SkipSpecialHeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * skip special headers. + * + * @param name The name parameter. + * @param foo The foo 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> deleteWithSpecialHeadersWithResponse(String name, String foo, + RequestOptions requestOptions) { + return this.serviceClient.deleteWithSpecialHeadersWithResponseAsync(name, foo, requestOptions); + } + + /** + * skip special headers. + * + * @param name The name parameter. + * @param foo The foo 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 deleteWithSpecialHeaders(String name, String foo) { + // Generated convenience method for deleteWithSpecialHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteWithSpecialHeadersWithResponse(name, foo, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/SkipSpecialHeadersClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/SkipSpecialHeadersClient.java new file mode 100644 index 000000000..40043ed82 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/SkipSpecialHeadersClient.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders; + +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.cadl.specialheaders.implementation.SkipSpecialHeadersImpl; + +/** + * Initializes a new instance of the synchronous SpecialHeadersClient type. + */ +@ServiceClient(builder = SpecialHeadersClientBuilder.class) +public final class SkipSpecialHeadersClient { + @Generated + private final SkipSpecialHeadersImpl serviceClient; + + /** + * Initializes an instance of SkipSpecialHeadersClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SkipSpecialHeadersClient(SkipSpecialHeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * skip special headers. + * + * @param name The name parameter. + * @param foo The foo 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 deleteWithSpecialHeadersWithResponse(String name, String foo, RequestOptions requestOptions) { + return this.serviceClient.deleteWithSpecialHeadersWithResponse(name, foo, requestOptions); + } + + /** + * skip special headers. + * + * @param name The name parameter. + * @param foo The foo 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 deleteWithSpecialHeaders(String name, String foo) { + // Generated convenience method for deleteWithSpecialHeadersWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteWithSpecialHeadersWithResponse(name, foo, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/SpecialHeadersClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/SpecialHeadersClientBuilder.java new file mode 100644 index 000000000..019f90130 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/SpecialHeadersClientBuilder.java @@ -0,0 +1,376 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.specialheaders.implementation.SpecialHeadersClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the SpecialHeadersClient type. + */ +@ServiceClientBuilder( + serviceClients = { + RepeatabilityHeadersClient.class, + EtagHeadersClient.class, + EtagHeadersOptionalBodyClient.class, + SkipSpecialHeadersClient.class, + RepeatabilityHeadersAsyncClient.class, + EtagHeadersAsyncClient.class, + EtagHeadersOptionalBodyAsyncClient.class, + SkipSpecialHeadersAsyncClient.class }) +public final class SpecialHeadersClientBuilder 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("cadl-specialheaders.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the SpecialHeadersClientBuilder. + */ + @Generated + public SpecialHeadersClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialHeadersClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialHeadersClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialHeadersClientBuilder 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 SpecialHeadersClientBuilder 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 SpecialHeadersClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialHeadersClientBuilder 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 SpecialHeadersClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialHeadersClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private SpecialHeadersServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the SpecialHeadersClientBuilder. + */ + @Generated + public SpecialHeadersClientBuilder serviceVersion(SpecialHeadersServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 SpecialHeadersClientBuilder. + */ + @Generated + public SpecialHeadersClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of SpecialHeadersClientImpl with the provided parameters. + * + * @return an instance of SpecialHeadersClientImpl. + */ + @Generated + private SpecialHeadersClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + SpecialHeadersServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : SpecialHeadersServiceVersion.getLatest(); + SpecialHeadersClientImpl client = new SpecialHeadersClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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("client-request-id")); + 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 RepeatabilityHeadersAsyncClient class. + * + * @return an instance of RepeatabilityHeadersAsyncClient. + */ + @Generated + public RepeatabilityHeadersAsyncClient buildRepeatabilityHeadersAsyncClient() { + return new RepeatabilityHeadersAsyncClient(buildInnerClient().getRepeatabilityHeaders()); + } + + /** + * Builds an instance of EtagHeadersAsyncClient class. + * + * @return an instance of EtagHeadersAsyncClient. + */ + @Generated + public EtagHeadersAsyncClient buildEtagHeadersAsyncClient() { + return new EtagHeadersAsyncClient(buildInnerClient().getEtagHeaders()); + } + + /** + * Builds an instance of EtagHeadersOptionalBodyAsyncClient class. + * + * @return an instance of EtagHeadersOptionalBodyAsyncClient. + */ + @Generated + public EtagHeadersOptionalBodyAsyncClient buildEtagHeadersOptionalBodyAsyncClient() { + return new EtagHeadersOptionalBodyAsyncClient(buildInnerClient().getEtagHeadersOptionalBodies()); + } + + /** + * Builds an instance of SkipSpecialHeadersAsyncClient class. + * + * @return an instance of SkipSpecialHeadersAsyncClient. + */ + @Generated + public SkipSpecialHeadersAsyncClient buildSkipSpecialHeadersAsyncClient() { + return new SkipSpecialHeadersAsyncClient(buildInnerClient().getSkipSpecialHeaders()); + } + + /** + * Builds an instance of RepeatabilityHeadersClient class. + * + * @return an instance of RepeatabilityHeadersClient. + */ + @Generated + public RepeatabilityHeadersClient buildRepeatabilityHeadersClient() { + return new RepeatabilityHeadersClient(buildInnerClient().getRepeatabilityHeaders()); + } + + /** + * Builds an instance of EtagHeadersClient class. + * + * @return an instance of EtagHeadersClient. + */ + @Generated + public EtagHeadersClient buildEtagHeadersClient() { + return new EtagHeadersClient(buildInnerClient().getEtagHeaders()); + } + + /** + * Builds an instance of EtagHeadersOptionalBodyClient class. + * + * @return an instance of EtagHeadersOptionalBodyClient. + */ + @Generated + public EtagHeadersOptionalBodyClient buildEtagHeadersOptionalBodyClient() { + return new EtagHeadersOptionalBodyClient(buildInnerClient().getEtagHeadersOptionalBodies()); + } + + /** + * Builds an instance of SkipSpecialHeadersClient class. + * + * @return an instance of SkipSpecialHeadersClient. + */ + @Generated + public SkipSpecialHeadersClient buildSkipSpecialHeadersClient() { + return new SkipSpecialHeadersClient(buildInnerClient().getSkipSpecialHeaders()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SpecialHeadersClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/SpecialHeadersServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/SpecialHeadersServiceVersion.java new file mode 100644 index 000000000..afa4fdbcd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/SpecialHeadersServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of SpecialHeadersClient. + */ +public enum SpecialHeadersServiceVersion implements ServiceVersion { + /** + * Enum value 2022-06-01-preview. + */ + V2022_06_01_PREVIEW("2022-06-01-preview"); + + private final String version; + + SpecialHeadersServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link SpecialHeadersServiceVersion}. + */ + public static SpecialHeadersServiceVersion getLatest() { + return V2022_06_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersImpl.java new file mode 100644 index 000000000..18b60b853 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersImpl.java @@ -0,0 +1,591 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.implementation; + +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.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.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.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.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.cadl.specialheaders.SpecialHeadersServiceVersion; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in EtagHeaders. + */ +public final class EtagHeadersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EtagHeadersService service; + + /** + * The service client containing this operation class. + */ + private final SpecialHeadersClientImpl client; + + /** + * Initializes an instance of EtagHeadersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + EtagHeadersImpl(SpecialHeadersClientImpl client) { + this.service + = RestProxy.create(EtagHeadersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public SpecialHeadersServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for SpecialHeadersClientEtagHeaders to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SpecialHeadersClient") + public interface EtagHeadersService { + @Put("/etag-headers/resources/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putWithRequestHeaders(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Put("/etag-headers/resources/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putWithRequestHeadersSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Patch("/etag-headers/resources/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchWithMatchHeaders(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + Context context); + + @Patch("/etag-headers/resources/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchWithMatchHeadersSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + Context context); + + @Get("/etag-headers/resources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listWithEtag(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/etag-headers/resources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listWithEtagSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listWithEtagNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listWithEtagNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * Create or replace operation template. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putWithRequestHeadersWithResponseAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.putWithRequestHeaders(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, contentType, accept, resource, requestOptions, + context)); + } + + /** + * Create or replace operation template. + *

Header Parameters

+ * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putWithRequestHeadersWithResponse(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.putWithRequestHeadersSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, contentType, accept, resource, requestOptions, + Context.NONE); + } + + /** + * Create or update operation template. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> patchWithMatchHeadersWithResponseAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.patchWithMatchHeaders(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, contentType, accept, resource, requestOptions, + context)); + } + + /** + * Create or update operation template. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response patchWithMatchHeadersWithResponse(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return service.patchWithMatchHeadersSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, contentType, accept, resource, requestOptions, + Context.NONE); + } + + /** + * Resource list operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 paged collection of Resource items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listWithEtagSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listWithEtag(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Resource list operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 paged collection of Resource items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listWithEtagAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listWithEtagSinglePageAsync(requestOptions), + nextLink -> listWithEtagNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * Resource list operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 paged collection of Resource items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listWithEtagSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listWithEtagSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Resource list operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 paged collection of Resource items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listWithEtag(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listWithEtagSinglePage(requestOptions), + nextLink -> listWithEtagNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Resource list operation template. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of Resource items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listWithEtagNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.listWithEtagNext(nextLink, this.client.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Resource list operation template. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of Resource items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listWithEtagNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listWithEtagNextSync(nextLink, this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersOptionalBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersOptionalBodiesImpl.java new file mode 100644 index 000000000..ec32792dc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/EtagHeadersOptionalBodiesImpl.java @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.implementation; + +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.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.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.HttpHeaderName; +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.cadl.specialheaders.SpecialHeadersServiceVersion; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in EtagHeadersOptionalBodies. + */ +public final class EtagHeadersOptionalBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EtagHeadersOptionalBodiesService service; + + /** + * The service client containing this operation class. + */ + private final SpecialHeadersClientImpl client; + + /** + * Initializes an instance of EtagHeadersOptionalBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + EtagHeadersOptionalBodiesImpl(SpecialHeadersClientImpl client) { + this.service = RestProxy.create(EtagHeadersOptionalBodiesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public SpecialHeadersServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for SpecialHeadersClientEtagHeadersOptionalBodies to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SpecialHeadersClient") + public interface EtagHeadersOptionalBodiesService { + @Put("/etag-headers-optional-body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putWithOptionalBody(@HostParam("endpoint") String endpoint, + @QueryParam("format") String format, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/etag-headers-optional-body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putWithOptionalBodySync(@HostParam("endpoint") String endpoint, + @QueryParam("format") String format, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * etag headers among other optional query/header/body parameters. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
timestampOffsetDateTimeNoThe timestamp parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param format The format 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putWithOptionalBodyWithResponseAsync(String format, + RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return FluxUtil.withContext(context -> service.putWithOptionalBody(this.client.getEndpoint(), format, accept, + requestOptionsLocal, context)); + } + + /** + * etag headers among other optional query/header/body parameters. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Header Parameters

+ * + * + * + * + * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
If-Unmodified-SinceOffsetDateTimeNoThe request should only proceed if the + * entity was not modified after this time.
If-Modified-SinceOffsetDateTimeNoThe request should only proceed if the entity + * was modified after this time.
timestampOffsetDateTimeNoThe timestamp parameter
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param format The format 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putWithOptionalBodyWithResponse(String format, RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return service.putWithOptionalBodySync(this.client.getEndpoint(), format, accept, requestOptionsLocal, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/JsonMergePatchHelper.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/JsonMergePatchHelper.java new file mode 100644 index 000000000..649890716 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/JsonMergePatchHelper.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.implementation; + +import com.cadl.specialheaders.models.Resource; + +/** + * This is the Helper class to enable json merge patch serialization for a model. + */ +public class JsonMergePatchHelper { + private static ResourceAccessor resourceAccessor; + + public interface ResourceAccessor { + Resource prepareModelForJsonMergePatch(Resource resource, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(Resource resource); + } + + public static void setResourceAccessor(ResourceAccessor accessor) { + resourceAccessor = accessor; + } + + public static ResourceAccessor getResourceAccessor() { + return resourceAccessor; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/OperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/OperationLocationPollingStrategy.java new file mode 100644 index 000000000..d06960c0b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/OperationLocationPollingStrategy.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.OperationResourcePollingStrategy; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.time.OffsetDateTime; + +// DO NOT modify this helper class + +/** + * Implements an operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class OperationLocationPollingStrategy extends OperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(OperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + final Mono> pollResponseMono + = PollingUtils.deserializeResponse((BinaryData) response.getValue(), serializer, pollResponseType) + .onErrorResume(exception -> { + LOGGER.info("Failed to parse initial response."); + return Mono.empty(); + }) + .map(value -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, value, retryAfter)); + return pollResponseMono.switchIfEmpty( + Mono.fromSupplier(() -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, null, retryAfter))); + } else { + return Mono + .error( + new AzureException(String.format( + "Operation failed or cancelled with status code %d," + + ", '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + } + + /** + * {@inheritDoc} + */ + @Override + public Mono getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + return Mono.error(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + return Mono.error(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + return PollingUtils + .deserializeResponse(latestResponseBody, serializer, PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE) + .flatMap(value -> { + if (value.get(propertyName) != null) { + return BinaryData.fromObjectAsync(value.get(propertyName)) + .flatMap(result -> PollingUtils.deserializeResponse(result, serializer, resultType)); + } else { + return Mono.error(new AzureException("Cannot get final result")); + } + }) + .switchIfEmpty(Mono.error(new AzureException("Cannot get final result"))); + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/PollingUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/PollingUtils.java new file mode 100644 index 000000000..5c3b85c8b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/PollingUtils.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.net.URI; +import java.net.URISyntaxException; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.temporal.ChronoUnit; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +// DO NOT modify this helper class + +final class PollingUtils { + + public static final TypeReference> POST_POLL_RESULT_TYPE_REFERENCE + = new TypeReference>() { + }; + + public static final HttpHeaderName OPERATION_LOCATION_HEADER = HttpHeaderName.fromString("Operation-Location"); + + public static final String HTTP_METHOD = "httpMethod"; + public static final String REQUEST_URL = "requestURL"; + public static final String POLL_RESPONSE_BODY = "pollResponseBody"; + + private static final String FORWARD_SLASH = "/"; + + public static String getAbsolutePath(String path, String endpoint, ClientLogger logger) { + try { + URI uri = new URI(path); + if (!uri.isAbsolute()) { + if (CoreUtils.isNullOrEmpty(endpoint)) { + throw logger.logExceptionAsError(new IllegalArgumentException( + "Relative path requires endpoint to be non-null and non-empty to create an absolute path.")); + } + + if (endpoint.endsWith(FORWARD_SLASH) && path.startsWith(FORWARD_SLASH)) { + return endpoint + path.substring(1); + } else if (!endpoint.endsWith(FORWARD_SLASH) && !path.startsWith(FORWARD_SLASH)) { + return endpoint + FORWARD_SLASH + path; + } else { + return endpoint + path; + } + } + } catch (URISyntaxException ex) { + throw logger.logExceptionAsWarning(new IllegalArgumentException("'path' must be a valid URI.", ex)); + } + return path; + } + + public static T deserializeResponseSync(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + T value; + if (binaryData == null) { + value = null; + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = typeReference.getJavaClass().cast(binaryData.toReplayableBinaryData()); + } else { + value = binaryData.toObject(typeReference, serializer); + } + return value; + } + + @SuppressWarnings("unchecked") + public static Mono deserializeResponse(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + Mono value; + if (binaryData == null) { + value = Mono.empty(); + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = (Mono) binaryData.toReplayableBinaryDataAsync(); + } else { + value = binaryData.toObjectAsync(typeReference, serializer); + } + return value; + } + + private static final HttpHeaderName RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("retry-after-ms"); + private static final HttpHeaderName X_MS_RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("x-ms-retry-after-ms"); + + public static Duration getRetryAfterFromHeaders(HttpHeaders headers, Supplier nowSupplier) { + // Found 'x-ms-retry-after-ms' header, use a Duration of milliseconds based on the value. + Duration retryDelay = tryGetRetryDelay(headers, X_MS_RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'retry-after-ms' header, use a Duration of milliseconds based on the value. + retryDelay = tryGetRetryDelay(headers, RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'Retry-After' header. First, attempt to resolve it as a Duration of seconds. If that fails, then + // attempt to resolve it as an HTTP date (RFC1123). + retryDelay = tryGetRetryDelay(headers, HttpHeaderName.RETRY_AFTER, + headerValue -> tryParseLongOrDateTime(headerValue, nowSupplier)); + + // Either the retry delay will have been found or it'll be null, null indicates no retry after. + return retryDelay; + } + + private static Duration tryGetRetryDelay(HttpHeaders headers, HttpHeaderName headerName, + Function delayParser) { + String headerValue = headers.getValue(headerName); + + return CoreUtils.isNullOrEmpty(headerValue) ? null : delayParser.apply(headerValue); + } + + private static Duration tryParseLongOrDateTime(String value, Supplier nowSupplier) { + long delaySeconds; + try { + OffsetDateTime retryAfter = new DateTimeRfc1123(value).getDateTime(); + + delaySeconds = nowSupplier.get().until(retryAfter, ChronoUnit.SECONDS); + } catch (DateTimeException ex) { + delaySeconds = tryParseLong(value); + } + + return (delaySeconds >= 0) ? Duration.ofSeconds(delaySeconds) : null; + } + + private static long tryParseLong(String value) { + try { + return Long.parseLong(value); + } catch (NumberFormatException ex) { + return -1; + } + } + + private static Duration tryGetDelayMillis(String value) { + long delayMillis = tryParseLong(value); + return (delayMillis >= 0) ? Duration.ofMillis(delayMillis) : null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/RepeatabilityHeadersImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/RepeatabilityHeadersImpl.java new file mode 100644 index 000000000..b45fdf9a7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/RepeatabilityHeadersImpl.java @@ -0,0 +1,824 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +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.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.HttpHeaderName; +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.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.TypeReference; +import com.cadl.specialheaders.SpecialHeadersServiceVersion; +import com.cadl.specialheaders.models.Resource; +import java.time.Duration; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in RepeatabilityHeaders. + */ +public final class RepeatabilityHeadersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RepeatabilityHeadersService service; + + /** + * The service client containing this operation class. + */ + private final SpecialHeadersClientImpl client; + + /** + * Initializes an instance of RepeatabilityHeadersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + RepeatabilityHeadersImpl(SpecialHeadersClientImpl client) { + this.service = RestProxy.create(RepeatabilityHeadersService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public SpecialHeadersServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for SpecialHeadersClientRepeatabilityHeaders to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SpecialHeadersClient") + public interface RepeatabilityHeadersService { + @Get("/repeatability-headers/resources/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/repeatability-headers/resources/{name}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/repeatability-headers/resources/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Put("/repeatability-headers/resources/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Post("/repeatability-headers/resources/{name}:post") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> post(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/repeatability-headers/resources/{name}:post") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response postSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Patch("/repeatability-headers/resources/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createLro(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + Context context); + + @Patch("/repeatability-headers/resources/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createLroSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + Context context); + } + + /** + * Resource read operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, accept, requestOptions, context)); + } + + /** + * Resource read operation template. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, accept, + requestOptions, Context.NONE); + } + + /** + * Send a put request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putWithResponseAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-request-id"), CoreUtils.randomUuid().toString()); + } + }); + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-first-sent")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-first-sent"), + DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); + } + }); + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + name, contentType, accept, resource, requestOptionsLocal, context)); + } + + /** + * Send a put request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putWithResponse(String name, BinaryData resource, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-request-id"), CoreUtils.randomUuid().toString()); + } + }); + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-first-sent")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-first-sent"), + DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); + } + }); + return service.putSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + contentType, accept, resource, requestOptionsLocal, Context.NONE); + } + + /** + * Send a post request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-request-id"), CoreUtils.randomUuid().toString()); + } + }); + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-first-sent")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-first-sent"), + DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); + } + }); + return FluxUtil.withContext(context -> service.post(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, accept, requestOptionsLocal, context)); + } + + /** + * Send a post request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-request-id"), CoreUtils.randomUuid().toString()); + } + }); + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-first-sent")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-first-sent"), + DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); + } + }); + return service.postSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, accept, + requestOptionsLocal, Context.NONE); + } + + /** + * Send a LRO request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createLroWithResponseAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-request-id"), CoreUtils.randomUuid().toString()); + } + }); + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-first-sent")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-first-sent"), + DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); + } + }); + return FluxUtil.withContext( + context -> service.createLro(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + contentType, accept, resource, requestOptionsLocal, context)); + } + + /** + * Send a LRO request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createLroWithResponse(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-request-id"), CoreUtils.randomUuid().toString()); + } + }); + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-first-sent")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-first-sent"), + DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); + } + }); + return service.createLroSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, + contentType, accept, resource, requestOptionsLocal, Context.NONE); + } + + /** + * Send a LRO request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateLroAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.createLroWithResponseAsync(name, resource, requestOptions), + new com.cadl.specialheaders.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Send a LRO request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateLro(String name, BinaryData resource, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.createLroWithResponse(name, resource, requestOptions), + new com.cadl.specialheaders.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Send a LRO request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateLroWithModelAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.createLroWithResponseAsync(name, resource, requestOptions), + new com.cadl.specialheaders.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(Resource.class)); + } + + /** + * Send a LRO request with header Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     type: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateLroWithModel(String name, BinaryData resource, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.createLroWithResponse(name, resource, requestOptions), + new com.cadl.specialheaders.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(Resource.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/SkipSpecialHeadersImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/SkipSpecialHeadersImpl.java new file mode 100644 index 000000000..0903fb3ee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/SkipSpecialHeadersImpl.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.implementation; + +import com.azure.core.annotation.Delete; +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.PathParam; +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 com.cadl.specialheaders.SpecialHeadersServiceVersion; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in SkipSpecialHeaders. + */ +public final class SkipSpecialHeadersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SkipSpecialHeadersService service; + + /** + * The service client containing this operation class. + */ + private final SpecialHeadersClientImpl client; + + /** + * Initializes an instance of SkipSpecialHeadersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SkipSpecialHeadersImpl(SpecialHeadersClientImpl client) { + this.service = RestProxy.create(SkipSpecialHeadersService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public SpecialHeadersServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for SpecialHeadersClientSkipSpecialHeaders to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SpecialHeadersClient") + public interface SkipSpecialHeadersService { + @Delete("/skip-special-headers/resources/{name}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteWithSpecialHeaders(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("foo") String foo, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Delete("/skip-special-headers/resources/{name}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteWithSpecialHeadersSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("foo") String foo, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * skip special headers. + * + * @param name The name parameter. + * @param foo The foo 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> deleteWithSpecialHeadersWithResponseAsync(String name, String foo, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteWithSpecialHeaders(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, foo, accept, requestOptions, context)); + } + + /** + * skip special headers. + * + * @param name The name parameter. + * @param foo The foo 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 deleteWithSpecialHeadersWithResponse(String name, String foo, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteWithSpecialHeadersSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, foo, accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/SpecialHeadersClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/SpecialHeadersClientImpl.java new file mode 100644 index 000000000..fd88cb458 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/SpecialHeadersClientImpl.java @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.cadl.specialheaders.SpecialHeadersServiceVersion; + +/** + * Initializes a new instance of the SpecialHeadersClient type. + */ +public final class SpecialHeadersClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final SpecialHeadersServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public SpecialHeadersServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * The RepeatabilityHeadersImpl object to access its operations. + */ + private final RepeatabilityHeadersImpl repeatabilityHeaders; + + /** + * Gets the RepeatabilityHeadersImpl object to access its operations. + * + * @return the RepeatabilityHeadersImpl object. + */ + public RepeatabilityHeadersImpl getRepeatabilityHeaders() { + return this.repeatabilityHeaders; + } + + /** + * The EtagHeadersImpl object to access its operations. + */ + private final EtagHeadersImpl etagHeaders; + + /** + * Gets the EtagHeadersImpl object to access its operations. + * + * @return the EtagHeadersImpl object. + */ + public EtagHeadersImpl getEtagHeaders() { + return this.etagHeaders; + } + + /** + * The EtagHeadersOptionalBodiesImpl object to access its operations. + */ + private final EtagHeadersOptionalBodiesImpl etagHeadersOptionalBodies; + + /** + * Gets the EtagHeadersOptionalBodiesImpl object to access its operations. + * + * @return the EtagHeadersOptionalBodiesImpl object. + */ + public EtagHeadersOptionalBodiesImpl getEtagHeadersOptionalBodies() { + return this.etagHeadersOptionalBodies; + } + + /** + * The SkipSpecialHeadersImpl object to access its operations. + */ + private final SkipSpecialHeadersImpl skipSpecialHeaders; + + /** + * Gets the SkipSpecialHeadersImpl object to access its operations. + * + * @return the SkipSpecialHeadersImpl object. + */ + public SkipSpecialHeadersImpl getSkipSpecialHeaders() { + return this.skipSpecialHeaders; + } + + /** + * Initializes an instance of SpecialHeadersClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public SpecialHeadersClientImpl(String endpoint, SpecialHeadersServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of SpecialHeadersClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public SpecialHeadersClientImpl(HttpPipeline httpPipeline, String endpoint, + SpecialHeadersServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of SpecialHeadersClient 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. + * @param serviceVersion Service version. + */ + public SpecialHeadersClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + SpecialHeadersServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.repeatabilityHeaders = new RepeatabilityHeadersImpl(this); + this.etagHeaders = new EtagHeadersImpl(this); + this.etagHeadersOptionalBodies = new EtagHeadersOptionalBodiesImpl(this); + this.skipSpecialHeaders = new SkipSpecialHeadersImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/SyncOperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/SyncOperationLocationPollingStrategy.java new file mode 100644 index 000000000..8439eeff7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/SyncOperationLocationPollingStrategy.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncOperationResourcePollingStrategy; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; + +import java.io.UncheckedIOException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Map; + +// DO NOT modify this helper class + +/** + * Implements a synchronous operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class SyncOperationLocationPollingStrategy extends SyncOperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(SyncOperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public PollResponse onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + T initialResponseType = null; + try { + initialResponseType = PollingUtils.deserializeResponseSync((BinaryData) response.getValue(), serializer, + pollResponseType); + } catch (UncheckedIOException e) { + LOGGER.info("Failed to parse initial response."); + } + return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, initialResponseType, retryAfter); + } + + throw LOGGER.logExceptionAsError(new AzureException( + String.format("Operation failed or cancelled with status code %d, '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + + /** + * {@inheritDoc} + */ + public U getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + Map pollResult = PollingUtils.deserializeResponseSync(latestResponseBody, serializer, + PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE); + if (pollResult != null && pollResult.get(propertyName) != null) { + return PollingUtils.deserializeResponseSync(BinaryData.fromObject(pollResult.get(propertyName)), + serializer, resultType); + } else { + throw LOGGER.logExceptionAsError(new AzureException("Cannot get final result")); + } + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/package-info.java new file mode 100644 index 000000000..78afa4856 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 SpecialHeaders. + * + */ +package com.cadl.specialheaders.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/models/Resource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/models/Resource.java new file mode 100644 index 000000000..ed957f974 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/models/Resource.java @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.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 com.cadl.specialheaders.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * The Resource model. + */ +@Fluent +public final class Resource implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private String name; + + /* + * The description property. + */ + @Generated + private String description; + + /* + * The type property. + */ + @Generated + private String type; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setResourceAccessor(new JsonMergePatchHelper.ResourceAccessor() { + @Override + public Resource prepareModelForJsonMergePatch(Resource model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(Resource model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of Resource class. + */ + @Generated + public Resource() { + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the description property: The description property. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The description property. + * + * @param description the description value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setDescription(String description) { + this.description = description; + this.updatedProperties.add("description"); + return this; + } + + /** + * Get the type property: The type property. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Set the type property: The type property. + *

Required when create the resource.

+ * + * @param type the type value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setType(String type) { + this.type = type; + this.updatedProperties.add("type"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("description")) { + if (this.description == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", this.description); + } + } + if (updatedProperties.contains("type")) { + if (this.type == null) { + jsonWriter.writeNullField("type"); + } else { + jsonWriter.writeStringField("type", this.type); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource 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 Resource. + */ + @Generated + public static Resource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Resource deserializedResource = new Resource(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedResource.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedResource.name = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedResource.description = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedResource.type = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedResource; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/models/package-info.java new file mode 100644 index 000000000..e657436c7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/models/package-info.java @@ -0,0 +1,10 @@ +// 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 SpecialHeaders. + * + */ +package com.cadl.specialheaders.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/package-info.java new file mode 100644 index 000000000..3a5847166 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/specialheaders/package-info.java @@ -0,0 +1,10 @@ +// 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 SpecialHeaders. + * + */ +package com.cadl.specialheaders; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/UnionAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/UnionAsyncClient.java new file mode 100644 index 000000000..cf6c83781 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/UnionAsyncClient.java @@ -0,0 +1,311 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union; + +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 com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollOperationDetails; +import com.cadl.union.implementation.UnionFlattenOpsImpl; +import com.cadl.union.implementation.models.SendLongRequest; +import com.cadl.union.implementation.models.SendRequest; +import com.cadl.union.models.Result; +import com.cadl.union.models.SendLongOptions; +import com.cadl.union.models.User; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class, isAsync = true) +public final class UnionAsyncClient { + @Generated + private final UnionFlattenOpsImpl serviceClient; + + /** + * Initializes an instance of UnionAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionAsyncClient(UnionFlattenOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: BinaryData (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendRequest The sendRequest 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> sendWithResponse(String id, BinaryData sendRequest, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(id, sendRequest, requestOptions); + } + + /** + * The sendLong operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: String (Required)
+     *     dataInt: int (Required)
+     *     dataUnion: BinaryData (Optional)
+     *     dataLong: Long (Optional)
+     *     data_float: Double (Optional)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendLongRequest The sendLongRequest 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> sendLongWithResponse(String id, BinaryData sendLongRequest, + RequestOptions requestOptions) { + return this.serviceClient.sendLongWithResponseAsync(id, sendLongRequest, requestOptions); + } + + /** + * The get operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
dataBinaryDataNoThe data parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * A long-running remote procedure call (RPC) operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         result (Optional): (recursive schema, see result above)
+     *         data: BinaryData (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 the {@link PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginGenerate(RequestOptions requestOptions) { + return this.serviceClient.beginGenerateAsync(requestOptions); + } + + /** + * The send operation. + * + * @param id The id parameter. + * @param input The input parameter. + * @param user The user 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 send(String id, BinaryData input, User user) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest sendRequestObj = new SendRequest(input).setUser(user); + BinaryData sendRequest = BinaryData.fromObject(sendRequestObj); + return sendWithResponse(id, sendRequest, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The send operation. + * + * @param id The id parameter. + * @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 send(String id, BinaryData input) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest sendRequestObj = new SendRequest(input); + BinaryData sendRequest = BinaryData.fromObject(sendRequestObj); + return sendWithResponse(id, sendRequest, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The sendLong operation. + * + * @param options Options for sendLong API. + * @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 sendLong(SendLongOptions options) { + // Generated convenience method for sendLongWithResponse + RequestOptions requestOptions = new RequestOptions(); + String id = options.getId(); + String filter = options.getFilter(); + SendLongRequest sendLongRequestObj + = new SendLongRequest(options.getInput(), options.getDataInt()).setUser(options.getUser()) + .setDataUnion(options.getDataUnion()) + .setDataLong(options.getDataLong()) + .setDataFloat(options.getDataFloat()); + BinaryData sendLongRequest = BinaryData.fromObject(sendLongRequestObj); + if (filter != null) { + requestOptions.addQueryParam("filter", filter, false); + } + return sendLongWithResponse(id, sendLongRequest, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The get operation. + * + * @param data The data 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 get(BinaryData data) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (data != null) { + requestOptions.addQueryParam("data", String.valueOf(data), false); + } + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The get 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * A long-running remote procedure call (RPC) 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 the {@link PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginGenerate() { + // Generated convenience method for beginGenerateWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginGenerateWithModelAsync(requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/UnionClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/UnionClient.java new file mode 100644 index 000000000..ed19ddb79 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/UnionClient.java @@ -0,0 +1,303 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union; + +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.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; +import com.cadl.union.implementation.UnionFlattenOpsImpl; +import com.cadl.union.implementation.models.SendLongRequest; +import com.cadl.union.implementation.models.SendRequest; +import com.cadl.union.models.Result; +import com.cadl.union.models.SendLongOptions; +import com.cadl.union.models.User; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class UnionClient { + @Generated + private final UnionFlattenOpsImpl serviceClient; + + /** + * Initializes an instance of UnionClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionClient(UnionFlattenOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: BinaryData (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendRequest The sendRequest 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 sendWithResponse(String id, BinaryData sendRequest, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(id, sendRequest, requestOptions); + } + + /** + * The sendLong operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: String (Required)
+     *     dataInt: int (Required)
+     *     dataUnion: BinaryData (Optional)
+     *     dataLong: Long (Optional)
+     *     data_float: Double (Optional)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendLongRequest The sendLongRequest 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 sendLongWithResponse(String id, BinaryData sendLongRequest, RequestOptions requestOptions) { + return this.serviceClient.sendLongWithResponse(id, sendLongRequest, requestOptions); + } + + /** + * The get operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
dataBinaryDataNoThe data parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * A long-running remote procedure call (RPC) operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         result (Optional): (recursive schema, see result above)
+     *         data: BinaryData (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 the {@link SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginGenerate(RequestOptions requestOptions) { + return this.serviceClient.beginGenerate(requestOptions); + } + + /** + * The send operation. + * + * @param id The id parameter. + * @param input The input parameter. + * @param user The user 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 send(String id, BinaryData input, User user) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest sendRequestObj = new SendRequest(input).setUser(user); + BinaryData sendRequest = BinaryData.fromObject(sendRequestObj); + sendWithResponse(id, sendRequest, requestOptions).getValue(); + } + + /** + * The send operation. + * + * @param id The id parameter. + * @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 send(String id, BinaryData input) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest sendRequestObj = new SendRequest(input); + BinaryData sendRequest = BinaryData.fromObject(sendRequestObj); + sendWithResponse(id, sendRequest, requestOptions).getValue(); + } + + /** + * The sendLong operation. + * + * @param options Options for sendLong API. + * @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 sendLong(SendLongOptions options) { + // Generated convenience method for sendLongWithResponse + RequestOptions requestOptions = new RequestOptions(); + String id = options.getId(); + String filter = options.getFilter(); + SendLongRequest sendLongRequestObj + = new SendLongRequest(options.getInput(), options.getDataInt()).setUser(options.getUser()) + .setDataUnion(options.getDataUnion()) + .setDataLong(options.getDataLong()) + .setDataFloat(options.getDataFloat()); + BinaryData sendLongRequest = BinaryData.fromObject(sendLongRequestObj); + if (filter != null) { + requestOptions.addQueryParam("filter", filter, false); + } + sendLongWithResponse(id, sendLongRequest, requestOptions).getValue(); + } + + /** + * The get operation. + * + * @param data The data 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 get(BinaryData data) { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (data != null) { + requestOptions.addQueryParam("data", String.valueOf(data), false); + } + getWithResponse(requestOptions).getValue(); + } + + /** + * The get 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + getWithResponse(requestOptions).getValue(); + } + + /** + * A long-running remote procedure call (RPC) 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 the {@link SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginGenerate() { + // Generated convenience method for beginGenerateWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginGenerateWithModel(requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/UnionClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/UnionClientBuilder.java new file mode 100644 index 000000000..5d3264051 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/UnionClientBuilder.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.union.implementation.UnionClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the UnionClient type. + */ +@ServiceClientBuilder(serviceClients = { UnionClient.class, UnionAsyncClient.class }) +public final class UnionClientBuilder 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("cadl-union.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the UnionClientBuilder. + */ + @Generated + public UnionClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder 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 UnionClientBuilder 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 UnionClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder 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 UnionClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private UnionServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the UnionClientBuilder. + */ + @Generated + public UnionClientBuilder serviceVersion(UnionServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 UnionClientBuilder. + */ + @Generated + public UnionClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of UnionClientImpl with the provided parameters. + * + * @return an instance of UnionClientImpl. + */ + @Generated + private UnionClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + UnionServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : UnionServiceVersion.getLatest(); + UnionClientImpl client = new UnionClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 UnionAsyncClient class. + * + * @return an instance of UnionAsyncClient. + */ + @Generated + public UnionAsyncClient buildAsyncClient() { + return new UnionAsyncClient(buildInnerClient().getUnionFlattenOps()); + } + + /** + * Builds an instance of UnionClient class. + * + * @return an instance of UnionClient. + */ + @Generated + public UnionClient buildClient() { + return new UnionClient(buildInnerClient().getUnionFlattenOps()); + } + + private static final ClientLogger LOGGER = new ClientLogger(UnionClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/UnionServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/UnionServiceVersion.java new file mode 100644 index 000000000..0007d1bea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/UnionServiceVersion.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of UnionClient. + */ +public enum UnionServiceVersion implements ServiceVersion { + /** + * Enum value 2022-03-01-preview. + */ + V2022_03_01_PREVIEW("2022-03-01-preview"), + + /** + * Enum value 2022-06-01-preview. + */ + V2022_06_01_PREVIEW("2022-06-01-preview"); + + private final String version; + + UnionServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link UnionServiceVersion}. + */ + public static UnionServiceVersion getLatest() { + return V2022_06_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/OperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/OperationLocationPollingStrategy.java new file mode 100644 index 000000000..37fbef30e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/OperationLocationPollingStrategy.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.OperationResourcePollingStrategy; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.time.OffsetDateTime; + +// DO NOT modify this helper class + +/** + * Implements an operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class OperationLocationPollingStrategy extends OperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(OperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + final Mono> pollResponseMono + = PollingUtils.deserializeResponse((BinaryData) response.getValue(), serializer, pollResponseType) + .onErrorResume(exception -> { + LOGGER.info("Failed to parse initial response."); + return Mono.empty(); + }) + .map(value -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, value, retryAfter)); + return pollResponseMono.switchIfEmpty( + Mono.fromSupplier(() -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, null, retryAfter))); + } else { + return Mono + .error( + new AzureException(String.format( + "Operation failed or cancelled with status code %d," + + ", '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + } + + /** + * {@inheritDoc} + */ + @Override + public Mono getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + return Mono.error(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + return Mono.error(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + return PollingUtils + .deserializeResponse(latestResponseBody, serializer, PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE) + .flatMap(value -> { + if (value.get(propertyName) != null) { + return BinaryData.fromObjectAsync(value.get(propertyName)) + .flatMap(result -> PollingUtils.deserializeResponse(result, serializer, resultType)); + } else { + return Mono.error(new AzureException("Cannot get final result")); + } + }) + .switchIfEmpty(Mono.error(new AzureException("Cannot get final result"))); + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/PollingUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/PollingUtils.java new file mode 100644 index 000000000..a8fb4572e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/PollingUtils.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.net.URI; +import java.net.URISyntaxException; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.temporal.ChronoUnit; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +// DO NOT modify this helper class + +final class PollingUtils { + + public static final TypeReference> POST_POLL_RESULT_TYPE_REFERENCE + = new TypeReference>() { + }; + + public static final HttpHeaderName OPERATION_LOCATION_HEADER = HttpHeaderName.fromString("Operation-Location"); + + public static final String HTTP_METHOD = "httpMethod"; + public static final String REQUEST_URL = "requestURL"; + public static final String POLL_RESPONSE_BODY = "pollResponseBody"; + + private static final String FORWARD_SLASH = "/"; + + public static String getAbsolutePath(String path, String endpoint, ClientLogger logger) { + try { + URI uri = new URI(path); + if (!uri.isAbsolute()) { + if (CoreUtils.isNullOrEmpty(endpoint)) { + throw logger.logExceptionAsError(new IllegalArgumentException( + "Relative path requires endpoint to be non-null and non-empty to create an absolute path.")); + } + + if (endpoint.endsWith(FORWARD_SLASH) && path.startsWith(FORWARD_SLASH)) { + return endpoint + path.substring(1); + } else if (!endpoint.endsWith(FORWARD_SLASH) && !path.startsWith(FORWARD_SLASH)) { + return endpoint + FORWARD_SLASH + path; + } else { + return endpoint + path; + } + } + } catch (URISyntaxException ex) { + throw logger.logExceptionAsWarning(new IllegalArgumentException("'path' must be a valid URI.", ex)); + } + return path; + } + + public static T deserializeResponseSync(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + T value; + if (binaryData == null) { + value = null; + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = typeReference.getJavaClass().cast(binaryData.toReplayableBinaryData()); + } else { + value = binaryData.toObject(typeReference, serializer); + } + return value; + } + + @SuppressWarnings("unchecked") + public static Mono deserializeResponse(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + Mono value; + if (binaryData == null) { + value = Mono.empty(); + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = (Mono) binaryData.toReplayableBinaryDataAsync(); + } else { + value = binaryData.toObjectAsync(typeReference, serializer); + } + return value; + } + + private static final HttpHeaderName RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("retry-after-ms"); + private static final HttpHeaderName X_MS_RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("x-ms-retry-after-ms"); + + public static Duration getRetryAfterFromHeaders(HttpHeaders headers, Supplier nowSupplier) { + // Found 'x-ms-retry-after-ms' header, use a Duration of milliseconds based on the value. + Duration retryDelay = tryGetRetryDelay(headers, X_MS_RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'retry-after-ms' header, use a Duration of milliseconds based on the value. + retryDelay = tryGetRetryDelay(headers, RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'Retry-After' header. First, attempt to resolve it as a Duration of seconds. If that fails, then + // attempt to resolve it as an HTTP date (RFC1123). + retryDelay = tryGetRetryDelay(headers, HttpHeaderName.RETRY_AFTER, + headerValue -> tryParseLongOrDateTime(headerValue, nowSupplier)); + + // Either the retry delay will have been found or it'll be null, null indicates no retry after. + return retryDelay; + } + + private static Duration tryGetRetryDelay(HttpHeaders headers, HttpHeaderName headerName, + Function delayParser) { + String headerValue = headers.getValue(headerName); + + return CoreUtils.isNullOrEmpty(headerValue) ? null : delayParser.apply(headerValue); + } + + private static Duration tryParseLongOrDateTime(String value, Supplier nowSupplier) { + long delaySeconds; + try { + OffsetDateTime retryAfter = new DateTimeRfc1123(value).getDateTime(); + + delaySeconds = nowSupplier.get().until(retryAfter, ChronoUnit.SECONDS); + } catch (DateTimeException ex) { + delaySeconds = tryParseLong(value); + } + + return (delaySeconds >= 0) ? Duration.ofSeconds(delaySeconds) : null; + } + + private static long tryParseLong(String value) { + try { + return Long.parseLong(value); + } catch (NumberFormatException ex) { + return -1; + } + } + + private static Duration tryGetDelayMillis(String value) { + long delayMillis = tryParseLong(value); + return (delayMillis >= 0) ? Duration.ofMillis(delayMillis) : null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/SyncOperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/SyncOperationLocationPollingStrategy.java new file mode 100644 index 000000000..85c9c796e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/SyncOperationLocationPollingStrategy.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncOperationResourcePollingStrategy; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; + +import java.io.UncheckedIOException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Map; + +// DO NOT modify this helper class + +/** + * Implements a synchronous operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class SyncOperationLocationPollingStrategy extends SyncOperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(SyncOperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public PollResponse onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + T initialResponseType = null; + try { + initialResponseType = PollingUtils.deserializeResponseSync((BinaryData) response.getValue(), serializer, + pollResponseType); + } catch (UncheckedIOException e) { + LOGGER.info("Failed to parse initial response."); + } + return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, initialResponseType, retryAfter); + } + + throw LOGGER.logExceptionAsError(new AzureException( + String.format("Operation failed or cancelled with status code %d, '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + + /** + * {@inheritDoc} + */ + public U getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + Map pollResult = PollingUtils.deserializeResponseSync(latestResponseBody, serializer, + PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE); + if (pollResult != null && pollResult.get(propertyName) != null) { + return PollingUtils.deserializeResponseSync(BinaryData.fromObject(pollResult.get(propertyName)), + serializer, resultType); + } else { + throw LOGGER.logExceptionAsError(new AzureException("Cannot get final result")); + } + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/UnionClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/UnionClientImpl.java new file mode 100644 index 000000000..240291b03 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/UnionClientImpl.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.cadl.union.UnionServiceVersion; + +/** + * Initializes a new instance of the UnionClient type. + */ +public final class UnionClientImpl { + /** + */ + private final String endpoint; + + /** + * Gets. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final UnionServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public UnionServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * The UnionFlattenOpsImpl object to access its operations. + */ + private final UnionFlattenOpsImpl unionFlattenOps; + + /** + * Gets the UnionFlattenOpsImpl object to access its operations. + * + * @return the UnionFlattenOpsImpl object. + */ + public UnionFlattenOpsImpl getUnionFlattenOps() { + return this.unionFlattenOps; + } + + /** + * Initializes an instance of UnionClient client. + * + * @param endpoint + * @param serviceVersion Service version. + */ + public UnionClientImpl(String endpoint, UnionServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of UnionClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint + * @param serviceVersion Service version. + */ + public UnionClientImpl(HttpPipeline httpPipeline, String endpoint, UnionServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of UnionClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint + * @param serviceVersion Service version. + */ + public UnionClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + UnionServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.unionFlattenOps = new UnionFlattenOpsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/UnionFlattenOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/UnionFlattenOpsImpl.java new file mode 100644 index 000000000..9a7ee5cd5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/UnionFlattenOpsImpl.java @@ -0,0 +1,598 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +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.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.PollingStrategyOptions; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.TypeReference; +import com.cadl.union.UnionServiceVersion; +import com.cadl.union.models.Result; +import java.time.Duration; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in UnionFlattenOps. + */ +public final class UnionFlattenOpsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionFlattenOpsService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of UnionFlattenOpsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionFlattenOpsImpl(UnionClientImpl client) { + this.service + = RestProxy.create(UnionFlattenOpsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public UnionServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for UnionClientUnionFlattenOps to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}/openai") + @ServiceInterface(name = "UnionClientUnionFlat") + public interface UnionFlattenOpsService { + @Post("/union/send") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, @QueryParam("id") String id, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest, RequestOptions requestOptions, Context context); + + @Post("/union/send") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @QueryParam("id") String id, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest, RequestOptions requestOptions, Context context); + + @Post("/union/send-long") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> sendLong(@HostParam("endpoint") String endpoint, @QueryParam("id") String id, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendLongRequest, RequestOptions requestOptions, Context context); + + @Post("/union/send-long") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendLongSync(@HostParam("endpoint") String endpoint, @QueryParam("id") String id, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendLongRequest, RequestOptions requestOptions, Context context); + + @Get("/union/param") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/union/param") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Post("/union/generate") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> generate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/union/generate") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response generateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: BinaryData (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendRequest The sendRequest 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> sendWithResponseAsync(String id, BinaryData sendRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.send(this.client.getEndpoint(), id, + this.client.getServiceVersion().getVersion(), contentType, sendRequest, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: BinaryData (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendRequest The sendRequest 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 sendWithResponse(String id, BinaryData sendRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), id, this.client.getServiceVersion().getVersion(), + contentType, sendRequest, requestOptions, Context.NONE); + } + + /** + * The sendLong operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: String (Required)
+     *     dataInt: int (Required)
+     *     dataUnion: BinaryData (Optional)
+     *     dataLong: Long (Optional)
+     *     data_float: Double (Optional)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendLongRequest The sendLongRequest 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> sendLongWithResponseAsync(String id, BinaryData sendLongRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.sendLong(this.client.getEndpoint(), id, + this.client.getServiceVersion().getVersion(), contentType, sendLongRequest, requestOptions, context)); + } + + /** + * The sendLong operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoThe filter parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     user (Optional): {
+     *         user: String (Required)
+     *     }
+     *     input: String (Required)
+     *     dataInt: int (Required)
+     *     dataUnion: BinaryData (Optional)
+     *     dataLong: Long (Optional)
+     *     data_float: Double (Optional)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param sendLongRequest The sendLongRequest 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 sendLongWithResponse(String id, BinaryData sendLongRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendLongSync(this.client.getEndpoint(), id, this.client.getServiceVersion().getVersion(), + contentType, sendLongRequest, requestOptions, Context.NONE); + } + + /** + * The get operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
dataBinaryDataNoThe data parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> getWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The get operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
dataBinaryDataNoThe data parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 getWithResponse(RequestOptions requestOptions) { + return service.getSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * A long-running remote procedure call (RPC) operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         result (Optional): (recursive schema, see result above)
+     *         data: BinaryData (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 provides status details for long running operations along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> generateWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.generate(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)); + } + + /** + * A long-running remote procedure call (RPC) operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         result (Optional): (recursive schema, see result above)
+     *         data: BinaryData (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 provides status details for long running operations along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response generateWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.generateSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), accept, + requestOptions, Context.NONE); + } + + /** + * A long-running remote procedure call (RPC) operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         result (Optional): (recursive schema, see result above)
+     *         data: BinaryData (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 the {@link PollerFlux} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginGenerateAsync(RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.generateWithResponseAsync(requestOptions), + new com.cadl.union.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}/openai".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * A long-running remote procedure call (RPC) operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         result (Optional): (recursive schema, see result above)
+     *         data: BinaryData (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 the {@link SyncPoller} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginGenerate(RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.generateWithResponse(requestOptions), + new com.cadl.union.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}/openai".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * A long-running remote procedure call (RPC) operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         result (Optional): (recursive schema, see result above)
+     *         data: BinaryData (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 the {@link PollerFlux} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginGenerateWithModelAsync(RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.generateWithResponseAsync(requestOptions), + new com.cadl.union.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}/openai".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(Result.class)); + } + + /** + * A long-running remote procedure call (RPC) operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         name: String (Required)
+     *         result (Optional): (recursive schema, see result above)
+     *         data: BinaryData (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 the {@link SyncPoller} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginGenerateWithModel(RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.generateWithResponse(requestOptions), + new com.cadl.union.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}/openai".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(Result.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/models/SendLongRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/models/SendLongRequest.java new file mode 100644 index 000000000..c5c4ee9c0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/models/SendLongRequest.java @@ -0,0 +1,243 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.union.models.User; +import java.io.IOException; + +/** + * The SendLongRequest model. + */ +@Fluent +public final class SendLongRequest implements JsonSerializable { + /* + * The user property. + */ + @Generated + private User user; + + /* + * The input property. + */ + @Generated + private final String input; + + /* + * The dataInt property. + */ + @Generated + private final int dataInt; + + /* + * The dataUnion property. + */ + @Generated + private BinaryData dataUnion; + + /* + * The dataLong property. + */ + @Generated + private Long dataLong; + + /* + * The data_float property. + */ + @Generated + private Double dataFloat; + + /** + * Creates an instance of SendLongRequest class. + * + * @param input the input value to set. + * @param dataInt the dataInt value to set. + */ + @Generated + public SendLongRequest(String input, int dataInt) { + this.input = input; + this.dataInt = dataInt; + } + + /** + * Get the user property: The user property. + * + * @return the user value. + */ + @Generated + public User getUser() { + return this.user; + } + + /** + * Set the user property: The user property. + * + * @param user the user value to set. + * @return the SendLongRequest object itself. + */ + @Generated + public SendLongRequest setUser(User user) { + this.user = user; + return this; + } + + /** + * Get the input property: The input property. + * + * @return the input value. + */ + @Generated + public String getInput() { + return this.input; + } + + /** + * Get the dataInt property: The dataInt property. + * + * @return the dataInt value. + */ + @Generated + public int getDataInt() { + return this.dataInt; + } + + /** + * Get the dataUnion property: The dataUnion property. + * + * @return the dataUnion value. + */ + @Generated + public BinaryData getDataUnion() { + return this.dataUnion; + } + + /** + * Set the dataUnion property: The dataUnion property. + * + * @param dataUnion the dataUnion value to set. + * @return the SendLongRequest object itself. + */ + @Generated + public SendLongRequest setDataUnion(BinaryData dataUnion) { + this.dataUnion = dataUnion; + return this; + } + + /** + * Get the dataLong property: The dataLong property. + * + * @return the dataLong value. + */ + @Generated + public Long getDataLong() { + return this.dataLong; + } + + /** + * Set the dataLong property: The dataLong property. + * + * @param dataLong the dataLong value to set. + * @return the SendLongRequest object itself. + */ + @Generated + public SendLongRequest setDataLong(Long dataLong) { + this.dataLong = dataLong; + return this; + } + + /** + * Get the dataFloat property: The data_float property. + * + * @return the dataFloat value. + */ + @Generated + public Double getDataFloat() { + return this.dataFloat; + } + + /** + * Set the dataFloat property: The data_float property. + * + * @param dataFloat the dataFloat value to set. + * @return the SendLongRequest object itself. + */ + @Generated + public SendLongRequest setDataFloat(Double dataFloat) { + this.dataFloat = dataFloat; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("input", this.input); + jsonWriter.writeIntField("dataInt", this.dataInt); + jsonWriter.writeJsonField("user", this.user); + if (this.dataUnion != null) { + jsonWriter.writeUntypedField("dataUnion", this.dataUnion.toObject(Object.class)); + } + jsonWriter.writeNumberField("dataLong", this.dataLong); + jsonWriter.writeNumberField("data_float", this.dataFloat); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendLongRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendLongRequest 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 SendLongRequest. + */ + @Generated + public static SendLongRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String input = null; + int dataInt = 0; + User user = null; + BinaryData dataUnion = null; + Long dataLong = null; + Double dataFloat = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("input".equals(fieldName)) { + input = reader.getString(); + } else if ("dataInt".equals(fieldName)) { + dataInt = reader.getInt(); + } else if ("user".equals(fieldName)) { + user = User.fromJson(reader); + } else if ("dataUnion".equals(fieldName)) { + dataUnion = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("dataLong".equals(fieldName)) { + dataLong = reader.getNullable(JsonReader::getLong); + } else if ("data_float".equals(fieldName)) { + dataFloat = reader.getNullable(JsonReader::getDouble); + } else { + reader.skipChildren(); + } + } + SendLongRequest deserializedSendLongRequest = new SendLongRequest(input, dataInt); + deserializedSendLongRequest.user = user; + deserializedSendLongRequest.dataUnion = dataUnion; + deserializedSendLongRequest.dataLong = dataLong; + deserializedSendLongRequest.dataFloat = dataFloat; + + return deserializedSendLongRequest; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/models/SendRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/models/SendRequest.java new file mode 100644 index 000000000..8cec2cf9e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/models/SendRequest.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 com.cadl.union.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.union.models.User; +import java.io.IOException; + +/** + * The SendRequest model. + */ +@Fluent +public final class SendRequest implements JsonSerializable { + /* + * The user property. + */ + @Generated + private User user; + + /* + * The input property. + */ + @Generated + private final BinaryData input; + + /** + * Creates an instance of SendRequest class. + * + * @param input the input value to set. + */ + @Generated + public SendRequest(BinaryData input) { + this.input = input; + } + + /** + * Get the user property: The user property. + * + * @return the user value. + */ + @Generated + public User getUser() { + return this.user; + } + + /** + * Set the user property: The user property. + * + * @param user the user value to set. + * @return the SendRequest object itself. + */ + @Generated + public SendRequest setUser(User user) { + this.user = user; + return this; + } + + /** + * Get the input property: The input property. + * + * @return the input value. + */ + @Generated + public BinaryData getInput() { + return this.input; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeUntypedField("input", this.input.toObject(Object.class)); + jsonWriter.writeJsonField("user", this.user); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest 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 SendRequest. + */ + @Generated + public static SendRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData input = null; + User user = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("input".equals(fieldName)) { + input = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("user".equals(fieldName)) { + user = User.fromJson(reader); + } else { + reader.skipChildren(); + } + } + SendRequest deserializedSendRequest = new SendRequest(input); + deserializedSendRequest.user = user; + + return deserializedSendRequest; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/models/SubResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/models/SubResult.java new file mode 100644 index 000000000..aa2f21de3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/models/SubResult.java @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.cadl.union.models.Result; +import java.io.IOException; + +/** + * The SubResult model. + */ +@Fluent +public final class SubResult extends Result { + /* + * The text property. + */ + @Generated + private String text; + + /* + * The arrayData property. + */ + @Generated + private BinaryData arrayData; + + /** + * Creates an instance of SubResult class. + * + * @param name the name value to set. + * @param data the data value to set. + */ + @Generated + public SubResult(String name, BinaryData data) { + super(name, data); + } + + /** + * Get the text property: The text property. + * + * @return the text value. + */ + @Generated + public String getText() { + return this.text; + } + + /** + * Set the text property: The text property. + * + * @param text the text value to set. + * @return the SubResult object itself. + */ + @Generated + public SubResult setText(String text) { + this.text = text; + return this; + } + + /** + * Get the arrayData property: The arrayData property. + * + * @return the arrayData value. + */ + @Generated + public BinaryData getArrayData() { + return this.arrayData; + } + + /** + * Set the arrayData property: The arrayData property. + * + * @param arrayData the arrayData value to set. + * @return the SubResult object itself. + */ + @Generated + public SubResult setArrayData(BinaryData arrayData) { + this.arrayData = arrayData; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public SubResult setResult(Result result) { + super.setResult(result); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeUntypedField("data", getData().toObject(Object.class)); + jsonWriter.writeJsonField("result", getResult()); + jsonWriter.writeStringField("text", this.text); + if (this.arrayData != null) { + jsonWriter.writeUntypedField("arrayData", this.arrayData.toObject(Object.class)); + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SubResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SubResult 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 SubResult. + */ + @Generated + public static SubResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + BinaryData data = null; + Result result = null; + String text = null; + BinaryData arrayData = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("data".equals(fieldName)) { + data = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("result".equals(fieldName)) { + result = Result.fromJson(reader); + } else if ("text".equals(fieldName)) { + text = reader.getString(); + } else if ("arrayData".equals(fieldName)) { + arrayData = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + SubResult deserializedSubResult = new SubResult(name, data); + deserializedSubResult.setResult(result); + deserializedSubResult.text = text; + deserializedSubResult.arrayData = arrayData; + + return deserializedSubResult; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/models/package-info.java new file mode 100644 index 000000000..54ed60731 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Union. + * + */ +package com.cadl.union.implementation.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/package-info.java new file mode 100644 index 000000000..bf6920b0f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Union. + * + */ +package com.cadl.union.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/ArrayData.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/ArrayData.java new file mode 100644 index 000000000..b3ea3717b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/ArrayData.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.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; +import java.util.List; + +/** + * The ArrayData model. + */ +@Immutable +public final class ArrayData implements JsonSerializable { + /* + * The data property. + */ + @Generated + private final List data; + + /** + * Creates an instance of ArrayData class. + * + * @param data the data value to set. + */ + @Generated + public ArrayData(List data) { + this.data = data; + } + + /** + * Get the data property: The data property. + * + * @return the data value. + */ + @Generated + public List getData() { + return this.data; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("data", this.data, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ArrayData from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ArrayData 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 ArrayData. + */ + @Generated + public static ArrayData fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List data = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("data".equals(fieldName)) { + data = reader.readArray(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + return new ArrayData(data); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/Result.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/Result.java new file mode 100644 index 000000000..0918b6482 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/Result.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +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 Result model. + */ +@Fluent +public class Result implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The result property. + */ + @Generated + private Result result; + + /* + * The data property. + */ + @Generated + private final BinaryData data; + + /** + * Creates an instance of Result class. + * + * @param name the name value to set. + * @param data the data value to set. + */ + @Generated + public Result(String name, BinaryData data) { + this.name = name; + this.data = data; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the result property: The result property. + * + * @return the result value. + */ + @Generated + public Result getResult() { + return this.result; + } + + /** + * Set the result property: The result property. + * + * @param result the result value to set. + * @return the Result object itself. + */ + @Generated + public Result setResult(Result result) { + this.result = result; + return this; + } + + /** + * Get the data property: The data property. + * + * @return the data value. + */ + @Generated + public BinaryData getData() { + return this.data; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeUntypedField("data", this.data.toObject(Object.class)); + jsonWriter.writeJsonField("result", this.result); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Result from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Result 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 Result. + */ + @Generated + public static Result fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + BinaryData data = null; + Result result = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("data".equals(fieldName)) { + data = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("result".equals(fieldName)) { + result = Result.fromJson(reader); + } else { + reader.skipChildren(); + } + } + Result deserializedResult = new Result(name, data); + deserializedResult.result = result; + + return deserializedResult; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/SendLongOptions.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/SendLongOptions.java new file mode 100644 index 000000000..7d14286ea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/SendLongOptions.java @@ -0,0 +1,217 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; + +/** + * Options for sendLong API. + */ +@Fluent +public final class SendLongOptions { + /* + * The id property. + */ + @Generated + private final String id; + + /* + * The filter property. + */ + @Generated + private String filter; + + /* + * The user property. + */ + @Generated + private User user; + + /* + * The input property. + */ + @Generated + private final String input; + + /* + * The dataInt property. + */ + @Generated + private final int dataInt; + + /* + * The dataUnion property. + */ + @Generated + private BinaryData dataUnion; + + /* + * The dataLong property. + */ + @Generated + private Long dataLong; + + /* + * The data_float property. + */ + @Generated + private Double dataFloat; + + /** + * Creates an instance of SendLongOptions class. + * + * @param id the id value to set. + * @param input the input value to set. + * @param dataInt the dataInt value to set. + */ + @Generated + public SendLongOptions(String id, String input, int dataInt) { + this.id = id; + this.input = input; + this.dataInt = dataInt; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the filter property: The filter property. + * + * @return the filter value. + */ + @Generated + public String getFilter() { + return this.filter; + } + + /** + * Set the filter property: The filter property. + * + * @param filter the filter value to set. + * @return the SendLongOptions object itself. + */ + @Generated + public SendLongOptions setFilter(String filter) { + this.filter = filter; + return this; + } + + /** + * Get the user property: The user property. + * + * @return the user value. + */ + @Generated + public User getUser() { + return this.user; + } + + /** + * Set the user property: The user property. + * + * @param user the user value to set. + * @return the SendLongOptions object itself. + */ + @Generated + public SendLongOptions setUser(User user) { + this.user = user; + return this; + } + + /** + * Get the input property: The input property. + * + * @return the input value. + */ + @Generated + public String getInput() { + return this.input; + } + + /** + * Get the dataInt property: The dataInt property. + * + * @return the dataInt value. + */ + @Generated + public int getDataInt() { + return this.dataInt; + } + + /** + * Get the dataUnion property: The dataUnion property. + * + * @return the dataUnion value. + */ + @Generated + public BinaryData getDataUnion() { + return this.dataUnion; + } + + /** + * Set the dataUnion property: The dataUnion property. + * + * @param dataUnion the dataUnion value to set. + * @return the SendLongOptions object itself. + */ + @Generated + public SendLongOptions setDataUnion(BinaryData dataUnion) { + this.dataUnion = dataUnion; + return this; + } + + /** + * Get the dataLong property: The dataLong property. + * + * @return the dataLong value. + */ + @Generated + public Long getDataLong() { + return this.dataLong; + } + + /** + * Set the dataLong property: The dataLong property. + * + * @param dataLong the dataLong value to set. + * @return the SendLongOptions object itself. + */ + @Generated + public SendLongOptions setDataLong(Long dataLong) { + this.dataLong = dataLong; + return this; + } + + /** + * Get the dataFloat property: The data_float property. + * + * @return the dataFloat value. + */ + @Generated + public Double getDataFloat() { + return this.dataFloat; + } + + /** + * Set the dataFloat property: The data_float property. + * + * @param dataFloat the dataFloat value to set. + * @return the SendLongOptions object itself. + */ + @Generated + public SendLongOptions setDataFloat(Double dataFloat) { + this.dataFloat = dataFloat; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/User.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/User.java new file mode 100644 index 000000000..120f2fa9e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/User.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.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; + +/** + * The User model. + */ +@Immutable +public final class User implements JsonSerializable { + /* + * The user property. + */ + @Generated + private final String user; + + /** + * Creates an instance of User class. + * + * @param user the user value to set. + */ + @Generated + public User(String user) { + this.user = user; + } + + /** + * Get the user property: The user property. + * + * @return the user value. + */ + @Generated + public String getUser() { + return this.user; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("user", this.user); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of User from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of User 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 User. + */ + @Generated + public static User fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String user = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("user".equals(fieldName)) { + user = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new User(user); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/package-info.java new file mode 100644 index 000000000..9f88326ef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Union. + * + */ +package com.cadl.union.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/package-info.java new file mode 100644 index 000000000..a460087fa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/union/package-info.java @@ -0,0 +1,10 @@ +// 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 Union. + * + */ +package com.cadl.union; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/VersioningAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/VersioningAsyncClient.java new file mode 100644 index 000000000..5050cafee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/VersioningAsyncClient.java @@ -0,0 +1,301 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning; + +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.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollOperationDetails; +import com.cadl.versioning.implementation.VersioningOpsImpl; +import com.cadl.versioning.models.ExportedResource; +import com.cadl.versioning.models.Resource; +import java.util.List; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; + +/** + * Initializes a new instance of the asynchronous VersioningClient type. + */ +@ServiceClient(builder = VersioningClientBuilder.class, isAsync = true) +public final class VersioningAsyncClient { + @Generated + private final VersioningOpsImpl serviceClient; + + /** + * Initializes an instance of VersioningAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VersioningAsyncClient(VersioningOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Long-running resource action operation template. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
projectFileVersionStringNoThe projectFileVersion parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         id: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name 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 PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginExport(String name, RequestOptions requestOptions) { + return this.serviceClient.beginExportAsync(name, requestOptions); + } + + /** + * Resource list operation template. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
selectList<String>NoSelect the specified fields to be included in the + * response. Call {@link RequestOptions#addQueryParam} to add string to array.
expandStringNoThe expand parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (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 paged collection of Resource items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(RequestOptions requestOptions) { + return this.serviceClient.listAsync(requestOptions); + } + + /** + * Long-running resource create or replace operation template. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateLongRunning(String name, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.beginCreateLongRunningAsync(name, resource, requestOptions); + } + + /** + * Long-running resource action operation template. + * + * @param name The name parameter. + * @param projectFileVersion The projectFileVersion 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 the {@link PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginExport(String name, String projectFileVersion) { + // Generated convenience method for beginExportWithModel + RequestOptions requestOptions = new RequestOptions(); + if (projectFileVersion != null) { + requestOptions.addQueryParam("projectFileVersion", projectFileVersion, false); + } + return serviceClient.beginExportWithModelAsync(name, requestOptions); + } + + /** + * Long-running resource action operation template. + * + * @param name The name 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 the {@link PollerFlux} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginExport(String name) { + // Generated convenience method for beginExportWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginExportWithModelAsync(name, requestOptions); + } + + /** + * Resource list operation template. + * + * @param select Select the specified fields to be included in the response. + * @param expand The expand 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 paged collection of Resource items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(List select, String expand) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (select != null) { + for (String paramItemValue : select) { + if (paramItemValue != null) { + requestOptions.addQueryParam("select", paramItemValue, false); + } + } + } + if (expand != null) { + requestOptions.addQueryParam("expand", expand, false); + } + PagedFlux pagedFluxResponse = list(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Resource list operation template. + * + * @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 paged collection of Resource items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = list(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Long-running resource create or replace operation template. + * + * @param name The name parameter. + * @param resource The resource instance. + * @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 the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateLongRunning(String name, Resource resource) { + // Generated convenience method for beginCreateLongRunningWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginCreateLongRunningWithModelAsync(name, BinaryData.fromObject(resource), + requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/VersioningClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/VersioningClient.java new file mode 100644 index 000000000..444642996 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/VersioningClient.java @@ -0,0 +1,272 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning; + +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.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; +import com.cadl.versioning.implementation.VersioningOpsImpl; +import com.cadl.versioning.models.ExportedResource; +import com.cadl.versioning.models.Resource; +import java.util.List; + +/** + * Initializes a new instance of the synchronous VersioningClient type. + */ +@ServiceClient(builder = VersioningClientBuilder.class) +public final class VersioningClient { + @Generated + private final VersioningOpsImpl serviceClient; + + /** + * Initializes an instance of VersioningClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VersioningClient(VersioningOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Long-running resource action operation template. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
projectFileVersionStringNoThe projectFileVersion parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         id: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name 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 SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginExport(String name, RequestOptions requestOptions) { + return this.serviceClient.beginExport(name, requestOptions); + } + + /** + * Resource list operation template. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
selectList<String>NoSelect the specified fields to be included in the + * response. Call {@link RequestOptions#addQueryParam} to add string to array.
expandStringNoThe expand parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (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 paged collection of Resource items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + return this.serviceClient.list(requestOptions); + } + + /** + * Long-running resource create or replace operation template. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateLongRunning(String name, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.beginCreateLongRunning(name, resource, requestOptions); + } + + /** + * Long-running resource action operation template. + * + * @param name The name parameter. + * @param projectFileVersion The projectFileVersion 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 the {@link SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginExport(String name, String projectFileVersion) { + // Generated convenience method for beginExportWithModel + RequestOptions requestOptions = new RequestOptions(); + if (projectFileVersion != null) { + requestOptions.addQueryParam("projectFileVersion", projectFileVersion, false); + } + return serviceClient.beginExportWithModel(name, requestOptions); + } + + /** + * Long-running resource action operation template. + * + * @param name The name 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 the {@link SyncPoller} for polling of provides status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginExport(String name) { + // Generated convenience method for beginExportWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginExportWithModel(name, requestOptions); + } + + /** + * Resource list operation template. + * + * @param select Select the specified fields to be included in the response. + * @param expand The expand 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 paged collection of Resource items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(List select, String expand) { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + if (select != null) { + for (String paramItemValue : select) { + if (paramItemValue != null) { + requestOptions.addQueryParam("select", paramItemValue, false); + } + } + } + if (expand != null) { + requestOptions.addQueryParam("expand", expand, false); + } + return serviceClient.list(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(Resource.class)); + } + + /** + * Resource list operation template. + * + * @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 paged collection of Resource items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.list(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(Resource.class)); + } + + /** + * Long-running resource create or replace operation template. + * + * @param name The name parameter. + * @param resource The resource instance. + * @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 the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateLongRunning(String name, Resource resource) { + // Generated convenience method for beginCreateLongRunningWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginCreateLongRunningWithModel(name, BinaryData.fromObject(resource), requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/VersioningClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/VersioningClientBuilder.java new file mode 100644 index 000000000..bf3f21753 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/VersioningClientBuilder.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.versioning.implementation.VersioningClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the VersioningClient type. + */ +@ServiceClientBuilder(serviceClients = { VersioningClient.class, VersioningAsyncClient.class }) +public final class VersioningClientBuilder 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("cadl-versioning.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the VersioningClientBuilder. + */ + @Generated + public VersioningClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VersioningClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VersioningClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VersioningClientBuilder 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 VersioningClientBuilder 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 VersioningClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VersioningClientBuilder 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 VersioningClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VersioningClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private VersioningServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the VersioningClientBuilder. + */ + @Generated + public VersioningClientBuilder serviceVersion(VersioningServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 VersioningClientBuilder. + */ + @Generated + public VersioningClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of VersioningClientImpl with the provided parameters. + * + * @return an instance of VersioningClientImpl. + */ + @Generated + private VersioningClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + VersioningServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : VersioningServiceVersion.getLatest(); + VersioningClientImpl client = new VersioningClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 VersioningAsyncClient class. + * + * @return an instance of VersioningAsyncClient. + */ + @Generated + public VersioningAsyncClient buildAsyncClient() { + return new VersioningAsyncClient(buildInnerClient().getVersioningOps()); + } + + /** + * Builds an instance of VersioningClient class. + * + * @return an instance of VersioningClient. + */ + @Generated + public VersioningClient buildClient() { + return new VersioningClient(buildInnerClient().getVersioningOps()); + } + + private static final ClientLogger LOGGER = new ClientLogger(VersioningClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/VersioningServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/VersioningServiceVersion.java new file mode 100644 index 000000000..600c0fa42 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/VersioningServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of VersioningClient. + */ +public enum VersioningServiceVersion implements ServiceVersion { + /** + * Enum value 2022-09-01. + */ + V2022_09_01("2022-09-01"); + + private final String version; + + VersioningServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link VersioningServiceVersion}. + */ + public static VersioningServiceVersion getLatest() { + return V2022_09_01; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/OperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/OperationLocationPollingStrategy.java new file mode 100644 index 000000000..eaac16276 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/OperationLocationPollingStrategy.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.OperationResourcePollingStrategy; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.time.OffsetDateTime; + +// DO NOT modify this helper class + +/** + * Implements an operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class OperationLocationPollingStrategy extends OperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(OperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public OperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public Mono> onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + final Mono> pollResponseMono + = PollingUtils.deserializeResponse((BinaryData) response.getValue(), serializer, pollResponseType) + .onErrorResume(exception -> { + LOGGER.info("Failed to parse initial response."); + return Mono.empty(); + }) + .map(value -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, value, retryAfter)); + return pollResponseMono.switchIfEmpty( + Mono.fromSupplier(() -> new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, null, retryAfter))); + } else { + return Mono + .error( + new AzureException(String.format( + "Operation failed or cancelled with status code %d," + + ", '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + } + + /** + * {@inheritDoc} + */ + @Override + public Mono getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + return Mono.error(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + return Mono.error(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + return PollingUtils + .deserializeResponse(latestResponseBody, serializer, PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE) + .flatMap(value -> { + if (value.get(propertyName) != null) { + return BinaryData.fromObjectAsync(value.get(propertyName)) + .flatMap(result -> PollingUtils.deserializeResponse(result, serializer, resultType)); + } else { + return Mono.error(new AzureException("Cannot get final result")); + } + }) + .switchIfEmpty(Mono.error(new AzureException("Cannot get final result"))); + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/PollingUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/PollingUtils.java new file mode 100644 index 000000000..b67972a84 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/PollingUtils.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; +import reactor.core.publisher.Mono; + +import java.net.URI; +import java.net.URISyntaxException; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.temporal.ChronoUnit; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +// DO NOT modify this helper class + +final class PollingUtils { + + public static final TypeReference> POST_POLL_RESULT_TYPE_REFERENCE + = new TypeReference>() { + }; + + public static final HttpHeaderName OPERATION_LOCATION_HEADER = HttpHeaderName.fromString("Operation-Location"); + + public static final String HTTP_METHOD = "httpMethod"; + public static final String REQUEST_URL = "requestURL"; + public static final String POLL_RESPONSE_BODY = "pollResponseBody"; + + private static final String FORWARD_SLASH = "/"; + + public static String getAbsolutePath(String path, String endpoint, ClientLogger logger) { + try { + URI uri = new URI(path); + if (!uri.isAbsolute()) { + if (CoreUtils.isNullOrEmpty(endpoint)) { + throw logger.logExceptionAsError(new IllegalArgumentException( + "Relative path requires endpoint to be non-null and non-empty to create an absolute path.")); + } + + if (endpoint.endsWith(FORWARD_SLASH) && path.startsWith(FORWARD_SLASH)) { + return endpoint + path.substring(1); + } else if (!endpoint.endsWith(FORWARD_SLASH) && !path.startsWith(FORWARD_SLASH)) { + return endpoint + FORWARD_SLASH + path; + } else { + return endpoint + path; + } + } + } catch (URISyntaxException ex) { + throw logger.logExceptionAsWarning(new IllegalArgumentException("'path' must be a valid URI.", ex)); + } + return path; + } + + public static T deserializeResponseSync(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + T value; + if (binaryData == null) { + value = null; + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = typeReference.getJavaClass().cast(binaryData.toReplayableBinaryData()); + } else { + value = binaryData.toObject(typeReference, serializer); + } + return value; + } + + @SuppressWarnings("unchecked") + public static Mono deserializeResponse(BinaryData binaryData, ObjectSerializer serializer, + TypeReference typeReference) { + Mono value; + if (binaryData == null) { + value = Mono.empty(); + } else if (typeReference.getJavaClass().isAssignableFrom(BinaryData.class)) { + // T is BinaryData + value = (Mono) binaryData.toReplayableBinaryDataAsync(); + } else { + value = binaryData.toObjectAsync(typeReference, serializer); + } + return value; + } + + private static final HttpHeaderName RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("retry-after-ms"); + private static final HttpHeaderName X_MS_RETRY_AFTER_MS_HEADER = HttpHeaderName.fromString("x-ms-retry-after-ms"); + + public static Duration getRetryAfterFromHeaders(HttpHeaders headers, Supplier nowSupplier) { + // Found 'x-ms-retry-after-ms' header, use a Duration of milliseconds based on the value. + Duration retryDelay = tryGetRetryDelay(headers, X_MS_RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'retry-after-ms' header, use a Duration of milliseconds based on the value. + retryDelay = tryGetRetryDelay(headers, RETRY_AFTER_MS_HEADER, s -> tryGetDelayMillis(s)); + if (retryDelay != null) { + return retryDelay; + } + + // Found 'Retry-After' header. First, attempt to resolve it as a Duration of seconds. If that fails, then + // attempt to resolve it as an HTTP date (RFC1123). + retryDelay = tryGetRetryDelay(headers, HttpHeaderName.RETRY_AFTER, + headerValue -> tryParseLongOrDateTime(headerValue, nowSupplier)); + + // Either the retry delay will have been found or it'll be null, null indicates no retry after. + return retryDelay; + } + + private static Duration tryGetRetryDelay(HttpHeaders headers, HttpHeaderName headerName, + Function delayParser) { + String headerValue = headers.getValue(headerName); + + return CoreUtils.isNullOrEmpty(headerValue) ? null : delayParser.apply(headerValue); + } + + private static Duration tryParseLongOrDateTime(String value, Supplier nowSupplier) { + long delaySeconds; + try { + OffsetDateTime retryAfter = new DateTimeRfc1123(value).getDateTime(); + + delaySeconds = nowSupplier.get().until(retryAfter, ChronoUnit.SECONDS); + } catch (DateTimeException ex) { + delaySeconds = tryParseLong(value); + } + + return (delaySeconds >= 0) ? Duration.ofSeconds(delaySeconds) : null; + } + + private static long tryParseLong(String value) { + try { + return Long.parseLong(value); + } catch (NumberFormatException ex) { + return -1; + } + } + + private static Duration tryGetDelayMillis(String value) { + long delayMillis = tryParseLong(value); + return (delayMillis >= 0) ? Duration.ofMillis(delayMillis) : null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/SyncOperationLocationPollingStrategy.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/SyncOperationLocationPollingStrategy.java new file mode 100644 index 000000000..35a1bc8a8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/SyncOperationLocationPollingStrategy.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning.implementation; + +import com.azure.core.exception.AzureException; +import com.azure.core.http.HttpHeader; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollResponse; +import com.azure.core.util.polling.PollingContext; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncOperationResourcePollingStrategy; +import com.azure.core.util.serializer.JsonSerializerProviders; +import com.azure.core.util.serializer.ObjectSerializer; +import com.azure.core.util.serializer.TypeReference; + +import java.io.UncheckedIOException; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Map; + +// DO NOT modify this helper class + +/** + * Implements a synchronous operation location polling strategy, from Operation-Location. + * + * @param the type of the response type from a polling call, or BinaryData if raw response body should be kept + * @param the type of the final result object to deserialize into, or BinaryData if raw response body should be + * kept + */ +public final class SyncOperationLocationPollingStrategy extends SyncOperationResourcePollingStrategy { + + private static final ClientLogger LOGGER = new ClientLogger(SyncOperationLocationPollingStrategy.class); + + private final ObjectSerializer serializer; + private final String endpoint; + private final String propertyName; + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions) { + this(pollingStrategyOptions, null); + } + + /** + * Creates an instance of the operation resource polling strategy. + * + * @param pollingStrategyOptions options to configure this polling strategy. + * @param propertyName the name of the property to extract final result. + * @throws NullPointerException if {@code pollingStrategyOptions} is null. + */ + public SyncOperationLocationPollingStrategy(PollingStrategyOptions pollingStrategyOptions, String propertyName) { + super(PollingUtils.OPERATION_LOCATION_HEADER, pollingStrategyOptions); + this.propertyName = propertyName; + this.endpoint = pollingStrategyOptions.getEndpoint(); + this.serializer = pollingStrategyOptions.getSerializer() != null + ? pollingStrategyOptions.getSerializer() + : JsonSerializerProviders.createInstance(true); + } + + /** + * {@inheritDoc} + */ + @Override + public PollResponse onInitialResponse(Response response, PollingContext pollingContext, + TypeReference pollResponseType) { + // Response is Response + + HttpHeader operationLocationHeader = response.getHeaders().get(PollingUtils.OPERATION_LOCATION_HEADER); + if (operationLocationHeader != null) { + pollingContext.setData(PollingUtils.OPERATION_LOCATION_HEADER.getCaseSensitiveName(), + PollingUtils.getAbsolutePath(operationLocationHeader.getValue(), endpoint, LOGGER)); + } + final String httpMethod = response.getRequest().getHttpMethod().name(); + pollingContext.setData(PollingUtils.HTTP_METHOD, httpMethod); + pollingContext.setData(PollingUtils.REQUEST_URL, response.getRequest().getUrl().toString()); + + if (response.getStatusCode() == 200 + || response.getStatusCode() == 201 + || response.getStatusCode() == 202 + || response.getStatusCode() == 204) { + final Duration retryAfter + = PollingUtils.getRetryAfterFromHeaders(response.getHeaders(), OffsetDateTime::now); + T initialResponseType = null; + try { + initialResponseType = PollingUtils.deserializeResponseSync((BinaryData) response.getValue(), serializer, + pollResponseType); + } catch (UncheckedIOException e) { + LOGGER.info("Failed to parse initial response."); + } + return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, initialResponseType, retryAfter); + } + + throw LOGGER.logExceptionAsError(new AzureException( + String.format("Operation failed or cancelled with status code %d, '%s' header: %s, and response body: %s", + response.getStatusCode(), PollingUtils.OPERATION_LOCATION_HEADER, operationLocationHeader, + response.getValue()))); + } + + /** + * {@inheritDoc} + */ + public U getResult(PollingContext pollingContext, TypeReference resultType) { + if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.FAILED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation failed.")); + } else if (pollingContext.getLatestResponse().getStatus() == LongRunningOperationStatus.USER_CANCELLED) { + throw LOGGER.logExceptionAsError(new AzureException("Long running operation cancelled.")); + } + if (propertyName != null) { + // take the last poll response body from PollingContext, + // and de-serialize the property as final result + BinaryData latestResponseBody + = BinaryData.fromString(pollingContext.getData(PollingUtils.POLL_RESPONSE_BODY)); + Map pollResult = PollingUtils.deserializeResponseSync(latestResponseBody, serializer, + PollingUtils.POST_POLL_RESULT_TYPE_REFERENCE); + if (pollResult != null && pollResult.get(propertyName) != null) { + return PollingUtils.deserializeResponseSync(BinaryData.fromObject(pollResult.get(propertyName)), + serializer, resultType); + } else { + throw LOGGER.logExceptionAsError(new AzureException("Cannot get final result")); + } + } else { + return super.getResult(pollingContext, resultType); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/VersioningClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/VersioningClientImpl.java new file mode 100644 index 000000000..b64dbb93f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/VersioningClientImpl.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.cadl.versioning.VersioningServiceVersion; + +/** + * Initializes a new instance of the VersioningClient type. + */ +public final class VersioningClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final VersioningServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public VersioningServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * The VersioningOpsImpl object to access its operations. + */ + private final VersioningOpsImpl versioningOps; + + /** + * Gets the VersioningOpsImpl object to access its operations. + * + * @return the VersioningOpsImpl object. + */ + public VersioningOpsImpl getVersioningOps() { + return this.versioningOps; + } + + /** + * Initializes an instance of VersioningClient client. + * + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public VersioningClientImpl(String endpoint, VersioningServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of VersioningClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param serviceVersion Service version. + */ + public VersioningClientImpl(HttpPipeline httpPipeline, String endpoint, VersioningServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of VersioningClient 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. + * @param serviceVersion Service version. + */ + public VersioningClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + VersioningServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.versioningOps = new VersioningOpsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/VersioningOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/VersioningOpsImpl.java new file mode 100644 index 000000000..e32901663 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/VersioningOpsImpl.java @@ -0,0 +1,973 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +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.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.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.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.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.PollOperationDetails; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.TypeReference; +import com.cadl.versioning.VersioningServiceVersion; +import com.cadl.versioning.models.ExportedResource; +import com.cadl.versioning.models.Resource; +import java.time.Duration; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in VersioningOps. + */ +public final class VersioningOpsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final VersioningOpsService service; + + /** + * The service client containing this operation class. + */ + private final VersioningClientImpl client; + + /** + * Initializes an instance of VersioningOpsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + VersioningOpsImpl(VersioningClientImpl client) { + this.service + = RestProxy.create(VersioningOpsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public VersioningServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for VersioningClientVersioningOps to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "VersioningClientVers") + public interface VersioningOpsService { + @Post("/versioning/resources/{name}:export") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> export(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/versioning/resources/{name}:export") + @ExpectedResponses({ 202 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response exportSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/versioning/resources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/versioning/resources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/versioning/resources/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createLongRunning(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Put("/versioning/resources/{name}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createLongRunningSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("name") String name, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * Long-running resource action operation template. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
projectFileVersionStringNoThe projectFileVersion parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         id: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name 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 provides status details for long running operations along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> exportWithResponseAsync(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.export(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, accept, requestOptions, context)); + } + + /** + * Long-running resource action operation template. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
projectFileVersionStringNoThe projectFileVersion parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         id: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name 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 provides status details for long running operations along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response exportWithResponse(String name, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.exportSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), name, accept, + requestOptions, Context.NONE); + } + + /** + * Long-running resource action operation template. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
projectFileVersionStringNoThe projectFileVersion parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         id: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name 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 PollerFlux} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginExportAsync(String name, RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.exportWithResponseAsync(name, requestOptions), + new com.cadl.versioning.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Long-running resource action operation template. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
projectFileVersionStringNoThe projectFileVersion parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         id: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name 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 SyncPoller} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginExport(String name, RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.exportWithResponse(name, requestOptions), + new com.cadl.versioning.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Long-running resource action operation template. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
projectFileVersionStringNoThe projectFileVersion parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         id: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name 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 PollerFlux} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginExportWithModelAsync(String name, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), () -> this.exportWithResponseAsync(name, requestOptions), + new com.cadl.versioning.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), + TypeReference.createInstance(ExportedResource.class)); + } + + /** + * Long-running resource action operation template. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
projectFileVersionStringNoThe projectFileVersion parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     status: String(NotStarted/Running/Succeeded/Failed/Canceled) (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     *     result (Optional): {
+     *         id: String (Required)
+     *         resourceUri: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param name The name 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 SyncPoller} for polling of provides status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginExportWithModel(String name, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), () -> this.exportWithResponse(name, requestOptions), + new com.cadl.versioning.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion()), + "result"), + TypeReference.createInstance(PollOperationDetails.class), + TypeReference.createInstance(ExportedResource.class)); + } + + /** + * Resource list operation template. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
selectList<String>NoSelect the specified fields to be included in the + * response. Call {@link RequestOptions#addQueryParam} to add string to array.
expandStringNoThe expand parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (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 paged collection of Resource items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Resource list operation template. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
selectList<String>NoSelect the specified fields to be included in the + * response. Call {@link RequestOptions#addQueryParam} to add string to array.
expandStringNoThe expand parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (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 paged collection of Resource items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>(() -> listSinglePageAsync(requestOptions), + nextLink -> listNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * Resource list operation template. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
selectList<String>NoSelect the specified fields to be included in the + * response. Call {@link RequestOptions#addQueryParam} to add string to array.
expandStringNoThe expand parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (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 paged collection of Resource items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Resource list operation template. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
selectList<String>NoSelect the specified fields to be included in the + * response. Call {@link RequestOptions#addQueryParam} to add string to array.
expandStringNoThe expand parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (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 paged collection of Resource items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>(() -> listSinglePage(requestOptions), + nextLink -> listNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Long-running resource create or replace operation template. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createLongRunningWithResponseAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createLongRunning(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), name, contentType, accept, resource, requestOptions, + context)); + } + + /** + * Long-running resource create or replace operation template. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createLongRunningWithResponse(String name, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createLongRunningSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + name, contentType, accept, resource, requestOptions, Context.NONE); + } + + /** + * Long-running resource create or replace operation template. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateLongRunningAsync(String name, BinaryData resource, + RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.createLongRunningWithResponseAsync(name, resource, requestOptions), + new com.cadl.versioning.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Long-running resource create or replace operation template. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateLongRunning(String name, BinaryData resource, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.createLongRunningWithResponse(name, resource, requestOptions), + new com.cadl.versioning.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); + } + + /** + * Long-running resource create or replace operation template. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCreateLongRunningWithModelAsync(String name, + BinaryData resource, RequestOptions requestOptions) { + return PollerFlux.create(Duration.ofSeconds(1), + () -> this.createLongRunningWithResponseAsync(name, resource, requestOptions), + new com.cadl.versioning.implementation.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion())), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(Resource.class)); + } + + /** + * Long-running resource create or replace operation template. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param resource The resource instance. + * @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 SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCreateLongRunningWithModel(String name, BinaryData resource, + RequestOptions requestOptions) { + return SyncPoller.createPoller(Duration.ofSeconds(1), + () -> this.createLongRunningWithResponse(name, resource, requestOptions), + new com.cadl.versioning.implementation.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.client.getHttpPipeline()) + .setEndpoint("{endpoint}".replace("{endpoint}", this.client.getEndpoint())) + .setContext(requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.client.getServiceVersion().getVersion())), + TypeReference.createInstance(PollOperationDetails.class), TypeReference.createInstance(Resource.class)); + } + + /** + * Resource list operation template. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of Resource items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listNext(nextLink, this.client.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Resource list operation template. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: String (Required)
+     *     name: String (Required)
+     *     type: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of Resource items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listNextSync(nextLink, this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/package-info.java new file mode 100644 index 000000000..4b2eff3c1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Versioning. + * + */ +package com.cadl.versioning.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/ExportedResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/ExportedResource.java new file mode 100644 index 000000000..a99b5ec77 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/ExportedResource.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning.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; + +/** + * The ExportedResource model. + */ +@Immutable +public final class ExportedResource implements JsonSerializable { + /* + * The id property. + */ + @Generated + private final String id; + + /* + * The resourceUri property. + */ + @Generated + private final String resourceUri; + + /** + * Creates an instance of ExportedResource class. + * + * @param id the id value to set. + * @param resourceUri the resourceUri value to set. + */ + @Generated + private ExportedResource(String id, String resourceUri) { + this.id = id; + this.resourceUri = resourceUri; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the resourceUri property: The resourceUri property. + * + * @return the resourceUri value. + */ + @Generated + public String getResourceUri() { + return this.resourceUri; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("resourceUri", this.resourceUri); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExportedResource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExportedResource 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 ExportedResource. + */ + @Generated + public static ExportedResource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String resourceUri = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("resourceUri".equals(fieldName)) { + resourceUri = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ExportedResource(id, resourceUri); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/Resource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/Resource.java new file mode 100644 index 000000000..13a201bae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/Resource.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning.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; + +/** + * The Resource model. + */ +@Immutable +public final class Resource implements JsonSerializable { + /* + * The id property. + */ + @Generated + private String id; + + /* + * The name property. + */ + @Generated + private String name; + + /* + * The type property. + */ + @Generated + private final String type; + + /** + * Creates an instance of Resource class. + * + * @param type the type value to set. + */ + @Generated + public Resource(String type) { + this.type = type; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the type property: The type property. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource 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 Resource. + */ + @Generated + public static Resource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + Resource deserializedResource = new Resource(type); + deserializedResource.id = id; + deserializedResource.name = name; + + return deserializedResource; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/package-info.java new file mode 100644 index 000000000..5ad41e583 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Versioning. + * + */ +package com.cadl.versioning.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/package-info.java new file mode 100644 index 000000000..f4b888011 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/versioning/package-info.java @@ -0,0 +1,10 @@ +// 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 Versioning. + * + */ +package com.cadl.versioning; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityAsyncClient.java new file mode 100644 index 000000000..784156e5c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityAsyncClient.java @@ -0,0 +1,253 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility; + +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 com.cadl.visibility.implementation.VisibilityClientImpl; +import com.cadl.visibility.models.Dog; +import com.cadl.visibility.models.ReadDog; +import com.cadl.visibility.models.RoundTripModel; +import com.cadl.visibility.models.WriteDog; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous VisibilityClient type. + */ +@ServiceClient(builder = VisibilityClientBuilder.class, isAsync = true) +public final class VisibilityAsyncClient { + @Generated + private final VisibilityClientImpl serviceClient; + + /** + * Initializes an instance of VisibilityAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VisibilityAsyncClient(VisibilityClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The create operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param dog The dog 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createWithResponse(BinaryData dog, RequestOptions requestOptions) { + return this.serviceClient.createWithResponseAsync(dog, requestOptions); + } + + /** + * The query operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param dog The dog 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> queryWithResponse(BinaryData dog, RequestOptions requestOptions) { + return this.serviceClient.queryWithResponseAsync(dog, requestOptions); + } + + /** + * The roundtrip operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     secretName: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     secretName: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> roundtripWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.roundtripWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Dog.class)); + } + + /** + * The create operation. + * + * @param dog The dog 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono create(WriteDog dog) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createWithResponse(BinaryData.fromObject(dog), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Dog.class)); + } + + /** + * The query operation. + * + * @param dog The dog 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono query(ReadDog dog) { + // Generated convenience method for queryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return queryWithResponse(BinaryData.fromObject(dog), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Dog.class)); + } + + /** + * The roundtrip operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono roundtrip(RoundTripModel body) { + // Generated convenience method for roundtripWithResponse + RequestOptions requestOptions = new RequestOptions(); + return roundtripWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(RoundTripModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityClient.java new file mode 100644 index 000000000..201032e4b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityClient.java @@ -0,0 +1,248 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility; + +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.cadl.visibility.implementation.VisibilityClientImpl; +import com.cadl.visibility.models.Dog; +import com.cadl.visibility.models.ReadDog; +import com.cadl.visibility.models.RoundTripModel; +import com.cadl.visibility.models.WriteDog; + +/** + * Initializes a new instance of the synchronous VisibilityClient type. + */ +@ServiceClient(builder = VisibilityClientBuilder.class) +public final class VisibilityClient { + @Generated + private final VisibilityClientImpl serviceClient; + + /** + * Initializes an instance of VisibilityClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VisibilityClient(VisibilityClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The create operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param dog The dog 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createWithResponse(BinaryData dog, RequestOptions requestOptions) { + return this.serviceClient.createWithResponse(dog, requestOptions); + } + + /** + * The query operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param dog The dog 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response queryWithResponse(BinaryData dog, RequestOptions requestOptions) { + return this.serviceClient.queryWithResponse(dog, requestOptions); + } + + /** + * The roundtrip operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     secretName: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     secretName: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response roundtripWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.roundtripWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Dog get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(Dog.class); + } + + /** + * The create operation. + * + * @param dog The dog 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Dog create(WriteDog dog) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createWithResponse(BinaryData.fromObject(dog), requestOptions).getValue().toObject(Dog.class); + } + + /** + * The query operation. + * + * @param dog The dog 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Dog query(ReadDog dog) { + // Generated convenience method for queryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return queryWithResponse(BinaryData.fromObject(dog), requestOptions).getValue().toObject(Dog.class); + } + + /** + * The roundtrip operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public RoundTripModel roundtrip(RoundTripModel body) { + // Generated convenience method for roundtripWithResponse + RequestOptions requestOptions = new RequestOptions(); + return roundtripWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(RoundTripModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityClientBuilder.java new file mode 100644 index 000000000..832b8adc3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityClientBuilder.java @@ -0,0 +1,334 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.visibility.implementation.VisibilityClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the VisibilityClient type. + */ +@ServiceClientBuilder( + serviceClients = { + VisibilityClient.class, + VisibilityReadClient.class, + VisibilityWriteClient.class, + VisibilityAsyncClient.class, + VisibilityReadAsyncClient.class, + VisibilityWriteAsyncClient.class }) +public final class VisibilityClientBuilder 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("cadl-visibility.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the VisibilityClientBuilder. + */ + @Generated + public VisibilityClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VisibilityClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VisibilityClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VisibilityClientBuilder 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 VisibilityClientBuilder 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 VisibilityClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VisibilityClientBuilder 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 VisibilityClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VisibilityClientBuilder 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 VisibilityClientBuilder. + */ + @Generated + public VisibilityClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of VisibilityClientImpl with the provided parameters. + * + * @return an instance of VisibilityClientImpl. + */ + @Generated + private VisibilityClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + VisibilityClientImpl client + = new VisibilityClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 VisibilityAsyncClient class. + * + * @return an instance of VisibilityAsyncClient. + */ + @Generated + public VisibilityAsyncClient buildAsyncClient() { + return new VisibilityAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of VisibilityReadAsyncClient class. + * + * @return an instance of VisibilityReadAsyncClient. + */ + @Generated + public VisibilityReadAsyncClient buildVisibilityReadAsyncClient() { + return new VisibilityReadAsyncClient(buildInnerClient().getVisibilityReads()); + } + + /** + * Builds an instance of VisibilityWriteAsyncClient class. + * + * @return an instance of VisibilityWriteAsyncClient. + */ + @Generated + public VisibilityWriteAsyncClient buildVisibilityWriteAsyncClient() { + return new VisibilityWriteAsyncClient(buildInnerClient().getVisibilityWrites()); + } + + /** + * Builds an instance of VisibilityClient class. + * + * @return an instance of VisibilityClient. + */ + @Generated + public VisibilityClient buildClient() { + return new VisibilityClient(buildInnerClient()); + } + + /** + * Builds an instance of VisibilityReadClient class. + * + * @return an instance of VisibilityReadClient. + */ + @Generated + public VisibilityReadClient buildVisibilityReadClient() { + return new VisibilityReadClient(buildInnerClient().getVisibilityReads()); + } + + /** + * Builds an instance of VisibilityWriteClient class. + * + * @return an instance of VisibilityWriteClient. + */ + @Generated + public VisibilityWriteClient buildVisibilityWriteClient() { + return new VisibilityWriteClient(buildInnerClient().getVisibilityWrites()); + } + + private static final ClientLogger LOGGER = new ClientLogger(VisibilityClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityReadAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityReadAsyncClient.java new file mode 100644 index 000000000..dede5b5e6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityReadAsyncClient.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility; + +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 com.cadl.visibility.implementation.VisibilityReadsImpl; +import com.cadl.visibility.models.Dog; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous VisibilityClient type. + */ +@ServiceClient(builder = VisibilityClientBuilder.class, isAsync = true) +public final class VisibilityReadAsyncClient { + @Generated + private final VisibilityReadsImpl serviceClient; + + /** + * Initializes an instance of VisibilityReadAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VisibilityReadAsyncClient(VisibilityReadsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Dog.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityReadClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityReadClient.java new file mode 100644 index 000000000..03d4633cd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityReadClient.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility; + +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.cadl.visibility.implementation.VisibilityReadsImpl; +import com.cadl.visibility.models.Dog; + +/** + * Initializes a new instance of the synchronous VisibilityClient type. + */ +@ServiceClient(builder = VisibilityClientBuilder.class) +public final class VisibilityReadClient { + @Generated + private final VisibilityReadsImpl serviceClient; + + /** + * Initializes an instance of VisibilityReadClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VisibilityReadClient(VisibilityReadsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Dog get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(Dog.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityWriteAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityWriteAsyncClient.java new file mode 100644 index 000000000..88373b5f5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityWriteAsyncClient.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility; + +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 com.cadl.visibility.implementation.VisibilityWritesImpl; +import com.cadl.visibility.models.Dog; +import com.cadl.visibility.models.WriteDog; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous VisibilityClient type. + */ +@ServiceClient(builder = VisibilityClientBuilder.class, isAsync = true) +public final class VisibilityWriteAsyncClient { + @Generated + private final VisibilityWritesImpl serviceClient; + + /** + * Initializes an instance of VisibilityWriteAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VisibilityWriteAsyncClient(VisibilityWritesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The create operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param dog The dog 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createWithResponse(BinaryData dog, RequestOptions requestOptions) { + return this.serviceClient.createWithResponseAsync(dog, requestOptions); + } + + /** + * The create operation. + * + * @param dog The dog 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono create(WriteDog dog) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createWithResponse(BinaryData.fromObject(dog), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Dog.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityWriteClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityWriteClient.java new file mode 100644 index 000000000..8f9c534c2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/VisibilityWriteClient.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility; + +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.cadl.visibility.implementation.VisibilityWritesImpl; +import com.cadl.visibility.models.Dog; +import com.cadl.visibility.models.WriteDog; + +/** + * Initializes a new instance of the synchronous VisibilityClient type. + */ +@ServiceClient(builder = VisibilityClientBuilder.class) +public final class VisibilityWriteClient { + @Generated + private final VisibilityWritesImpl serviceClient; + + /** + * Initializes an instance of VisibilityWriteClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VisibilityWriteClient(VisibilityWritesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The create operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param dog The dog 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createWithResponse(BinaryData dog, RequestOptions requestOptions) { + return this.serviceClient.createWithResponse(dog, requestOptions); + } + + /** + * The create operation. + * + * @param dog The dog 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Dog create(WriteDog dog) { + // Generated convenience method for createWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createWithResponse(BinaryData.fromObject(dog), requestOptions).getValue().toObject(Dog.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/implementation/VisibilityClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/implementation/VisibilityClientImpl.java new file mode 100644 index 000000000..e7e945194 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/implementation/VisibilityClientImpl.java @@ -0,0 +1,502 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.Put; +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 VisibilityClient type. + */ +public final class VisibilityClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final VisibilityClientService 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; + } + + /** + * The VisibilityReadsImpl object to access its operations. + */ + private final VisibilityReadsImpl visibilityReads; + + /** + * Gets the VisibilityReadsImpl object to access its operations. + * + * @return the VisibilityReadsImpl object. + */ + public VisibilityReadsImpl getVisibilityReads() { + return this.visibilityReads; + } + + /** + * The VisibilityWritesImpl object to access its operations. + */ + private final VisibilityWritesImpl visibilityWrites; + + /** + * Gets the VisibilityWritesImpl object to access its operations. + * + * @return the VisibilityWritesImpl object. + */ + public VisibilityWritesImpl getVisibilityWrites() { + return this.visibilityWrites; + } + + /** + * Initializes an instance of VisibilityClient client. + * + * @param endpoint Service host. + */ + public VisibilityClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of VisibilityClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public VisibilityClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of VisibilityClient 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 VisibilityClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.visibilityReads = new VisibilityReadsImpl(this); + this.visibilityWrites = new VisibilityWritesImpl(this); + this.service = RestProxy.create(VisibilityClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for VisibilityClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "VisibilityClient") + public interface VisibilityClientService { + @Get("/visibility/read") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/visibility/read") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/visibility/write") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> create(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData dog, RequestOptions requestOptions, Context context); + + @Put("/visibility/write") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData dog, RequestOptions requestOptions, Context context); + + @Post("/visibility/query") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> query(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData dog, RequestOptions requestOptions, Context context); + + @Post("/visibility/query") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response querySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData dog, RequestOptions requestOptions, Context context); + + @Put("/visibility/roundtrip") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> roundtrip(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/visibility/roundtrip") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response roundtripSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The create operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param dog The dog 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createWithResponseAsync(BinaryData dog, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.create(this.getEndpoint(), contentType, accept, dog, requestOptions, context)); + } + + /** + * The create operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param dog The dog 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createWithResponse(BinaryData dog, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createSync(this.getEndpoint(), contentType, accept, dog, requestOptions, Context.NONE); + } + + /** + * The query operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param dog The dog 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> queryWithResponseAsync(BinaryData dog, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.query(this.getEndpoint(), contentType, accept, dog, requestOptions, context)); + } + + /** + * The query operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param dog The dog 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response queryWithResponse(BinaryData dog, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.querySync(this.getEndpoint(), contentType, accept, dog, requestOptions, Context.NONE); + } + + /** + * The roundtrip operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     secretName: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     secretName: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> roundtripWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.roundtrip(this.getEndpoint(), contentType, accept, body, requestOptions, context)); + } + + /** + * The roundtrip operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     secretName: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     secretName: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response roundtripWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.roundtripSync(this.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/implementation/VisibilityReadsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/implementation/VisibilityReadsImpl.java new file mode 100644 index 000000000..0cc46f0a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/implementation/VisibilityReadsImpl.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.BinaryData; +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 VisibilityReads. + */ +public final class VisibilityReadsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final VisibilityReadsService service; + + /** + * The service client containing this operation class. + */ + private final VisibilityClientImpl client; + + /** + * Initializes an instance of VisibilityReadsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + VisibilityReadsImpl(VisibilityClientImpl client) { + this.service + = RestProxy.create(VisibilityReadsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for VisibilityClientVisibilityReads to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "VisibilityClientVisi") + public interface VisibilityReadsService { + @Get("/read") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/read") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/implementation/VisibilityWritesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/implementation/VisibilityWritesImpl.java new file mode 100644 index 000000000..19648f316 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/implementation/VisibilityWritesImpl.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility.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.Put; +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.BinaryData; +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 VisibilityWrites. + */ +public final class VisibilityWritesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final VisibilityWritesService service; + + /** + * The service client containing this operation class. + */ + private final VisibilityClientImpl client; + + /** + * Initializes an instance of VisibilityWritesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + VisibilityWritesImpl(VisibilityClientImpl client) { + this.service + = RestProxy.create(VisibilityWritesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for VisibilityClientVisibilityWrites to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "VisibilityClientVisi") + public interface VisibilityWritesService { + @Put("/write") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> create(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData dog, RequestOptions requestOptions, Context context); + + @Put("/write") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData dog, RequestOptions requestOptions, Context context); + } + + /** + * The create operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param dog The dog 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createWithResponseAsync(BinaryData dog, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.create(this.client.getEndpoint(), contentType, accept, dog, requestOptions, context)); + } + + /** + * The create operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: int (Required)
+     *     secretName: String (Required)
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param dog The dog 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createWithResponse(BinaryData dog, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createSync(this.client.getEndpoint(), contentType, accept, dog, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/implementation/package-info.java new file mode 100644 index 000000000..372a0dec6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Visibility. + * + */ +package com.cadl.visibility.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/Dog.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/Dog.java new file mode 100644 index 000000000..4cee0b6e1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/Dog.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility.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; + +/** + * The Dog model. + */ +@Immutable +public final class Dog implements JsonSerializable { + /* + * The id property. + */ + @Generated + private int id; + + /* + * The secretName property. + */ + @Generated + private final String secretName; + + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Dog class. + * + * @param secretName the secretName value to set. + * @param name the name value to set. + */ + @Generated + private Dog(String secretName, String name) { + this.secretName = secretName; + this.name = name; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public int getId() { + return this.id; + } + + /** + * Get the secretName property: The secretName property. + * + * @return the secretName value. + */ + @Generated + public String getSecretName() { + return this.secretName; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("secretName", this.secretName); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Dog from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Dog 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 Dog. + */ + @Generated + public static Dog fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int id = 0; + String secretName = null; + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getInt(); + } else if ("secretName".equals(fieldName)) { + secretName = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + Dog deserializedDog = new Dog(secretName, name); + deserializedDog.id = id; + + return deserializedDog; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/ReadDog.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/ReadDog.java new file mode 100644 index 000000000..caf20c385 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/ReadDog.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility.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; + +/** + * The ReadDog model. + */ +@Immutable +public final class ReadDog implements JsonSerializable { + /* + * The id property. + */ + @Generated + private final int id; + + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ReadDog class. + * + * @param id the id value to set. + * @param name the name value to set. + */ + @Generated + public ReadDog(int id, String name) { + this.id = id; + this.name = name; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public int getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("id", this.id); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ReadDog from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ReadDog 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 ReadDog. + */ + @Generated + public static ReadDog fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int id = 0; + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getInt(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ReadDog(id, name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/RoundTripModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/RoundTripModel.java new file mode 100644 index 000000000..15b2835b0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/RoundTripModel.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility.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; + +/** + * The RoundTripModel model. + */ +@Immutable +public final class RoundTripModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The secretName property. + */ + @Generated + private final String secretName; + + /** + * Creates an instance of RoundTripModel class. + * + * @param name the name value to set. + * @param secretName the secretName value to set. + */ + @Generated + public RoundTripModel(String name, String secretName) { + this.name = name; + this.secretName = secretName; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the secretName property: The secretName property. + * + * @return the secretName value. + */ + @Generated + public String getSecretName() { + return this.secretName; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("secretName", this.secretName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RoundTripModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RoundTripModel 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 RoundTripModel. + */ + @Generated + public static RoundTripModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String secretName = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("secretName".equals(fieldName)) { + secretName = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new RoundTripModel(name, secretName); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/WriteDog.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/WriteDog.java new file mode 100644 index 000000000..7e5e80652 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/WriteDog.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility.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; + +/** + * The WriteDog model. + */ +@Immutable +public final class WriteDog implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of WriteDog class. + * + * @param name the name value to set. + */ + @Generated + public WriteDog(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of WriteDog from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WriteDog 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 WriteDog. + */ + @Generated + public static WriteDog fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new WriteDog(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/package-info.java new file mode 100644 index 000000000..7ed97612a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Visibility. + * + */ +package com.cadl.visibility.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/package-info.java new file mode 100644 index 000000000..e81e5eac3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/visibility/package-info.java @@ -0,0 +1,10 @@ +// 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 Visibility. + * + */ +package com.cadl.visibility; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/WireTypeAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/WireTypeAsyncClient.java new file mode 100644 index 000000000..b85ecb9d6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/WireTypeAsyncClient.java @@ -0,0 +1,207 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.wiretype; + +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 com.cadl.wiretype.implementation.WireTypeOpsImpl; +import com.cadl.wiretype.models.SubClass; +import com.cadl.wiretype.models.SubClassBothMismatch; +import com.cadl.wiretype.models.SubClassMismatch; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous WireTypeClient type. + */ +@ServiceClient(builder = WireTypeClientBuilder.class, isAsync = true) +public final class WireTypeAsyncClient { + @Generated + private final WireTypeOpsImpl serviceClient; + + /** + * Initializes an instance of WireTypeAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + WireTypeAsyncClient(WireTypeOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The superClassMismatch operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     dateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     dateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> superClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.superClassMismatchWithResponseAsync(body, requestOptions); + } + + /** + * The subClassMismatch operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     dateTime: OffsetDateTime (Required)
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     dateTime: OffsetDateTime (Required)
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> subClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.subClassMismatchWithResponseAsync(body, requestOptions); + } + + /** + * The bothClassMismatch operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     base64url: Base64Url (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     base64url: Base64Url (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> bothClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.bothClassMismatchWithResponseAsync(body, requestOptions); + } + + /** + * The superClassMismatch operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono superClassMismatch(SubClass body) { + // Generated convenience method for superClassMismatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return superClassMismatchWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SubClass.class)); + } + + /** + * The subClassMismatch operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono subClassMismatch(SubClassMismatch body) { + // Generated convenience method for subClassMismatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return subClassMismatchWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SubClassMismatch.class)); + } + + /** + * The bothClassMismatch operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono bothClassMismatch(SubClassBothMismatch body) { + // Generated convenience method for bothClassMismatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return bothClassMismatchWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SubClassBothMismatch.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/WireTypeClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/WireTypeClient.java new file mode 100644 index 000000000..fc83bfc09 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/WireTypeClient.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 com.cadl.wiretype; + +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.cadl.wiretype.implementation.WireTypeOpsImpl; +import com.cadl.wiretype.models.SubClass; +import com.cadl.wiretype.models.SubClassBothMismatch; +import com.cadl.wiretype.models.SubClassMismatch; + +/** + * Initializes a new instance of the synchronous WireTypeClient type. + */ +@ServiceClient(builder = WireTypeClientBuilder.class) +public final class WireTypeClient { + @Generated + private final WireTypeOpsImpl serviceClient; + + /** + * Initializes an instance of WireTypeClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + WireTypeClient(WireTypeOpsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The superClassMismatch operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     dateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     dateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response superClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.superClassMismatchWithResponse(body, requestOptions); + } + + /** + * The subClassMismatch operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     dateTime: OffsetDateTime (Required)
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     dateTime: OffsetDateTime (Required)
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response subClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.subClassMismatchWithResponse(body, requestOptions); + } + + /** + * The bothClassMismatch operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     base64url: Base64Url (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     base64url: Base64Url (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response bothClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.bothClassMismatchWithResponse(body, requestOptions); + } + + /** + * The superClassMismatch operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SubClass superClassMismatch(SubClass body) { + // Generated convenience method for superClassMismatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return superClassMismatchWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(SubClass.class); + } + + /** + * The subClassMismatch operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SubClassMismatch subClassMismatch(SubClassMismatch body) { + // Generated convenience method for subClassMismatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return subClassMismatchWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(SubClassMismatch.class); + } + + /** + * The bothClassMismatch operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SubClassBothMismatch bothClassMismatch(SubClassBothMismatch body) { + // Generated convenience method for bothClassMismatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return bothClassMismatchWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(SubClassBothMismatch.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/WireTypeClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/WireTypeClientBuilder.java new file mode 100644 index 000000000..7469c3979 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/WireTypeClientBuilder.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 com.cadl.wiretype; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.cadl.wiretype.implementation.WireTypeClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the WireTypeClient type. + */ +@ServiceClientBuilder(serviceClients = { WireTypeClient.class, WireTypeAsyncClient.class }) +public final class WireTypeClientBuilder 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("cadl-wiretype.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the WireTypeClientBuilder. + */ + @Generated + public WireTypeClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public WireTypeClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public WireTypeClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public WireTypeClientBuilder 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 WireTypeClientBuilder 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 WireTypeClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public WireTypeClientBuilder 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 WireTypeClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public WireTypeClientBuilder 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 WireTypeClientBuilder. + */ + @Generated + public WireTypeClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of WireTypeClientImpl with the provided parameters. + * + * @return an instance of WireTypeClientImpl. + */ + @Generated + private WireTypeClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + WireTypeClientImpl client + = new WireTypeClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 WireTypeAsyncClient class. + * + * @return an instance of WireTypeAsyncClient. + */ + @Generated + public WireTypeAsyncClient buildAsyncClient() { + return new WireTypeAsyncClient(buildInnerClient().getWireTypeOps()); + } + + /** + * Builds an instance of WireTypeClient class. + * + * @return an instance of WireTypeClient. + */ + @Generated + public WireTypeClient buildClient() { + return new WireTypeClient(buildInnerClient().getWireTypeOps()); + } + + private static final ClientLogger LOGGER = new ClientLogger(WireTypeClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/implementation/WireTypeClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/implementation/WireTypeClientImpl.java new file mode 100644 index 000000000..8a6e2a8d3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/implementation/WireTypeClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.wiretype.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the WireTypeClient type. + */ +public final class WireTypeClientImpl { + /** + * 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; + } + + /** + * The WireTypeOpsImpl object to access its operations. + */ + private final WireTypeOpsImpl wireTypeOps; + + /** + * Gets the WireTypeOpsImpl object to access its operations. + * + * @return the WireTypeOpsImpl object. + */ + public WireTypeOpsImpl getWireTypeOps() { + return this.wireTypeOps; + } + + /** + * Initializes an instance of WireTypeClient client. + * + * @param endpoint Service host. + */ + public WireTypeClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of WireTypeClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public WireTypeClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of WireTypeClient 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 WireTypeClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.wireTypeOps = new WireTypeOpsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/implementation/WireTypeOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/implementation/WireTypeOpsImpl.java new file mode 100644 index 000000000..2670cb132 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/implementation/WireTypeOpsImpl.java @@ -0,0 +1,340 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.wiretype.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.Put; +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.BinaryData; +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 WireTypeOps. + */ +public final class WireTypeOpsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final WireTypeOpsService service; + + /** + * The service client containing this operation class. + */ + private final WireTypeClientImpl client; + + /** + * Initializes an instance of WireTypeOpsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + WireTypeOpsImpl(WireTypeClientImpl client) { + this.service + = RestProxy.create(WireTypeOpsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for WireTypeClientWireTypeOps to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "WireTypeClientWireTy") + public interface WireTypeOpsService { + @Put("/wireType/superClassMismatch") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> superClassMismatch(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/wireType/superClassMismatch") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response superClassMismatchSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/wireType/subClassMismatch") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> subClassMismatch(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/wireType/subClassMismatch") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response subClassMismatchSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/wireType/bothClassMismatch") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> bothClassMismatch(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/wireType/bothClassMismatch") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response bothClassMismatchSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The superClassMismatch operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     dateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     dateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> superClassMismatchWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.superClassMismatch(this.client.getEndpoint(), contentType, + accept, body, requestOptions, context)); + } + + /** + * The superClassMismatch operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     dateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     dateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response superClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.superClassMismatchSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The subClassMismatch operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     dateTime: OffsetDateTime (Required)
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     dateTime: OffsetDateTime (Required)
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> subClassMismatchWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.subClassMismatch(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The subClassMismatch operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     dateTime: OffsetDateTime (Required)
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     dateTime: OffsetDateTime (Required)
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response subClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.subClassMismatchSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The bothClassMismatch operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     base64url: Base64Url (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     base64url: Base64Url (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> bothClassMismatchWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.bothClassMismatch(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The bothClassMismatch operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     base64url: Base64Url (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     dateTimeRfc7231: DateTimeRfc1123 (Required)
+     *     base64url: Base64Url (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response bothClassMismatchWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.bothClassMismatchSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/implementation/package-info.java new file mode 100644 index 000000000..8773eb016 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/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 WireType. + * Test for mismatch of wire type and client type on class constructors. + * + */ +package com.cadl.wiretype.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SubClass.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SubClass.java new file mode 100644 index 000000000..cd782a02c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SubClass.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.wiretype.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Objects; + +/** + * The SubClass model. + */ +@Immutable +public final class SubClass extends SuperClassMismatch { + /* + * The dateTime property. + */ + @Generated + private final OffsetDateTime dateTime; + + /** + * Creates an instance of SubClass class. + * + * @param dateTimeRfc7231 the dateTimeRfc7231 value to set. + * @param dateTime the dateTime value to set. + */ + @Generated + public SubClass(OffsetDateTime dateTimeRfc7231, OffsetDateTime dateTime) { + super(dateTimeRfc7231); + this.dateTime = dateTime; + } + + /** + * Get the dateTime property: The dateTime property. + * + * @return the dateTime value. + */ + @Generated + public OffsetDateTime getDateTime() { + return this.dateTime; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (getDateTimeRfc7231() != null) { + jsonWriter.writeStringField("dateTimeRfc7231", + Objects.toString(new DateTimeRfc1123(getDateTimeRfc7231()), null)); + } + jsonWriter.writeStringField("dateTime", + this.dateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.dateTime)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SubClass from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SubClass 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 SubClass. + */ + @Generated + public static SubClass fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime dateTimeRfc7231 = null; + OffsetDateTime dateTime = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dateTimeRfc7231".equals(fieldName)) { + DateTimeRfc1123 dateTimeRfc7231Holder + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + if (dateTimeRfc7231Holder != null) { + dateTimeRfc7231 = dateTimeRfc7231Holder.getDateTime(); + } + } else if ("dateTime".equals(fieldName)) { + dateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new SubClass(dateTimeRfc7231, dateTime); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SubClassBothMismatch.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SubClassBothMismatch.java new file mode 100644 index 000000000..6979c40eb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SubClassBothMismatch.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 com.cadl.wiretype.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.Base64Url; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** + * The SubClassBothMismatch model. + */ +@Immutable +public final class SubClassBothMismatch extends SuperClassMismatch { + /* + * The base64url property. + */ + @Generated + private final Base64Url base64url; + + /** + * Creates an instance of SubClassBothMismatch class. + * + * @param dateTimeRfc7231 the dateTimeRfc7231 value to set. + * @param base64url the base64url value to set. + */ + @Generated + public SubClassBothMismatch(OffsetDateTime dateTimeRfc7231, byte[] base64url) { + super(dateTimeRfc7231); + if (base64url == null) { + this.base64url = null; + } else { + this.base64url = Base64Url.encode(base64url); + } + } + + /** + * Get the base64url property: The base64url property. + * + * @return the base64url value. + */ + @Generated + public byte[] getBase64url() { + if (this.base64url == null) { + return null; + } + return this.base64url.decodedBytes(); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (getDateTimeRfc7231() != null) { + jsonWriter.writeStringField("dateTimeRfc7231", + Objects.toString(new DateTimeRfc1123(getDateTimeRfc7231()), null)); + } + jsonWriter.writeStringField("base64url", Objects.toString(this.base64url, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SubClassBothMismatch from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SubClassBothMismatch 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 SubClassBothMismatch. + */ + @Generated + public static SubClassBothMismatch fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime dateTimeRfc7231 = null; + byte[] base64url = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dateTimeRfc7231".equals(fieldName)) { + DateTimeRfc1123 dateTimeRfc7231Holder + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + if (dateTimeRfc7231Holder != null) { + dateTimeRfc7231 = dateTimeRfc7231Holder.getDateTime(); + } + } else if ("base64url".equals(fieldName)) { + Base64Url base64urlHolder + = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + if (base64urlHolder != null) { + base64url = base64urlHolder.decodedBytes(); + } + } else { + reader.skipChildren(); + } + } + return new SubClassBothMismatch(dateTimeRfc7231, base64url); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SubClassMismatch.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SubClassMismatch.java new file mode 100644 index 000000000..baf579e61 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SubClassMismatch.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 com.cadl.wiretype.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Objects; + +/** + * The SubClassMismatch model. + */ +@Immutable +public final class SubClassMismatch extends SuperClass { + /* + * The dateTimeRfc7231 property. + */ + @Generated + private final DateTimeRfc1123 dateTimeRfc7231; + + /** + * Creates an instance of SubClassMismatch class. + * + * @param dateTime the dateTime value to set. + * @param dateTimeRfc7231 the dateTimeRfc7231 value to set. + */ + @Generated + public SubClassMismatch(OffsetDateTime dateTime, OffsetDateTime dateTimeRfc7231) { + super(dateTime); + if (dateTimeRfc7231 == null) { + this.dateTimeRfc7231 = null; + } else { + this.dateTimeRfc7231 = new DateTimeRfc1123(dateTimeRfc7231); + } + } + + /** + * Get the dateTimeRfc7231 property: The dateTimeRfc7231 property. + * + * @return the dateTimeRfc7231 value. + */ + @Generated + public OffsetDateTime getDateTimeRfc7231() { + if (this.dateTimeRfc7231 == null) { + return null; + } + return this.dateTimeRfc7231.getDateTime(); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("dateTime", + getDateTime() == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(getDateTime())); + jsonWriter.writeStringField("dateTimeRfc7231", Objects.toString(this.dateTimeRfc7231, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SubClassMismatch from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SubClassMismatch 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 SubClassMismatch. + */ + @Generated + public static SubClassMismatch fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime dateTime = null; + OffsetDateTime dateTimeRfc7231 = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dateTime".equals(fieldName)) { + dateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("dateTimeRfc7231".equals(fieldName)) { + DateTimeRfc1123 dateTimeRfc7231Holder + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + if (dateTimeRfc7231Holder != null) { + dateTimeRfc7231 = dateTimeRfc7231Holder.getDateTime(); + } + } else { + reader.skipChildren(); + } + } + return new SubClassMismatch(dateTime, dateTimeRfc7231); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SuperClass.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SuperClass.java new file mode 100644 index 000000000..4929171ce --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SuperClass.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 com.cadl.wiretype.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * The SuperClass model. + */ +@Immutable +public class SuperClass implements JsonSerializable { + /* + * The dateTime property. + */ + @Generated + private final OffsetDateTime dateTime; + + /** + * Creates an instance of SuperClass class. + * + * @param dateTime the dateTime value to set. + */ + @Generated + public SuperClass(OffsetDateTime dateTime) { + this.dateTime = dateTime; + } + + /** + * Get the dateTime property: The dateTime property. + * + * @return the dateTime value. + */ + @Generated + public OffsetDateTime getDateTime() { + return this.dateTime; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("dateTime", + this.dateTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.dateTime)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SuperClass from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SuperClass 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 SuperClass. + */ + @Generated + public static SuperClass fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime dateTime = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dateTime".equals(fieldName)) { + dateTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new SuperClass(dateTime); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SuperClassMismatch.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SuperClassMismatch.java new file mode 100644 index 000000000..31e904b08 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/SuperClassMismatch.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.wiretype.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.DateTimeRfc1123; +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.time.OffsetDateTime; +import java.util.Objects; + +/** + * The SuperClassMismatch model. + */ +@Immutable +public class SuperClassMismatch implements JsonSerializable { + /* + * The dateTimeRfc7231 property. + */ + @Generated + private final DateTimeRfc1123 dateTimeRfc7231; + + /** + * Creates an instance of SuperClassMismatch class. + * + * @param dateTimeRfc7231 the dateTimeRfc7231 value to set. + */ + @Generated + public SuperClassMismatch(OffsetDateTime dateTimeRfc7231) { + if (dateTimeRfc7231 == null) { + this.dateTimeRfc7231 = null; + } else { + this.dateTimeRfc7231 = new DateTimeRfc1123(dateTimeRfc7231); + } + } + + /** + * Get the dateTimeRfc7231 property: The dateTimeRfc7231 property. + * + * @return the dateTimeRfc7231 value. + */ + @Generated + public OffsetDateTime getDateTimeRfc7231() { + if (this.dateTimeRfc7231 == null) { + return null; + } + return this.dateTimeRfc7231.getDateTime(); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("dateTimeRfc7231", Objects.toString(this.dateTimeRfc7231, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SuperClassMismatch from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SuperClassMismatch 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 SuperClassMismatch. + */ + @Generated + public static SuperClassMismatch fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime dateTimeRfc7231 = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dateTimeRfc7231".equals(fieldName)) { + DateTimeRfc1123 dateTimeRfc7231Holder + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + if (dateTimeRfc7231Holder != null) { + dateTimeRfc7231 = dateTimeRfc7231Holder.getDateTime(); + } + } else { + reader.skipChildren(); + } + } + return new SuperClassMismatch(dateTimeRfc7231); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/models/package-info.java new file mode 100644 index 000000000..6ec7b343e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/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 WireType. + * Test for mismatch of wire type and client type on class constructors. + * + */ +package com.cadl.wiretype.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/package-info.java new file mode 100644 index 000000000..f5ffd8c89 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/wiretype/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 WireType. + * Test for mismatch of wire type and client type on class constructors. + * + */ +package com.cadl.wiretype; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/ClientModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/ClientModelAsyncClient.java new file mode 100644 index 000000000..ad6a0fe3d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/ClientModelAsyncClient.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming; + +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 com.client.naming.implementation.ClientModelsImpl; +import com.client.naming.models.ClientModel; +import com.client.naming.models.JavaModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NamingClient type. + */ +@ServiceClient(builder = NamingClientBuilder.class, isAsync = true) +public final class ClientModelAsyncClient { + @Generated + private final ClientModelsImpl serviceClient; + + /** + * Initializes an instance of ClientModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ClientModelAsyncClient(ClientModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The client operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> clientWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.clientWithResponseAsync(body, requestOptions); + } + + /** + * The language operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> languageWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.languageWithResponseAsync(body, requestOptions); + } + + /** + * The client operation. + * + * @param body The body 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 client(ClientModel body) { + // Generated convenience method for clientWithResponse + RequestOptions requestOptions = new RequestOptions(); + return clientWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The language operation. + * + * @param body The body 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 language(JavaModel body) { + // Generated convenience method for languageWithResponse + RequestOptions requestOptions = new RequestOptions(); + return languageWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/ClientModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/ClientModelClient.java new file mode 100644 index 000000000..4417a4d8f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/ClientModelClient.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming; + +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.client.naming.implementation.ClientModelsImpl; +import com.client.naming.models.ClientModel; +import com.client.naming.models.JavaModel; + +/** + * Initializes a new instance of the synchronous NamingClient type. + */ +@ServiceClient(builder = NamingClientBuilder.class) +public final class ClientModelClient { + @Generated + private final ClientModelsImpl serviceClient; + + /** + * Initializes an instance of ClientModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ClientModelClient(ClientModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The client operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 clientWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.clientWithResponse(body, requestOptions); + } + + /** + * The language operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 languageWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.languageWithResponse(body, requestOptions); + } + + /** + * The client operation. + * + * @param body The body 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 client(ClientModel body) { + // Generated convenience method for clientWithResponse + RequestOptions requestOptions = new RequestOptions(); + clientWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The language operation. + * + * @param body The body 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 language(JavaModel body) { + // Generated convenience method for languageWithResponse + RequestOptions requestOptions = new RequestOptions(); + languageWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/NamingAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/NamingAsyncClient.java new file mode 100644 index 000000000..431994ec2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/NamingAsyncClient.java @@ -0,0 +1,317 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming; + +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 com.client.naming.implementation.NamingClientImpl; +import com.client.naming.models.ClientNameAndJsonEncodedNameModel; +import com.client.naming.models.ClientNameModel; +import com.client.naming.models.LanguageClientNameModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NamingClient type. + */ +@ServiceClient(builder = NamingClientBuilder.class, isAsync = true) +public final class NamingAsyncClient { + @Generated + private final NamingClientImpl serviceClient; + + /** + * Initializes an instance of NamingAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NamingAsyncClient(NamingClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The clientName operation. + * + * @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> clientNameWithResponse(RequestOptions requestOptions) { + return this.serviceClient.clientNameWithResponseAsync(requestOptions); + } + + /** + * The parameter operation. + * + * @param clientName The clientName 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> parameterWithResponse(String clientName, RequestOptions requestOptions) { + return this.serviceClient.parameterWithResponseAsync(clientName, requestOptions); + } + + /** + * The client operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> clientWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.clientWithResponseAsync(body, requestOptions); + } + + /** + * The language operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> languageWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.languageWithResponseAsync(body, requestOptions); + } + + /** + * The compatibleWithEncodedName operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     wireName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> compatibleWithEncodedNameWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.compatibleWithEncodedNameWithResponseAsync(body, requestOptions); + } + + /** + * The request operation. + * + * @param clientName The clientName 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> requestWithResponse(String clientName, RequestOptions requestOptions) { + return this.serviceClient.requestWithResponseAsync(clientName, requestOptions); + } + + /** + * The response operation. + * + * @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> responseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.responseWithResponseAsync(requestOptions); + } + + /** + * The clientName 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono clientName() { + // Generated convenience method for clientNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + return clientNameWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The parameter operation. + * + * @param clientName The clientName 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 parameter(String clientName) { + // Generated convenience method for parameterWithResponse + RequestOptions requestOptions = new RequestOptions(); + return parameterWithResponse(clientName, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The client operation. + * + * @param body The body 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 client(ClientNameModel body) { + // Generated convenience method for clientWithResponse + RequestOptions requestOptions = new RequestOptions(); + return clientWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The language operation. + * + * @param body The body 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 language(LanguageClientNameModel body) { + // Generated convenience method for languageWithResponse + RequestOptions requestOptions = new RequestOptions(); + return languageWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The compatibleWithEncodedName operation. + * + * @param body The body 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 compatibleWithEncodedName(ClientNameAndJsonEncodedNameModel body) { + // Generated convenience method for compatibleWithEncodedNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + return compatibleWithEncodedNameWithResponse(BinaryData.fromObject(body), requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The request operation. + * + * @param clientName The clientName 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 request(String clientName) { + // Generated convenience method for requestWithResponse + RequestOptions requestOptions = new RequestOptions(); + return requestWithResponse(clientName, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The response 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono response() { + // Generated convenience method for responseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return responseWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/NamingClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/NamingClient.java new file mode 100644 index 000000000..0bde96552 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/NamingClient.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming; + +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.client.naming.implementation.NamingClientImpl; +import com.client.naming.models.ClientNameAndJsonEncodedNameModel; +import com.client.naming.models.ClientNameModel; +import com.client.naming.models.LanguageClientNameModel; + +/** + * Initializes a new instance of the synchronous NamingClient type. + */ +@ServiceClient(builder = NamingClientBuilder.class) +public final class NamingClient { + @Generated + private final NamingClientImpl serviceClient; + + /** + * Initializes an instance of NamingClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NamingClient(NamingClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The clientName operation. + * + * @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 clientNameWithResponse(RequestOptions requestOptions) { + return this.serviceClient.clientNameWithResponse(requestOptions); + } + + /** + * The parameter operation. + * + * @param clientName The clientName 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 parameterWithResponse(String clientName, RequestOptions requestOptions) { + return this.serviceClient.parameterWithResponse(clientName, requestOptions); + } + + /** + * The client operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 clientWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.clientWithResponse(body, requestOptions); + } + + /** + * The language operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 languageWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.languageWithResponse(body, requestOptions); + } + + /** + * The compatibleWithEncodedName operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     wireName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 compatibleWithEncodedNameWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.compatibleWithEncodedNameWithResponse(body, requestOptions); + } + + /** + * The request operation. + * + * @param clientName The clientName 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 requestWithResponse(String clientName, RequestOptions requestOptions) { + return this.serviceClient.requestWithResponse(clientName, requestOptions); + } + + /** + * The response operation. + * + * @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 responseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.responseWithResponse(requestOptions); + } + + /** + * The clientName 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void clientName() { + // Generated convenience method for clientNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + clientNameWithResponse(requestOptions).getValue(); + } + + /** + * The parameter operation. + * + * @param clientName The clientName 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 parameter(String clientName) { + // Generated convenience method for parameterWithResponse + RequestOptions requestOptions = new RequestOptions(); + parameterWithResponse(clientName, requestOptions).getValue(); + } + + /** + * The client operation. + * + * @param body The body 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 client(ClientNameModel body) { + // Generated convenience method for clientWithResponse + RequestOptions requestOptions = new RequestOptions(); + clientWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The language operation. + * + * @param body The body 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 language(LanguageClientNameModel body) { + // Generated convenience method for languageWithResponse + RequestOptions requestOptions = new RequestOptions(); + languageWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The compatibleWithEncodedName operation. + * + * @param body The body 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 compatibleWithEncodedName(ClientNameAndJsonEncodedNameModel body) { + // Generated convenience method for compatibleWithEncodedNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + compatibleWithEncodedNameWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The request operation. + * + * @param clientName The clientName 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 request(String clientName) { + // Generated convenience method for requestWithResponse + RequestOptions requestOptions = new RequestOptions(); + requestWithResponse(clientName, requestOptions).getValue(); + } + + /** + * The response 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void response() { + // Generated convenience method for responseWithResponse + RequestOptions requestOptions = new RequestOptions(); + responseWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/NamingClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/NamingClientBuilder.java new file mode 100644 index 000000000..87c6004ab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/NamingClientBuilder.java @@ -0,0 +1,334 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.client.naming.implementation.NamingClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the NamingClient type. + */ +@ServiceClientBuilder( + serviceClients = { + NamingClient.class, + ClientModelClient.class, + UnionEnumClient.class, + NamingAsyncClient.class, + ClientModelAsyncClient.class, + UnionEnumAsyncClient.class }) +public final class NamingClientBuilder 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("client-naming.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the NamingClientBuilder. + */ + @Generated + public NamingClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NamingClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NamingClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NamingClientBuilder 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 NamingClientBuilder 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 NamingClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NamingClientBuilder 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 NamingClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NamingClientBuilder 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 NamingClientBuilder. + */ + @Generated + public NamingClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of NamingClientImpl with the provided parameters. + * + * @return an instance of NamingClientImpl. + */ + @Generated + private NamingClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + NamingClientImpl client + = new NamingClientImpl(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 NamingAsyncClient class. + * + * @return an instance of NamingAsyncClient. + */ + @Generated + public NamingAsyncClient buildAsyncClient() { + return new NamingAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ClientModelAsyncClient class. + * + * @return an instance of ClientModelAsyncClient. + */ + @Generated + public ClientModelAsyncClient buildClientModelAsyncClient() { + return new ClientModelAsyncClient(buildInnerClient().getClientModels()); + } + + /** + * Builds an instance of UnionEnumAsyncClient class. + * + * @return an instance of UnionEnumAsyncClient. + */ + @Generated + public UnionEnumAsyncClient buildUnionEnumAsyncClient() { + return new UnionEnumAsyncClient(buildInnerClient().getUnionEnums()); + } + + /** + * Builds an instance of NamingClient class. + * + * @return an instance of NamingClient. + */ + @Generated + public NamingClient buildClient() { + return new NamingClient(buildInnerClient()); + } + + /** + * Builds an instance of ClientModelClient class. + * + * @return an instance of ClientModelClient. + */ + @Generated + public ClientModelClient buildClientModelClient() { + return new ClientModelClient(buildInnerClient().getClientModels()); + } + + /** + * Builds an instance of UnionEnumClient class. + * + * @return an instance of UnionEnumClient. + */ + @Generated + public UnionEnumClient buildUnionEnumClient() { + return new UnionEnumClient(buildInnerClient().getUnionEnums()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NamingClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/UnionEnumAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/UnionEnumAsyncClient.java new file mode 100644 index 000000000..e13d74913 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/UnionEnumAsyncClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming; + +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 com.client.naming.implementation.UnionEnumsImpl; +import com.client.naming.models.ClientExtensibleEnum; +import com.client.naming.models.ExtensibleEnum; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NamingClient type. + */ +@ServiceClient(builder = NamingClientBuilder.class, isAsync = true) +public final class UnionEnumAsyncClient { + @Generated + private final UnionEnumsImpl serviceClient; + + /** + * Initializes an instance of UnionEnumAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionEnumAsyncClient(UnionEnumsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The unionEnumName operation. + *

Request Body Schema

+ * + *
{@code
+     * String(value1)
+     * }
+ * + * @param body The body 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> unionEnumNameWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.unionEnumNameWithResponseAsync(body, requestOptions); + } + + /** + * The unionEnumMemberName operation. + *

Request Body Schema

+ * + *
{@code
+     * String(value1 / value2)
+     * }
+ * + * @param body The body 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> unionEnumMemberNameWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.unionEnumMemberNameWithResponseAsync(body, requestOptions); + } + + /** + * The unionEnumName operation. + * + * @param body The body 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 unionEnumName(ClientExtensibleEnum body) { + // Generated convenience method for unionEnumNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + return unionEnumNameWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The unionEnumMemberName operation. + * + * @param body The body 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 unionEnumMemberName(ExtensibleEnum body) { + // Generated convenience method for unionEnumMemberNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + return unionEnumMemberNameWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), + requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/UnionEnumClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/UnionEnumClient.java new file mode 100644 index 000000000..fb22deed5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/UnionEnumClient.java @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming; + +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.client.naming.implementation.UnionEnumsImpl; +import com.client.naming.models.ClientExtensibleEnum; +import com.client.naming.models.ExtensibleEnum; + +/** + * Initializes a new instance of the synchronous NamingClient type. + */ +@ServiceClient(builder = NamingClientBuilder.class) +public final class UnionEnumClient { + @Generated + private final UnionEnumsImpl serviceClient; + + /** + * Initializes an instance of UnionEnumClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionEnumClient(UnionEnumsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The unionEnumName operation. + *

Request Body Schema

+ * + *
{@code
+     * String(value1)
+     * }
+ * + * @param body The body 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 unionEnumNameWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.unionEnumNameWithResponse(body, requestOptions); + } + + /** + * The unionEnumMemberName operation. + *

Request Body Schema

+ * + *
{@code
+     * String(value1 / value2)
+     * }
+ * + * @param body The body 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 unionEnumMemberNameWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.unionEnumMemberNameWithResponse(body, requestOptions); + } + + /** + * The unionEnumName operation. + * + * @param body The body 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 unionEnumName(ClientExtensibleEnum body) { + // Generated convenience method for unionEnumNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + unionEnumNameWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .getValue(); + } + + /** + * The unionEnumMemberName operation. + * + * @param body The body 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 unionEnumMemberName(ExtensibleEnum body) { + // Generated convenience method for unionEnumMemberNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + unionEnumMemberNameWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/implementation/ClientModelsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/implementation/ClientModelsImpl.java new file mode 100644 index 000000000..8e2403e6b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/implementation/ClientModelsImpl.java @@ -0,0 +1,199 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ClientModels. + */ +public final class ClientModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ClientModelsService service; + + /** + * The service client containing this operation class. + */ + private final NamingClientImpl client; + + /** + * Initializes an instance of ClientModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ClientModelsImpl(NamingClientImpl client) { + this.service + = RestProxy.create(ClientModelsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for NamingClientClientModels to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NamingClientClientMo") + public interface ClientModelsService { + @Post("/client/naming/model/client") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> client(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/client/naming/model/client") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response clientSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/client/naming/model/language") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> language(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/client/naming/model/language") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response languageSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The client operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> clientWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.client(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The client operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 clientWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.clientSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The language operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> languageWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.language(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The language operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 languageWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.languageSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/implementation/NamingClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/implementation/NamingClientImpl.java new file mode 100644 index 000000000..2b80eddc7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/implementation/NamingClientImpl.java @@ -0,0 +1,565 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +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.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 NamingClient type. + */ +public final class NamingClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NamingClientService 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; + } + + /** + * The ClientModelsImpl object to access its operations. + */ + private final ClientModelsImpl clientModels; + + /** + * Gets the ClientModelsImpl object to access its operations. + * + * @return the ClientModelsImpl object. + */ + public ClientModelsImpl getClientModels() { + return this.clientModels; + } + + /** + * The UnionEnumsImpl object to access its operations. + */ + private final UnionEnumsImpl unionEnums; + + /** + * Gets the UnionEnumsImpl object to access its operations. + * + * @return the UnionEnumsImpl object. + */ + public UnionEnumsImpl getUnionEnums() { + return this.unionEnums; + } + + /** + * Initializes an instance of NamingClient client. + * + * @param endpoint Service host. + */ + public NamingClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NamingClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public NamingClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NamingClient 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 NamingClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.clientModels = new ClientModelsImpl(this); + this.unionEnums = new UnionEnumsImpl(this); + this.service = RestProxy.create(NamingClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for NamingClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NamingClient") + public interface NamingClientService { + @Post("/client/naming/operation") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> clientName(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Post("/client/naming/operation") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response clientNameSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Post("/client/naming/parameter") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> parameter(@HostParam("endpoint") String endpoint, + @QueryParam("defaultName") String clientName, RequestOptions requestOptions, Context context); + + @Post("/client/naming/parameter") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response parameterSync(@HostParam("endpoint") String endpoint, + @QueryParam("defaultName") String clientName, RequestOptions requestOptions, Context context); + + @Post("/client/naming/property/client") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> client(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/client/naming/property/client") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response clientSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/client/naming/property/language") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> language(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/client/naming/property/language") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response languageSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/client/naming/property/compatible-with-encoded-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> compatibleWithEncodedName(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/client/naming/property/compatible-with-encoded-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response compatibleWithEncodedNameSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/client/naming/header") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> request(@HostParam("endpoint") String endpoint, + @HeaderParam("default-name") String clientName, RequestOptions requestOptions, Context context); + + @Post("/client/naming/header") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response requestSync(@HostParam("endpoint") String endpoint, + @HeaderParam("default-name") String clientName, RequestOptions requestOptions, Context context); + + @Get("/client/naming/header") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> response(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/client/naming/header") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response responseSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + } + + /** + * The clientName operation. + * + * @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> clientNameWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.clientName(this.getEndpoint(), requestOptions, context)); + } + + /** + * The clientName operation. + * + * @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 clientNameWithResponse(RequestOptions requestOptions) { + return service.clientNameSync(this.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The parameter operation. + * + * @param clientName The clientName 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> parameterWithResponseAsync(String clientName, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.parameter(this.getEndpoint(), clientName, requestOptions, context)); + } + + /** + * The parameter operation. + * + * @param clientName The clientName 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 parameterWithResponse(String clientName, RequestOptions requestOptions) { + return service.parameterSync(this.getEndpoint(), clientName, requestOptions, Context.NONE); + } + + /** + * The client operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> clientWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.client(this.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The client operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 clientWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.clientSync(this.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The language operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> languageWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.language(this.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The language operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     defaultName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 languageWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.languageSync(this.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The compatibleWithEncodedName operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     wireName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> compatibleWithEncodedNameWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.compatibleWithEncodedName(this.getEndpoint(), contentType, body, + requestOptions, context)); + } + + /** + * The compatibleWithEncodedName operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     wireName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 compatibleWithEncodedNameWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.compatibleWithEncodedNameSync(this.getEndpoint(), contentType, body, requestOptions, + Context.NONE); + } + + /** + * The request operation. + * + * @param clientName The clientName 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> requestWithResponseAsync(String clientName, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.request(this.getEndpoint(), clientName, requestOptions, context)); + } + + /** + * The request operation. + * + * @param clientName The clientName 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 requestWithResponse(String clientName, RequestOptions requestOptions) { + return service.requestSync(this.getEndpoint(), clientName, requestOptions, Context.NONE); + } + + /** + * The response operation. + * + * @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> responseWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.response(this.getEndpoint(), requestOptions, context)); + } + + /** + * The response operation. + * + * @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 responseWithResponse(RequestOptions requestOptions) { + return service.responseSync(this.getEndpoint(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/implementation/UnionEnumsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/implementation/UnionEnumsImpl.java new file mode 100644 index 000000000..ed4791a76 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/implementation/UnionEnumsImpl.java @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in UnionEnums. + */ +public final class UnionEnumsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionEnumsService service; + + /** + * The service client containing this operation class. + */ + private final NamingClientImpl client; + + /** + * Initializes an instance of UnionEnumsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionEnumsImpl(NamingClientImpl client) { + this.service + = RestProxy.create(UnionEnumsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for NamingClientUnionEnums to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NamingClientUnionEnu") + public interface UnionEnumsService { + @Post("/client/naming/union-enum/union-enum-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> unionEnumName(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/client/naming/union-enum/union-enum-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response unionEnumNameSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/client/naming/union-enum/union-enum-member-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> unionEnumMemberName(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/client/naming/union-enum/union-enum-member-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response unionEnumMemberNameSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The unionEnumName operation. + *

Request Body Schema

+ * + *
{@code
+     * String(value1)
+     * }
+ * + * @param body The body 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> unionEnumNameWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.unionEnumName(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The unionEnumName operation. + *

Request Body Schema

+ * + *
{@code
+     * String(value1)
+     * }
+ * + * @param body The body 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 unionEnumNameWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.unionEnumNameSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The unionEnumMemberName operation. + *

Request Body Schema

+ * + *
{@code
+     * String(value1 / value2)
+     * }
+ * + * @param body The body 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> unionEnumMemberNameWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.unionEnumMemberName(this.client.getEndpoint(), contentType, body, + requestOptions, context)); + } + + /** + * The unionEnumMemberName operation. + *

Request Body Schema

+ * + *
{@code
+     * String(value1 / value2)
+     * }
+ * + * @param body The body 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 unionEnumMemberNameWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.unionEnumMemberNameSync(this.client.getEndpoint(), contentType, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/implementation/package-info.java new file mode 100644 index 000000000..a2e599f5e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/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 Naming. + * Describe changing names of types in a client with `@clientName`. + * + */ +package com.client.naming.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ClientExtensibleEnum.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ClientExtensibleEnum.java new file mode 100644 index 000000000..11469122b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ClientExtensibleEnum.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for ClientExtensibleEnum. + */ +public final class ClientExtensibleEnum extends ExpandableStringEnum { + /** + * Static value value1 for ClientExtensibleEnum. + */ + @Generated + public static final ClientExtensibleEnum ENUM_VALUE1 = fromString("value1"); + + /** + * Creates a new instance of ClientExtensibleEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ClientExtensibleEnum() { + } + + /** + * Creates or finds a ClientExtensibleEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding ClientExtensibleEnum. + */ + @Generated + public static ClientExtensibleEnum fromString(String name) { + return fromString(name, ClientExtensibleEnum.class); + } + + /** + * Gets known ClientExtensibleEnum values. + * + * @return known ClientExtensibleEnum values. + */ + @Generated + public static Collection values() { + return values(ClientExtensibleEnum.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ClientModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ClientModel.java new file mode 100644 index 000000000..daf4056ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ClientModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming.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; + +/** + * The ClientModel model. + */ +@Immutable +public final class ClientModel implements JsonSerializable { + /* + * Pass in true + */ + @Generated + private final boolean defaultName; + + /** + * Creates an instance of ClientModel class. + * + * @param defaultName the defaultName value to set. + */ + @Generated + public ClientModel(boolean defaultName) { + this.defaultName = defaultName; + } + + /** + * Get the defaultName property: Pass in true. + * + * @return the defaultName value. + */ + @Generated + public boolean isDefaultName() { + return this.defaultName; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("defaultName", this.defaultName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ClientModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ClientModel 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 ClientModel. + */ + @Generated + public static ClientModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean defaultName = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("defaultName".equals(fieldName)) { + defaultName = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new ClientModel(defaultName); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ClientNameAndJsonEncodedNameModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ClientNameAndJsonEncodedNameModel.java new file mode 100644 index 000000000..1a67dec7e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ClientNameAndJsonEncodedNameModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming.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; + +/** + * The ClientNameAndJsonEncodedNameModel model. + */ +@Immutable +public final class ClientNameAndJsonEncodedNameModel implements JsonSerializable { + /* + * Pass in true + */ + @Generated + private final boolean clientName; + + /** + * Creates an instance of ClientNameAndJsonEncodedNameModel class. + * + * @param clientName the clientName value to set. + */ + @Generated + public ClientNameAndJsonEncodedNameModel(boolean clientName) { + this.clientName = clientName; + } + + /** + * Get the clientName property: Pass in true. + * + * @return the clientName value. + */ + @Generated + public boolean isClientName() { + return this.clientName; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("wireName", this.clientName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ClientNameAndJsonEncodedNameModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ClientNameAndJsonEncodedNameModel 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 ClientNameAndJsonEncodedNameModel. + */ + @Generated + public static ClientNameAndJsonEncodedNameModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean clientName = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wireName".equals(fieldName)) { + clientName = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new ClientNameAndJsonEncodedNameModel(clientName); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ClientNameModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ClientNameModel.java new file mode 100644 index 000000000..474a310f6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ClientNameModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming.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; + +/** + * The ClientNameModel model. + */ +@Immutable +public final class ClientNameModel implements JsonSerializable { + /* + * Pass in true + */ + @Generated + private final boolean clientName; + + /** + * Creates an instance of ClientNameModel class. + * + * @param clientName the clientName value to set. + */ + @Generated + public ClientNameModel(boolean clientName) { + this.clientName = clientName; + } + + /** + * Get the clientName property: Pass in true. + * + * @return the clientName value. + */ + @Generated + public boolean isClientName() { + return this.clientName; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("defaultName", this.clientName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ClientNameModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ClientNameModel 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 ClientNameModel. + */ + @Generated + public static ClientNameModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean clientName = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("defaultName".equals(fieldName)) { + clientName = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new ClientNameModel(clientName); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ExtensibleEnum.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ExtensibleEnum.java new file mode 100644 index 000000000..8661b4875 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/ExtensibleEnum.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for ExtensibleEnum. + */ +public final class ExtensibleEnum extends ExpandableStringEnum { + /** + * Static value value1 for ExtensibleEnum. + */ + @Generated + public static final ExtensibleEnum CLIENT_ENUM_VALUE1 = fromString("value1"); + + /** + * Static value value2 for ExtensibleEnum. + */ + @Generated + public static final ExtensibleEnum CLIENT_ENUM_VALUE2 = fromString("value2"); + + /** + * Creates a new instance of ExtensibleEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ExtensibleEnum() { + } + + /** + * Creates or finds a ExtensibleEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding ExtensibleEnum. + */ + @Generated + public static ExtensibleEnum fromString(String name) { + return fromString(name, ExtensibleEnum.class); + } + + /** + * Gets known ExtensibleEnum values. + * + * @return known ExtensibleEnum values. + */ + @Generated + public static Collection values() { + return values(ExtensibleEnum.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/JavaModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/JavaModel.java new file mode 100644 index 000000000..ab0de3bd9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/JavaModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming.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; + +/** + * The JavaModel model. + */ +@Immutable +public final class JavaModel implements JsonSerializable { + /* + * Pass in true + */ + @Generated + private final boolean defaultName; + + /** + * Creates an instance of JavaModel class. + * + * @param defaultName the defaultName value to set. + */ + @Generated + public JavaModel(boolean defaultName) { + this.defaultName = defaultName; + } + + /** + * Get the defaultName property: Pass in true. + * + * @return the defaultName value. + */ + @Generated + public boolean isDefaultName() { + return this.defaultName; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("defaultName", this.defaultName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of JavaModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of JavaModel 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 JavaModel. + */ + @Generated + public static JavaModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean defaultName = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("defaultName".equals(fieldName)) { + defaultName = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new JavaModel(defaultName); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/LanguageClientNameModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/LanguageClientNameModel.java new file mode 100644 index 000000000..a993d18b5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/LanguageClientNameModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming.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; + +/** + * The LanguageClientNameModel model. + */ +@Immutable +public final class LanguageClientNameModel implements JsonSerializable { + /* + * Pass in true + */ + @Generated + private final boolean javaName; + + /** + * Creates an instance of LanguageClientNameModel class. + * + * @param javaName the javaName value to set. + */ + @Generated + public LanguageClientNameModel(boolean javaName) { + this.javaName = javaName; + } + + /** + * Get the javaName property: Pass in true. + * + * @return the javaName value. + */ + @Generated + public boolean isJavaName() { + return this.javaName; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("defaultName", this.javaName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LanguageClientNameModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LanguageClientNameModel 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 LanguageClientNameModel. + */ + @Generated + public static LanguageClientNameModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean javaName = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("defaultName".equals(fieldName)) { + javaName = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new LanguageClientNameModel(javaName); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/models/package-info.java new file mode 100644 index 000000000..d79d26312 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/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 Naming. + * Describe changing names of types in a client with `@clientName`. + * + */ +package com.client.naming.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/package-info.java new file mode 100644 index 000000000..85c14e8de --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/naming/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 Naming. + * Describe changing names of types in a client with `@clientName`. + * + */ +package com.client.naming; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/BarAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/BarAsyncClient.java new file mode 100644 index 000000000..bbe990bbf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/BarAsyncClient.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 com.client.structure.service; + +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 com.client.structure.service.implementation.BarsImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class, isAsync = true) +public final class BarAsyncClient { + @Generated + private final BarsImpl serviceClient; + + /** + * Initializes an instance of BarAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BarAsyncClient(BarsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The five operation. + * + * @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> fiveWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fiveWithResponseAsync(requestOptions); + } + + /** + * The six operation. + * + * @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> sixWithResponse(RequestOptions requestOptions) { + return this.serviceClient.sixWithResponseAsync(requestOptions); + } + + /** + * The five 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono five() { + // Generated convenience method for fiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + return fiveWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The six 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono six() { + // Generated convenience method for sixWithResponse + RequestOptions requestOptions = new RequestOptions(); + return sixWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/BarClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/BarClient.java new file mode 100644 index 000000000..143f32d99 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/BarClient.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.client.structure.service.implementation.BarsImpl; + +/** + * Initializes a new instance of the synchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class) +public final class BarClient { + @Generated + private final BarsImpl serviceClient; + + /** + * Initializes an instance of BarClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BarClient(BarsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The five operation. + * + * @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 fiveWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fiveWithResponse(requestOptions); + } + + /** + * The six operation. + * + * @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 sixWithResponse(RequestOptions requestOptions) { + return this.serviceClient.sixWithResponse(requestOptions); + } + + /** + * The five 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void five() { + // Generated convenience method for fiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + fiveWithResponse(requestOptions).getValue(); + } + + /** + * The six 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void six() { + // Generated convenience method for sixWithResponse + RequestOptions requestOptions = new RequestOptions(); + sixWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/BazFooAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/BazFooAsyncClient.java new file mode 100644 index 000000000..148e5f967 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/BazFooAsyncClient.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 com.client.structure.service; + +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 com.client.structure.service.implementation.BazFoosImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class, isAsync = true) +public final class BazFooAsyncClient { + @Generated + private final BazFoosImpl serviceClient; + + /** + * Initializes an instance of BazFooAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BazFooAsyncClient(BazFoosImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The seven operation. + * + * @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> sevenWithResponse(RequestOptions requestOptions) { + return this.serviceClient.sevenWithResponseAsync(requestOptions); + } + + /** + * The seven 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono seven() { + // Generated convenience method for sevenWithResponse + RequestOptions requestOptions = new RequestOptions(); + return sevenWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/BazFooClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/BazFooClient.java new file mode 100644 index 000000000..ad4d877d2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/BazFooClient.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.client.structure.service.implementation.BazFoosImpl; + +/** + * Initializes a new instance of the synchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class) +public final class BazFooClient { + @Generated + private final BazFoosImpl serviceClient; + + /** + * Initializes an instance of BazFooClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BazFooClient(BazFoosImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The seven operation. + * + * @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 sevenWithResponse(RequestOptions requestOptions) { + return this.serviceClient.sevenWithResponse(requestOptions); + } + + /** + * The seven 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void seven() { + // Generated convenience method for sevenWithResponse + RequestOptions requestOptions = new RequestOptions(); + sevenWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientAAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientAAsyncClient.java new file mode 100644 index 000000000..d199f5905 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientAAsyncClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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 com.client.structure.service.implementation.ClientAClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ClientAClient type. + */ +@ServiceClient(builder = ClientAClientBuilder.class, isAsync = true) +public final class ClientAAsyncClient { + @Generated + private final ClientAClientImpl serviceClient; + + /** + * Initializes an instance of ClientAAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ClientAAsyncClient(ClientAClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The renamedOne operation. + * + * @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> renamedOneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedOneWithResponseAsync(requestOptions); + } + + /** + * The renamedThree operation. + * + * @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> renamedThreeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedThreeWithResponseAsync(requestOptions); + } + + /** + * The renamedFive operation. + * + * @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> renamedFiveWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedFiveWithResponseAsync(requestOptions); + } + + /** + * The renamedOne 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renamedOne() { + // Generated convenience method for renamedOneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renamedOneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The renamedThree 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renamedThree() { + // Generated convenience method for renamedThreeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renamedThreeWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The renamedFive 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renamedFive() { + // Generated convenience method for renamedFiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renamedFiveWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientAClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientAClient.java new file mode 100644 index 000000000..cfee8230e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientAClient.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.client.structure.service.implementation.ClientAClientImpl; + +/** + * Initializes a new instance of the synchronous ClientAClient type. + */ +@ServiceClient(builder = ClientAClientBuilder.class) +public final class ClientAClient { + @Generated + private final ClientAClientImpl serviceClient; + + /** + * Initializes an instance of ClientAClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ClientAClient(ClientAClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The renamedOne operation. + * + * @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 renamedOneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedOneWithResponse(requestOptions); + } + + /** + * The renamedThree operation. + * + * @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 renamedThreeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedThreeWithResponse(requestOptions); + } + + /** + * The renamedFive operation. + * + * @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 renamedFiveWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedFiveWithResponse(requestOptions); + } + + /** + * The renamedOne 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renamedOne() { + // Generated convenience method for renamedOneWithResponse + RequestOptions requestOptions = new RequestOptions(); + renamedOneWithResponse(requestOptions).getValue(); + } + + /** + * The renamedThree 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renamedThree() { + // Generated convenience method for renamedThreeWithResponse + RequestOptions requestOptions = new RequestOptions(); + renamedThreeWithResponse(requestOptions).getValue(); + } + + /** + * The renamedFive 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renamedFive() { + // Generated convenience method for renamedFiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + renamedFiveWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientAClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientAClientBuilder.java new file mode 100644 index 000000000..524b82128 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientAClientBuilder.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.client.structure.service.implementation.ClientAClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ClientAClient type. + */ +@ServiceClientBuilder(serviceClients = { ClientAClient.class, ClientAAsyncClient.class }) +public final class ClientAClientBuilder 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("client-structure-service.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ClientAClientBuilder. + */ + @Generated + public ClientAClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ClientAClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ClientAClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ClientAClientBuilder 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 ClientAClientBuilder 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 ClientAClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ClientAClientBuilder 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 ClientAClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ClientAClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + @Generated + private String client; + + /** + * Sets Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + * + * @param client the client value. + * @return the ClientAClientBuilder. + */ + @Generated + public ClientAClientBuilder client(String client) { + this.client = client; + 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 ClientAClientBuilder. + */ + @Generated + public ClientAClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ClientAClientImpl with the provided parameters. + * + * @return an instance of ClientAClientImpl. + */ + @Generated + private ClientAClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ClientAClientImpl client = new ClientAClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, this.client); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(client, "'client' cannot be null."); + } + + @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 ClientAAsyncClient class. + * + * @return an instance of ClientAAsyncClient. + */ + @Generated + public ClientAAsyncClient buildAsyncClient() { + return new ClientAAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ClientAClient class. + * + * @return an instance of ClientAClient. + */ + @Generated + public ClientAClient buildClient() { + return new ClientAClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ClientAClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientBAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientBAsyncClient.java new file mode 100644 index 000000000..0959d2f24 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientBAsyncClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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 com.client.structure.service.implementation.ClientBClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ClientBClient type. + */ +@ServiceClient(builder = ClientBClientBuilder.class, isAsync = true) +public final class ClientBAsyncClient { + @Generated + private final ClientBClientImpl serviceClient; + + /** + * Initializes an instance of ClientBAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ClientBAsyncClient(ClientBClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The renamedTwo operation. + * + * @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> renamedTwoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedTwoWithResponseAsync(requestOptions); + } + + /** + * The renamedFour operation. + * + * @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> renamedFourWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedFourWithResponseAsync(requestOptions); + } + + /** + * The renamedSix operation. + * + * @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> renamedSixWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedSixWithResponseAsync(requestOptions); + } + + /** + * The renamedTwo 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renamedTwo() { + // Generated convenience method for renamedTwoWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renamedTwoWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The renamedFour 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renamedFour() { + // Generated convenience method for renamedFourWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renamedFourWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The renamedSix 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renamedSix() { + // Generated convenience method for renamedSixWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renamedSixWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientBClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientBClient.java new file mode 100644 index 000000000..21ff8cf93 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientBClient.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.client.structure.service.implementation.ClientBClientImpl; + +/** + * Initializes a new instance of the synchronous ClientBClient type. + */ +@ServiceClient(builder = ClientBClientBuilder.class) +public final class ClientBClient { + @Generated + private final ClientBClientImpl serviceClient; + + /** + * Initializes an instance of ClientBClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ClientBClient(ClientBClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The renamedTwo operation. + * + * @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 renamedTwoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedTwoWithResponse(requestOptions); + } + + /** + * The renamedFour operation. + * + * @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 renamedFourWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedFourWithResponse(requestOptions); + } + + /** + * The renamedSix operation. + * + * @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 renamedSixWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedSixWithResponse(requestOptions); + } + + /** + * The renamedTwo 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renamedTwo() { + // Generated convenience method for renamedTwoWithResponse + RequestOptions requestOptions = new RequestOptions(); + renamedTwoWithResponse(requestOptions).getValue(); + } + + /** + * The renamedFour 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renamedFour() { + // Generated convenience method for renamedFourWithResponse + RequestOptions requestOptions = new RequestOptions(); + renamedFourWithResponse(requestOptions).getValue(); + } + + /** + * The renamedSix 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renamedSix() { + // Generated convenience method for renamedSixWithResponse + RequestOptions requestOptions = new RequestOptions(); + renamedSixWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientBClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientBClientBuilder.java new file mode 100644 index 000000000..5e62b0f4a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ClientBClientBuilder.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.client.structure.service.implementation.ClientBClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ClientBClient type. + */ +@ServiceClientBuilder(serviceClients = { ClientBClient.class, ClientBAsyncClient.class }) +public final class ClientBClientBuilder 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("client-structure-service.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ClientBClientBuilder. + */ + @Generated + public ClientBClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ClientBClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ClientBClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ClientBClientBuilder 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 ClientBClientBuilder 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 ClientBClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ClientBClientBuilder 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 ClientBClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ClientBClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + @Generated + private String client; + + /** + * Sets Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + * + * @param client the client value. + * @return the ClientBClientBuilder. + */ + @Generated + public ClientBClientBuilder client(String client) { + this.client = client; + 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 ClientBClientBuilder. + */ + @Generated + public ClientBClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ClientBClientImpl with the provided parameters. + * + * @return an instance of ClientBClientImpl. + */ + @Generated + private ClientBClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ClientBClientImpl client = new ClientBClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, this.client); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(client, "'client' cannot be null."); + } + + @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 ClientBAsyncClient class. + * + * @return an instance of ClientBAsyncClient. + */ + @Generated + public ClientBAsyncClient buildAsyncClient() { + return new ClientBAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ClientBClient class. + * + * @return an instance of ClientBClient. + */ + @Generated + public ClientBClient buildClient() { + return new ClientBClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ClientBClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/FooAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/FooAsyncClient.java new file mode 100644 index 000000000..59cad1963 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/FooAsyncClient.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 com.client.structure.service; + +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 com.client.structure.service.implementation.FoosImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class, isAsync = true) +public final class FooAsyncClient { + @Generated + private final FoosImpl serviceClient; + + /** + * Initializes an instance of FooAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FooAsyncClient(FoosImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The three operation. + * + * @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> threeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.threeWithResponseAsync(requestOptions); + } + + /** + * The four operation. + * + * @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> fourWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fourWithResponseAsync(requestOptions); + } + + /** + * The three 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono three() { + // Generated convenience method for threeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return threeWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The four 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono four() { + // Generated convenience method for fourWithResponse + RequestOptions requestOptions = new RequestOptions(); + return fourWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/FooClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/FooClient.java new file mode 100644 index 000000000..1117edf9d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/FooClient.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.client.structure.service.implementation.FoosImpl; + +/** + * Initializes a new instance of the synchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class) +public final class FooClient { + @Generated + private final FoosImpl serviceClient; + + /** + * Initializes an instance of FooClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FooClient(FoosImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The three operation. + * + * @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 threeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.threeWithResponse(requestOptions); + } + + /** + * The four operation. + * + * @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 fourWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fourWithResponse(requestOptions); + } + + /** + * The three 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void three() { + // Generated convenience method for threeWithResponse + RequestOptions requestOptions = new RequestOptions(); + threeWithResponse(requestOptions).getValue(); + } + + /** + * The four 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void four() { + // Generated convenience method for fourWithResponse + RequestOptions requestOptions = new RequestOptions(); + fourWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/Group1AsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/Group1AsyncClient.java new file mode 100644 index 000000000..1d3bdb8d6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/Group1AsyncClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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 com.client.structure.service.implementation.Group1sImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous TwoOperationGroupClient type. + */ +@ServiceClient(builder = TwoOperationGroupClientBuilder.class, isAsync = true) +public final class Group1AsyncClient { + @Generated + private final Group1sImpl serviceClient; + + /** + * Initializes an instance of Group1AsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Group1AsyncClient(Group1sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The one operation. + * + * @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> oneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.oneWithResponseAsync(requestOptions); + } + + /** + * The three operation. + * + * @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> threeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.threeWithResponseAsync(requestOptions); + } + + /** + * The four operation. + * + * @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> fourWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fourWithResponseAsync(requestOptions); + } + + /** + * The one 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono one() { + // Generated convenience method for oneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return oneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The three 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono three() { + // Generated convenience method for threeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return threeWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The four 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono four() { + // Generated convenience method for fourWithResponse + RequestOptions requestOptions = new RequestOptions(); + return fourWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/Group1Client.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/Group1Client.java new file mode 100644 index 000000000..23f65d395 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/Group1Client.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.client.structure.service.implementation.Group1sImpl; + +/** + * Initializes a new instance of the synchronous TwoOperationGroupClient type. + */ +@ServiceClient(builder = TwoOperationGroupClientBuilder.class) +public final class Group1Client { + @Generated + private final Group1sImpl serviceClient; + + /** + * Initializes an instance of Group1Client class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Group1Client(Group1sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The one operation. + * + * @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 oneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.oneWithResponse(requestOptions); + } + + /** + * The three operation. + * + * @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 threeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.threeWithResponse(requestOptions); + } + + /** + * The four operation. + * + * @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 fourWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fourWithResponse(requestOptions); + } + + /** + * The one 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void one() { + // Generated convenience method for oneWithResponse + RequestOptions requestOptions = new RequestOptions(); + oneWithResponse(requestOptions).getValue(); + } + + /** + * The three 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void three() { + // Generated convenience method for threeWithResponse + RequestOptions requestOptions = new RequestOptions(); + threeWithResponse(requestOptions).getValue(); + } + + /** + * The four 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void four() { + // Generated convenience method for fourWithResponse + RequestOptions requestOptions = new RequestOptions(); + fourWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/Group2AsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/Group2AsyncClient.java new file mode 100644 index 000000000..cbbd24cad --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/Group2AsyncClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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 com.client.structure.service.implementation.Group2sImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous TwoOperationGroupClient type. + */ +@ServiceClient(builder = TwoOperationGroupClientBuilder.class, isAsync = true) +public final class Group2AsyncClient { + @Generated + private final Group2sImpl serviceClient; + + /** + * Initializes an instance of Group2AsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Group2AsyncClient(Group2sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The two operation. + * + * @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> twoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.twoWithResponseAsync(requestOptions); + } + + /** + * The five operation. + * + * @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> fiveWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fiveWithResponseAsync(requestOptions); + } + + /** + * The six operation. + * + * @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> sixWithResponse(RequestOptions requestOptions) { + return this.serviceClient.sixWithResponseAsync(requestOptions); + } + + /** + * The two 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono two() { + // Generated convenience method for twoWithResponse + RequestOptions requestOptions = new RequestOptions(); + return twoWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The five 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono five() { + // Generated convenience method for fiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + return fiveWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The six 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono six() { + // Generated convenience method for sixWithResponse + RequestOptions requestOptions = new RequestOptions(); + return sixWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/Group2Client.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/Group2Client.java new file mode 100644 index 000000000..08f284dd7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/Group2Client.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.client.structure.service.implementation.Group2sImpl; + +/** + * Initializes a new instance of the synchronous TwoOperationGroupClient type. + */ +@ServiceClient(builder = TwoOperationGroupClientBuilder.class) +public final class Group2Client { + @Generated + private final Group2sImpl serviceClient; + + /** + * Initializes an instance of Group2Client class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Group2Client(Group2sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The two operation. + * + * @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 twoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.twoWithResponse(requestOptions); + } + + /** + * The five operation. + * + * @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 fiveWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fiveWithResponse(requestOptions); + } + + /** + * The six operation. + * + * @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 sixWithResponse(RequestOptions requestOptions) { + return this.serviceClient.sixWithResponse(requestOptions); + } + + /** + * The two 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void two() { + // Generated convenience method for twoWithResponse + RequestOptions requestOptions = new RequestOptions(); + twoWithResponse(requestOptions).getValue(); + } + + /** + * The five 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void five() { + // Generated convenience method for fiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + fiveWithResponse(requestOptions).getValue(); + } + + /** + * The six 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void six() { + // Generated convenience method for sixWithResponse + RequestOptions requestOptions = new RequestOptions(); + sixWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/GroupAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/GroupAsyncClient.java new file mode 100644 index 000000000..cad293365 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/GroupAsyncClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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 com.client.structure.service.implementation.GroupsImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous RenamedOperationClient type. + */ +@ServiceClient(builder = RenamedOperationClientBuilder.class, isAsync = true) +public final class GroupAsyncClient { + @Generated + private final GroupsImpl serviceClient; + + /** + * Initializes an instance of GroupAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + GroupAsyncClient(GroupsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The renamedTwo operation. + * + * @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> renamedTwoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedTwoWithResponseAsync(requestOptions); + } + + /** + * The renamedFour operation. + * + * @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> renamedFourWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedFourWithResponseAsync(requestOptions); + } + + /** + * The renamedSix operation. + * + * @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> renamedSixWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedSixWithResponseAsync(requestOptions); + } + + /** + * The renamedTwo 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renamedTwo() { + // Generated convenience method for renamedTwoWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renamedTwoWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The renamedFour 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renamedFour() { + // Generated convenience method for renamedFourWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renamedFourWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The renamedSix 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renamedSix() { + // Generated convenience method for renamedSixWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renamedSixWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/GroupClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/GroupClient.java new file mode 100644 index 000000000..2c2634b88 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/GroupClient.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.client.structure.service.implementation.GroupsImpl; + +/** + * Initializes a new instance of the synchronous RenamedOperationClient type. + */ +@ServiceClient(builder = RenamedOperationClientBuilder.class) +public final class GroupClient { + @Generated + private final GroupsImpl serviceClient; + + /** + * Initializes an instance of GroupClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + GroupClient(GroupsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The renamedTwo operation. + * + * @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 renamedTwoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedTwoWithResponse(requestOptions); + } + + /** + * The renamedFour operation. + * + * @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 renamedFourWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedFourWithResponse(requestOptions); + } + + /** + * The renamedSix operation. + * + * @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 renamedSixWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedSixWithResponse(requestOptions); + } + + /** + * The renamedTwo 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renamedTwo() { + // Generated convenience method for renamedTwoWithResponse + RequestOptions requestOptions = new RequestOptions(); + renamedTwoWithResponse(requestOptions).getValue(); + } + + /** + * The renamedFour 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renamedFour() { + // Generated convenience method for renamedFourWithResponse + RequestOptions requestOptions = new RequestOptions(); + renamedFourWithResponse(requestOptions).getValue(); + } + + /** + * The renamedSix 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renamedSix() { + // Generated convenience method for renamedSixWithResponse + RequestOptions requestOptions = new RequestOptions(); + renamedSixWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/QuxAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/QuxAsyncClient.java new file mode 100644 index 000000000..e030c3411 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/QuxAsyncClient.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 com.client.structure.service; + +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 com.client.structure.service.implementation.QuxesImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class, isAsync = true) +public final class QuxAsyncClient { + @Generated + private final QuxesImpl serviceClient; + + /** + * Initializes an instance of QuxAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + QuxAsyncClient(QuxesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The eight operation. + * + * @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> eightWithResponse(RequestOptions requestOptions) { + return this.serviceClient.eightWithResponseAsync(requestOptions); + } + + /** + * The eight 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono eight() { + // Generated convenience method for eightWithResponse + RequestOptions requestOptions = new RequestOptions(); + return eightWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/QuxBarAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/QuxBarAsyncClient.java new file mode 100644 index 000000000..0b2b66db8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/QuxBarAsyncClient.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 com.client.structure.service; + +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 com.client.structure.service.implementation.QuxBarsImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class, isAsync = true) +public final class QuxBarAsyncClient { + @Generated + private final QuxBarsImpl serviceClient; + + /** + * Initializes an instance of QuxBarAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + QuxBarAsyncClient(QuxBarsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The nine operation. + * + * @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> nineWithResponse(RequestOptions requestOptions) { + return this.serviceClient.nineWithResponseAsync(requestOptions); + } + + /** + * The nine 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono nine() { + // Generated convenience method for nineWithResponse + RequestOptions requestOptions = new RequestOptions(); + return nineWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/QuxBarClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/QuxBarClient.java new file mode 100644 index 000000000..e78b9258e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/QuxBarClient.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.client.structure.service.implementation.QuxBarsImpl; + +/** + * Initializes a new instance of the synchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class) +public final class QuxBarClient { + @Generated + private final QuxBarsImpl serviceClient; + + /** + * Initializes an instance of QuxBarClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + QuxBarClient(QuxBarsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The nine operation. + * + * @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 nineWithResponse(RequestOptions requestOptions) { + return this.serviceClient.nineWithResponse(requestOptions); + } + + /** + * The nine 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void nine() { + // Generated convenience method for nineWithResponse + RequestOptions requestOptions = new RequestOptions(); + nineWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/QuxClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/QuxClient.java new file mode 100644 index 000000000..0bc793ca5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/QuxClient.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.client.structure.service.implementation.QuxesImpl; + +/** + * Initializes a new instance of the synchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class) +public final class QuxClient { + @Generated + private final QuxesImpl serviceClient; + + /** + * Initializes an instance of QuxClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + QuxClient(QuxesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The eight operation. + * + * @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 eightWithResponse(RequestOptions requestOptions) { + return this.serviceClient.eightWithResponse(requestOptions); + } + + /** + * The eight 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void eight() { + // Generated convenience method for eightWithResponse + RequestOptions requestOptions = new RequestOptions(); + eightWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/RenamedOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/RenamedOperationAsyncClient.java new file mode 100644 index 000000000..672d3d149 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/RenamedOperationAsyncClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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 com.client.structure.service.implementation.RenamedOperationClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous RenamedOperationClient type. + */ +@ServiceClient(builder = RenamedOperationClientBuilder.class, isAsync = true) +public final class RenamedOperationAsyncClient { + @Generated + private final RenamedOperationClientImpl serviceClient; + + /** + * Initializes an instance of RenamedOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RenamedOperationAsyncClient(RenamedOperationClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The renamedOne operation. + * + * @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> renamedOneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedOneWithResponseAsync(requestOptions); + } + + /** + * The renamedThree operation. + * + * @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> renamedThreeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedThreeWithResponseAsync(requestOptions); + } + + /** + * The renamedFive operation. + * + * @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> renamedFiveWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedFiveWithResponseAsync(requestOptions); + } + + /** + * The renamedOne 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renamedOne() { + // Generated convenience method for renamedOneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renamedOneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The renamedThree 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renamedThree() { + // Generated convenience method for renamedThreeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renamedThreeWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The renamedFive 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono renamedFive() { + // Generated convenience method for renamedFiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + return renamedFiveWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/RenamedOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/RenamedOperationClient.java new file mode 100644 index 000000000..35497b163 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/RenamedOperationClient.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.client.structure.service.implementation.RenamedOperationClientImpl; + +/** + * Initializes a new instance of the synchronous RenamedOperationClient type. + */ +@ServiceClient(builder = RenamedOperationClientBuilder.class) +public final class RenamedOperationClient { + @Generated + private final RenamedOperationClientImpl serviceClient; + + /** + * Initializes an instance of RenamedOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RenamedOperationClient(RenamedOperationClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The renamedOne operation. + * + * @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 renamedOneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedOneWithResponse(requestOptions); + } + + /** + * The renamedThree operation. + * + * @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 renamedThreeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedThreeWithResponse(requestOptions); + } + + /** + * The renamedFive operation. + * + * @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 renamedFiveWithResponse(RequestOptions requestOptions) { + return this.serviceClient.renamedFiveWithResponse(requestOptions); + } + + /** + * The renamedOne 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renamedOne() { + // Generated convenience method for renamedOneWithResponse + RequestOptions requestOptions = new RequestOptions(); + renamedOneWithResponse(requestOptions).getValue(); + } + + /** + * The renamedThree 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renamedThree() { + // Generated convenience method for renamedThreeWithResponse + RequestOptions requestOptions = new RequestOptions(); + renamedThreeWithResponse(requestOptions).getValue(); + } + + /** + * The renamedFive 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void renamedFive() { + // Generated convenience method for renamedFiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + renamedFiveWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/RenamedOperationClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/RenamedOperationClientBuilder.java new file mode 100644 index 000000000..25a6292f7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/RenamedOperationClientBuilder.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.client.structure.service.implementation.RenamedOperationClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the RenamedOperationClient type. + */ +@ServiceClientBuilder( + serviceClients = { + RenamedOperationClient.class, + GroupClient.class, + RenamedOperationAsyncClient.class, + GroupAsyncClient.class }) +public final class RenamedOperationClientBuilder 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("client-structure-service.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the RenamedOperationClientBuilder. + */ + @Generated + public RenamedOperationClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RenamedOperationClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RenamedOperationClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RenamedOperationClientBuilder 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 RenamedOperationClientBuilder 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 RenamedOperationClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RenamedOperationClientBuilder 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 RenamedOperationClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RenamedOperationClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + @Generated + private String client; + + /** + * Sets Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + * + * @param client the client value. + * @return the RenamedOperationClientBuilder. + */ + @Generated + public RenamedOperationClientBuilder client(String client) { + this.client = client; + 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 RenamedOperationClientBuilder. + */ + @Generated + public RenamedOperationClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of RenamedOperationClientImpl with the provided parameters. + * + * @return an instance of RenamedOperationClientImpl. + */ + @Generated + private RenamedOperationClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + RenamedOperationClientImpl client = new RenamedOperationClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, this.client); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(client, "'client' cannot be null."); + } + + @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 RenamedOperationAsyncClient class. + * + * @return an instance of RenamedOperationAsyncClient. + */ + @Generated + public RenamedOperationAsyncClient buildAsyncClient() { + return new RenamedOperationAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of GroupAsyncClient class. + * + * @return an instance of GroupAsyncClient. + */ + @Generated + public GroupAsyncClient buildGroupAsyncClient() { + return new GroupAsyncClient(buildInnerClient().getGroups()); + } + + /** + * Builds an instance of RenamedOperationClient class. + * + * @return an instance of RenamedOperationClient. + */ + @Generated + public RenamedOperationClient buildClient() { + return new RenamedOperationClient(buildInnerClient()); + } + + /** + * Builds an instance of GroupClient class. + * + * @return an instance of GroupClient. + */ + @Generated + public GroupClient buildGroupClient() { + return new GroupClient(buildInnerClient().getGroups()); + } + + private static final ClientLogger LOGGER = new ClientLogger(RenamedOperationClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ServiceClientAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ServiceClientAsyncClient.java new file mode 100644 index 000000000..ddb468ea1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ServiceClientAsyncClient.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 com.client.structure.service; + +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 com.client.structure.service.implementation.ServiceClientClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class, isAsync = true) +public final class ServiceClientAsyncClient { + @Generated + private final ServiceClientClientImpl serviceClient; + + /** + * Initializes an instance of ServiceClientAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ServiceClientAsyncClient(ServiceClientClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The one operation. + * + * @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> oneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.oneWithResponseAsync(requestOptions); + } + + /** + * The two operation. + * + * @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> twoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.twoWithResponseAsync(requestOptions); + } + + /** + * The one 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono one() { + // Generated convenience method for oneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return oneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The two 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono two() { + // Generated convenience method for twoWithResponse + RequestOptions requestOptions = new RequestOptions(); + return twoWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ServiceClientClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ServiceClientClient.java new file mode 100644 index 000000000..d2a83aecb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ServiceClientClient.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.client.structure.service.implementation.ServiceClientClientImpl; + +/** + * Initializes a new instance of the synchronous ServiceClientClient type. + */ +@ServiceClient(builder = ServiceClientClientBuilder.class) +public final class ServiceClientClient { + @Generated + private final ServiceClientClientImpl serviceClient; + + /** + * Initializes an instance of ServiceClientClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ServiceClientClient(ServiceClientClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The one operation. + * + * @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 oneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.oneWithResponse(requestOptions); + } + + /** + * The two operation. + * + * @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 twoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.twoWithResponse(requestOptions); + } + + /** + * The one 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void one() { + // Generated convenience method for oneWithResponse + RequestOptions requestOptions = new RequestOptions(); + oneWithResponse(requestOptions).getValue(); + } + + /** + * The two 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void two() { + // Generated convenience method for twoWithResponse + RequestOptions requestOptions = new RequestOptions(); + twoWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ServiceClientClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ServiceClientClientBuilder.java new file mode 100644 index 000000000..b162ae111 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/ServiceClientClientBuilder.java @@ -0,0 +1,420 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.client.structure.service.implementation.ServiceClientClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ServiceClientClient type. + */ +@ServiceClientBuilder( + serviceClients = { + ServiceClientClient.class, + BazFooClient.class, + QuxClient.class, + QuxBarClient.class, + FooClient.class, + BarClient.class, + ServiceClientAsyncClient.class, + BazFooAsyncClient.class, + QuxAsyncClient.class, + QuxBarAsyncClient.class, + FooAsyncClient.class, + BarAsyncClient.class }) +public final class ServiceClientClientBuilder 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("client-structure-service.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ServiceClientClientBuilder. + */ + @Generated + public ServiceClientClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder 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 ServiceClientClientBuilder 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 ServiceClientClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder 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 ServiceClientClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ServiceClientClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + @Generated + private String client; + + /** + * Sets Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + * + * @param client the client value. + * @return the ServiceClientClientBuilder. + */ + @Generated + public ServiceClientClientBuilder client(String client) { + this.client = client; + 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 ServiceClientClientBuilder. + */ + @Generated + public ServiceClientClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ServiceClientClientImpl with the provided parameters. + * + * @return an instance of ServiceClientClientImpl. + */ + @Generated + private ServiceClientClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ServiceClientClientImpl client = new ServiceClientClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, this.client); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(client, "'client' cannot be null."); + } + + @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 ServiceClientAsyncClient class. + * + * @return an instance of ServiceClientAsyncClient. + */ + @Generated + public ServiceClientAsyncClient buildAsyncClient() { + return new ServiceClientAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of BazFooAsyncClient class. + * + * @return an instance of BazFooAsyncClient. + */ + @Generated + public BazFooAsyncClient buildBazFooAsyncClient() { + return new BazFooAsyncClient(buildInnerClient().getBazFoos()); + } + + /** + * Builds an instance of QuxAsyncClient class. + * + * @return an instance of QuxAsyncClient. + */ + @Generated + public QuxAsyncClient buildQuxAsyncClient() { + return new QuxAsyncClient(buildInnerClient().getQuxes()); + } + + /** + * Builds an instance of QuxBarAsyncClient class. + * + * @return an instance of QuxBarAsyncClient. + */ + @Generated + public QuxBarAsyncClient buildQuxBarAsyncClient() { + return new QuxBarAsyncClient(buildInnerClient().getQuxBars()); + } + + /** + * Builds an instance of FooAsyncClient class. + * + * @return an instance of FooAsyncClient. + */ + @Generated + public FooAsyncClient buildFooAsyncClient() { + return new FooAsyncClient(buildInnerClient().getFoos()); + } + + /** + * Builds an instance of BarAsyncClient class. + * + * @return an instance of BarAsyncClient. + */ + @Generated + public BarAsyncClient buildBarAsyncClient() { + return new BarAsyncClient(buildInnerClient().getBars()); + } + + /** + * Builds an instance of ServiceClientClient class. + * + * @return an instance of ServiceClientClient. + */ + @Generated + public ServiceClientClient buildClient() { + return new ServiceClientClient(buildInnerClient()); + } + + /** + * Builds an instance of BazFooClient class. + * + * @return an instance of BazFooClient. + */ + @Generated + public BazFooClient buildBazFooClient() { + return new BazFooClient(buildInnerClient().getBazFoos()); + } + + /** + * Builds an instance of QuxClient class. + * + * @return an instance of QuxClient. + */ + @Generated + public QuxClient buildQuxClient() { + return new QuxClient(buildInnerClient().getQuxes()); + } + + /** + * Builds an instance of QuxBarClient class. + * + * @return an instance of QuxBarClient. + */ + @Generated + public QuxBarClient buildQuxBarClient() { + return new QuxBarClient(buildInnerClient().getQuxBars()); + } + + /** + * Builds an instance of FooClient class. + * + * @return an instance of FooClient. + */ + @Generated + public FooClient buildFooClient() { + return new FooClient(buildInnerClient().getFoos()); + } + + /** + * Builds an instance of BarClient class. + * + * @return an instance of BarClient. + */ + @Generated + public BarClient buildBarClient() { + return new BarClient(buildInnerClient().getBars()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ServiceClientClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/TwoOperationGroupClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/TwoOperationGroupClientBuilder.java new file mode 100644 index 000000000..9e78ba001 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/TwoOperationGroupClientBuilder.java @@ -0,0 +1,328 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.client.structure.service.implementation.TwoOperationGroupClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the TwoOperationGroupClient type. + */ +@ServiceClientBuilder( + serviceClients = { Group1Client.class, Group2Client.class, Group1AsyncClient.class, Group2AsyncClient.class }) +public final class TwoOperationGroupClientBuilder 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("client-structure-service.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the TwoOperationGroupClientBuilder. + */ + @Generated + public TwoOperationGroupClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TwoOperationGroupClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TwoOperationGroupClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TwoOperationGroupClientBuilder 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 TwoOperationGroupClientBuilder 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 TwoOperationGroupClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TwoOperationGroupClientBuilder 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 TwoOperationGroupClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TwoOperationGroupClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + @Generated + private String client; + + /** + * Sets Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + * + * @param client the client value. + * @return the TwoOperationGroupClientBuilder. + */ + @Generated + public TwoOperationGroupClientBuilder client(String client) { + this.client = client; + 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 TwoOperationGroupClientBuilder. + */ + @Generated + public TwoOperationGroupClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of TwoOperationGroupClientImpl with the provided parameters. + * + * @return an instance of TwoOperationGroupClientImpl. + */ + @Generated + private TwoOperationGroupClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + TwoOperationGroupClientImpl client = new TwoOperationGroupClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, this.client); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(client, "'client' cannot be null."); + } + + @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 Group1AsyncClient class. + * + * @return an instance of Group1AsyncClient. + */ + @Generated + public Group1AsyncClient buildGroup1AsyncClient() { + return new Group1AsyncClient(buildInnerClient().getGroup1s()); + } + + /** + * Builds an instance of Group2AsyncClient class. + * + * @return an instance of Group2AsyncClient. + */ + @Generated + public Group2AsyncClient buildGroup2AsyncClient() { + return new Group2AsyncClient(buildInnerClient().getGroup2s()); + } + + /** + * Builds an instance of Group1Client class. + * + * @return an instance of Group1Client. + */ + @Generated + public Group1Client buildGroup1Client() { + return new Group1Client(buildInnerClient().getGroup1s()); + } + + /** + * Builds an instance of Group2Client class. + * + * @return an instance of Group2Client. + */ + @Generated + public Group2Client buildGroup2Client() { + return new Group2Client(buildInnerClient().getGroup2s()); + } + + private static final ClientLogger LOGGER = new ClientLogger(TwoOperationGroupClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/BarsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/BarsImpl.java new file mode 100644 index 000000000..cbaaebe08 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/BarsImpl.java @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 Bars. + */ +public final class BarsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BarsService service; + + /** + * The service client containing this operation class. + */ + private final ServiceClientClientImpl client; + + /** + * Initializes an instance of BarsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BarsImpl(ServiceClientClientImpl client) { + this.service = RestProxy.create(BarsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ServiceClientClientBars to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}/client/structure/{client}") + @ServiceInterface(name = "ServiceClientClientB") + public interface BarsService { + @Post("/five") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> five(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/five") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response fiveSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/six") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> six(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/six") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sixSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + } + + /** + * The five operation. + * + * @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> fiveWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.five(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The five operation. + * + * @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 fiveWithResponse(RequestOptions requestOptions) { + return service.fiveSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } + + /** + * The six operation. + * + * @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> sixWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.six(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The six operation. + * + * @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 sixWithResponse(RequestOptions requestOptions) { + return service.sixSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/BazFoosImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/BazFoosImpl.java new file mode 100644 index 000000000..4fec7b0a1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/BazFoosImpl.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 com.client.structure.service.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 BazFoos. + */ +public final class BazFoosImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BazFoosService service; + + /** + * The service client containing this operation class. + */ + private final ServiceClientClientImpl client; + + /** + * Initializes an instance of BazFoosImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BazFoosImpl(ServiceClientClientImpl client) { + this.service = RestProxy.create(BazFoosService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ServiceClientClientBazFoos to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}/client/structure/{client}") + @ServiceInterface(name = "ServiceClientClientB") + public interface BazFoosService { + @Post("/seven") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> seven(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/seven") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sevenSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + } + + /** + * The seven operation. + * + * @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> sevenWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.seven(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The seven operation. + * + * @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 sevenWithResponse(RequestOptions requestOptions) { + return service.sevenSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/ClientAClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/ClientAClientImpl.java new file mode 100644 index 000000000..0522be5c4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/ClientAClientImpl.java @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 ClientAClient type. + */ +public final class ClientAClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ClientAClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + private final String client; + + /** + * Gets Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + * + * @return the client value. + */ + public String getClient() { + return this.client; + } + + /** + * 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 ClientAClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public ClientAClientImpl(String endpoint, String client) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, client); + } + + /** + * Initializes an instance of ClientAClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public ClientAClientImpl(HttpPipeline httpPipeline, String endpoint, String client) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, client); + } + + /** + * Initializes an instance of ClientAClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public ClientAClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + String client) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.client = client; + this.service = RestProxy.create(ClientAClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for ClientAClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}/client/structure/{client}") + @ServiceInterface(name = "ClientAClient") + public interface ClientAClientService { + @Post("/one") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renamedOne(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/one") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renamedOneSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/three") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renamedThree(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/three") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renamedThreeSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/five") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renamedFive(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/five") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renamedFiveSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + } + + /** + * The renamedOne operation. + * + * @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> renamedOneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.renamedOne(this.getEndpoint(), this.getClient(), requestOptions, context)); + } + + /** + * The renamedOne operation. + * + * @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 renamedOneWithResponse(RequestOptions requestOptions) { + return service.renamedOneSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); + } + + /** + * The renamedThree operation. + * + * @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> renamedThreeWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.renamedThree(this.getEndpoint(), this.getClient(), requestOptions, context)); + } + + /** + * The renamedThree operation. + * + * @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 renamedThreeWithResponse(RequestOptions requestOptions) { + return service.renamedThreeSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); + } + + /** + * The renamedFive operation. + * + * @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> renamedFiveWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.renamedFive(this.getEndpoint(), this.getClient(), requestOptions, context)); + } + + /** + * The renamedFive operation. + * + * @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 renamedFiveWithResponse(RequestOptions requestOptions) { + return service.renamedFiveSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/ClientBClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/ClientBClientImpl.java new file mode 100644 index 000000000..e52b68219 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/ClientBClientImpl.java @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 ClientBClient type. + */ +public final class ClientBClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ClientBClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + private final String client; + + /** + * Gets Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + * + * @return the client value. + */ + public String getClient() { + return this.client; + } + + /** + * 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 ClientBClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public ClientBClientImpl(String endpoint, String client) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, client); + } + + /** + * Initializes an instance of ClientBClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public ClientBClientImpl(HttpPipeline httpPipeline, String endpoint, String client) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, client); + } + + /** + * Initializes an instance of ClientBClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public ClientBClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + String client) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.client = client; + this.service = RestProxy.create(ClientBClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for ClientBClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}/client/structure/{client}") + @ServiceInterface(name = "ClientBClient") + public interface ClientBClientService { + @Post("/two") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renamedTwo(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/two") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renamedTwoSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/four") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renamedFour(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/four") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renamedFourSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/six") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renamedSix(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/six") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renamedSixSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + } + + /** + * The renamedTwo operation. + * + * @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> renamedTwoWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.renamedTwo(this.getEndpoint(), this.getClient(), requestOptions, context)); + } + + /** + * The renamedTwo operation. + * + * @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 renamedTwoWithResponse(RequestOptions requestOptions) { + return service.renamedTwoSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); + } + + /** + * The renamedFour operation. + * + * @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> renamedFourWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.renamedFour(this.getEndpoint(), this.getClient(), requestOptions, context)); + } + + /** + * The renamedFour operation. + * + * @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 renamedFourWithResponse(RequestOptions requestOptions) { + return service.renamedFourSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); + } + + /** + * The renamedSix operation. + * + * @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> renamedSixWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.renamedSix(this.getEndpoint(), this.getClient(), requestOptions, context)); + } + + /** + * The renamedSix operation. + * + * @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 renamedSixWithResponse(RequestOptions requestOptions) { + return service.renamedSixSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/FoosImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/FoosImpl.java new file mode 100644 index 000000000..e83cf6bf7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/FoosImpl.java @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 Foos. + */ +public final class FoosImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FoosService service; + + /** + * The service client containing this operation class. + */ + private final ServiceClientClientImpl client; + + /** + * Initializes an instance of FoosImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FoosImpl(ServiceClientClientImpl client) { + this.service = RestProxy.create(FoosService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ServiceClientClientFoos to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}/client/structure/{client}") + @ServiceInterface(name = "ServiceClientClientF") + public interface FoosService { + @Post("/three") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> three(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/three") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response threeSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/four") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> four(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/four") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response fourSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + } + + /** + * The three operation. + * + * @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> threeWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.three(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The three operation. + * + * @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 threeWithResponse(RequestOptions requestOptions) { + return service.threeSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } + + /** + * The four operation. + * + * @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> fourWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.four(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The four operation. + * + * @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 fourWithResponse(RequestOptions requestOptions) { + return service.fourSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/Group1sImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/Group1sImpl.java new file mode 100644 index 000000000..bdd1938e5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/Group1sImpl.java @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 Group1s. + */ +public final class Group1sImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Group1sService service; + + /** + * The service client containing this operation class. + */ + private final TwoOperationGroupClientImpl client; + + /** + * Initializes an instance of Group1sImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Group1sImpl(TwoOperationGroupClientImpl client) { + this.service = RestProxy.create(Group1sService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for TwoOperationGroupClientGroup1s to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}/client/structure/{client}") + @ServiceInterface(name = "TwoOperationGroupCli") + public interface Group1sService { + @Post("/one") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> one(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/one") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response oneSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/three") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> three(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/three") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response threeSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/four") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> four(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/four") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response fourSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + } + + /** + * The one operation. + * + * @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> oneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.one(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The one operation. + * + * @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 oneWithResponse(RequestOptions requestOptions) { + return service.oneSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } + + /** + * The three operation. + * + * @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> threeWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.three(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The three operation. + * + * @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 threeWithResponse(RequestOptions requestOptions) { + return service.threeSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } + + /** + * The four operation. + * + * @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> fourWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.four(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The four operation. + * + * @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 fourWithResponse(RequestOptions requestOptions) { + return service.fourSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/Group2sImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/Group2sImpl.java new file mode 100644 index 000000000..01e5b5591 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/Group2sImpl.java @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 Group2s. + */ +public final class Group2sImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Group2sService service; + + /** + * The service client containing this operation class. + */ + private final TwoOperationGroupClientImpl client; + + /** + * Initializes an instance of Group2sImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Group2sImpl(TwoOperationGroupClientImpl client) { + this.service = RestProxy.create(Group2sService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for TwoOperationGroupClientGroup2s to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}/client/structure/{client}") + @ServiceInterface(name = "TwoOperationGroupCli") + public interface Group2sService { + @Post("/two") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> two(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/two") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response twoSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/five") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> five(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/five") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response fiveSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/six") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> six(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/six") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sixSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + } + + /** + * The two operation. + * + * @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> twoWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.two(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The two operation. + * + * @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 twoWithResponse(RequestOptions requestOptions) { + return service.twoSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } + + /** + * The five operation. + * + * @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> fiveWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.five(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The five operation. + * + * @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 fiveWithResponse(RequestOptions requestOptions) { + return service.fiveSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } + + /** + * The six operation. + * + * @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> sixWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.six(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The six operation. + * + * @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 sixWithResponse(RequestOptions requestOptions) { + return service.sixSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/GroupsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/GroupsImpl.java new file mode 100644 index 000000000..3d5398973 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/GroupsImpl.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 com.client.structure.service.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 Groups. + */ +public final class GroupsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final GroupsService service; + + /** + * The service client containing this operation class. + */ + private final RenamedOperationClientImpl client; + + /** + * Initializes an instance of GroupsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + GroupsImpl(RenamedOperationClientImpl client) { + this.service = RestProxy.create(GroupsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for RenamedOperationClientGroups to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}/client/structure/{client}") + @ServiceInterface(name = "RenamedOperationClie") + public interface GroupsService { + @Post("/two") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renamedTwo(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/two") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renamedTwoSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/four") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renamedFour(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/four") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renamedFourSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/six") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renamedSix(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/six") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renamedSixSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + } + + /** + * The renamedTwo operation. + * + * @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> renamedTwoWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.renamedTwo(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The renamedTwo operation. + * + * @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 renamedTwoWithResponse(RequestOptions requestOptions) { + return service.renamedTwoSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } + + /** + * The renamedFour operation. + * + * @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> renamedFourWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.renamedFour(this.client.getEndpoint(), this.client.getClient(), + requestOptions, context)); + } + + /** + * The renamedFour operation. + * + * @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 renamedFourWithResponse(RequestOptions requestOptions) { + return service.renamedFourSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, + Context.NONE); + } + + /** + * The renamedSix operation. + * + * @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> renamedSixWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.renamedSix(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The renamedSix operation. + * + * @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 renamedSixWithResponse(RequestOptions requestOptions) { + return service.renamedSixSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/QuxBarsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/QuxBarsImpl.java new file mode 100644 index 000000000..c1fd91c81 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/QuxBarsImpl.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 com.client.structure.service.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 QuxBars. + */ +public final class QuxBarsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QuxBarsService service; + + /** + * The service client containing this operation class. + */ + private final ServiceClientClientImpl client; + + /** + * Initializes an instance of QuxBarsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QuxBarsImpl(ServiceClientClientImpl client) { + this.service = RestProxy.create(QuxBarsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ServiceClientClientQuxBars to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}/client/structure/{client}") + @ServiceInterface(name = "ServiceClientClientQ") + public interface QuxBarsService { + @Post("/nine") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> nine(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/nine") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response nineSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + } + + /** + * The nine operation. + * + * @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> nineWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.nine(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The nine operation. + * + * @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 nineWithResponse(RequestOptions requestOptions) { + return service.nineSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/QuxesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/QuxesImpl.java new file mode 100644 index 000000000..7ef995cda --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/QuxesImpl.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 com.client.structure.service.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 Quxes. + */ +public final class QuxesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QuxesService service; + + /** + * The service client containing this operation class. + */ + private final ServiceClientClientImpl client; + + /** + * Initializes an instance of QuxesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QuxesImpl(ServiceClientClientImpl client) { + this.service = RestProxy.create(QuxesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ServiceClientClientQuxes to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}/client/structure/{client}") + @ServiceInterface(name = "ServiceClientClientQ") + public interface QuxesService { + @Post("/eight") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> eight(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/eight") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response eightSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + } + + /** + * The eight operation. + * + * @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> eightWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.eight(this.client.getEndpoint(), this.client.getClient(), requestOptions, context)); + } + + /** + * The eight operation. + * + * @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 eightWithResponse(RequestOptions requestOptions) { + return service.eightSync(this.client.getEndpoint(), this.client.getClient(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/RenamedOperationClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/RenamedOperationClientImpl.java new file mode 100644 index 000000000..a0727fb3f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/RenamedOperationClientImpl.java @@ -0,0 +1,306 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 RenamedOperationClient type. + */ +public final class RenamedOperationClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RenamedOperationClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + private final String client; + + /** + * Gets Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + * + * @return the client value. + */ + public String getClient() { + return this.client; + } + + /** + * 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; + } + + /** + * The GroupsImpl object to access its operations. + */ + private final GroupsImpl groups; + + /** + * Gets the GroupsImpl object to access its operations. + * + * @return the GroupsImpl object. + */ + public GroupsImpl getGroups() { + return this.groups; + } + + /** + * Initializes an instance of RenamedOperationClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public RenamedOperationClientImpl(String endpoint, String client) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, client); + } + + /** + * Initializes an instance of RenamedOperationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public RenamedOperationClientImpl(HttpPipeline httpPipeline, String endpoint, String client) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, client); + } + + /** + * Initializes an instance of RenamedOperationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public RenamedOperationClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + String client) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.client = client; + this.groups = new GroupsImpl(this); + this.service + = RestProxy.create(RenamedOperationClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for RenamedOperationClient to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}/client/structure/{client}") + @ServiceInterface(name = "RenamedOperationClie") + public interface RenamedOperationClientService { + @Post("/one") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renamedOne(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/one") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renamedOneSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/three") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renamedThree(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/three") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renamedThreeSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/five") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> renamedFive(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/five") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response renamedFiveSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + } + + /** + * The renamedOne operation. + * + * @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> renamedOneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.renamedOne(this.getEndpoint(), this.getClient(), requestOptions, context)); + } + + /** + * The renamedOne operation. + * + * @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 renamedOneWithResponse(RequestOptions requestOptions) { + return service.renamedOneSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); + } + + /** + * The renamedThree operation. + * + * @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> renamedThreeWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.renamedThree(this.getEndpoint(), this.getClient(), requestOptions, context)); + } + + /** + * The renamedThree operation. + * + * @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 renamedThreeWithResponse(RequestOptions requestOptions) { + return service.renamedThreeSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); + } + + /** + * The renamedFive operation. + * + * @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> renamedFiveWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.renamedFive(this.getEndpoint(), this.getClient(), requestOptions, context)); + } + + /** + * The renamedFive operation. + * + * @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 renamedFiveWithResponse(RequestOptions requestOptions) { + return service.renamedFiveSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/ServiceClientClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/ServiceClientClientImpl.java new file mode 100644 index 000000000..ffe789643 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/ServiceClientClientImpl.java @@ -0,0 +1,317 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 ServiceClientClient type. + */ +public final class ServiceClientClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ServiceClientClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + private final String client; + + /** + * Gets Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + * + * @return the client value. + */ + public String getClient() { + return this.client; + } + + /** + * 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; + } + + /** + * The BazFoosImpl object to access its operations. + */ + private final BazFoosImpl bazFoos; + + /** + * Gets the BazFoosImpl object to access its operations. + * + * @return the BazFoosImpl object. + */ + public BazFoosImpl getBazFoos() { + return this.bazFoos; + } + + /** + * The QuxesImpl object to access its operations. + */ + private final QuxesImpl quxes; + + /** + * Gets the QuxesImpl object to access its operations. + * + * @return the QuxesImpl object. + */ + public QuxesImpl getQuxes() { + return this.quxes; + } + + /** + * The QuxBarsImpl object to access its operations. + */ + private final QuxBarsImpl quxBars; + + /** + * Gets the QuxBarsImpl object to access its operations. + * + * @return the QuxBarsImpl object. + */ + public QuxBarsImpl getQuxBars() { + return this.quxBars; + } + + /** + * The FoosImpl object to access its operations. + */ + private final FoosImpl foos; + + /** + * Gets the FoosImpl object to access its operations. + * + * @return the FoosImpl object. + */ + public FoosImpl getFoos() { + return this.foos; + } + + /** + * The BarsImpl object to access its operations. + */ + private final BarsImpl bars; + + /** + * Gets the BarsImpl object to access its operations. + * + * @return the BarsImpl object. + */ + public BarsImpl getBars() { + return this.bars; + } + + /** + * Initializes an instance of ServiceClientClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public ServiceClientClientImpl(String endpoint, String client) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, client); + } + + /** + * Initializes an instance of ServiceClientClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public ServiceClientClientImpl(HttpPipeline httpPipeline, String endpoint, String client) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, client); + } + + /** + * Initializes an instance of ServiceClientClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public ServiceClientClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + String client) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.client = client; + this.bazFoos = new BazFoosImpl(this); + this.quxes = new QuxesImpl(this); + this.quxBars = new QuxBarsImpl(this); + this.foos = new FoosImpl(this); + this.bars = new BarsImpl(this); + this.service + = RestProxy.create(ServiceClientClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for ServiceClientClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}/client/structure/{client}") + @ServiceInterface(name = "ServiceClientClient") + public interface ServiceClientClientService { + @Post("/one") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> one(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/one") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response oneSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/two") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> two(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + + @Post("/two") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response twoSync(@HostParam("endpoint") String endpoint, @HostParam("client") String client, + RequestOptions requestOptions, Context context); + } + + /** + * The one operation. + * + * @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> oneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.one(this.getEndpoint(), this.getClient(), requestOptions, context)); + } + + /** + * The one operation. + * + * @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 oneWithResponse(RequestOptions requestOptions) { + return service.oneSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); + } + + /** + * The two operation. + * + * @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> twoWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.two(this.getEndpoint(), this.getClient(), requestOptions, context)); + } + + /** + * The two operation. + * + * @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 twoWithResponse(RequestOptions requestOptions) { + return service.twoSync(this.getEndpoint(), this.getClient(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/TwoOperationGroupClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/TwoOperationGroupClientImpl.java new file mode 100644 index 000000000..3f7d5359e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/TwoOperationGroupClientImpl.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the TwoOperationGroupClient type. + */ +public final class TwoOperationGroupClientImpl { + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + private final String client; + + /** + * Gets Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + * + * @return the client value. + */ + public String getClient() { + return this.client; + } + + /** + * 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; + } + + /** + * The Group1sImpl object to access its operations. + */ + private final Group1sImpl group1s; + + /** + * Gets the Group1sImpl object to access its operations. + * + * @return the Group1sImpl object. + */ + public Group1sImpl getGroup1s() { + return this.group1s; + } + + /** + * The Group2sImpl object to access its operations. + */ + private final Group2sImpl group2s; + + /** + * Gets the Group2sImpl object to access its operations. + * + * @return the Group2sImpl object. + */ + public Group2sImpl getGroup2s() { + return this.group2s; + } + + /** + * Initializes an instance of TwoOperationGroupClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public TwoOperationGroupClientImpl(String endpoint, String client) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, client); + } + + /** + * Initializes an instance of TwoOperationGroupClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public TwoOperationGroupClientImpl(HttpPipeline httpPipeline, String endpoint, String client) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, client); + } + + /** + * Initializes an instance of TwoOperationGroupClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param client Need to be set as 'default', 'multi-client', 'renamed-operation', 'two-operation-group' in client. + */ + public TwoOperationGroupClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + String client) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.client = client; + this.group1s = new Group1sImpl(this); + this.group2s = new Group2sImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/package-info.java new file mode 100644 index 000000000..a826ad8f3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/implementation/package-info.java @@ -0,0 +1,18 @@ +// 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 Service. + * Test that we can use @client and @operationGroup decorators to customize client side code structure, such + * as: + * 1. have everything as default. + * 2. to rename client or operation group + * 3. one client can have more than one operations groups + * 4. split one interface into two clients + * 5. have two clients with operations come from different interfaces + * 6. have two clients with a hierarchy relation. + * + */ +package com.client.structure.service.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/package-info.java new file mode 100644 index 000000000..620fd1727 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/client/structure/service/package-info.java @@ -0,0 +1,18 @@ +// 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 Service. + * Test that we can use @client and @operationGroup decorators to customize client side code structure, such + * as: + * 1. have everything as default. + * 2. to rename client or operation group + * 3. one client can have more than one operations groups + * 4. split one interface into two clients + * 5. have two clients with operations come from different interfaces + * 6. have two clients with a hierarchy relation. + * + */ +package com.client.structure.service; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/BytesClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/BytesClientBuilder.java new file mode 100644 index 000000000..df2b8d006 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/BytesClientBuilder.java @@ -0,0 +1,378 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.encode.bytes.implementation.BytesClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the BytesClient type. + */ +@ServiceClientBuilder( + serviceClients = { + QueryClient.class, + PropertyClient.class, + HeaderClient.class, + RequestBodyClient.class, + ResponseBodyClient.class, + QueryAsyncClient.class, + PropertyAsyncClient.class, + HeaderAsyncClient.class, + RequestBodyAsyncClient.class, + ResponseBodyAsyncClient.class }) +public final class BytesClientBuilder 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("encode-bytes.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the BytesClientBuilder. + */ + @Generated + public BytesClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BytesClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BytesClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BytesClientBuilder 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 BytesClientBuilder 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 BytesClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BytesClientBuilder 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 BytesClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BytesClientBuilder 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 BytesClientBuilder. + */ + @Generated + public BytesClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of BytesClientImpl with the provided parameters. + * + * @return an instance of BytesClientImpl. + */ + @Generated + private BytesClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + BytesClientImpl client + = new BytesClientImpl(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 QueryAsyncClient class. + * + * @return an instance of QueryAsyncClient. + */ + @Generated + public QueryAsyncClient buildQueryAsyncClient() { + return new QueryAsyncClient(buildInnerClient().getQueries()); + } + + /** + * Builds an instance of PropertyAsyncClient class. + * + * @return an instance of PropertyAsyncClient. + */ + @Generated + public PropertyAsyncClient buildPropertyAsyncClient() { + return new PropertyAsyncClient(buildInnerClient().getProperties()); + } + + /** + * Builds an instance of HeaderAsyncClient class. + * + * @return an instance of HeaderAsyncClient. + */ + @Generated + public HeaderAsyncClient buildHeaderAsyncClient() { + return new HeaderAsyncClient(buildInnerClient().getHeaders()); + } + + /** + * Builds an instance of RequestBodyAsyncClient class. + * + * @return an instance of RequestBodyAsyncClient. + */ + @Generated + public RequestBodyAsyncClient buildRequestBodyAsyncClient() { + return new RequestBodyAsyncClient(buildInnerClient().getRequestBodies()); + } + + /** + * Builds an instance of ResponseBodyAsyncClient class. + * + * @return an instance of ResponseBodyAsyncClient. + */ + @Generated + public ResponseBodyAsyncClient buildResponseBodyAsyncClient() { + return new ResponseBodyAsyncClient(buildInnerClient().getResponseBodies()); + } + + /** + * Builds an instance of QueryClient class. + * + * @return an instance of QueryClient. + */ + @Generated + public QueryClient buildQueryClient() { + return new QueryClient(buildInnerClient().getQueries()); + } + + /** + * Builds an instance of PropertyClient class. + * + * @return an instance of PropertyClient. + */ + @Generated + public PropertyClient buildPropertyClient() { + return new PropertyClient(buildInnerClient().getProperties()); + } + + /** + * Builds an instance of HeaderClient class. + * + * @return an instance of HeaderClient. + */ + @Generated + public HeaderClient buildHeaderClient() { + return new HeaderClient(buildInnerClient().getHeaders()); + } + + /** + * Builds an instance of RequestBodyClient class. + * + * @return an instance of RequestBodyClient. + */ + @Generated + public RequestBodyClient buildRequestBodyClient() { + return new RequestBodyClient(buildInnerClient().getRequestBodies()); + } + + /** + * Builds an instance of ResponseBodyClient class. + * + * @return an instance of ResponseBodyClient. + */ + @Generated + public ResponseBodyClient buildResponseBodyClient() { + return new ResponseBodyClient(buildInnerClient().getResponseBodies()); + } + + private static final ClientLogger LOGGER = new ClientLogger(BytesClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/HeaderAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/HeaderAsyncClient.java new file mode 100644 index 000000000..1c6f4aa3d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/HeaderAsyncClient.java @@ -0,0 +1,187 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes; + +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 com.encode.bytes.implementation.HeadersImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BytesClient type. + */ +@ServiceClient(builder = BytesClientBuilder.class, isAsync = true) +public final class HeaderAsyncClient { + @Generated + private final HeadersImpl serviceClient; + + /** + * Initializes an instance of HeaderAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + HeaderAsyncClient(HeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @param value The value 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> defaultMethodWithResponse(byte[] value, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponseAsync(value, requestOptions); + } + + /** + * The base64 operation. + * + * @param value The value 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> base64WithResponse(byte[] value, RequestOptions requestOptions) { + return this.serviceClient.base64WithResponseAsync(value, requestOptions); + } + + /** + * The base64url operation. + * + * @param value The value 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> base64urlWithResponse(byte[] value, RequestOptions requestOptions) { + return this.serviceClient.base64urlWithResponseAsync(value, requestOptions); + } + + /** + * The base64urlArray operation. + * + * @param value The value 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> base64urlArrayWithResponse(List value, RequestOptions requestOptions) { + return this.serviceClient.base64urlArrayWithResponseAsync(value, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethod(byte[] value) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The base64 operation. + * + * @param value The value 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 base64(byte[] value) { + // Generated convenience method for base64WithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64WithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The base64url operation. + * + * @param value The value 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 base64url(byte[] value) { + // Generated convenience method for base64urlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64urlWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The base64urlArray operation. + * + * @param value The value 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 base64urlArray(List value) { + // Generated convenience method for base64urlArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64urlArrayWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/HeaderClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/HeaderClient.java new file mode 100644 index 000000000..ebcfef71e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/HeaderClient.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes; + +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.encode.bytes.implementation.HeadersImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous BytesClient type. + */ +@ServiceClient(builder = BytesClientBuilder.class) +public final class HeaderClient { + @Generated + private final HeadersImpl serviceClient; + + /** + * Initializes an instance of HeaderClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + HeaderClient(HeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethodWithResponse(byte[] value, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponse(value, requestOptions); + } + + /** + * The base64 operation. + * + * @param value The value 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 base64WithResponse(byte[] value, RequestOptions requestOptions) { + return this.serviceClient.base64WithResponse(value, requestOptions); + } + + /** + * The base64url operation. + * + * @param value The value 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 base64urlWithResponse(byte[] value, RequestOptions requestOptions) { + return this.serviceClient.base64urlWithResponse(value, requestOptions); + } + + /** + * The base64urlArray operation. + * + * @param value The value 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 base64urlArrayWithResponse(List value, RequestOptions requestOptions) { + return this.serviceClient.base64urlArrayWithResponse(value, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethod(byte[] value) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + defaultMethodWithResponse(value, requestOptions).getValue(); + } + + /** + * The base64 operation. + * + * @param value The value 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 base64(byte[] value) { + // Generated convenience method for base64WithResponse + RequestOptions requestOptions = new RequestOptions(); + base64WithResponse(value, requestOptions).getValue(); + } + + /** + * The base64url operation. + * + * @param value The value 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 base64url(byte[] value) { + // Generated convenience method for base64urlWithResponse + RequestOptions requestOptions = new RequestOptions(); + base64urlWithResponse(value, requestOptions).getValue(); + } + + /** + * The base64urlArray operation. + * + * @param value The value 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 base64urlArray(List value) { + // Generated convenience method for base64urlArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + base64urlArrayWithResponse(value, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/PropertyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/PropertyAsyncClient.java new file mode 100644 index 000000000..15185865a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/PropertyAsyncClient.java @@ -0,0 +1,259 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes; + +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 com.encode.bytes.implementation.PropertiesImpl; +import com.encode.bytes.models.Base64BytesProperty; +import com.encode.bytes.models.Base64urlArrayBytesProperty; +import com.encode.bytes.models.Base64urlBytesProperty; +import com.encode.bytes.models.DefaultBytesProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BytesClient type. + */ +@ServiceClient(builder = BytesClientBuilder.class, isAsync = true) +public final class PropertyAsyncClient { + @Generated + private final PropertiesImpl serviceClient; + + /** + * Initializes an instance of PropertyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PropertyAsyncClient(PropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> defaultMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponseAsync(body, requestOptions); + } + + /** + * The base64 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> base64WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.base64WithResponseAsync(body, requestOptions); + } + + /** + * The base64url operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: Base64Url (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: Base64Url (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> base64urlWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.base64urlWithResponseAsync(body, requestOptions); + } + + /** + * The base64urlArray operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         Base64Url (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         Base64Url (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> base64urlArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.base64urlArrayWithResponseAsync(body, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono defaultMethod(DefaultBytesProperty body) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DefaultBytesProperty.class)); + } + + /** + * The base64 operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono base64(Base64BytesProperty body) { + // Generated convenience method for base64WithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64WithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Base64BytesProperty.class)); + } + + /** + * The base64url operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono base64url(Base64urlBytesProperty body) { + // Generated convenience method for base64urlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64urlWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Base64urlBytesProperty.class)); + } + + /** + * The base64urlArray operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono base64urlArray(Base64urlArrayBytesProperty body) { + // Generated convenience method for base64urlArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64urlArrayWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Base64urlArrayBytesProperty.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/PropertyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/PropertyClient.java new file mode 100644 index 000000000..ff873baa5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/PropertyClient.java @@ -0,0 +1,257 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes; + +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.encode.bytes.implementation.PropertiesImpl; +import com.encode.bytes.models.Base64BytesProperty; +import com.encode.bytes.models.Base64urlArrayBytesProperty; +import com.encode.bytes.models.Base64urlBytesProperty; +import com.encode.bytes.models.DefaultBytesProperty; + +/** + * Initializes a new instance of the synchronous BytesClient type. + */ +@ServiceClient(builder = BytesClientBuilder.class) +public final class PropertyClient { + @Generated + private final PropertiesImpl serviceClient; + + /** + * Initializes an instance of PropertyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PropertyClient(PropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response defaultMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponse(body, requestOptions); + } + + /** + * The base64 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response base64WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.base64WithResponse(body, requestOptions); + } + + /** + * The base64url operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: Base64Url (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: Base64Url (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response base64urlWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.base64urlWithResponse(body, requestOptions); + } + + /** + * The base64urlArray operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         Base64Url (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         Base64Url (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response base64urlArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.base64urlArrayWithResponse(body, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DefaultBytesProperty defaultMethod(DefaultBytesProperty body) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(DefaultBytesProperty.class); + } + + /** + * The base64 operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Base64BytesProperty base64(Base64BytesProperty body) { + // Generated convenience method for base64WithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64WithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(Base64BytesProperty.class); + } + + /** + * The base64url operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Base64urlBytesProperty base64url(Base64urlBytesProperty body) { + // Generated convenience method for base64urlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64urlWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(Base64urlBytesProperty.class); + } + + /** + * The base64urlArray operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Base64urlArrayBytesProperty base64urlArray(Base64urlArrayBytesProperty body) { + // Generated convenience method for base64urlArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64urlArrayWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(Base64urlArrayBytesProperty.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/QueryAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/QueryAsyncClient.java new file mode 100644 index 000000000..f1d8148e1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/QueryAsyncClient.java @@ -0,0 +1,187 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes; + +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 com.encode.bytes.implementation.QueriesImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BytesClient type. + */ +@ServiceClient(builder = BytesClientBuilder.class, isAsync = true) +public final class QueryAsyncClient { + @Generated + private final QueriesImpl serviceClient; + + /** + * Initializes an instance of QueryAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + QueryAsyncClient(QueriesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @param value The value 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> defaultMethodWithResponse(byte[] value, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponseAsync(value, requestOptions); + } + + /** + * The base64 operation. + * + * @param value The value 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> base64WithResponse(byte[] value, RequestOptions requestOptions) { + return this.serviceClient.base64WithResponseAsync(value, requestOptions); + } + + /** + * The base64url operation. + * + * @param value The value 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> base64urlWithResponse(byte[] value, RequestOptions requestOptions) { + return this.serviceClient.base64urlWithResponseAsync(value, requestOptions); + } + + /** + * The base64urlArray operation. + * + * @param value The value 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> base64urlArrayWithResponse(List value, RequestOptions requestOptions) { + return this.serviceClient.base64urlArrayWithResponseAsync(value, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethod(byte[] value) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The base64 operation. + * + * @param value The value 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 base64(byte[] value) { + // Generated convenience method for base64WithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64WithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The base64url operation. + * + * @param value The value 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 base64url(byte[] value) { + // Generated convenience method for base64urlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64urlWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The base64urlArray operation. + * + * @param value The value 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 base64urlArray(List value) { + // Generated convenience method for base64urlArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64urlArrayWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/QueryClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/QueryClient.java new file mode 100644 index 000000000..3f6c8ea6d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/QueryClient.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes; + +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.encode.bytes.implementation.QueriesImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous BytesClient type. + */ +@ServiceClient(builder = BytesClientBuilder.class) +public final class QueryClient { + @Generated + private final QueriesImpl serviceClient; + + /** + * Initializes an instance of QueryClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + QueryClient(QueriesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethodWithResponse(byte[] value, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponse(value, requestOptions); + } + + /** + * The base64 operation. + * + * @param value The value 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 base64WithResponse(byte[] value, RequestOptions requestOptions) { + return this.serviceClient.base64WithResponse(value, requestOptions); + } + + /** + * The base64url operation. + * + * @param value The value 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 base64urlWithResponse(byte[] value, RequestOptions requestOptions) { + return this.serviceClient.base64urlWithResponse(value, requestOptions); + } + + /** + * The base64urlArray operation. + * + * @param value The value 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 base64urlArrayWithResponse(List value, RequestOptions requestOptions) { + return this.serviceClient.base64urlArrayWithResponse(value, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethod(byte[] value) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + defaultMethodWithResponse(value, requestOptions).getValue(); + } + + /** + * The base64 operation. + * + * @param value The value 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 base64(byte[] value) { + // Generated convenience method for base64WithResponse + RequestOptions requestOptions = new RequestOptions(); + base64WithResponse(value, requestOptions).getValue(); + } + + /** + * The base64url operation. + * + * @param value The value 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 base64url(byte[] value) { + // Generated convenience method for base64urlWithResponse + RequestOptions requestOptions = new RequestOptions(); + base64urlWithResponse(value, requestOptions).getValue(); + } + + /** + * The base64urlArray operation. + * + * @param value The value 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 base64urlArray(List value) { + // Generated convenience method for base64urlArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + base64urlArrayWithResponse(value, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/RequestBodyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/RequestBodyAsyncClient.java new file mode 100644 index 000000000..1cde0b084 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/RequestBodyAsyncClient.java @@ -0,0 +1,251 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes; + +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.Base64Url; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import com.encode.bytes.implementation.RequestBodiesImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BytesClient type. + */ +@ServiceClient(builder = BytesClientBuilder.class, isAsync = true) +public final class RequestBodyAsyncClient { + @Generated + private final RequestBodiesImpl serviceClient; + + /** + * Initializes an instance of RequestBodyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RequestBodyAsyncClient(RequestBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @param value The value 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> defaultMethodWithResponse(BinaryData value, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponseAsync(value, requestOptions); + } + + /** + * The octetStream operation. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param value The value 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> octetStreamWithResponse(BinaryData value, RequestOptions requestOptions) { + return this.serviceClient.octetStreamWithResponseAsync(value, requestOptions); + } + + /** + * The customContentType operation. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param value The value 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> customContentTypeWithResponse(BinaryData value, RequestOptions requestOptions) { + return this.serviceClient.customContentTypeWithResponseAsync(value, requestOptions); + } + + /** + * The base64 operation. + *

Request Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @param value The value 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> base64WithResponse(BinaryData value, RequestOptions requestOptions) { + return this.serviceClient.base64WithResponseAsync(value, requestOptions); + } + + /** + * The base64url operation. + *

Request Body Schema

+ * + *
{@code
+     * Base64Url
+     * }
+ * + * @param value The value 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> base64urlWithResponse(BinaryData value, RequestOptions requestOptions) { + return this.serviceClient.base64urlWithResponseAsync(value, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethod(byte[] value) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(BinaryData.fromObject(value), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The octetStream operation. + * + * @param value The value 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 octetStream(BinaryData value) { + // Generated convenience method for octetStreamWithResponse + RequestOptions requestOptions = new RequestOptions(); + return octetStreamWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The customContentType operation. + * + * @param value The value 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 customContentType(BinaryData value) { + // Generated convenience method for customContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return customContentTypeWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The base64 operation. + * + * @param value The value 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 base64(byte[] value) { + // Generated convenience method for base64WithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64WithResponse(BinaryData.fromObject(value), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The base64url operation. + * + * @param value The value 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 base64url(byte[] value) { + // Generated convenience method for base64urlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64urlWithResponse(BinaryData.fromObject(Base64Url.encode(value)), requestOptions) + .flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/RequestBodyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/RequestBodyClient.java new file mode 100644 index 000000000..b5e7b95b0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/RequestBodyClient.java @@ -0,0 +1,243 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes; + +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.Base64Url; +import com.azure.core.util.BinaryData; +import com.encode.bytes.implementation.RequestBodiesImpl; + +/** + * Initializes a new instance of the synchronous BytesClient type. + */ +@ServiceClient(builder = BytesClientBuilder.class) +public final class RequestBodyClient { + @Generated + private final RequestBodiesImpl serviceClient; + + /** + * Initializes an instance of RequestBodyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RequestBodyClient(RequestBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @param value The value 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 defaultMethodWithResponse(BinaryData value, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponse(value, requestOptions); + } + + /** + * The octetStream operation. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param value The value 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 octetStreamWithResponse(BinaryData value, RequestOptions requestOptions) { + return this.serviceClient.octetStreamWithResponse(value, requestOptions); + } + + /** + * The customContentType operation. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param value The value 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 customContentTypeWithResponse(BinaryData value, RequestOptions requestOptions) { + return this.serviceClient.customContentTypeWithResponse(value, requestOptions); + } + + /** + * The base64 operation. + *

Request Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @param value The value 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 base64WithResponse(BinaryData value, RequestOptions requestOptions) { + return this.serviceClient.base64WithResponse(value, requestOptions); + } + + /** + * The base64url operation. + *

Request Body Schema

+ * + *
{@code
+     * Base64Url
+     * }
+ * + * @param value The value 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 base64urlWithResponse(BinaryData value, RequestOptions requestOptions) { + return this.serviceClient.base64urlWithResponse(value, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethod(byte[] value) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + defaultMethodWithResponse(BinaryData.fromObject(value), requestOptions).getValue(); + } + + /** + * The octetStream operation. + * + * @param value The value 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 octetStream(BinaryData value) { + // Generated convenience method for octetStreamWithResponse + RequestOptions requestOptions = new RequestOptions(); + octetStreamWithResponse(value, requestOptions).getValue(); + } + + /** + * The customContentType operation. + * + * @param value The value 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 customContentType(BinaryData value) { + // Generated convenience method for customContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + customContentTypeWithResponse(value, requestOptions).getValue(); + } + + /** + * The base64 operation. + * + * @param value The value 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 base64(byte[] value) { + // Generated convenience method for base64WithResponse + RequestOptions requestOptions = new RequestOptions(); + base64WithResponse(BinaryData.fromObject(value), requestOptions).getValue(); + } + + /** + * The base64url operation. + * + * @param value The value 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 base64url(byte[] value) { + // Generated convenience method for base64urlWithResponse + RequestOptions requestOptions = new RequestOptions(); + base64urlWithResponse(BinaryData.fromObject(Base64Url.encode(value)), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/ResponseBodyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/ResponseBodyAsyncClient.java new file mode 100644 index 000000000..ab7775c60 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/ResponseBodyAsyncClient.java @@ -0,0 +1,238 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes; + +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.Base64Url; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import com.encode.bytes.implementation.ResponseBodiesImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BytesClient type. + */ +@ServiceClient(builder = BytesClientBuilder.class, isAsync = true) +public final class ResponseBodyAsyncClient { + @Generated + private final ResponseBodiesImpl serviceClient; + + /** + * Initializes an instance of ResponseBodyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ResponseBodyAsyncClient(ResponseBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + *

Response Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @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 represent a byte array along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> defaultMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponseAsync(requestOptions); + } + + /** + * The octetStream operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> octetStreamWithResponse(RequestOptions requestOptions) { + return this.serviceClient.octetStreamWithResponseAsync(requestOptions); + } + + /** + * The customContentType operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> customContentTypeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.customContentTypeWithResponseAsync(requestOptions); + } + + /** + * The base64 operation. + *

Response Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @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 represent a byte array along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> base64WithResponse(RequestOptions requestOptions) { + return this.serviceClient.base64WithResponseAsync(requestOptions); + } + + /** + * The base64url operation. + *

Response Body Schema

+ * + *
{@code
+     * Base64Url
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> base64urlWithResponse(RequestOptions requestOptions) { + return this.serviceClient.base64urlWithResponseAsync(requestOptions); + } + + /** + * The defaultMethod 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 represent a byte array on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono defaultMethod() { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(byte[].class)); + } + + /** + * The octetStream 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono octetStream() { + // Generated convenience method for octetStreamWithResponse + RequestOptions requestOptions = new RequestOptions(); + return octetStreamWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The customContentType 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono customContentType() { + // Generated convenience method for customContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return customContentTypeWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The base64 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 represent a byte array on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono base64() { + // Generated convenience method for base64WithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64WithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(byte[].class)); + } + + /** + * The base64url 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono base64url() { + // Generated convenience method for base64urlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64urlWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Base64Url.class).decodedBytes()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/ResponseBodyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/ResponseBodyClient.java new file mode 100644 index 000000000..a6660515b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/ResponseBodyClient.java @@ -0,0 +1,233 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes; + +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.Base64Url; +import com.azure.core.util.BinaryData; +import com.encode.bytes.implementation.ResponseBodiesImpl; + +/** + * Initializes a new instance of the synchronous BytesClient type. + */ +@ServiceClient(builder = BytesClientBuilder.class) +public final class ResponseBodyClient { + @Generated + private final ResponseBodiesImpl serviceClient; + + /** + * Initializes an instance of ResponseBodyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ResponseBodyClient(ResponseBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + *

Response Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @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 represent a byte array along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response defaultMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponse(requestOptions); + } + + /** + * The octetStream operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response octetStreamWithResponse(RequestOptions requestOptions) { + return this.serviceClient.octetStreamWithResponse(requestOptions); + } + + /** + * The customContentType operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response customContentTypeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.customContentTypeWithResponse(requestOptions); + } + + /** + * The base64 operation. + *

Response Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @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 represent a byte array along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response base64WithResponse(RequestOptions requestOptions) { + return this.serviceClient.base64WithResponse(requestOptions); + } + + /** + * The base64url operation. + *

Response Body Schema

+ * + *
{@code
+     * Base64Url
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response base64urlWithResponse(RequestOptions requestOptions) { + return this.serviceClient.base64urlWithResponse(requestOptions); + } + + /** + * The defaultMethod 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 represent a byte array. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public byte[] defaultMethod() { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(requestOptions).getValue().toObject(byte[].class); + } + + /** + * The octetStream 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData octetStream() { + // Generated convenience method for octetStreamWithResponse + RequestOptions requestOptions = new RequestOptions(); + return octetStreamWithResponse(requestOptions).getValue(); + } + + /** + * The customContentType 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData customContentType() { + // Generated convenience method for customContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return customContentTypeWithResponse(requestOptions).getValue(); + } + + /** + * The base64 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 represent a byte array. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public byte[] base64() { + // Generated convenience method for base64WithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64WithResponse(requestOptions).getValue().toObject(byte[].class); + } + + /** + * The base64url 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public byte[] base64url() { + // Generated convenience method for base64urlWithResponse + RequestOptions requestOptions = new RequestOptions(); + return base64urlWithResponse(requestOptions).getValue().toObject(Base64Url.class).decodedBytes(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/BytesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/BytesClientImpl.java new file mode 100644 index 000000000..e6da811f4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/BytesClientImpl.java @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the BytesClient type. + */ +public final class BytesClientImpl { + /** + * 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; + } + + /** + * The QueriesImpl object to access its operations. + */ + private final QueriesImpl queries; + + /** + * Gets the QueriesImpl object to access its operations. + * + * @return the QueriesImpl object. + */ + public QueriesImpl getQueries() { + return this.queries; + } + + /** + * The PropertiesImpl object to access its operations. + */ + private final PropertiesImpl properties; + + /** + * Gets the PropertiesImpl object to access its operations. + * + * @return the PropertiesImpl object. + */ + public PropertiesImpl getProperties() { + return this.properties; + } + + /** + * The HeadersImpl object to access its operations. + */ + private final HeadersImpl headers; + + /** + * Gets the HeadersImpl object to access its operations. + * + * @return the HeadersImpl object. + */ + public HeadersImpl getHeaders() { + return this.headers; + } + + /** + * The RequestBodiesImpl object to access its operations. + */ + private final RequestBodiesImpl requestBodies; + + /** + * Gets the RequestBodiesImpl object to access its operations. + * + * @return the RequestBodiesImpl object. + */ + public RequestBodiesImpl getRequestBodies() { + return this.requestBodies; + } + + /** + * The ResponseBodiesImpl object to access its operations. + */ + private final ResponseBodiesImpl responseBodies; + + /** + * Gets the ResponseBodiesImpl object to access its operations. + * + * @return the ResponseBodiesImpl object. + */ + public ResponseBodiesImpl getResponseBodies() { + return this.responseBodies; + } + + /** + * Initializes an instance of BytesClient client. + * + * @param endpoint Service host. + */ + public BytesClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of BytesClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public BytesClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of BytesClient 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 BytesClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.queries = new QueriesImpl(this); + this.properties = new PropertiesImpl(this); + this.headers = new HeadersImpl(this); + this.requestBodies = new RequestBodiesImpl(this); + this.responseBodies = new ResponseBodiesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/HeadersImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/HeadersImpl.java new file mode 100644 index 000000000..583636ef7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/HeadersImpl.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 com.encode.bytes.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.Base64Url; +import com.azure.core.util.Base64Util; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.CollectionFormat; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.List; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Headers. + */ +public final class HeadersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final HeadersService service; + + /** + * The service client containing this operation class. + */ + private final BytesClientImpl client; + + /** + * Initializes an instance of HeadersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + HeadersImpl(BytesClientImpl client) { + this.service = RestProxy.create(HeadersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for BytesClientHeaders to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BytesClientHeaders") + public interface HeadersService { + @Get("/encode/bytes/header/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> defaultMethod(@HostParam("endpoint") String endpoint, @HeaderParam("value") String value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/header/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defaultMethodSync(@HostParam("endpoint") String endpoint, @HeaderParam("value") String value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/header/base64") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64(@HostParam("endpoint") String endpoint, @HeaderParam("value") String value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/header/base64") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64Sync(@HostParam("endpoint") String endpoint, @HeaderParam("value") String value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/header/base64url") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64url(@HostParam("endpoint") String endpoint, @HeaderParam("value") Base64Url value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/header/base64url") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64urlSync(@HostParam("endpoint") String endpoint, @HeaderParam("value") Base64Url value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/header/base64url-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64urlArray(@HostParam("endpoint") String endpoint, @HeaderParam("value") String value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/header/base64url-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64urlArraySync(@HostParam("endpoint") String endpoint, @HeaderParam("value") String value, + RequestOptions requestOptions, Context context); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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> defaultMethodWithResponseAsync(byte[] value, RequestOptions requestOptions) { + String valueConverted = Base64Util.encodeToString(value); + return FluxUtil.withContext( + context -> service.defaultMethod(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethodWithResponse(byte[] value, RequestOptions requestOptions) { + String valueConverted = Base64Util.encodeToString(value); + return service.defaultMethodSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } + + /** + * The base64 operation. + * + * @param value The value 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> base64WithResponseAsync(byte[] value, RequestOptions requestOptions) { + String valueConverted = Base64Util.encodeToString(value); + return FluxUtil + .withContext(context -> service.base64(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The base64 operation. + * + * @param value The value 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 base64WithResponse(byte[] value, RequestOptions requestOptions) { + String valueConverted = Base64Util.encodeToString(value); + return service.base64Sync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } + + /** + * The base64url operation. + * + * @param value The value 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> base64urlWithResponseAsync(byte[] value, RequestOptions requestOptions) { + Base64Url valueConverted = Base64Url.encode(value); + return FluxUtil.withContext( + context -> service.base64url(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The base64url operation. + * + * @param value The value 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 base64urlWithResponse(byte[] value, RequestOptions requestOptions) { + Base64Url valueConverted = Base64Url.encode(value); + return service.base64urlSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } + + /** + * The base64urlArray operation. + * + * @param value The value 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> base64urlArrayWithResponseAsync(List value, RequestOptions requestOptions) { + String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() + .serializeIterable( + value.stream().map(paramItemValue -> Base64Url.encode(paramItemValue)).collect(Collectors.toList()), + CollectionFormat.CSV); + return FluxUtil.withContext( + context -> service.base64urlArray(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The base64urlArray operation. + * + * @param value The value 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 base64urlArrayWithResponse(List value, RequestOptions requestOptions) { + String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() + .serializeIterable( + value.stream().map(paramItemValue -> Base64Url.encode(paramItemValue)).collect(Collectors.toList()), + CollectionFormat.CSV); + return service.base64urlArraySync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/PropertiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/PropertiesImpl.java new file mode 100644 index 000000000..cf13e81e8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/PropertiesImpl.java @@ -0,0 +1,420 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Properties. + */ +public final class PropertiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PropertiesService service; + + /** + * The service client containing this operation class. + */ + private final BytesClientImpl client; + + /** + * Initializes an instance of PropertiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PropertiesImpl(BytesClientImpl client) { + this.service + = RestProxy.create(PropertiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for BytesClientProperties to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BytesClientPropertie") + public interface PropertiesService { + @Post("/encode/bytes/property/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> defaultMethod(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/property/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defaultMethodSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/property/base64") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/property/base64") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64Sync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/property/base64url") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64url(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/property/base64url") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64urlSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/property/base64url-array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64urlArray(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/property/base64url-array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64urlArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> defaultMethodWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.defaultMethod(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response defaultMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.defaultMethodSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The base64 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> base64WithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.base64(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); + } + + /** + * The base64 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: byte[] (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response base64WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.base64Sync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); + } + + /** + * The base64url operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: Base64Url (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: Base64Url (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> base64urlWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.base64url(this.client.getEndpoint(), contentType, accept, body, + requestOptions, context)); + } + + /** + * The base64url operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: Base64Url (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: Base64Url (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response base64urlWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.base64urlSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The base64urlArray operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         Base64Url (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         Base64Url (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> base64urlArrayWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.base64urlArray(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The base64urlArray operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         Base64Url (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         Base64Url (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response base64urlArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.base64urlArraySync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/QueriesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/QueriesImpl.java new file mode 100644 index 000000000..238ac4a18 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/QueriesImpl.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 com.encode.bytes.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.Base64Url; +import com.azure.core.util.Base64Util; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.CollectionFormat; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.List; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Queries. + */ +public final class QueriesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QueriesService service; + + /** + * The service client containing this operation class. + */ + private final BytesClientImpl client; + + /** + * Initializes an instance of QueriesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QueriesImpl(BytesClientImpl client) { + this.service = RestProxy.create(QueriesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for BytesClientQueries to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BytesClientQueries") + public interface QueriesService { + @Get("/encode/bytes/query/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> defaultMethod(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/query/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defaultMethodSync(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/query/base64") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/query/base64") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64Sync(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/query/base64url") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64url(@HostParam("endpoint") String endpoint, @QueryParam("value") Base64Url value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/query/base64url") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64urlSync(@HostParam("endpoint") String endpoint, @QueryParam("value") Base64Url value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/query/base64url-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64urlArray(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/query/base64url-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64urlArraySync(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, + RequestOptions requestOptions, Context context); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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> defaultMethodWithResponseAsync(byte[] value, RequestOptions requestOptions) { + String valueConverted = Base64Util.encodeToString(value); + return FluxUtil.withContext( + context -> service.defaultMethod(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethodWithResponse(byte[] value, RequestOptions requestOptions) { + String valueConverted = Base64Util.encodeToString(value); + return service.defaultMethodSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } + + /** + * The base64 operation. + * + * @param value The value 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> base64WithResponseAsync(byte[] value, RequestOptions requestOptions) { + String valueConverted = Base64Util.encodeToString(value); + return FluxUtil + .withContext(context -> service.base64(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The base64 operation. + * + * @param value The value 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 base64WithResponse(byte[] value, RequestOptions requestOptions) { + String valueConverted = Base64Util.encodeToString(value); + return service.base64Sync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } + + /** + * The base64url operation. + * + * @param value The value 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> base64urlWithResponseAsync(byte[] value, RequestOptions requestOptions) { + Base64Url valueConverted = Base64Url.encode(value); + return FluxUtil.withContext( + context -> service.base64url(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The base64url operation. + * + * @param value The value 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 base64urlWithResponse(byte[] value, RequestOptions requestOptions) { + Base64Url valueConverted = Base64Url.encode(value); + return service.base64urlSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } + + /** + * The base64urlArray operation. + * + * @param value The value 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> base64urlArrayWithResponseAsync(List value, RequestOptions requestOptions) { + String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() + .serializeIterable( + value.stream().map(paramItemValue -> Base64Url.encode(paramItemValue)).collect(Collectors.toList()), + CollectionFormat.CSV); + return FluxUtil.withContext( + context -> service.base64urlArray(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The base64urlArray operation. + * + * @param value The value 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 base64urlArrayWithResponse(List value, RequestOptions requestOptions) { + String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() + .serializeIterable( + value.stream().map(paramItemValue -> Base64Url.encode(paramItemValue)).collect(Collectors.toList()), + CollectionFormat.CSV); + return service.base64urlArraySync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/RequestBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/RequestBodiesImpl.java new file mode 100644 index 000000000..87b035b66 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/RequestBodiesImpl.java @@ -0,0 +1,387 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in RequestBodies. + */ +public final class RequestBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RequestBodiesService service; + + /** + * The service client containing this operation class. + */ + private final BytesClientImpl client; + + /** + * Initializes an instance of RequestBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + RequestBodiesImpl(BytesClientImpl client) { + this.service + = RestProxy.create(RequestBodiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for BytesClientRequestBodies to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BytesClientRequestBo") + public interface RequestBodiesService { + @Post("/encode/bytes/body/request/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> defaultMethod(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData value, + RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/body/request/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defaultMethodSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData value, + RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/body/request/octet-stream") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> octetStream(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/octet-stream") BinaryData value, + RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/body/request/octet-stream") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response octetStreamSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/octet-stream") BinaryData value, + RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/body/request/custom-content-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> customContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("image/png") BinaryData value, + RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/body/request/custom-content-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response customContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("image/png") BinaryData value, + RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/body/request/base64") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData value, + RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/body/request/base64") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64Sync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData value, + RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/body/request/base64url") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64url(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData value, + RequestOptions requestOptions, Context context); + + @Post("/encode/bytes/body/request/base64url") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64urlSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData value, + RequestOptions requestOptions, Context context); + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @param value The value 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> defaultMethodWithResponseAsync(BinaryData value, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.defaultMethod(this.client.getEndpoint(), contentType, value, requestOptions, context)); + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @param value The value 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 defaultMethodWithResponse(BinaryData value, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.defaultMethodSync(this.client.getEndpoint(), contentType, value, requestOptions, Context.NONE); + } + + /** + * The octetStream operation. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param value The value 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> octetStreamWithResponseAsync(BinaryData value, RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + return FluxUtil.withContext( + context -> service.octetStream(this.client.getEndpoint(), contentType, value, requestOptions, context)); + } + + /** + * The octetStream operation. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param value The value 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 octetStreamWithResponse(BinaryData value, RequestOptions requestOptions) { + final String contentType = "application/octet-stream"; + return service.octetStreamSync(this.client.getEndpoint(), contentType, value, requestOptions, Context.NONE); + } + + /** + * The customContentType operation. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param value The value 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> customContentTypeWithResponseAsync(BinaryData value, RequestOptions requestOptions) { + final String contentType = "image/png"; + return FluxUtil.withContext(context -> service.customContentType(this.client.getEndpoint(), contentType, value, + requestOptions, context)); + } + + /** + * The customContentType operation. + *

Request Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @param value The value 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 customContentTypeWithResponse(BinaryData value, RequestOptions requestOptions) { + final String contentType = "image/png"; + return service.customContentTypeSync(this.client.getEndpoint(), contentType, value, requestOptions, + Context.NONE); + } + + /** + * The base64 operation. + *

Request Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @param value The value 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> base64WithResponseAsync(BinaryData value, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.base64(this.client.getEndpoint(), contentType, value, requestOptions, context)); + } + + /** + * The base64 operation. + *

Request Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @param value The value 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 base64WithResponse(BinaryData value, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.base64Sync(this.client.getEndpoint(), contentType, value, requestOptions, Context.NONE); + } + + /** + * The base64url operation. + *

Request Body Schema

+ * + *
{@code
+     * Base64Url
+     * }
+ * + * @param value The value 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> base64urlWithResponseAsync(BinaryData value, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.base64url(this.client.getEndpoint(), contentType, value, requestOptions, context)); + } + + /** + * The base64url operation. + *

Request Body Schema

+ * + *
{@code
+     * Base64Url
+     * }
+ * + * @param value The value 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 base64urlWithResponse(BinaryData value, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.base64urlSync(this.client.getEndpoint(), contentType, value, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/ResponseBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/ResponseBodiesImpl.java new file mode 100644 index 000000000..8f84bfe68 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/ResponseBodiesImpl.java @@ -0,0 +1,365 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.BinaryData; +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 ResponseBodies. + */ +public final class ResponseBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ResponseBodiesService service; + + /** + * The service client containing this operation class. + */ + private final BytesClientImpl client; + + /** + * Initializes an instance of ResponseBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ResponseBodiesImpl(BytesClientImpl client) { + this.service + = RestProxy.create(ResponseBodiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for BytesClientResponseBodies to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BytesClientResponseB") + public interface ResponseBodiesService { + @Get("/encode/bytes/body/response/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> defaultMethod(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/body/response/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defaultMethodSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/body/response/octet-stream") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> octetStream(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/body/response/octet-stream") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response octetStreamSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/body/response/custom-content-type") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> customContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/body/response/custom-content-type") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response customContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/body/response/base64") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/body/response/base64") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64Sync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/body/response/base64url") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> base64url(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/encode/bytes/body/response/base64url") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response base64urlSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * The defaultMethod operation. + *

Response Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @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 represent a byte array along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> defaultMethodWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.defaultMethod(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The defaultMethod operation. + *

Response Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @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 represent a byte array along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response defaultMethodWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.defaultMethodSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The octetStream operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> octetStreamWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/octet-stream"; + return FluxUtil + .withContext(context -> service.octetStream(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The octetStream operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response octetStreamWithResponse(RequestOptions requestOptions) { + final String accept = "application/octet-stream"; + return service.octetStreamSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The customContentType operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> customContentTypeWithResponseAsync(RequestOptions requestOptions) { + final String accept = "image/png"; + return FluxUtil.withContext( + context -> service.customContentType(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The customContentType operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response customContentTypeWithResponse(RequestOptions requestOptions) { + final String accept = "image/png"; + return service.customContentTypeSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The base64 operation. + *

Response Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @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 represent a byte array along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> base64WithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.base64(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The base64 operation. + *

Response Body Schema

+ * + *
{@code
+     * byte[]
+     * }
+ * + * @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 represent a byte array along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response base64WithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.base64Sync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The base64url operation. + *

Response Body Schema

+ * + *
{@code
+     * Base64Url
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> base64urlWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.base64url(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The base64url operation. + *

Response Body Schema

+ * + *
{@code
+     * Base64Url
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response base64urlWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.base64urlSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/implementation/package-info.java new file mode 100644 index 000000000..ebbba3d63 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/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 Bytes. + * Test for encode decorator on bytes. + * + */ +package com.encode.bytes.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/Base64BytesProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/Base64BytesProperty.java new file mode 100644 index 000000000..9be79abd2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/Base64BytesProperty.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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 Base64BytesProperty model. + */ +@Immutable +public final class Base64BytesProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final byte[] value; + + /** + * Creates an instance of Base64BytesProperty class. + * + * @param value the value value to set. + */ + @Generated + public Base64BytesProperty(byte[] value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public byte[] getValue() { + return CoreUtils.clone(this.value); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBinaryField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Base64BytesProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Base64BytesProperty 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 Base64BytesProperty. + */ + @Generated + public static Base64BytesProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + byte[] value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getBinary(); + } else { + reader.skipChildren(); + } + } + return new Base64BytesProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/Base64urlArrayBytesProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/Base64urlArrayBytesProperty.java new file mode 100644 index 000000000..b358f5142 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/Base64urlArrayBytesProperty.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.Base64Url; +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; +import java.util.Objects; + +/** + * The Base64urlArrayBytesProperty model. + */ +@Immutable +public final class Base64urlArrayBytesProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final List value; + + /** + * Creates an instance of Base64urlArrayBytesProperty class. + * + * @param value the value value to set. + */ + @Generated + public Base64urlArrayBytesProperty(List value) { + if (value == null) { + this.value = null; + } else { + this.value = value.stream().map(el -> Base64Url.encode(el)).collect(java.util.stream.Collectors.toList()); + } + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public List getValue() { + if (this.value == null) { + return null; + } + return this.value.stream().map(el -> el.decodedBytes()).collect(java.util.stream.Collectors.toList()); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, + (writer, element) -> writer.writeString(Objects.toString(element, null))); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Base64urlArrayBytesProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Base64urlArrayBytesProperty 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 Base64urlArrayBytesProperty. + */ + @Generated + public static Base64urlArrayBytesProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.readArray(reader1 -> { + Base64Url reader1ValueHolder + = reader1.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + if (reader1ValueHolder != null) { + return reader1ValueHolder.decodedBytes(); + } else { + return null; + } + }); + } else { + reader.skipChildren(); + } + } + return new Base64urlArrayBytesProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/Base64urlBytesProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/Base64urlBytesProperty.java new file mode 100644 index 000000000..38789ff8e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/Base64urlBytesProperty.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.Base64Url; +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.Objects; + +/** + * The Base64urlBytesProperty model. + */ +@Immutable +public final class Base64urlBytesProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final Base64Url value; + + /** + * Creates an instance of Base64urlBytesProperty class. + * + * @param value the value value to set. + */ + @Generated + public Base64urlBytesProperty(byte[] value) { + if (value == null) { + this.value = null; + } else { + this.value = Base64Url.encode(value); + } + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public byte[] getValue() { + if (this.value == null) { + return null; + } + return this.value.decodedBytes(); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", Objects.toString(this.value, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Base64urlBytesProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Base64urlBytesProperty 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 Base64urlBytesProperty. + */ + @Generated + public static Base64urlBytesProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + byte[] value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + Base64Url valueHolder + = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); + if (valueHolder != null) { + value = valueHolder.decodedBytes(); + } + } else { + reader.skipChildren(); + } + } + return new Base64urlBytesProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/DefaultBytesProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/DefaultBytesProperty.java new file mode 100644 index 000000000..e008d43c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/DefaultBytesProperty.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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 DefaultBytesProperty model. + */ +@Immutable +public final class DefaultBytesProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final byte[] value; + + /** + * Creates an instance of DefaultBytesProperty class. + * + * @param value the value value to set. + */ + @Generated + public DefaultBytesProperty(byte[] value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public byte[] getValue() { + return CoreUtils.clone(this.value); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBinaryField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DefaultBytesProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DefaultBytesProperty 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 DefaultBytesProperty. + */ + @Generated + public static DefaultBytesProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + byte[] value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getBinary(); + } else { + reader.skipChildren(); + } + } + return new DefaultBytesProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/models/package-info.java new file mode 100644 index 000000000..c6cc4b653 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/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 Bytes. + * Test for encode decorator on bytes. + * + */ +package com.encode.bytes.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/package-info.java new file mode 100644 index 000000000..f15d64e12 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/bytes/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 Bytes. + * Test for encode decorator on bytes. + * + */ +package com.encode.bytes; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/DatetimeClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/DatetimeClientBuilder.java new file mode 100644 index 000000000..d228837b6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/DatetimeClientBuilder.java @@ -0,0 +1,356 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.encode.datetime.implementation.DatetimeClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the DatetimeClient type. + */ +@ServiceClientBuilder( + serviceClients = { + QueryClient.class, + PropertyClient.class, + HeaderClient.class, + ResponseHeaderClient.class, + QueryAsyncClient.class, + PropertyAsyncClient.class, + HeaderAsyncClient.class, + ResponseHeaderAsyncClient.class }) +public final class DatetimeClientBuilder 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("encode-datetime.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the DatetimeClientBuilder. + */ + @Generated + public DatetimeClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DatetimeClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DatetimeClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DatetimeClientBuilder 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 DatetimeClientBuilder 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 DatetimeClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DatetimeClientBuilder 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 DatetimeClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DatetimeClientBuilder 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 DatetimeClientBuilder. + */ + @Generated + public DatetimeClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of DatetimeClientImpl with the provided parameters. + * + * @return an instance of DatetimeClientImpl. + */ + @Generated + private DatetimeClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + DatetimeClientImpl client + = new DatetimeClientImpl(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 QueryAsyncClient class. + * + * @return an instance of QueryAsyncClient. + */ + @Generated + public QueryAsyncClient buildQueryAsyncClient() { + return new QueryAsyncClient(buildInnerClient().getQueries()); + } + + /** + * Builds an instance of PropertyAsyncClient class. + * + * @return an instance of PropertyAsyncClient. + */ + @Generated + public PropertyAsyncClient buildPropertyAsyncClient() { + return new PropertyAsyncClient(buildInnerClient().getProperties()); + } + + /** + * Builds an instance of HeaderAsyncClient class. + * + * @return an instance of HeaderAsyncClient. + */ + @Generated + public HeaderAsyncClient buildHeaderAsyncClient() { + return new HeaderAsyncClient(buildInnerClient().getHeaders()); + } + + /** + * Builds an instance of ResponseHeaderAsyncClient class. + * + * @return an instance of ResponseHeaderAsyncClient. + */ + @Generated + public ResponseHeaderAsyncClient buildResponseHeaderAsyncClient() { + return new ResponseHeaderAsyncClient(buildInnerClient().getResponseHeaders()); + } + + /** + * Builds an instance of QueryClient class. + * + * @return an instance of QueryClient. + */ + @Generated + public QueryClient buildQueryClient() { + return new QueryClient(buildInnerClient().getQueries()); + } + + /** + * Builds an instance of PropertyClient class. + * + * @return an instance of PropertyClient. + */ + @Generated + public PropertyClient buildPropertyClient() { + return new PropertyClient(buildInnerClient().getProperties()); + } + + /** + * Builds an instance of HeaderClient class. + * + * @return an instance of HeaderClient. + */ + @Generated + public HeaderClient buildHeaderClient() { + return new HeaderClient(buildInnerClient().getHeaders()); + } + + /** + * Builds an instance of ResponseHeaderClient class. + * + * @return an instance of ResponseHeaderClient. + */ + @Generated + public ResponseHeaderClient buildResponseHeaderClient() { + return new ResponseHeaderClient(buildInnerClient().getResponseHeaders()); + } + + private static final ClientLogger LOGGER = new ClientLogger(DatetimeClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/HeaderAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/HeaderAsyncClient.java new file mode 100644 index 000000000..fa0276753 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/HeaderAsyncClient.java @@ -0,0 +1,226 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime; + +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 com.encode.datetime.implementation.HeadersImpl; +import java.time.OffsetDateTime; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DatetimeClient type. + */ +@ServiceClient(builder = DatetimeClientBuilder.class, isAsync = true) +public final class HeaderAsyncClient { + @Generated + private final HeadersImpl serviceClient; + + /** + * Initializes an instance of HeaderAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + HeaderAsyncClient(HeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @param value The value 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> defaultMethodWithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponseAsync(value, requestOptions); + } + + /** + * The rfc3339 operation. + * + * @param value The value 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> rfc3339WithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.rfc3339WithResponseAsync(value, requestOptions); + } + + /** + * The rfc7231 operation. + * + * @param value The value 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> rfc7231WithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.rfc7231WithResponseAsync(value, requestOptions); + } + + /** + * The unixTimestamp operation. + * + * @param value The value 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> unixTimestampWithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.unixTimestampWithResponseAsync(value, requestOptions); + } + + /** + * The unixTimestampArray operation. + * + * @param value The value 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> unixTimestampArrayWithResponse(List value, + RequestOptions requestOptions) { + return this.serviceClient.unixTimestampArrayWithResponseAsync(value, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethod(OffsetDateTime value) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The rfc3339 operation. + * + * @param value The value 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 rfc3339(OffsetDateTime value) { + // Generated convenience method for rfc3339WithResponse + RequestOptions requestOptions = new RequestOptions(); + return rfc3339WithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The rfc7231 operation. + * + * @param value The value 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 rfc7231(OffsetDateTime value) { + // Generated convenience method for rfc7231WithResponse + RequestOptions requestOptions = new RequestOptions(); + return rfc7231WithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The unixTimestamp operation. + * + * @param value The value 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 unixTimestamp(OffsetDateTime value) { + // Generated convenience method for unixTimestampWithResponse + RequestOptions requestOptions = new RequestOptions(); + return unixTimestampWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The unixTimestampArray operation. + * + * @param value The value 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 unixTimestampArray(List value) { + // Generated convenience method for unixTimestampArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return unixTimestampArrayWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/HeaderClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/HeaderClient.java new file mode 100644 index 000000000..9a36603ff --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/HeaderClient.java @@ -0,0 +1,218 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime; + +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.encode.datetime.implementation.HeadersImpl; +import java.time.OffsetDateTime; +import java.util.List; + +/** + * Initializes a new instance of the synchronous DatetimeClient type. + */ +@ServiceClient(builder = DatetimeClientBuilder.class) +public final class HeaderClient { + @Generated + private final HeadersImpl serviceClient; + + /** + * Initializes an instance of HeaderClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + HeaderClient(HeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethodWithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponse(value, requestOptions); + } + + /** + * The rfc3339 operation. + * + * @param value The value 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 rfc3339WithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.rfc3339WithResponse(value, requestOptions); + } + + /** + * The rfc7231 operation. + * + * @param value The value 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 rfc7231WithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.rfc7231WithResponse(value, requestOptions); + } + + /** + * The unixTimestamp operation. + * + * @param value The value 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 unixTimestampWithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.unixTimestampWithResponse(value, requestOptions); + } + + /** + * The unixTimestampArray operation. + * + * @param value The value 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 unixTimestampArrayWithResponse(List value, RequestOptions requestOptions) { + return this.serviceClient.unixTimestampArrayWithResponse(value, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethod(OffsetDateTime value) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + defaultMethodWithResponse(value, requestOptions).getValue(); + } + + /** + * The rfc3339 operation. + * + * @param value The value 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 rfc3339(OffsetDateTime value) { + // Generated convenience method for rfc3339WithResponse + RequestOptions requestOptions = new RequestOptions(); + rfc3339WithResponse(value, requestOptions).getValue(); + } + + /** + * The rfc7231 operation. + * + * @param value The value 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 rfc7231(OffsetDateTime value) { + // Generated convenience method for rfc7231WithResponse + RequestOptions requestOptions = new RequestOptions(); + rfc7231WithResponse(value, requestOptions).getValue(); + } + + /** + * The unixTimestamp operation. + * + * @param value The value 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 unixTimestamp(OffsetDateTime value) { + // Generated convenience method for unixTimestampWithResponse + RequestOptions requestOptions = new RequestOptions(); + unixTimestampWithResponse(value, requestOptions).getValue(); + } + + /** + * The unixTimestampArray operation. + * + * @param value The value 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 unixTimestampArray(List value) { + // Generated convenience method for unixTimestampArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + unixTimestampArrayWithResponse(value, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/PropertyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/PropertyAsyncClient.java new file mode 100644 index 000000000..5539e67d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/PropertyAsyncClient.java @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime; + +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 com.encode.datetime.implementation.PropertiesImpl; +import com.encode.datetime.models.DefaultDatetimeProperty; +import com.encode.datetime.models.Rfc3339DatetimeProperty; +import com.encode.datetime.models.Rfc7231DatetimeProperty; +import com.encode.datetime.models.UnixTimestampArrayDatetimeProperty; +import com.encode.datetime.models.UnixTimestampDatetimeProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DatetimeClient type. + */ +@ServiceClient(builder = DatetimeClientBuilder.class, isAsync = true) +public final class PropertyAsyncClient { + @Generated + private final PropertiesImpl serviceClient; + + /** + * Initializes an instance of PropertyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PropertyAsyncClient(PropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> defaultMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponseAsync(body, requestOptions); + } + + /** + * The rfc3339 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> rfc3339WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.rfc3339WithResponseAsync(body, requestOptions); + } + + /** + * The rfc7231 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> rfc7231WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.rfc7231WithResponseAsync(body, requestOptions); + } + + /** + * The unixTimestamp operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> unixTimestampWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.unixTimestampWithResponseAsync(body, requestOptions); + } + + /** + * The unixTimestampArray operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         long (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         long (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> unixTimestampArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.unixTimestampArrayWithResponseAsync(body, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono defaultMethod(DefaultDatetimeProperty body) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DefaultDatetimeProperty.class)); + } + + /** + * The rfc3339 operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono rfc3339(Rfc3339DatetimeProperty body) { + // Generated convenience method for rfc3339WithResponse + RequestOptions requestOptions = new RequestOptions(); + return rfc3339WithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Rfc3339DatetimeProperty.class)); + } + + /** + * The rfc7231 operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono rfc7231(Rfc7231DatetimeProperty body) { + // Generated convenience method for rfc7231WithResponse + RequestOptions requestOptions = new RequestOptions(); + return rfc7231WithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Rfc7231DatetimeProperty.class)); + } + + /** + * The unixTimestamp operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono unixTimestamp(UnixTimestampDatetimeProperty body) { + // Generated convenience method for unixTimestampWithResponse + RequestOptions requestOptions = new RequestOptions(); + return unixTimestampWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnixTimestampDatetimeProperty.class)); + } + + /** + * The unixTimestampArray operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono unixTimestampArray(UnixTimestampArrayDatetimeProperty body) { + // Generated convenience method for unixTimestampArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return unixTimestampArrayWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnixTimestampArrayDatetimeProperty.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/PropertyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/PropertyClient.java new file mode 100644 index 000000000..ea134932f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/PropertyClient.java @@ -0,0 +1,311 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime; + +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.encode.datetime.implementation.PropertiesImpl; +import com.encode.datetime.models.DefaultDatetimeProperty; +import com.encode.datetime.models.Rfc3339DatetimeProperty; +import com.encode.datetime.models.Rfc7231DatetimeProperty; +import com.encode.datetime.models.UnixTimestampArrayDatetimeProperty; +import com.encode.datetime.models.UnixTimestampDatetimeProperty; + +/** + * Initializes a new instance of the synchronous DatetimeClient type. + */ +@ServiceClient(builder = DatetimeClientBuilder.class) +public final class PropertyClient { + @Generated + private final PropertiesImpl serviceClient; + + /** + * Initializes an instance of PropertyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PropertyClient(PropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response defaultMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponse(body, requestOptions); + } + + /** + * The rfc3339 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response rfc3339WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.rfc3339WithResponse(body, requestOptions); + } + + /** + * The rfc7231 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response rfc7231WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.rfc7231WithResponse(body, requestOptions); + } + + /** + * The unixTimestamp operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response unixTimestampWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.unixTimestampWithResponse(body, requestOptions); + } + + /** + * The unixTimestampArray operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         long (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         long (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response unixTimestampArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.unixTimestampArrayWithResponse(body, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DefaultDatetimeProperty defaultMethod(DefaultDatetimeProperty body) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(DefaultDatetimeProperty.class); + } + + /** + * The rfc3339 operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Rfc3339DatetimeProperty rfc3339(Rfc3339DatetimeProperty body) { + // Generated convenience method for rfc3339WithResponse + RequestOptions requestOptions = new RequestOptions(); + return rfc3339WithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(Rfc3339DatetimeProperty.class); + } + + /** + * The rfc7231 operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Rfc7231DatetimeProperty rfc7231(Rfc7231DatetimeProperty body) { + // Generated convenience method for rfc7231WithResponse + RequestOptions requestOptions = new RequestOptions(); + return rfc7231WithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(Rfc7231DatetimeProperty.class); + } + + /** + * The unixTimestamp operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnixTimestampDatetimeProperty unixTimestamp(UnixTimestampDatetimeProperty body) { + // Generated convenience method for unixTimestampWithResponse + RequestOptions requestOptions = new RequestOptions(); + return unixTimestampWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(UnixTimestampDatetimeProperty.class); + } + + /** + * The unixTimestampArray operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnixTimestampArrayDatetimeProperty unixTimestampArray(UnixTimestampArrayDatetimeProperty body) { + // Generated convenience method for unixTimestampArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return unixTimestampArrayWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(UnixTimestampArrayDatetimeProperty.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/QueryAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/QueryAsyncClient.java new file mode 100644 index 000000000..6eda4acc0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/QueryAsyncClient.java @@ -0,0 +1,226 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime; + +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 com.encode.datetime.implementation.QueriesImpl; +import java.time.OffsetDateTime; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DatetimeClient type. + */ +@ServiceClient(builder = DatetimeClientBuilder.class, isAsync = true) +public final class QueryAsyncClient { + @Generated + private final QueriesImpl serviceClient; + + /** + * Initializes an instance of QueryAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + QueryAsyncClient(QueriesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @param value The value 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> defaultMethodWithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponseAsync(value, requestOptions); + } + + /** + * The rfc3339 operation. + * + * @param value The value 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> rfc3339WithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.rfc3339WithResponseAsync(value, requestOptions); + } + + /** + * The rfc7231 operation. + * + * @param value The value 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> rfc7231WithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.rfc7231WithResponseAsync(value, requestOptions); + } + + /** + * The unixTimestamp operation. + * + * @param value The value 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> unixTimestampWithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.unixTimestampWithResponseAsync(value, requestOptions); + } + + /** + * The unixTimestampArray operation. + * + * @param value The value 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> unixTimestampArrayWithResponse(List value, + RequestOptions requestOptions) { + return this.serviceClient.unixTimestampArrayWithResponseAsync(value, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethod(OffsetDateTime value) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The rfc3339 operation. + * + * @param value The value 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 rfc3339(OffsetDateTime value) { + // Generated convenience method for rfc3339WithResponse + RequestOptions requestOptions = new RequestOptions(); + return rfc3339WithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The rfc7231 operation. + * + * @param value The value 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 rfc7231(OffsetDateTime value) { + // Generated convenience method for rfc7231WithResponse + RequestOptions requestOptions = new RequestOptions(); + return rfc7231WithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The unixTimestamp operation. + * + * @param value The value 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 unixTimestamp(OffsetDateTime value) { + // Generated convenience method for unixTimestampWithResponse + RequestOptions requestOptions = new RequestOptions(); + return unixTimestampWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The unixTimestampArray operation. + * + * @param value The value 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 unixTimestampArray(List value) { + // Generated convenience method for unixTimestampArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return unixTimestampArrayWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/QueryClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/QueryClient.java new file mode 100644 index 000000000..595c60c5a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/QueryClient.java @@ -0,0 +1,218 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime; + +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.encode.datetime.implementation.QueriesImpl; +import java.time.OffsetDateTime; +import java.util.List; + +/** + * Initializes a new instance of the synchronous DatetimeClient type. + */ +@ServiceClient(builder = DatetimeClientBuilder.class) +public final class QueryClient { + @Generated + private final QueriesImpl serviceClient; + + /** + * Initializes an instance of QueryClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + QueryClient(QueriesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethodWithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponse(value, requestOptions); + } + + /** + * The rfc3339 operation. + * + * @param value The value 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 rfc3339WithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.rfc3339WithResponse(value, requestOptions); + } + + /** + * The rfc7231 operation. + * + * @param value The value 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 rfc7231WithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.rfc7231WithResponse(value, requestOptions); + } + + /** + * The unixTimestamp operation. + * + * @param value The value 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 unixTimestampWithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return this.serviceClient.unixTimestampWithResponse(value, requestOptions); + } + + /** + * The unixTimestampArray operation. + * + * @param value The value 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 unixTimestampArrayWithResponse(List value, RequestOptions requestOptions) { + return this.serviceClient.unixTimestampArrayWithResponse(value, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethod(OffsetDateTime value) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + defaultMethodWithResponse(value, requestOptions).getValue(); + } + + /** + * The rfc3339 operation. + * + * @param value The value 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 rfc3339(OffsetDateTime value) { + // Generated convenience method for rfc3339WithResponse + RequestOptions requestOptions = new RequestOptions(); + rfc3339WithResponse(value, requestOptions).getValue(); + } + + /** + * The rfc7231 operation. + * + * @param value The value 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 rfc7231(OffsetDateTime value) { + // Generated convenience method for rfc7231WithResponse + RequestOptions requestOptions = new RequestOptions(); + rfc7231WithResponse(value, requestOptions).getValue(); + } + + /** + * The unixTimestamp operation. + * + * @param value The value 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 unixTimestamp(OffsetDateTime value) { + // Generated convenience method for unixTimestampWithResponse + RequestOptions requestOptions = new RequestOptions(); + unixTimestampWithResponse(value, requestOptions).getValue(); + } + + /** + * The unixTimestampArray operation. + * + * @param value The value 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 unixTimestampArray(List value) { + // Generated convenience method for unixTimestampArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + unixTimestampArrayWithResponse(value, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/ResponseHeaderAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/ResponseHeaderAsyncClient.java new file mode 100644 index 000000000..1347086f4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/ResponseHeaderAsyncClient.java @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime; + +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 com.encode.datetime.implementation.ResponseHeadersImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DatetimeClient type. + */ +@ServiceClient(builder = DatetimeClientBuilder.class, isAsync = true) +public final class ResponseHeaderAsyncClient { + @Generated + private final ResponseHeadersImpl serviceClient; + + /** + * Initializes an instance of ResponseHeaderAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ResponseHeaderAsyncClient(ResponseHeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @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> defaultMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponseAsync(requestOptions); + } + + /** + * The rfc3339 operation. + * + * @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> rfc3339WithResponse(RequestOptions requestOptions) { + return this.serviceClient.rfc3339WithResponseAsync(requestOptions); + } + + /** + * The rfc7231 operation. + * + * @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> rfc7231WithResponse(RequestOptions requestOptions) { + return this.serviceClient.rfc7231WithResponseAsync(requestOptions); + } + + /** + * The unixTimestamp operation. + * + * @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> unixTimestampWithResponse(RequestOptions requestOptions) { + return this.serviceClient.unixTimestampWithResponseAsync(requestOptions); + } + + /** + * The defaultMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono defaultMethod() { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The rfc3339 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono rfc3339() { + // Generated convenience method for rfc3339WithResponse + RequestOptions requestOptions = new RequestOptions(); + return rfc3339WithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The rfc7231 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono rfc7231() { + // Generated convenience method for rfc7231WithResponse + RequestOptions requestOptions = new RequestOptions(); + return rfc7231WithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The unixTimestamp 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono unixTimestamp() { + // Generated convenience method for unixTimestampWithResponse + RequestOptions requestOptions = new RequestOptions(); + return unixTimestampWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/ResponseHeaderClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/ResponseHeaderClient.java new file mode 100644 index 000000000..ab3436607 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/ResponseHeaderClient.java @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime; + +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.encode.datetime.implementation.ResponseHeadersImpl; + +/** + * Initializes a new instance of the synchronous DatetimeClient type. + */ +@ServiceClient(builder = DatetimeClientBuilder.class) +public final class ResponseHeaderClient { + @Generated + private final ResponseHeadersImpl serviceClient; + + /** + * Initializes an instance of ResponseHeaderClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ResponseHeaderClient(ResponseHeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @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 defaultMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponse(requestOptions); + } + + /** + * The rfc3339 operation. + * + * @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 rfc3339WithResponse(RequestOptions requestOptions) { + return this.serviceClient.rfc3339WithResponse(requestOptions); + } + + /** + * The rfc7231 operation. + * + * @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 rfc7231WithResponse(RequestOptions requestOptions) { + return this.serviceClient.rfc7231WithResponse(requestOptions); + } + + /** + * The unixTimestamp operation. + * + * @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 unixTimestampWithResponse(RequestOptions requestOptions) { + return this.serviceClient.unixTimestampWithResponse(requestOptions); + } + + /** + * The defaultMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void defaultMethod() { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + defaultMethodWithResponse(requestOptions).getValue(); + } + + /** + * The rfc3339 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void rfc3339() { + // Generated convenience method for rfc3339WithResponse + RequestOptions requestOptions = new RequestOptions(); + rfc3339WithResponse(requestOptions).getValue(); + } + + /** + * The rfc7231 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void rfc7231() { + // Generated convenience method for rfc7231WithResponse + RequestOptions requestOptions = new RequestOptions(); + rfc7231WithResponse(requestOptions).getValue(); + } + + /** + * The unixTimestamp 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void unixTimestamp() { + // Generated convenience method for unixTimestampWithResponse + RequestOptions requestOptions = new RequestOptions(); + unixTimestampWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/DatetimeClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/DatetimeClientImpl.java new file mode 100644 index 000000000..7074d5879 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/DatetimeClientImpl.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the DatetimeClient type. + */ +public final class DatetimeClientImpl { + /** + * 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; + } + + /** + * The QueriesImpl object to access its operations. + */ + private final QueriesImpl queries; + + /** + * Gets the QueriesImpl object to access its operations. + * + * @return the QueriesImpl object. + */ + public QueriesImpl getQueries() { + return this.queries; + } + + /** + * The PropertiesImpl object to access its operations. + */ + private final PropertiesImpl properties; + + /** + * Gets the PropertiesImpl object to access its operations. + * + * @return the PropertiesImpl object. + */ + public PropertiesImpl getProperties() { + return this.properties; + } + + /** + * The HeadersImpl object to access its operations. + */ + private final HeadersImpl headers; + + /** + * Gets the HeadersImpl object to access its operations. + * + * @return the HeadersImpl object. + */ + public HeadersImpl getHeaders() { + return this.headers; + } + + /** + * The ResponseHeadersImpl object to access its operations. + */ + private final ResponseHeadersImpl responseHeaders; + + /** + * Gets the ResponseHeadersImpl object to access its operations. + * + * @return the ResponseHeadersImpl object. + */ + public ResponseHeadersImpl getResponseHeaders() { + return this.responseHeaders; + } + + /** + * Initializes an instance of DatetimeClient client. + * + * @param endpoint Service host. + */ + public DatetimeClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of DatetimeClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public DatetimeClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of DatetimeClient 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 DatetimeClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.queries = new QueriesImpl(this); + this.properties = new PropertiesImpl(this); + this.headers = new HeadersImpl(this); + this.responseHeaders = new ResponseHeadersImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/HeadersImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/HeadersImpl.java new file mode 100644 index 000000000..b3357760f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/HeadersImpl.java @@ -0,0 +1,334 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.CollectionFormat; +import com.azure.core.util.serializer.JacksonAdapter; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Headers. + */ +public final class HeadersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final HeadersService service; + + /** + * The service client containing this operation class. + */ + private final DatetimeClientImpl client; + + /** + * Initializes an instance of HeadersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + HeadersImpl(DatetimeClientImpl client) { + this.service = RestProxy.create(HeadersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DatetimeClientHeaders to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DatetimeClientHeader") + public interface HeadersService { + @Get("/encode/datetime/header/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> defaultMethod(@HostParam("endpoint") String endpoint, + @HeaderParam("value") DateTimeRfc1123 value, RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/header/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defaultMethodSync(@HostParam("endpoint") String endpoint, + @HeaderParam("value") DateTimeRfc1123 value, RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/header/rfc3339") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> rfc3339(@HostParam("endpoint") String endpoint, @HeaderParam("value") OffsetDateTime value, + RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/header/rfc3339") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response rfc3339Sync(@HostParam("endpoint") String endpoint, @HeaderParam("value") OffsetDateTime value, + RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/header/rfc7231") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> rfc7231(@HostParam("endpoint") String endpoint, + @HeaderParam("value") DateTimeRfc1123 value, RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/header/rfc7231") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response rfc7231Sync(@HostParam("endpoint") String endpoint, @HeaderParam("value") DateTimeRfc1123 value, + RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/header/unix-timestamp") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> unixTimestamp(@HostParam("endpoint") String endpoint, @HeaderParam("value") long value, + RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/header/unix-timestamp") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response unixTimestampSync(@HostParam("endpoint") String endpoint, @HeaderParam("value") long value, + RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/header/unix-timestamp-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> unixTimestampArray(@HostParam("endpoint") String endpoint, + @HeaderParam("value") String value, RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/header/unix-timestamp-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response unixTimestampArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("value") String value, RequestOptions requestOptions, Context context); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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> defaultMethodWithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { + DateTimeRfc1123 valueConverted = new DateTimeRfc1123(value); + return FluxUtil.withContext( + context -> service.defaultMethod(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethodWithResponse(OffsetDateTime value, RequestOptions requestOptions) { + DateTimeRfc1123 valueConverted = new DateTimeRfc1123(value); + return service.defaultMethodSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } + + /** + * The rfc3339 operation. + * + * @param value The value 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> rfc3339WithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.rfc3339(this.client.getEndpoint(), value, requestOptions, context)); + } + + /** + * The rfc3339 operation. + * + * @param value The value 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 rfc3339WithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return service.rfc3339Sync(this.client.getEndpoint(), value, requestOptions, Context.NONE); + } + + /** + * The rfc7231 operation. + * + * @param value The value 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> rfc7231WithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { + DateTimeRfc1123 valueConverted = new DateTimeRfc1123(value); + return FluxUtil.withContext( + context -> service.rfc7231(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The rfc7231 operation. + * + * @param value The value 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 rfc7231WithResponse(OffsetDateTime value, RequestOptions requestOptions) { + DateTimeRfc1123 valueConverted = new DateTimeRfc1123(value); + return service.rfc7231Sync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } + + /** + * The unixTimestamp operation. + * + * @param value The value 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> unixTimestampWithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { + long valueConverted = value.toEpochSecond(); + return FluxUtil.withContext( + context -> service.unixTimestamp(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The unixTimestamp operation. + * + * @param value The value 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 unixTimestampWithResponse(OffsetDateTime value, RequestOptions requestOptions) { + long valueConverted = value.toEpochSecond(); + return service.unixTimestampSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } + + /** + * The unixTimestampArray operation. + * + * @param value The value 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> unixTimestampArrayWithResponseAsync(List value, + RequestOptions requestOptions) { + String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() + .serializeIterable( + value.stream().map(paramItemValue -> paramItemValue.toEpochSecond()).collect(Collectors.toList()), + CollectionFormat.CSV); + return FluxUtil.withContext( + context -> service.unixTimestampArray(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The unixTimestampArray operation. + * + * @param value The value 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 unixTimestampArrayWithResponse(List value, RequestOptions requestOptions) { + String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() + .serializeIterable( + value.stream().map(paramItemValue -> paramItemValue.toEpochSecond()).collect(Collectors.toList()), + CollectionFormat.CSV); + return service.unixTimestampArraySync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/PropertiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/PropertiesImpl.java new file mode 100644 index 000000000..0ee32e70e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/PropertiesImpl.java @@ -0,0 +1,508 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Properties. + */ +public final class PropertiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PropertiesService service; + + /** + * The service client containing this operation class. + */ + private final DatetimeClientImpl client; + + /** + * Initializes an instance of PropertiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PropertiesImpl(DatetimeClientImpl client) { + this.service + = RestProxy.create(PropertiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DatetimeClientProperties to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DatetimeClientProper") + public interface PropertiesService { + @Post("/encode/datetime/property/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> defaultMethod(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/datetime/property/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defaultMethodSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/datetime/property/rfc3339") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> rfc3339(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/datetime/property/rfc3339") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response rfc3339Sync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/datetime/property/rfc7231") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> rfc7231(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/datetime/property/rfc7231") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response rfc7231Sync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/datetime/property/unix-timestamp") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> unixTimestamp(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/datetime/property/unix-timestamp") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response unixTimestampSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/datetime/property/unix-timestamp-array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> unixTimestampArray(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/datetime/property/unix-timestamp-array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response unixTimestampArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> defaultMethodWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.defaultMethod(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response defaultMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.defaultMethodSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The rfc3339 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> rfc3339WithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.rfc3339(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); + } + + /** + * The rfc3339 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response rfc3339WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.rfc3339Sync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); + } + + /** + * The rfc7231 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> rfc7231WithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.rfc7231(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); + } + + /** + * The rfc7231 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: DateTimeRfc1123 (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response rfc7231WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.rfc7231Sync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); + } + + /** + * The unixTimestamp operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> unixTimestampWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.unixTimestamp(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The unixTimestamp operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response unixTimestampWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.unixTimestampSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The unixTimestampArray operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         long (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         long (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> unixTimestampArrayWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.unixTimestampArray(this.client.getEndpoint(), contentType, + accept, body, requestOptions, context)); + } + + /** + * The unixTimestampArray operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         long (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         long (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response unixTimestampArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.unixTimestampArraySync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/QueriesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/QueriesImpl.java new file mode 100644 index 000000000..3d1d80eb6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/QueriesImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime.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.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.CollectionFormat; +import com.azure.core.util.serializer.JacksonAdapter; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Queries. + */ +public final class QueriesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QueriesService service; + + /** + * The service client containing this operation class. + */ + private final DatetimeClientImpl client; + + /** + * Initializes an instance of QueriesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QueriesImpl(DatetimeClientImpl client) { + this.service = RestProxy.create(QueriesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DatetimeClientQueries to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DatetimeClientQuerie") + public interface QueriesService { + @Get("/encode/datetime/query/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> defaultMethod(@HostParam("endpoint") String endpoint, + @QueryParam("value") OffsetDateTime value, RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/query/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defaultMethodSync(@HostParam("endpoint") String endpoint, + @QueryParam("value") OffsetDateTime value, RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/query/rfc3339") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> rfc3339(@HostParam("endpoint") String endpoint, @QueryParam("value") OffsetDateTime value, + RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/query/rfc3339") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response rfc3339Sync(@HostParam("endpoint") String endpoint, @QueryParam("value") OffsetDateTime value, + RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/query/rfc7231") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> rfc7231(@HostParam("endpoint") String endpoint, @QueryParam("value") DateTimeRfc1123 value, + RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/query/rfc7231") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response rfc7231Sync(@HostParam("endpoint") String endpoint, @QueryParam("value") DateTimeRfc1123 value, + RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/query/unix-timestamp") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> unixTimestamp(@HostParam("endpoint") String endpoint, @QueryParam("value") long value, + RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/query/unix-timestamp") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response unixTimestampSync(@HostParam("endpoint") String endpoint, @QueryParam("value") long value, + RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/query/unix-timestamp-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> unixTimestampArray(@HostParam("endpoint") String endpoint, + @QueryParam("value") String value, RequestOptions requestOptions, Context context); + + @Get("/encode/datetime/query/unix-timestamp-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response unixTimestampArraySync(@HostParam("endpoint") String endpoint, @QueryParam("value") String value, + RequestOptions requestOptions, Context context); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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> defaultMethodWithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.defaultMethod(this.client.getEndpoint(), value, requestOptions, context)); + } + + /** + * The defaultMethod operation. + * + * @param value The value 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 defaultMethodWithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return service.defaultMethodSync(this.client.getEndpoint(), value, requestOptions, Context.NONE); + } + + /** + * The rfc3339 operation. + * + * @param value The value 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> rfc3339WithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.rfc3339(this.client.getEndpoint(), value, requestOptions, context)); + } + + /** + * The rfc3339 operation. + * + * @param value The value 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 rfc3339WithResponse(OffsetDateTime value, RequestOptions requestOptions) { + return service.rfc3339Sync(this.client.getEndpoint(), value, requestOptions, Context.NONE); + } + + /** + * The rfc7231 operation. + * + * @param value The value 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> rfc7231WithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { + DateTimeRfc1123 valueConverted = new DateTimeRfc1123(value); + return FluxUtil.withContext( + context -> service.rfc7231(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The rfc7231 operation. + * + * @param value The value 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 rfc7231WithResponse(OffsetDateTime value, RequestOptions requestOptions) { + DateTimeRfc1123 valueConverted = new DateTimeRfc1123(value); + return service.rfc7231Sync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } + + /** + * The unixTimestamp operation. + * + * @param value The value 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> unixTimestampWithResponseAsync(OffsetDateTime value, RequestOptions requestOptions) { + long valueConverted = value.toEpochSecond(); + return FluxUtil.withContext( + context -> service.unixTimestamp(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The unixTimestamp operation. + * + * @param value The value 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 unixTimestampWithResponse(OffsetDateTime value, RequestOptions requestOptions) { + long valueConverted = value.toEpochSecond(); + return service.unixTimestampSync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } + + /** + * The unixTimestampArray operation. + * + * @param value The value 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> unixTimestampArrayWithResponseAsync(List value, + RequestOptions requestOptions) { + String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() + .serializeIterable( + value.stream().map(paramItemValue -> paramItemValue.toEpochSecond()).collect(Collectors.toList()), + CollectionFormat.CSV); + return FluxUtil.withContext( + context -> service.unixTimestampArray(this.client.getEndpoint(), valueConverted, requestOptions, context)); + } + + /** + * The unixTimestampArray operation. + * + * @param value The value 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 unixTimestampArrayWithResponse(List value, RequestOptions requestOptions) { + String valueConverted = JacksonAdapter.createDefaultSerializerAdapter() + .serializeIterable( + value.stream().map(paramItemValue -> paramItemValue.toEpochSecond()).collect(Collectors.toList()), + CollectionFormat.CSV); + return service.unixTimestampArraySync(this.client.getEndpoint(), valueConverted, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/ResponseHeadersImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/ResponseHeadersImpl.java new file mode 100644 index 000000000..b1a994d44 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/ResponseHeadersImpl.java @@ -0,0 +1,252 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime.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.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 ResponseHeaders. + */ +public final class ResponseHeadersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ResponseHeadersService service; + + /** + * The service client containing this operation class. + */ + private final DatetimeClientImpl client; + + /** + * Initializes an instance of ResponseHeadersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ResponseHeadersImpl(DatetimeClientImpl client) { + this.service + = RestProxy.create(ResponseHeadersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DatetimeClientResponseHeaders to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DatetimeClientRespon") + public interface ResponseHeadersService { + @Get("/encode/datetime/responseheader/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> defaultMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/encode/datetime/responseheader/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defaultMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/encode/datetime/responseheader/rfc3339") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> rfc3339(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/encode/datetime/responseheader/rfc3339") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response rfc3339Sync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/encode/datetime/responseheader/rfc7231") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> rfc7231(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/encode/datetime/responseheader/rfc7231") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response rfc7231Sync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/encode/datetime/responseheader/unix-timestamp") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> unixTimestamp(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/encode/datetime/responseheader/unix-timestamp") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response unixTimestampSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + } + + /** + * The defaultMethod operation. + * + * @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> defaultMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.defaultMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The defaultMethod operation. + * + * @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 defaultMethodWithResponse(RequestOptions requestOptions) { + return service.defaultMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The rfc3339 operation. + * + * @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> rfc3339WithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.rfc3339(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The rfc3339 operation. + * + * @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 rfc3339WithResponse(RequestOptions requestOptions) { + return service.rfc3339Sync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The rfc7231 operation. + * + * @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> rfc7231WithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.rfc7231(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The rfc7231 operation. + * + * @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 rfc7231WithResponse(RequestOptions requestOptions) { + return service.rfc7231Sync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The unixTimestamp operation. + * + * @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> unixTimestampWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.unixTimestamp(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The unixTimestamp operation. + * + * @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 unixTimestampWithResponse(RequestOptions requestOptions) { + return service.unixTimestampSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/implementation/package-info.java new file mode 100644 index 000000000..d62bec475 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/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 DatetimeModel. + * Test for encode decorator on datetime. + * + */ +package com.encode.datetime.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/DefaultDatetimeProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/DefaultDatetimeProperty.java new file mode 100644 index 000000000..54fafef7b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/DefaultDatetimeProperty.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 com.encode.datetime.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * The DefaultDatetimeProperty model. + */ +@Immutable +public final class DefaultDatetimeProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final OffsetDateTime value; + + /** + * Creates an instance of DefaultDatetimeProperty class. + * + * @param value the value value to set. + */ + @Generated + public DefaultDatetimeProperty(OffsetDateTime value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public OffsetDateTime getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", + this.value == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.value)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DefaultDatetimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DefaultDatetimeProperty 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 DefaultDatetimeProperty. + */ + @Generated + public static DefaultDatetimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new DefaultDatetimeProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/Rfc3339DatetimeProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/Rfc3339DatetimeProperty.java new file mode 100644 index 000000000..10fd0d386 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/Rfc3339DatetimeProperty.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 com.encode.datetime.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * The Rfc3339DatetimeProperty model. + */ +@Immutable +public final class Rfc3339DatetimeProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final OffsetDateTime value; + + /** + * Creates an instance of Rfc3339DatetimeProperty class. + * + * @param value the value value to set. + */ + @Generated + public Rfc3339DatetimeProperty(OffsetDateTime value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public OffsetDateTime getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", + this.value == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.value)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Rfc3339DatetimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Rfc3339DatetimeProperty 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 Rfc3339DatetimeProperty. + */ + @Generated + public static Rfc3339DatetimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new Rfc3339DatetimeProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/Rfc7231DatetimeProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/Rfc7231DatetimeProperty.java new file mode 100644 index 000000000..3ae739c26 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/Rfc7231DatetimeProperty.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.DateTimeRfc1123; +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.time.OffsetDateTime; +import java.util.Objects; + +/** + * The Rfc7231DatetimeProperty model. + */ +@Immutable +public final class Rfc7231DatetimeProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final DateTimeRfc1123 value; + + /** + * Creates an instance of Rfc7231DatetimeProperty class. + * + * @param value the value value to set. + */ + @Generated + public Rfc7231DatetimeProperty(OffsetDateTime value) { + if (value == null) { + this.value = null; + } else { + this.value = new DateTimeRfc1123(value); + } + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public OffsetDateTime getValue() { + if (this.value == null) { + return null; + } + return this.value.getDateTime(); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", Objects.toString(this.value, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Rfc7231DatetimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Rfc7231DatetimeProperty 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 Rfc7231DatetimeProperty. + */ + @Generated + public static Rfc7231DatetimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + DateTimeRfc1123 valueHolder + = reader.getNullable(nonNullReader -> new DateTimeRfc1123(nonNullReader.getString())); + if (valueHolder != null) { + value = valueHolder.getDateTime(); + } + } else { + reader.skipChildren(); + } + } + return new Rfc7231DatetimeProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/UnixTimestampArrayDatetimeProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/UnixTimestampArrayDatetimeProperty.java new file mode 100644 index 000000000..d0c448b0a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/UnixTimestampArrayDatetimeProperty.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime.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; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.List; + +/** + * The UnixTimestampArrayDatetimeProperty model. + */ +@Immutable +public final class UnixTimestampArrayDatetimeProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final List value; + + /** + * Creates an instance of UnixTimestampArrayDatetimeProperty class. + * + * @param value the value value to set. + */ + @Generated + public UnixTimestampArrayDatetimeProperty(List value) { + if (value == null) { + this.value = null; + } else { + this.value = value.stream().map(el -> el.toEpochSecond()).collect(java.util.stream.Collectors.toList()); + } + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public List getValue() { + if (this.value == null) { + return null; + } + return this.value.stream() + .map(el -> OffsetDateTime.ofInstant(Instant.ofEpochSecond(el), ZoneOffset.UTC)) + .collect(java.util.stream.Collectors.toList()); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeLong(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnixTimestampArrayDatetimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnixTimestampArrayDatetimeProperty 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 UnixTimestampArrayDatetimeProperty. + */ + @Generated + public static UnixTimestampArrayDatetimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.readArray( + reader1 -> OffsetDateTime.ofInstant(Instant.ofEpochSecond(reader1.getLong()), ZoneOffset.UTC)); + } else { + reader.skipChildren(); + } + } + return new UnixTimestampArrayDatetimeProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/UnixTimestampDatetimeProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/UnixTimestampDatetimeProperty.java new file mode 100644 index 000000000..9ae4f679e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/UnixTimestampDatetimeProperty.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 com.encode.datetime.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; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + +/** + * The UnixTimestampDatetimeProperty model. + */ +@Immutable +public final class UnixTimestampDatetimeProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final long value; + + /** + * Creates an instance of UnixTimestampDatetimeProperty class. + * + * @param value the value value to set. + */ + @Generated + public UnixTimestampDatetimeProperty(OffsetDateTime value) { + if (value == null) { + this.value = 0L; + } else { + this.value = value.toEpochSecond(); + } + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public OffsetDateTime getValue() { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.value), ZoneOffset.UTC); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeLongField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnixTimestampDatetimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnixTimestampDatetimeProperty 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 UnixTimestampDatetimeProperty. + */ + @Generated + public static UnixTimestampDatetimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = OffsetDateTime.ofInstant(Instant.ofEpochSecond(reader.getLong()), ZoneOffset.UTC); + } else { + reader.skipChildren(); + } + } + return new UnixTimestampDatetimeProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/models/package-info.java new file mode 100644 index 000000000..2fe7b9db4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/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 DatetimeModel. + * Test for encode decorator on datetime. + * + */ +package com.encode.datetime.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/package-info.java new file mode 100644 index 000000000..472006be2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/datetime/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 DatetimeModel. + * Test for encode decorator on datetime. + * + */ +package com.encode.datetime; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/DurationClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/DurationClientBuilder.java new file mode 100644 index 000000000..502799aad --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/DurationClientBuilder.java @@ -0,0 +1,334 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.encode.duration.implementation.DurationClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the DurationClient type. + */ +@ServiceClientBuilder( + serviceClients = { + QueryClient.class, + PropertyClient.class, + HeaderClient.class, + QueryAsyncClient.class, + PropertyAsyncClient.class, + HeaderAsyncClient.class }) +public final class DurationClientBuilder 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("encode-duration.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the DurationClientBuilder. + */ + @Generated + public DurationClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DurationClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DurationClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DurationClientBuilder 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 DurationClientBuilder 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 DurationClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DurationClientBuilder 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 DurationClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DurationClientBuilder 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 DurationClientBuilder. + */ + @Generated + public DurationClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of DurationClientImpl with the provided parameters. + * + * @return an instance of DurationClientImpl. + */ + @Generated + private DurationClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + DurationClientImpl client + = new DurationClientImpl(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 QueryAsyncClient class. + * + * @return an instance of QueryAsyncClient. + */ + @Generated + public QueryAsyncClient buildQueryAsyncClient() { + return new QueryAsyncClient(buildInnerClient().getQueries()); + } + + /** + * Builds an instance of PropertyAsyncClient class. + * + * @return an instance of PropertyAsyncClient. + */ + @Generated + public PropertyAsyncClient buildPropertyAsyncClient() { + return new PropertyAsyncClient(buildInnerClient().getProperties()); + } + + /** + * Builds an instance of HeaderAsyncClient class. + * + * @return an instance of HeaderAsyncClient. + */ + @Generated + public HeaderAsyncClient buildHeaderAsyncClient() { + return new HeaderAsyncClient(buildInnerClient().getHeaders()); + } + + /** + * Builds an instance of QueryClient class. + * + * @return an instance of QueryClient. + */ + @Generated + public QueryClient buildQueryClient() { + return new QueryClient(buildInnerClient().getQueries()); + } + + /** + * Builds an instance of PropertyClient class. + * + * @return an instance of PropertyClient. + */ + @Generated + public PropertyClient buildPropertyClient() { + return new PropertyClient(buildInnerClient().getProperties()); + } + + /** + * Builds an instance of HeaderClient class. + * + * @return an instance of HeaderClient. + */ + @Generated + public HeaderClient buildHeaderClient() { + return new HeaderClient(buildInnerClient().getHeaders()); + } + + private static final ClientLogger LOGGER = new ClientLogger(DurationClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/HeaderAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/HeaderAsyncClient.java new file mode 100644 index 000000000..ce31f0081 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/HeaderAsyncClient.java @@ -0,0 +1,262 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration; + +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 com.encode.duration.implementation.HeadersImpl; +import java.time.Duration; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DurationClient type. + */ +@ServiceClient(builder = DurationClientBuilder.class, isAsync = true) +public final class HeaderAsyncClient { + @Generated + private final HeadersImpl serviceClient; + + /** + * Initializes an instance of HeaderAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + HeaderAsyncClient(HeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @param duration The duration 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> defaultMethodWithResponse(Duration duration, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponseAsync(duration, requestOptions); + } + + /** + * The iso8601 operation. + * + * @param duration The duration 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> iso8601WithResponse(Duration duration, RequestOptions requestOptions) { + return this.serviceClient.iso8601WithResponseAsync(duration, requestOptions); + } + + /** + * The iso8601Array operation. + * + * @param duration The duration 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> iso8601ArrayWithResponse(List duration, RequestOptions requestOptions) { + return this.serviceClient.iso8601ArrayWithResponseAsync(duration, requestOptions); + } + + /** + * The int32Seconds operation. + * + * @param duration The duration 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> int32SecondsWithResponse(Duration duration, RequestOptions requestOptions) { + return this.serviceClient.int32SecondsWithResponseAsync(duration, requestOptions); + } + + /** + * The floatSeconds operation. + * + * @param duration The duration 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> floatSecondsWithResponse(Duration duration, RequestOptions requestOptions) { + return this.serviceClient.floatSecondsWithResponseAsync(duration, requestOptions); + } + + /** + * The float64Seconds operation. + * + * @param duration The duration 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> float64SecondsWithResponse(Duration duration, RequestOptions requestOptions) { + return this.serviceClient.float64SecondsWithResponseAsync(duration, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param duration The duration 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 defaultMethod(Duration duration) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(duration, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The iso8601 operation. + * + * @param duration The duration 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 iso8601(Duration duration) { + // Generated convenience method for iso8601WithResponse + RequestOptions requestOptions = new RequestOptions(); + return iso8601WithResponse(duration, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The iso8601Array operation. + * + * @param duration The duration 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 iso8601Array(List duration) { + // Generated convenience method for iso8601ArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return iso8601ArrayWithResponse(duration, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The int32Seconds operation. + * + * @param duration The duration 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 int32Seconds(Duration duration) { + // Generated convenience method for int32SecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return int32SecondsWithResponse(duration, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The floatSeconds operation. + * + * @param duration The duration 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 floatSeconds(Duration duration) { + // Generated convenience method for floatSecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return floatSecondsWithResponse(duration, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The float64Seconds operation. + * + * @param duration The duration 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 float64Seconds(Duration duration) { + // Generated convenience method for float64SecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return float64SecondsWithResponse(duration, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/HeaderClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/HeaderClient.java new file mode 100644 index 000000000..d290e9ed1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/HeaderClient.java @@ -0,0 +1,254 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration; + +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.encode.duration.implementation.HeadersImpl; +import java.time.Duration; +import java.util.List; + +/** + * Initializes a new instance of the synchronous DurationClient type. + */ +@ServiceClient(builder = DurationClientBuilder.class) +public final class HeaderClient { + @Generated + private final HeadersImpl serviceClient; + + /** + * Initializes an instance of HeaderClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + HeaderClient(HeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @param duration The duration 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 defaultMethodWithResponse(Duration duration, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponse(duration, requestOptions); + } + + /** + * The iso8601 operation. + * + * @param duration The duration 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 iso8601WithResponse(Duration duration, RequestOptions requestOptions) { + return this.serviceClient.iso8601WithResponse(duration, requestOptions); + } + + /** + * The iso8601Array operation. + * + * @param duration The duration 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 iso8601ArrayWithResponse(List duration, RequestOptions requestOptions) { + return this.serviceClient.iso8601ArrayWithResponse(duration, requestOptions); + } + + /** + * The int32Seconds operation. + * + * @param duration The duration 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 int32SecondsWithResponse(Duration duration, RequestOptions requestOptions) { + return this.serviceClient.int32SecondsWithResponse(duration, requestOptions); + } + + /** + * The floatSeconds operation. + * + * @param duration The duration 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 floatSecondsWithResponse(Duration duration, RequestOptions requestOptions) { + return this.serviceClient.floatSecondsWithResponse(duration, requestOptions); + } + + /** + * The float64Seconds operation. + * + * @param duration The duration 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 float64SecondsWithResponse(Duration duration, RequestOptions requestOptions) { + return this.serviceClient.float64SecondsWithResponse(duration, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param duration The duration 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 defaultMethod(Duration duration) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + defaultMethodWithResponse(duration, requestOptions).getValue(); + } + + /** + * The iso8601 operation. + * + * @param duration The duration 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 iso8601(Duration duration) { + // Generated convenience method for iso8601WithResponse + RequestOptions requestOptions = new RequestOptions(); + iso8601WithResponse(duration, requestOptions).getValue(); + } + + /** + * The iso8601Array operation. + * + * @param duration The duration 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 iso8601Array(List duration) { + // Generated convenience method for iso8601ArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + iso8601ArrayWithResponse(duration, requestOptions).getValue(); + } + + /** + * The int32Seconds operation. + * + * @param duration The duration 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 int32Seconds(Duration duration) { + // Generated convenience method for int32SecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + int32SecondsWithResponse(duration, requestOptions).getValue(); + } + + /** + * The floatSeconds operation. + * + * @param duration The duration 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 floatSeconds(Duration duration) { + // Generated convenience method for floatSecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + floatSecondsWithResponse(duration, requestOptions).getValue(); + } + + /** + * The float64Seconds operation. + * + * @param duration The duration 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 float64Seconds(Duration duration) { + // Generated convenience method for float64SecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + float64SecondsWithResponse(duration, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/PropertyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/PropertyAsyncClient.java new file mode 100644 index 000000000..e4968a20f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/PropertyAsyncClient.java @@ -0,0 +1,367 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration; + +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 com.encode.duration.implementation.PropertiesImpl; +import com.encode.duration.models.DefaultDurationProperty; +import com.encode.duration.models.Float64SecondsDurationProperty; +import com.encode.duration.models.FloatSecondsDurationArrayProperty; +import com.encode.duration.models.FloatSecondsDurationProperty; +import com.encode.duration.models.Int32SecondsDurationProperty; +import com.encode.duration.models.ISO8601DurationProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DurationClient type. + */ +@ServiceClient(builder = DurationClientBuilder.class, isAsync = true) +public final class PropertyAsyncClient { + @Generated + private final PropertiesImpl serviceClient; + + /** + * Initializes an instance of PropertyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PropertyAsyncClient(PropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> defaultMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponseAsync(body, requestOptions); + } + + /** + * The iso8601 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> iso8601WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.iso8601WithResponseAsync(body, requestOptions); + } + + /** + * The int32Seconds operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> int32SecondsWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.int32SecondsWithResponseAsync(body, requestOptions); + } + + /** + * The floatSeconds operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> floatSecondsWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.floatSecondsWithResponseAsync(body, requestOptions); + } + + /** + * The float64Seconds operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> float64SecondsWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.float64SecondsWithResponseAsync(body, requestOptions); + } + + /** + * The floatSecondsArray operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         double (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         double (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> floatSecondsArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.floatSecondsArrayWithResponseAsync(body, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono defaultMethod(DefaultDurationProperty body) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DefaultDurationProperty.class)); + } + + /** + * The iso8601 operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono iso8601(ISO8601DurationProperty body) { + // Generated convenience method for iso8601WithResponse + RequestOptions requestOptions = new RequestOptions(); + return iso8601WithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ISO8601DurationProperty.class)); + } + + /** + * The int32Seconds operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono int32Seconds(Int32SecondsDurationProperty body) { + // Generated convenience method for int32SecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return int32SecondsWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Int32SecondsDurationProperty.class)); + } + + /** + * The floatSeconds operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono floatSeconds(FloatSecondsDurationProperty body) { + // Generated convenience method for floatSecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return floatSecondsWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FloatSecondsDurationProperty.class)); + } + + /** + * The float64Seconds operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono float64Seconds(Float64SecondsDurationProperty body) { + // Generated convenience method for float64SecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return float64SecondsWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Float64SecondsDurationProperty.class)); + } + + /** + * The floatSecondsArray operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono floatSecondsArray(FloatSecondsDurationArrayProperty body) { + // Generated convenience method for floatSecondsArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return floatSecondsArrayWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FloatSecondsDurationArrayProperty.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/PropertyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/PropertyClient.java new file mode 100644 index 000000000..4b96b81f7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/PropertyClient.java @@ -0,0 +1,365 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration; + +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.encode.duration.implementation.PropertiesImpl; +import com.encode.duration.models.DefaultDurationProperty; +import com.encode.duration.models.Float64SecondsDurationProperty; +import com.encode.duration.models.FloatSecondsDurationArrayProperty; +import com.encode.duration.models.FloatSecondsDurationProperty; +import com.encode.duration.models.Int32SecondsDurationProperty; +import com.encode.duration.models.ISO8601DurationProperty; + +/** + * Initializes a new instance of the synchronous DurationClient type. + */ +@ServiceClient(builder = DurationClientBuilder.class) +public final class PropertyClient { + @Generated + private final PropertiesImpl serviceClient; + + /** + * Initializes an instance of PropertyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PropertyClient(PropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response defaultMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponse(body, requestOptions); + } + + /** + * The iso8601 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response iso8601WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.iso8601WithResponse(body, requestOptions); + } + + /** + * The int32Seconds operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response int32SecondsWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.int32SecondsWithResponse(body, requestOptions); + } + + /** + * The floatSeconds operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response floatSecondsWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.floatSecondsWithResponse(body, requestOptions); + } + + /** + * The float64Seconds operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response float64SecondsWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.float64SecondsWithResponse(body, requestOptions); + } + + /** + * The floatSecondsArray operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         double (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         double (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response floatSecondsArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.floatSecondsArrayWithResponse(body, requestOptions); + } + + /** + * The defaultMethod operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DefaultDurationProperty defaultMethod(DefaultDurationProperty body) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(DefaultDurationProperty.class); + } + + /** + * The iso8601 operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ISO8601DurationProperty iso8601(ISO8601DurationProperty body) { + // Generated convenience method for iso8601WithResponse + RequestOptions requestOptions = new RequestOptions(); + return iso8601WithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(ISO8601DurationProperty.class); + } + + /** + * The int32Seconds operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Int32SecondsDurationProperty int32Seconds(Int32SecondsDurationProperty body) { + // Generated convenience method for int32SecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return int32SecondsWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(Int32SecondsDurationProperty.class); + } + + /** + * The floatSeconds operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FloatSecondsDurationProperty floatSeconds(FloatSecondsDurationProperty body) { + // Generated convenience method for floatSecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return floatSecondsWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(FloatSecondsDurationProperty.class); + } + + /** + * The float64Seconds operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Float64SecondsDurationProperty float64Seconds(Float64SecondsDurationProperty body) { + // Generated convenience method for float64SecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return float64SecondsWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(Float64SecondsDurationProperty.class); + } + + /** + * The floatSecondsArray operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FloatSecondsDurationArrayProperty floatSecondsArray(FloatSecondsDurationArrayProperty body) { + // Generated convenience method for floatSecondsArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return floatSecondsArrayWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(FloatSecondsDurationArrayProperty.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/QueryAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/QueryAsyncClient.java new file mode 100644 index 000000000..4d562ee36 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/QueryAsyncClient.java @@ -0,0 +1,262 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration; + +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 com.encode.duration.implementation.QueriesImpl; +import java.time.Duration; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DurationClient type. + */ +@ServiceClient(builder = DurationClientBuilder.class, isAsync = true) +public final class QueryAsyncClient { + @Generated + private final QueriesImpl serviceClient; + + /** + * Initializes an instance of QueryAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + QueryAsyncClient(QueriesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @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> defaultMethodWithResponse(Duration input, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponseAsync(input, requestOptions); + } + + /** + * The iso8601 operation. + * + * @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> iso8601WithResponse(Duration input, RequestOptions requestOptions) { + return this.serviceClient.iso8601WithResponseAsync(input, requestOptions); + } + + /** + * The int32Seconds operation. + * + * @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> int32SecondsWithResponse(Duration input, RequestOptions requestOptions) { + return this.serviceClient.int32SecondsWithResponseAsync(input, requestOptions); + } + + /** + * The floatSeconds operation. + * + * @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> floatSecondsWithResponse(Duration input, RequestOptions requestOptions) { + return this.serviceClient.floatSecondsWithResponseAsync(input, requestOptions); + } + + /** + * The float64Seconds operation. + * + * @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> float64SecondsWithResponse(Duration input, RequestOptions requestOptions) { + return this.serviceClient.float64SecondsWithResponseAsync(input, requestOptions); + } + + /** + * The int32SecondsArray operation. + * + * @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> int32SecondsArrayWithResponse(List input, RequestOptions requestOptions) { + return this.serviceClient.int32SecondsArrayWithResponseAsync(input, requestOptions); + } + + /** + * The defaultMethod 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 defaultMethod(Duration input) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defaultMethodWithResponse(input, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The iso8601 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 iso8601(Duration input) { + // Generated convenience method for iso8601WithResponse + RequestOptions requestOptions = new RequestOptions(); + return iso8601WithResponse(input, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The int32Seconds 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 int32Seconds(Duration input) { + // Generated convenience method for int32SecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return int32SecondsWithResponse(input, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The floatSeconds 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 floatSeconds(Duration input) { + // Generated convenience method for floatSecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return floatSecondsWithResponse(input, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The float64Seconds 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 float64Seconds(Duration input) { + // Generated convenience method for float64SecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return float64SecondsWithResponse(input, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The int32SecondsArray 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 int32SecondsArray(List input) { + // Generated convenience method for int32SecondsArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return int32SecondsArrayWithResponse(input, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/QueryClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/QueryClient.java new file mode 100644 index 000000000..b8675c0a5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/QueryClient.java @@ -0,0 +1,254 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration; + +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.encode.duration.implementation.QueriesImpl; +import java.time.Duration; +import java.util.List; + +/** + * Initializes a new instance of the synchronous DurationClient type. + */ +@ServiceClient(builder = DurationClientBuilder.class) +public final class QueryClient { + @Generated + private final QueriesImpl serviceClient; + + /** + * Initializes an instance of QueryClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + QueryClient(QueriesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The defaultMethod operation. + * + * @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 defaultMethodWithResponse(Duration input, RequestOptions requestOptions) { + return this.serviceClient.defaultMethodWithResponse(input, requestOptions); + } + + /** + * The iso8601 operation. + * + * @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 iso8601WithResponse(Duration input, RequestOptions requestOptions) { + return this.serviceClient.iso8601WithResponse(input, requestOptions); + } + + /** + * The int32Seconds operation. + * + * @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 int32SecondsWithResponse(Duration input, RequestOptions requestOptions) { + return this.serviceClient.int32SecondsWithResponse(input, requestOptions); + } + + /** + * The floatSeconds operation. + * + * @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 floatSecondsWithResponse(Duration input, RequestOptions requestOptions) { + return this.serviceClient.floatSecondsWithResponse(input, requestOptions); + } + + /** + * The float64Seconds operation. + * + * @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 float64SecondsWithResponse(Duration input, RequestOptions requestOptions) { + return this.serviceClient.float64SecondsWithResponse(input, requestOptions); + } + + /** + * The int32SecondsArray operation. + * + * @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 int32SecondsArrayWithResponse(List input, RequestOptions requestOptions) { + return this.serviceClient.int32SecondsArrayWithResponse(input, requestOptions); + } + + /** + * The defaultMethod 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 defaultMethod(Duration input) { + // Generated convenience method for defaultMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + defaultMethodWithResponse(input, requestOptions).getValue(); + } + + /** + * The iso8601 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 iso8601(Duration input) { + // Generated convenience method for iso8601WithResponse + RequestOptions requestOptions = new RequestOptions(); + iso8601WithResponse(input, requestOptions).getValue(); + } + + /** + * The int32Seconds 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 int32Seconds(Duration input) { + // Generated convenience method for int32SecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + int32SecondsWithResponse(input, requestOptions).getValue(); + } + + /** + * The floatSeconds 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 floatSeconds(Duration input) { + // Generated convenience method for floatSecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + floatSecondsWithResponse(input, requestOptions).getValue(); + } + + /** + * The float64Seconds 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 float64Seconds(Duration input) { + // Generated convenience method for float64SecondsWithResponse + RequestOptions requestOptions = new RequestOptions(); + float64SecondsWithResponse(input, requestOptions).getValue(); + } + + /** + * The int32SecondsArray 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 int32SecondsArray(List input) { + // Generated convenience method for int32SecondsArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + int32SecondsArrayWithResponse(input, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/DurationClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/DurationClientImpl.java new file mode 100644 index 000000000..9d731a2bd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/DurationClientImpl.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the DurationClient type. + */ +public final class DurationClientImpl { + /** + * 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; + } + + /** + * The QueriesImpl object to access its operations. + */ + private final QueriesImpl queries; + + /** + * Gets the QueriesImpl object to access its operations. + * + * @return the QueriesImpl object. + */ + public QueriesImpl getQueries() { + return this.queries; + } + + /** + * The PropertiesImpl object to access its operations. + */ + private final PropertiesImpl properties; + + /** + * Gets the PropertiesImpl object to access its operations. + * + * @return the PropertiesImpl object. + */ + public PropertiesImpl getProperties() { + return this.properties; + } + + /** + * The HeadersImpl object to access its operations. + */ + private final HeadersImpl headers; + + /** + * Gets the HeadersImpl object to access its operations. + * + * @return the HeadersImpl object. + */ + public HeadersImpl getHeaders() { + return this.headers; + } + + /** + * Initializes an instance of DurationClient client. + * + * @param endpoint Service host. + */ + public DurationClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of DurationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public DurationClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of DurationClient 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 DurationClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.queries = new QueriesImpl(this); + this.properties = new PropertiesImpl(this); + this.headers = new HeadersImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/HeadersImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/HeadersImpl.java new file mode 100644 index 000000000..a966e154f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/HeadersImpl.java @@ -0,0 +1,378 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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 com.azure.core.util.serializer.CollectionFormat; +import com.azure.core.util.serializer.JacksonAdapter; +import java.time.Duration; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Headers. + */ +public final class HeadersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final HeadersService service; + + /** + * The service client containing this operation class. + */ + private final DurationClientImpl client; + + /** + * Initializes an instance of HeadersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + HeadersImpl(DurationClientImpl client) { + this.service = RestProxy.create(HeadersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DurationClientHeaders to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DurationClientHeader") + public interface HeadersService { + @Get("/encode/duration/header/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> defaultMethod(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") Duration duration, RequestOptions requestOptions, Context context); + + @Get("/encode/duration/header/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defaultMethodSync(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") Duration duration, RequestOptions requestOptions, Context context); + + @Get("/encode/duration/header/iso8601") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> iso8601(@HostParam("endpoint") String endpoint, @HeaderParam("duration") Duration duration, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/header/iso8601") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response iso8601Sync(@HostParam("endpoint") String endpoint, @HeaderParam("duration") Duration duration, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/header/iso8601-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> iso8601Array(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") String duration, RequestOptions requestOptions, Context context); + + @Get("/encode/duration/header/iso8601-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response iso8601ArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") String duration, RequestOptions requestOptions, Context context); + + @Get("/encode/duration/header/int32-seconds") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> int32Seconds(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") long duration, RequestOptions requestOptions, Context context); + + @Get("/encode/duration/header/int32-seconds") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response int32SecondsSync(@HostParam("endpoint") String endpoint, @HeaderParam("duration") long duration, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/header/float-seconds") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> floatSeconds(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") double duration, RequestOptions requestOptions, Context context); + + @Get("/encode/duration/header/float-seconds") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response floatSecondsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") double duration, RequestOptions requestOptions, Context context); + + @Get("/encode/duration/header/float64-seconds") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> float64Seconds(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") double duration, RequestOptions requestOptions, Context context); + + @Get("/encode/duration/header/float64-seconds") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response float64SecondsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("duration") double duration, RequestOptions requestOptions, Context context); + } + + /** + * The defaultMethod operation. + * + * @param duration The duration 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> defaultMethodWithResponseAsync(Duration duration, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.defaultMethod(this.client.getEndpoint(), duration, requestOptions, context)); + } + + /** + * The defaultMethod operation. + * + * @param duration The duration 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 defaultMethodWithResponse(Duration duration, RequestOptions requestOptions) { + return service.defaultMethodSync(this.client.getEndpoint(), duration, requestOptions, Context.NONE); + } + + /** + * The iso8601 operation. + * + * @param duration The duration 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> iso8601WithResponseAsync(Duration duration, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.iso8601(this.client.getEndpoint(), duration, requestOptions, context)); + } + + /** + * The iso8601 operation. + * + * @param duration The duration 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 iso8601WithResponse(Duration duration, RequestOptions requestOptions) { + return service.iso8601Sync(this.client.getEndpoint(), duration, requestOptions, Context.NONE); + } + + /** + * The iso8601Array operation. + * + * @param duration The duration 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> iso8601ArrayWithResponseAsync(List duration, RequestOptions requestOptions) { + String durationConverted + = JacksonAdapter.createDefaultSerializerAdapter().serializeIterable(duration, CollectionFormat.CSV); + return FluxUtil.withContext( + context -> service.iso8601Array(this.client.getEndpoint(), durationConverted, requestOptions, context)); + } + + /** + * The iso8601Array operation. + * + * @param duration The duration 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 iso8601ArrayWithResponse(List duration, RequestOptions requestOptions) { + String durationConverted + = JacksonAdapter.createDefaultSerializerAdapter().serializeIterable(duration, CollectionFormat.CSV); + return service.iso8601ArraySync(this.client.getEndpoint(), durationConverted, requestOptions, Context.NONE); + } + + /** + * The int32Seconds operation. + * + * @param duration The duration 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> int32SecondsWithResponseAsync(Duration duration, RequestOptions requestOptions) { + long durationConverted = duration.getSeconds(); + return FluxUtil.withContext( + context -> service.int32Seconds(this.client.getEndpoint(), durationConverted, requestOptions, context)); + } + + /** + * The int32Seconds operation. + * + * @param duration The duration 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 int32SecondsWithResponse(Duration duration, RequestOptions requestOptions) { + long durationConverted = duration.getSeconds(); + return service.int32SecondsSync(this.client.getEndpoint(), durationConverted, requestOptions, Context.NONE); + } + + /** + * The floatSeconds operation. + * + * @param duration The duration 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> floatSecondsWithResponseAsync(Duration duration, RequestOptions requestOptions) { + double durationConverted = (double) duration.toNanos() / 1000_000_000L; + return FluxUtil.withContext( + context -> service.floatSeconds(this.client.getEndpoint(), durationConverted, requestOptions, context)); + } + + /** + * The floatSeconds operation. + * + * @param duration The duration 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 floatSecondsWithResponse(Duration duration, RequestOptions requestOptions) { + double durationConverted = (double) duration.toNanos() / 1000_000_000L; + return service.floatSecondsSync(this.client.getEndpoint(), durationConverted, requestOptions, Context.NONE); + } + + /** + * The float64Seconds operation. + * + * @param duration The duration 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> float64SecondsWithResponseAsync(Duration duration, RequestOptions requestOptions) { + double durationConverted = (double) duration.toNanos() / 1000_000_000L; + return FluxUtil.withContext( + context -> service.float64Seconds(this.client.getEndpoint(), durationConverted, requestOptions, context)); + } + + /** + * The float64Seconds operation. + * + * @param duration The duration 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 float64SecondsWithResponse(Duration duration, RequestOptions requestOptions) { + double durationConverted = (double) duration.toNanos() / 1000_000_000L; + return service.float64SecondsSync(this.client.getEndpoint(), durationConverted, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/PropertiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/PropertiesImpl.java new file mode 100644 index 000000000..d3f98e085 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/PropertiesImpl.java @@ -0,0 +1,597 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Properties. + */ +public final class PropertiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PropertiesService service; + + /** + * The service client containing this operation class. + */ + private final DurationClientImpl client; + + /** + * Initializes an instance of PropertiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PropertiesImpl(DurationClientImpl client) { + this.service + = RestProxy.create(PropertiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DurationClientProperties to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DurationClientProper") + public interface PropertiesService { + @Post("/encode/duration/property/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> defaultMethod(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/duration/property/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defaultMethodSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/duration/property/iso8601") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> iso8601(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/duration/property/iso8601") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response iso8601Sync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/duration/property/int32-seconds") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> int32Seconds(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/duration/property/int32-seconds") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response int32SecondsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/duration/property/float-seconds") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> floatSeconds(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/duration/property/float-seconds") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response floatSecondsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/duration/property/float64-seconds") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> float64Seconds(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/duration/property/float64-seconds") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response float64SecondsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/duration/property/float-seconds-array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> floatSecondsArray(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/duration/property/float-seconds-array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response floatSecondsArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> defaultMethodWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.defaultMethod(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The defaultMethod operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response defaultMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.defaultMethodSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The iso8601 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> iso8601WithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.iso8601(this.client.getEndpoint(), contentType, accept, body, requestOptions, context)); + } + + /** + * The iso8601 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: Duration (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response iso8601WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.iso8601Sync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); + } + + /** + * The int32Seconds operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> int32SecondsWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.int32Seconds(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The int32Seconds operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response int32SecondsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.int32SecondsSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The floatSeconds operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> floatSecondsWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.floatSeconds(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The floatSeconds operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response floatSecondsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.floatSecondsSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The float64Seconds operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> float64SecondsWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.float64Seconds(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The float64Seconds operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value: double (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response float64SecondsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.float64SecondsSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The floatSecondsArray operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         double (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         double (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> floatSecondsArrayWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.floatSecondsArray(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The floatSecondsArray operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         double (Required)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     value (Required): [
+     *         double (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response floatSecondsArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.floatSecondsArraySync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/QueriesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/QueriesImpl.java new file mode 100644 index 000000000..ce7f88f87 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/QueriesImpl.java @@ -0,0 +1,384 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration.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 com.azure.core.util.serializer.CollectionFormat; +import com.azure.core.util.serializer.JacksonAdapter; +import java.time.Duration; +import java.util.List; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Queries. + */ +public final class QueriesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QueriesService service; + + /** + * The service client containing this operation class. + */ + private final DurationClientImpl client; + + /** + * Initializes an instance of QueriesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QueriesImpl(DurationClientImpl client) { + this.service = RestProxy.create(QueriesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DurationClientQueries to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DurationClientQuerie") + public interface QueriesService { + @Get("/encode/duration/query/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> defaultMethod(@HostParam("endpoint") String endpoint, @QueryParam("input") Duration input, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/query/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defaultMethodSync(@HostParam("endpoint") String endpoint, @QueryParam("input") Duration input, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/query/iso8601") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> iso8601(@HostParam("endpoint") String endpoint, @QueryParam("input") Duration input, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/query/iso8601") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response iso8601Sync(@HostParam("endpoint") String endpoint, @QueryParam("input") Duration input, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/query/int32-seconds") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> int32Seconds(@HostParam("endpoint") String endpoint, @QueryParam("input") long input, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/query/int32-seconds") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response int32SecondsSync(@HostParam("endpoint") String endpoint, @QueryParam("input") long input, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/query/float-seconds") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> floatSeconds(@HostParam("endpoint") String endpoint, @QueryParam("input") double input, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/query/float-seconds") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response floatSecondsSync(@HostParam("endpoint") String endpoint, @QueryParam("input") double input, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/query/float64-seconds") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> float64Seconds(@HostParam("endpoint") String endpoint, @QueryParam("input") double input, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/query/float64-seconds") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response float64SecondsSync(@HostParam("endpoint") String endpoint, @QueryParam("input") double input, + RequestOptions requestOptions, Context context); + + @Get("/encode/duration/query/int32-seconds-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> int32SecondsArray(@HostParam("endpoint") String endpoint, + @QueryParam("input") String input, RequestOptions requestOptions, Context context); + + @Get("/encode/duration/query/int32-seconds-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response int32SecondsArraySync(@HostParam("endpoint") String endpoint, @QueryParam("input") String input, + RequestOptions requestOptions, Context context); + } + + /** + * The defaultMethod operation. + * + * @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> defaultMethodWithResponseAsync(Duration input, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.defaultMethod(this.client.getEndpoint(), input, requestOptions, context)); + } + + /** + * The defaultMethod operation. + * + * @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 defaultMethodWithResponse(Duration input, RequestOptions requestOptions) { + return service.defaultMethodSync(this.client.getEndpoint(), input, requestOptions, Context.NONE); + } + + /** + * The iso8601 operation. + * + * @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> iso8601WithResponseAsync(Duration input, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.iso8601(this.client.getEndpoint(), input, requestOptions, context)); + } + + /** + * The iso8601 operation. + * + * @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 iso8601WithResponse(Duration input, RequestOptions requestOptions) { + return service.iso8601Sync(this.client.getEndpoint(), input, requestOptions, Context.NONE); + } + + /** + * The int32Seconds operation. + * + * @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> int32SecondsWithResponseAsync(Duration input, RequestOptions requestOptions) { + long inputConverted = input.getSeconds(); + return FluxUtil.withContext( + context -> service.int32Seconds(this.client.getEndpoint(), inputConverted, requestOptions, context)); + } + + /** + * The int32Seconds operation. + * + * @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 int32SecondsWithResponse(Duration input, RequestOptions requestOptions) { + long inputConverted = input.getSeconds(); + return service.int32SecondsSync(this.client.getEndpoint(), inputConverted, requestOptions, Context.NONE); + } + + /** + * The floatSeconds operation. + * + * @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> floatSecondsWithResponseAsync(Duration input, RequestOptions requestOptions) { + double inputConverted = (double) input.toNanos() / 1000_000_000L; + return FluxUtil.withContext( + context -> service.floatSeconds(this.client.getEndpoint(), inputConverted, requestOptions, context)); + } + + /** + * The floatSeconds operation. + * + * @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 floatSecondsWithResponse(Duration input, RequestOptions requestOptions) { + double inputConverted = (double) input.toNanos() / 1000_000_000L; + return service.floatSecondsSync(this.client.getEndpoint(), inputConverted, requestOptions, Context.NONE); + } + + /** + * The float64Seconds operation. + * + * @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> float64SecondsWithResponseAsync(Duration input, RequestOptions requestOptions) { + double inputConverted = (double) input.toNanos() / 1000_000_000L; + return FluxUtil.withContext( + context -> service.float64Seconds(this.client.getEndpoint(), inputConverted, requestOptions, context)); + } + + /** + * The float64Seconds operation. + * + * @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 float64SecondsWithResponse(Duration input, RequestOptions requestOptions) { + double inputConverted = (double) input.toNanos() / 1000_000_000L; + return service.float64SecondsSync(this.client.getEndpoint(), inputConverted, requestOptions, Context.NONE); + } + + /** + * The int32SecondsArray operation. + * + * @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> int32SecondsArrayWithResponseAsync(List input, + RequestOptions requestOptions) { + String inputConverted = JacksonAdapter.createDefaultSerializerAdapter() + .serializeIterable( + input.stream().map(paramItemValue -> paramItemValue.getSeconds()).collect(Collectors.toList()), + CollectionFormat.CSV); + return FluxUtil.withContext( + context -> service.int32SecondsArray(this.client.getEndpoint(), inputConverted, requestOptions, context)); + } + + /** + * The int32SecondsArray operation. + * + * @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 int32SecondsArrayWithResponse(List input, RequestOptions requestOptions) { + String inputConverted = JacksonAdapter.createDefaultSerializerAdapter() + .serializeIterable( + input.stream().map(paramItemValue -> paramItemValue.getSeconds()).collect(Collectors.toList()), + CollectionFormat.CSV); + return service.int32SecondsArraySync(this.client.getEndpoint(), inputConverted, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/implementation/package-info.java new file mode 100644 index 000000000..571f89ae6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/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 DurationModel. + * Test for encode decorator on duration. + * + */ +package com.encode.duration.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/DefaultDurationProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/DefaultDurationProperty.java new file mode 100644 index 000000000..931147c71 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/DefaultDurationProperty.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 com.encode.duration.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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.time.Duration; + +/** + * The DefaultDurationProperty model. + */ +@Immutable +public final class DefaultDurationProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final Duration value; + + /** + * Creates an instance of DefaultDurationProperty class. + * + * @param value the value value to set. + */ + @Generated + public DefaultDurationProperty(Duration value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public Duration getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", CoreUtils.durationToStringWithDays(this.value)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DefaultDurationProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DefaultDurationProperty 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 DefaultDurationProperty. + */ + @Generated + public static DefaultDurationProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Duration value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new DefaultDurationProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/Float64SecondsDurationProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/Float64SecondsDurationProperty.java new file mode 100644 index 000000000..af3c3035e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/Float64SecondsDurationProperty.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 com.encode.duration.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; +import java.time.Duration; + +/** + * The Float64SecondsDurationProperty model. + */ +@Immutable +public final class Float64SecondsDurationProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final double value; + + /** + * Creates an instance of Float64SecondsDurationProperty class. + * + * @param value the value value to set. + */ + @Generated + public Float64SecondsDurationProperty(Duration value) { + if (value == null) { + this.value = 0.0; + } else { + this.value = (double) value.toNanos() / 1000_000_000L; + } + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public Duration getValue() { + return Duration.ofNanos((long) (this.value * 1000_000_000L)); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Float64SecondsDurationProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Float64SecondsDurationProperty 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 Float64SecondsDurationProperty. + */ + @Generated + public static Float64SecondsDurationProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Duration value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = Duration.ofNanos((long) (reader.getDouble() * 1000_000_000L)); + } else { + reader.skipChildren(); + } + } + return new Float64SecondsDurationProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/FloatSecondsDurationArrayProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/FloatSecondsDurationArrayProperty.java new file mode 100644 index 000000000..624af16db --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/FloatSecondsDurationArrayProperty.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration.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; +import java.time.Duration; +import java.util.List; + +/** + * The FloatSecondsDurationArrayProperty model. + */ +@Immutable +public final class FloatSecondsDurationArrayProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final List value; + + /** + * Creates an instance of FloatSecondsDurationArrayProperty class. + * + * @param value the value value to set. + */ + @Generated + public FloatSecondsDurationArrayProperty(List value) { + if (value == null) { + this.value = null; + } else { + this.value = value.stream() + .map(el -> (double) el.toNanos() / 1000_000_000L) + .collect(java.util.stream.Collectors.toList()); + } + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public List getValue() { + if (this.value == null) { + return null; + } + return this.value.stream() + .map(el -> Duration.ofNanos((long) (el * 1000_000_000L))) + .collect(java.util.stream.Collectors.toList()); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeDouble(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FloatSecondsDurationArrayProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FloatSecondsDurationArrayProperty 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 FloatSecondsDurationArrayProperty. + */ + @Generated + public static FloatSecondsDurationArrayProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.readArray(reader1 -> Duration.ofNanos((long) (reader1.getDouble() * 1000_000_000L))); + } else { + reader.skipChildren(); + } + } + return new FloatSecondsDurationArrayProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/FloatSecondsDurationProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/FloatSecondsDurationProperty.java new file mode 100644 index 000000000..ca0298884 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/FloatSecondsDurationProperty.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 com.encode.duration.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; +import java.time.Duration; + +/** + * The FloatSecondsDurationProperty model. + */ +@Immutable +public final class FloatSecondsDurationProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final double value; + + /** + * Creates an instance of FloatSecondsDurationProperty class. + * + * @param value the value value to set. + */ + @Generated + public FloatSecondsDurationProperty(Duration value) { + if (value == null) { + this.value = 0.0; + } else { + this.value = (double) value.toNanos() / 1000_000_000L; + } + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public Duration getValue() { + return Duration.ofNanos((long) (this.value * 1000_000_000L)); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FloatSecondsDurationProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FloatSecondsDurationProperty 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 FloatSecondsDurationProperty. + */ + @Generated + public static FloatSecondsDurationProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Duration value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = Duration.ofNanos((long) (reader.getDouble() * 1000_000_000L)); + } else { + reader.skipChildren(); + } + } + return new FloatSecondsDurationProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/ISO8601DurationProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/ISO8601DurationProperty.java new file mode 100644 index 000000000..5e1d2f2a6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/ISO8601DurationProperty.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 com.encode.duration.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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.time.Duration; + +/** + * The ISO8601DurationProperty model. + */ +@Immutable +public final class ISO8601DurationProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final Duration value; + + /** + * Creates an instance of ISO8601DurationProperty class. + * + * @param value the value value to set. + */ + @Generated + public ISO8601DurationProperty(Duration value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public Duration getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", CoreUtils.durationToStringWithDays(this.value)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ISO8601DurationProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ISO8601DurationProperty 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 ISO8601DurationProperty. + */ + @Generated + public static ISO8601DurationProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Duration value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new ISO8601DurationProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/Int32SecondsDurationProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/Int32SecondsDurationProperty.java new file mode 100644 index 000000000..7cdde89d0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/Int32SecondsDurationProperty.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 com.encode.duration.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; +import java.time.Duration; + +/** + * The Int32SecondsDurationProperty model. + */ +@Immutable +public final class Int32SecondsDurationProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final long value; + + /** + * Creates an instance of Int32SecondsDurationProperty class. + * + * @param value the value value to set. + */ + @Generated + public Int32SecondsDurationProperty(Duration value) { + if (value == null) { + this.value = 0L; + } else { + this.value = value.getSeconds(); + } + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public Duration getValue() { + return Duration.ofSeconds(this.value); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeLongField("value", this.value); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Int32SecondsDurationProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Int32SecondsDurationProperty 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 Int32SecondsDurationProperty. + */ + @Generated + public static Int32SecondsDurationProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Duration value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = Duration.ofSeconds(reader.getLong()); + } else { + reader.skipChildren(); + } + } + return new Int32SecondsDurationProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/models/package-info.java new file mode 100644 index 000000000..b727def84 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/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 DurationModel. + * Test for encode decorator on duration. + * + */ +package com.encode.duration.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/package-info.java new file mode 100644 index 000000000..db6338155 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/encode/duration/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 DurationModel. + * Test for encode decorator on duration. + * + */ +package com.encode.duration; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/BasicClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/BasicClientBuilder.java new file mode 100644 index 000000000..db9f8484e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/BasicClientBuilder.java @@ -0,0 +1,312 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.basic; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.parameters.basic.implementation.BasicClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the BasicClient type. + */ +@ServiceClientBuilder( + serviceClients = { + ExplicitBodyClient.class, + ImplicitBodyClient.class, + ExplicitBodyAsyncClient.class, + ImplicitBodyAsyncClient.class }) +public final class BasicClientBuilder 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-basic.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the BasicClientBuilder. + */ + @Generated + public BasicClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BasicClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BasicClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BasicClientBuilder 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 BasicClientBuilder 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 BasicClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BasicClientBuilder 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 BasicClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BasicClientBuilder 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 BasicClientBuilder. + */ + @Generated + public BasicClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of BasicClientImpl with the provided parameters. + * + * @return an instance of BasicClientImpl. + */ + @Generated + private BasicClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + BasicClientImpl client + = new BasicClientImpl(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 ExplicitBodyAsyncClient class. + * + * @return an instance of ExplicitBodyAsyncClient. + */ + @Generated + public ExplicitBodyAsyncClient buildExplicitBodyAsyncClient() { + return new ExplicitBodyAsyncClient(buildInnerClient().getExplicitBodies()); + } + + /** + * Builds an instance of ImplicitBodyAsyncClient class. + * + * @return an instance of ImplicitBodyAsyncClient. + */ + @Generated + public ImplicitBodyAsyncClient buildImplicitBodyAsyncClient() { + return new ImplicitBodyAsyncClient(buildInnerClient().getImplicitBodies()); + } + + /** + * Builds an instance of ExplicitBodyClient class. + * + * @return an instance of ExplicitBodyClient. + */ + @Generated + public ExplicitBodyClient buildExplicitBodyClient() { + return new ExplicitBodyClient(buildInnerClient().getExplicitBodies()); + } + + /** + * Builds an instance of ImplicitBodyClient class. + * + * @return an instance of ImplicitBodyClient. + */ + @Generated + public ImplicitBodyClient buildImplicitBodyClient() { + return new ImplicitBodyClient(buildInnerClient().getImplicitBodies()); + } + + private static final ClientLogger LOGGER = new ClientLogger(BasicClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/ExplicitBodyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/ExplicitBodyAsyncClient.java new file mode 100644 index 000000000..fdf00056d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/ExplicitBodyAsyncClient.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.basic; + +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 com.parameters.basic.implementation.ExplicitBodiesImpl; +import com.parameters.basic.models.User; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BasicClient type. + */ +@ServiceClient(builder = BasicClientBuilder.class, isAsync = true) +public final class ExplicitBodyAsyncClient { + @Generated + private final ExplicitBodiesImpl serviceClient; + + /** + * Initializes an instance of ExplicitBodyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExplicitBodyAsyncClient(ExplicitBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The simple operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> simpleWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.simpleWithResponseAsync(body, requestOptions); + } + + /** + * The simple operation. + * + * @param body The body 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 simple(User body) { + // Generated convenience method for simpleWithResponse + RequestOptions requestOptions = new RequestOptions(); + return simpleWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/ExplicitBodyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/ExplicitBodyClient.java new file mode 100644 index 000000000..ee13ecf9b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/ExplicitBodyClient.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.basic; + +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.parameters.basic.implementation.ExplicitBodiesImpl; +import com.parameters.basic.models.User; + +/** + * Initializes a new instance of the synchronous BasicClient type. + */ +@ServiceClient(builder = BasicClientBuilder.class) +public final class ExplicitBodyClient { + @Generated + private final ExplicitBodiesImpl serviceClient; + + /** + * Initializes an instance of ExplicitBodyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExplicitBodyClient(ExplicitBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The simple operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 simpleWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.simpleWithResponse(body, requestOptions); + } + + /** + * The simple operation. + * + * @param body The body 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 simple(User body) { + // Generated convenience method for simpleWithResponse + RequestOptions requestOptions = new RequestOptions(); + simpleWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/ImplicitBodyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/ImplicitBodyAsyncClient.java new file mode 100644 index 000000000..f46dacbd4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/ImplicitBodyAsyncClient.java @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.basic; + +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 com.parameters.basic.implementation.ImplicitBodiesImpl; +import com.parameters.basic.implementation.models.SimpleRequest; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BasicClient type. + */ +@ServiceClient(builder = BasicClientBuilder.class, isAsync = true) +public final class ImplicitBodyAsyncClient { + @Generated + private final ImplicitBodiesImpl serviceClient; + + /** + * Initializes an instance of ImplicitBodyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ImplicitBodyAsyncClient(ImplicitBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The simple operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param simpleRequest The simpleRequest 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> simpleWithResponse(BinaryData simpleRequest, RequestOptions requestOptions) { + return this.serviceClient.simpleWithResponseAsync(simpleRequest, requestOptions); + } + + /** + * The simple operation. + * + * @param name The name 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 simple(String name) { + // Generated convenience method for simpleWithResponse + RequestOptions requestOptions = new RequestOptions(); + SimpleRequest simpleRequestObj = new SimpleRequest(name); + BinaryData simpleRequest = BinaryData.fromObject(simpleRequestObj); + return simpleWithResponse(simpleRequest, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/ImplicitBodyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/ImplicitBodyClient.java new file mode 100644 index 000000000..bb3c238c1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/ImplicitBodyClient.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.basic; + +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.parameters.basic.implementation.ImplicitBodiesImpl; +import com.parameters.basic.implementation.models.SimpleRequest; + +/** + * Initializes a new instance of the synchronous BasicClient type. + */ +@ServiceClient(builder = BasicClientBuilder.class) +public final class ImplicitBodyClient { + @Generated + private final ImplicitBodiesImpl serviceClient; + + /** + * Initializes an instance of ImplicitBodyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ImplicitBodyClient(ImplicitBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The simple operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param simpleRequest The simpleRequest 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 simpleWithResponse(BinaryData simpleRequest, RequestOptions requestOptions) { + return this.serviceClient.simpleWithResponse(simpleRequest, requestOptions); + } + + /** + * The simple operation. + * + * @param name The name 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 simple(String name) { + // Generated convenience method for simpleWithResponse + RequestOptions requestOptions = new RequestOptions(); + SimpleRequest simpleRequestObj = new SimpleRequest(name); + BinaryData simpleRequest = BinaryData.fromObject(simpleRequestObj); + simpleWithResponse(simpleRequest, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/BasicClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/BasicClientImpl.java new file mode 100644 index 000000000..d1abd782b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/BasicClientImpl.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 com.parameters.basic.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the BasicClient type. + */ +public final class BasicClientImpl { + /** + * 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; + } + + /** + * The ExplicitBodiesImpl object to access its operations. + */ + private final ExplicitBodiesImpl explicitBodies; + + /** + * Gets the ExplicitBodiesImpl object to access its operations. + * + * @return the ExplicitBodiesImpl object. + */ + public ExplicitBodiesImpl getExplicitBodies() { + return this.explicitBodies; + } + + /** + * The ImplicitBodiesImpl object to access its operations. + */ + private final ImplicitBodiesImpl implicitBodies; + + /** + * Gets the ImplicitBodiesImpl object to access its operations. + * + * @return the ImplicitBodiesImpl object. + */ + public ImplicitBodiesImpl getImplicitBodies() { + return this.implicitBodies; + } + + /** + * Initializes an instance of BasicClient client. + * + * @param endpoint Service host. + */ + public BasicClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of BasicClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public BasicClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of BasicClient 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 BasicClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.explicitBodies = new ExplicitBodiesImpl(this); + this.implicitBodies = new ImplicitBodiesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/ExplicitBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/ExplicitBodiesImpl.java new file mode 100644 index 000000000..1d8fb5892 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/ExplicitBodiesImpl.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.basic.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.Put; +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.BinaryData; +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 ExplicitBodies. + */ +public final class ExplicitBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExplicitBodiesService service; + + /** + * The service client containing this operation class. + */ + private final BasicClientImpl client; + + /** + * Initializes an instance of ExplicitBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExplicitBodiesImpl(BasicClientImpl client) { + this.service + = RestProxy.create(ExplicitBodiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for BasicClientExplicitBodies to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BasicClientExplicitB") + public interface ExplicitBodiesService { + @Put("/parameters/basic/explicit-body/simple") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> simple(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/parameters/basic/explicit-body/simple") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response simpleSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The simple operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> simpleWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.simple(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The simple operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 simpleWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.simpleSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/ImplicitBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/ImplicitBodiesImpl.java new file mode 100644 index 000000000..1278afcde --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/ImplicitBodiesImpl.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.basic.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.Put; +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.BinaryData; +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 ImplicitBodies. + */ +public final class ImplicitBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ImplicitBodiesService service; + + /** + * The service client containing this operation class. + */ + private final BasicClientImpl client; + + /** + * Initializes an instance of ImplicitBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ImplicitBodiesImpl(BasicClientImpl client) { + this.service + = RestProxy.create(ImplicitBodiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for BasicClientImplicitBodies to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BasicClientImplicitB") + public interface ImplicitBodiesService { + @Put("/parameters/basic/implicit-body/simple") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> simple(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData simpleRequest, + RequestOptions requestOptions, Context context); + + @Put("/parameters/basic/implicit-body/simple") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response simpleSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData simpleRequest, + RequestOptions requestOptions, Context context); + } + + /** + * The simple operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param simpleRequest The simpleRequest 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> simpleWithResponseAsync(BinaryData simpleRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.simple(this.client.getEndpoint(), contentType, simpleRequest, requestOptions, context)); + } + + /** + * The simple operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param simpleRequest The simpleRequest 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 simpleWithResponse(BinaryData simpleRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.simpleSync(this.client.getEndpoint(), contentType, simpleRequest, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/models/SimpleRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/models/SimpleRequest.java new file mode 100644 index 000000000..842595b4d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/models/SimpleRequest.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.basic.implementation.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; + +/** + * The SimpleRequest model. + */ +@Immutable +public final class SimpleRequest implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of SimpleRequest class. + * + * @param name the name value to set. + */ + @Generated + public SimpleRequest(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SimpleRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SimpleRequest 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 SimpleRequest. + */ + @Generated + public static SimpleRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SimpleRequest(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/models/package-info.java new file mode 100644 index 000000000..8c9a79b53 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/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 Basic. + * Test for basic parameters cases. + * + */ +package com.parameters.basic.implementation.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/implementation/package-info.java new file mode 100644 index 000000000..8f216e31c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/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 Basic. + * Test for basic parameters cases. + * + */ +package com.parameters.basic.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/models/User.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/models/User.java new file mode 100644 index 000000000..47c8d308f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/models/User.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.basic.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; + +/** + * This is a simple model. + */ +@Immutable +public final class User implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of User class. + * + * @param name the name value to set. + */ + @Generated + public User(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of User from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of User 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 User. + */ + @Generated + public static User fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new User(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/models/package-info.java new file mode 100644 index 000000000..93857b776 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/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 Basic. + * Test for basic parameters cases. + * + */ +package com.parameters.basic.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/package-info.java new file mode 100644 index 000000000..8cf26894c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/basic/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 Basic. + * Test for basic parameters cases. + * + */ +package com.parameters.basic; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/BodyOptionalityAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/BodyOptionalityAsyncClient.java new file mode 100644 index 000000000..f06a21f59 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/BodyOptionalityAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.bodyoptionality; + +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 com.parameters.bodyoptionality.implementation.BodyOptionalityClientImpl; +import com.parameters.bodyoptionality.implementation.models.RequiredImplicitRequest; +import com.parameters.bodyoptionality.models.BodyModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BodyOptionalityClient type. + */ +@ServiceClient(builder = BodyOptionalityClientBuilder.class, isAsync = true) +public final class BodyOptionalityAsyncClient { + @Generated + private final BodyOptionalityClientImpl serviceClient; + + /** + * Initializes an instance of BodyOptionalityAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BodyOptionalityAsyncClient(BodyOptionalityClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The requiredExplicit operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> requiredExplicitWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.requiredExplicitWithResponseAsync(body, requestOptions); + } + + /** + * The requiredImplicit operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param requiredImplicitRequest The requiredImplicitRequest 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> requiredImplicitWithResponse(BinaryData requiredImplicitRequest, + RequestOptions requestOptions) { + return this.serviceClient.requiredImplicitWithResponseAsync(requiredImplicitRequest, requestOptions); + } + + /** + * The requiredExplicit operation. + * + * @param body The body 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 requiredExplicit(BodyModel body) { + // Generated convenience method for requiredExplicitWithResponse + RequestOptions requestOptions = new RequestOptions(); + return requiredExplicitWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The requiredImplicit operation. + * + * @param name The name 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 requiredImplicit(String name) { + // Generated convenience method for requiredImplicitWithResponse + RequestOptions requestOptions = new RequestOptions(); + RequiredImplicitRequest requiredImplicitRequestObj = new RequiredImplicitRequest(name); + BinaryData requiredImplicitRequest = BinaryData.fromObject(requiredImplicitRequestObj); + return requiredImplicitWithResponse(requiredImplicitRequest, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/BodyOptionalityClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/BodyOptionalityClient.java new file mode 100644 index 000000000..ee0d67d69 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/BodyOptionalityClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.bodyoptionality; + +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.parameters.bodyoptionality.implementation.BodyOptionalityClientImpl; +import com.parameters.bodyoptionality.implementation.models.RequiredImplicitRequest; +import com.parameters.bodyoptionality.models.BodyModel; + +/** + * Initializes a new instance of the synchronous BodyOptionalityClient type. + */ +@ServiceClient(builder = BodyOptionalityClientBuilder.class) +public final class BodyOptionalityClient { + @Generated + private final BodyOptionalityClientImpl serviceClient; + + /** + * Initializes an instance of BodyOptionalityClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BodyOptionalityClient(BodyOptionalityClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The requiredExplicit operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 requiredExplicitWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.requiredExplicitWithResponse(body, requestOptions); + } + + /** + * The requiredImplicit operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param requiredImplicitRequest The requiredImplicitRequest 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 requiredImplicitWithResponse(BinaryData requiredImplicitRequest, + RequestOptions requestOptions) { + return this.serviceClient.requiredImplicitWithResponse(requiredImplicitRequest, requestOptions); + } + + /** + * The requiredExplicit operation. + * + * @param body The body 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 requiredExplicit(BodyModel body) { + // Generated convenience method for requiredExplicitWithResponse + RequestOptions requestOptions = new RequestOptions(); + requiredExplicitWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The requiredImplicit operation. + * + * @param name The name 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 requiredImplicit(String name) { + // Generated convenience method for requiredImplicitWithResponse + RequestOptions requestOptions = new RequestOptions(); + RequiredImplicitRequest requiredImplicitRequestObj = new RequiredImplicitRequest(name); + BinaryData requiredImplicitRequest = BinaryData.fromObject(requiredImplicitRequestObj); + requiredImplicitWithResponse(requiredImplicitRequest, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/BodyOptionalityClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/BodyOptionalityClientBuilder.java new file mode 100644 index 000000000..8ff3dc9c9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/BodyOptionalityClientBuilder.java @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.bodyoptionality; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.parameters.bodyoptionality.implementation.BodyOptionalityClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the BodyOptionalityClient type. + */ +@ServiceClientBuilder( + serviceClients = { + BodyOptionalityClient.class, + OptionalExplicitClient.class, + BodyOptionalityAsyncClient.class, + OptionalExplicitAsyncClient.class }) +public final class BodyOptionalityClientBuilder 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-bodyoptionality.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the BodyOptionalityClientBuilder. + */ + @Generated + public BodyOptionalityClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyOptionalityClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyOptionalityClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyOptionalityClientBuilder 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 BodyOptionalityClientBuilder 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 BodyOptionalityClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyOptionalityClientBuilder 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 BodyOptionalityClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public BodyOptionalityClientBuilder 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 BodyOptionalityClientBuilder. + */ + @Generated + public BodyOptionalityClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of BodyOptionalityClientImpl with the provided parameters. + * + * @return an instance of BodyOptionalityClientImpl. + */ + @Generated + private BodyOptionalityClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + BodyOptionalityClientImpl client = new BodyOptionalityClientImpl(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 BodyOptionalityAsyncClient class. + * + * @return an instance of BodyOptionalityAsyncClient. + */ + @Generated + public BodyOptionalityAsyncClient buildAsyncClient() { + return new BodyOptionalityAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of OptionalExplicitAsyncClient class. + * + * @return an instance of OptionalExplicitAsyncClient. + */ + @Generated + public OptionalExplicitAsyncClient buildOptionalExplicitAsyncClient() { + return new OptionalExplicitAsyncClient(buildInnerClient().getOptionalExplicits()); + } + + /** + * Builds an instance of BodyOptionalityClient class. + * + * @return an instance of BodyOptionalityClient. + */ + @Generated + public BodyOptionalityClient buildClient() { + return new BodyOptionalityClient(buildInnerClient()); + } + + /** + * Builds an instance of OptionalExplicitClient class. + * + * @return an instance of OptionalExplicitClient. + */ + @Generated + public OptionalExplicitClient buildOptionalExplicitClient() { + return new OptionalExplicitClient(buildInnerClient().getOptionalExplicits()); + } + + private static final ClientLogger LOGGER = new ClientLogger(BodyOptionalityClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/OptionalExplicitAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/OptionalExplicitAsyncClient.java new file mode 100644 index 000000000..3fc48d223 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/OptionalExplicitAsyncClient.java @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.bodyoptionality; + +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 com.parameters.bodyoptionality.implementation.OptionalExplicitsImpl; +import com.parameters.bodyoptionality.models.BodyModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous BodyOptionalityClient type. + */ +@ServiceClient(builder = BodyOptionalityClientBuilder.class, isAsync = true) +public final class OptionalExplicitAsyncClient { + @Generated + private final OptionalExplicitsImpl serviceClient; + + /** + * Initializes an instance of OptionalExplicitAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + OptionalExplicitAsyncClient(OptionalExplicitsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The set operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setWithResponse(RequestOptions requestOptions) { + return this.serviceClient.setWithResponseAsync(requestOptions); + } + + /** + * The omit operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> omitWithResponse(RequestOptions requestOptions) { + return this.serviceClient.omitWithResponseAsync(requestOptions); + } + + /** + * The set operation. + * + * @param body The body 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 set(BodyModel body) { + // Generated convenience method for setWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (body != null) { + requestOptions.setBody(BinaryData.fromObject(body)); + } + return setWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The set 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono set() { + // Generated convenience method for setWithResponse + RequestOptions requestOptions = new RequestOptions(); + return setWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The omit operation. + * + * @param body The body 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 omit(BodyModel body) { + // Generated convenience method for omitWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (body != null) { + requestOptions.setBody(BinaryData.fromObject(body)); + } + return omitWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The omit 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono omit() { + // Generated convenience method for omitWithResponse + RequestOptions requestOptions = new RequestOptions(); + return omitWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/OptionalExplicitClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/OptionalExplicitClient.java new file mode 100644 index 000000000..435a50794 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/OptionalExplicitClient.java @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.bodyoptionality; + +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.parameters.bodyoptionality.implementation.OptionalExplicitsImpl; +import com.parameters.bodyoptionality.models.BodyModel; + +/** + * Initializes a new instance of the synchronous BodyOptionalityClient type. + */ +@ServiceClient(builder = BodyOptionalityClientBuilder.class) +public final class OptionalExplicitClient { + @Generated + private final OptionalExplicitsImpl serviceClient; + + /** + * Initializes an instance of OptionalExplicitClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + OptionalExplicitClient(OptionalExplicitsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The set operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setWithResponse(RequestOptions requestOptions) { + return this.serviceClient.setWithResponse(requestOptions); + } + + /** + * The omit operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response omitWithResponse(RequestOptions requestOptions) { + return this.serviceClient.omitWithResponse(requestOptions); + } + + /** + * The set operation. + * + * @param body The body 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 set(BodyModel body) { + // Generated convenience method for setWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (body != null) { + requestOptions.setBody(BinaryData.fromObject(body)); + } + setWithResponse(requestOptions).getValue(); + } + + /** + * The set 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void set() { + // Generated convenience method for setWithResponse + RequestOptions requestOptions = new RequestOptions(); + setWithResponse(requestOptions).getValue(); + } + + /** + * The omit operation. + * + * @param body The body 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 omit(BodyModel body) { + // Generated convenience method for omitWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (body != null) { + requestOptions.setBody(BinaryData.fromObject(body)); + } + omitWithResponse(requestOptions).getValue(); + } + + /** + * The omit 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void omit() { + // Generated convenience method for omitWithResponse + RequestOptions requestOptions = new RequestOptions(); + omitWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/BodyOptionalityClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/BodyOptionalityClientImpl.java new file mode 100644 index 000000000..56a73fd13 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/BodyOptionalityClientImpl.java @@ -0,0 +1,286 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.bodyoptionality.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 BodyOptionalityClient type. + */ +public final class BodyOptionalityClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BodyOptionalityClientService 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; + } + + /** + * The OptionalExplicitsImpl object to access its operations. + */ + private final OptionalExplicitsImpl optionalExplicits; + + /** + * Gets the OptionalExplicitsImpl object to access its operations. + * + * @return the OptionalExplicitsImpl object. + */ + public OptionalExplicitsImpl getOptionalExplicits() { + return this.optionalExplicits; + } + + /** + * Initializes an instance of BodyOptionalityClient client. + * + * @param endpoint Service host. + */ + public BodyOptionalityClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of BodyOptionalityClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public BodyOptionalityClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of BodyOptionalityClient 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 BodyOptionalityClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.optionalExplicits = new OptionalExplicitsImpl(this); + this.service + = RestProxy.create(BodyOptionalityClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for BodyOptionalityClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BodyOptionalityClien") + public interface BodyOptionalityClientService { + @Post("/parameters/body-optionality/required-explicit") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> requiredExplicit(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/parameters/body-optionality/required-explicit") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response requiredExplicitSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/parameters/body-optionality/required-implicit") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> requiredImplicit(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData requiredImplicitRequest, RequestOptions requestOptions, + Context context); + + @Post("/parameters/body-optionality/required-implicit") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response requiredImplicitSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData requiredImplicitRequest, RequestOptions requestOptions, + Context context); + } + + /** + * The requiredExplicit operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> requiredExplicitWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.requiredExplicit(this.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The requiredExplicit operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 requiredExplicitWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.requiredExplicitSync(this.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The requiredImplicit operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param requiredImplicitRequest The requiredImplicitRequest 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> requiredImplicitWithResponseAsync(BinaryData requiredImplicitRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.requiredImplicit(this.getEndpoint(), contentType, + requiredImplicitRequest, requestOptions, context)); + } + + /** + * The requiredImplicit operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param requiredImplicitRequest The requiredImplicitRequest 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 requiredImplicitWithResponse(BinaryData requiredImplicitRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.requiredImplicitSync(this.getEndpoint(), contentType, requiredImplicitRequest, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/OptionalExplicitsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/OptionalExplicitsImpl.java new file mode 100644 index 000000000..cb4d687e7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/OptionalExplicitsImpl.java @@ -0,0 +1,237 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.bodyoptionality.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.HttpHeaderName; +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 OptionalExplicits. + */ +public final class OptionalExplicitsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final OptionalExplicitsService service; + + /** + * The service client containing this operation class. + */ + private final BodyOptionalityClientImpl client; + + /** + * Initializes an instance of OptionalExplicitsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OptionalExplicitsImpl(BodyOptionalityClientImpl client) { + this.service + = RestProxy.create(OptionalExplicitsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for BodyOptionalityClientOptionalExplicits to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "BodyOptionalityClien") + public interface OptionalExplicitsService { + @Post("/parameters/body-optionality/optional-explicit/set") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> set(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Post("/parameters/body-optionality/optional-explicit/set") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response setSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Post("/parameters/body-optionality/optional-explicit/omit") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> omit(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Post("/parameters/body-optionality/optional-explicit/omit") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response omitSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + } + + /** + * The set operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setWithResponseAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return FluxUtil.withContext(context -> service.set(this.client.getEndpoint(), requestOptionsLocal, context)); + } + + /** + * The set operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response setWithResponse(RequestOptions requestOptions) { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return service.setSync(this.client.getEndpoint(), requestOptionsLocal, Context.NONE); + } + + /** + * The omit operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> omitWithResponseAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return FluxUtil.withContext(context -> service.omit(this.client.getEndpoint(), requestOptionsLocal, context)); + } + + /** + * The omit operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response omitWithResponse(RequestOptions requestOptions) { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return service.omitSync(this.client.getEndpoint(), requestOptionsLocal, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/models/RequiredImplicitRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/models/RequiredImplicitRequest.java new file mode 100644 index 000000000..ede65f22d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/models/RequiredImplicitRequest.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.bodyoptionality.implementation.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; + +/** + * The RequiredImplicitRequest model. + */ +@Immutable +public final class RequiredImplicitRequest implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of RequiredImplicitRequest class. + * + * @param name the name value to set. + */ + @Generated + public RequiredImplicitRequest(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RequiredImplicitRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RequiredImplicitRequest 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 RequiredImplicitRequest. + */ + @Generated + public static RequiredImplicitRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new RequiredImplicitRequest(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/models/package-info.java new file mode 100644 index 000000000..5c9f425dc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/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 BodyOptionality. + * Test describing optionality of the request body. + * + */ +package com.parameters.bodyoptionality.implementation.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/implementation/package-info.java new file mode 100644 index 000000000..ee68c4df2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/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 BodyOptionality. + * Test describing optionality of the request body. + * + */ +package com.parameters.bodyoptionality.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/models/BodyModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/models/BodyModel.java new file mode 100644 index 000000000..a189b4c10 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/models/BodyModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.bodyoptionality.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; + +/** + * The BodyModel model. + */ +@Immutable +public final class BodyModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of BodyModel class. + * + * @param name the name value to set. + */ + @Generated + public BodyModel(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BodyModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BodyModel 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 BodyModel. + */ + @Generated + public static BodyModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new BodyModel(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/models/package-info.java new file mode 100644 index 000000000..0adc9b052 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/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 BodyOptionality. + * Test describing optionality of the request body. + * + */ +package com.parameters.bodyoptionality.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/package-info.java new file mode 100644 index 000000000..dcb6d3f4d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/bodyoptionality/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 BodyOptionality. + * Test describing optionality of the request body. + * + */ +package com.parameters.bodyoptionality; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/CollectionFormatClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/CollectionFormatClientBuilder.java new file mode 100644 index 000000000..f029cc7b9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/CollectionFormatClientBuilder.java @@ -0,0 +1,309 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.collectionformat; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.parameters.collectionformat.implementation.CollectionFormatClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the CollectionFormatClient type. + */ +@ServiceClientBuilder( + serviceClients = { QueryClient.class, HeaderClient.class, QueryAsyncClient.class, HeaderAsyncClient.class }) +public final class CollectionFormatClientBuilder 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-collectionformat.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the CollectionFormatClientBuilder. + */ + @Generated + public CollectionFormatClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public CollectionFormatClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public CollectionFormatClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public CollectionFormatClientBuilder 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 CollectionFormatClientBuilder 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 CollectionFormatClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public CollectionFormatClientBuilder 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 CollectionFormatClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public CollectionFormatClientBuilder 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 CollectionFormatClientBuilder. + */ + @Generated + public CollectionFormatClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of CollectionFormatClientImpl with the provided parameters. + * + * @return an instance of CollectionFormatClientImpl. + */ + @Generated + private CollectionFormatClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + CollectionFormatClientImpl client = new CollectionFormatClientImpl(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 QueryAsyncClient class. + * + * @return an instance of QueryAsyncClient. + */ + @Generated + public QueryAsyncClient buildQueryAsyncClient() { + return new QueryAsyncClient(buildInnerClient().getQueries()); + } + + /** + * Builds an instance of HeaderAsyncClient class. + * + * @return an instance of HeaderAsyncClient. + */ + @Generated + public HeaderAsyncClient buildHeaderAsyncClient() { + return new HeaderAsyncClient(buildInnerClient().getHeaders()); + } + + /** + * Builds an instance of QueryClient class. + * + * @return an instance of QueryClient. + */ + @Generated + public QueryClient buildQueryClient() { + return new QueryClient(buildInnerClient().getQueries()); + } + + /** + * Builds an instance of HeaderClient class. + * + * @return an instance of HeaderClient. + */ + @Generated + public HeaderClient buildHeaderClient() { + return new HeaderClient(buildInnerClient().getHeaders()); + } + + private static final ClientLogger LOGGER = new ClientLogger(CollectionFormatClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/HeaderAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/HeaderAsyncClient.java new file mode 100644 index 000000000..42b400018 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/HeaderAsyncClient.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 com.parameters.collectionformat; + +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 com.parameters.collectionformat.implementation.HeadersImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous CollectionFormatClient type. + */ +@ServiceClient(builder = CollectionFormatClientBuilder.class, isAsync = true) +public final class HeaderAsyncClient { + @Generated + private final HeadersImpl serviceClient; + + /** + * Initializes an instance of HeaderAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + HeaderAsyncClient(HeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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> csvWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.csvWithResponseAsync(colors, requestOptions); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 csv(List colors) { + // Generated convenience method for csvWithResponse + RequestOptions requestOptions = new RequestOptions(); + return csvWithResponse(colors, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/HeaderClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/HeaderClient.java new file mode 100644 index 000000000..4bbb7951a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/HeaderClient.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.collectionformat; + +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.parameters.collectionformat.implementation.HeadersImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous CollectionFormatClient type. + */ +@ServiceClient(builder = CollectionFormatClientBuilder.class) +public final class HeaderClient { + @Generated + private final HeadersImpl serviceClient; + + /** + * Initializes an instance of HeaderClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + HeaderClient(HeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 csvWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.csvWithResponse(colors, requestOptions); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 csv(List colors) { + // Generated convenience method for csvWithResponse + RequestOptions requestOptions = new RequestOptions(); + csvWithResponse(colors, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/QueryAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/QueryAsyncClient.java new file mode 100644 index 000000000..f7edbab0e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/QueryAsyncClient.java @@ -0,0 +1,224 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.collectionformat; + +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 com.parameters.collectionformat.implementation.QueriesImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous CollectionFormatClient type. + */ +@ServiceClient(builder = CollectionFormatClientBuilder.class, isAsync = true) +public final class QueryAsyncClient { + @Generated + private final QueriesImpl serviceClient; + + /** + * Initializes an instance of QueryAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + QueryAsyncClient(QueriesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The multi operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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> multiWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.multiWithResponseAsync(colors, requestOptions); + } + + /** + * The ssv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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> ssvWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.ssvWithResponseAsync(colors, requestOptions); + } + + /** + * The tsv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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> tsvWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.tsvWithResponseAsync(colors, requestOptions); + } + + /** + * The pipes operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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> pipesWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.pipesWithResponseAsync(colors, requestOptions); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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> csvWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.csvWithResponseAsync(colors, requestOptions); + } + + /** + * The multi operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 multi(List colors) { + // Generated convenience method for multiWithResponse + RequestOptions requestOptions = new RequestOptions(); + return multiWithResponse(colors, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The ssv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 ssv(List colors) { + // Generated convenience method for ssvWithResponse + RequestOptions requestOptions = new RequestOptions(); + return ssvWithResponse(colors, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The tsv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 tsv(List colors) { + // Generated convenience method for tsvWithResponse + RequestOptions requestOptions = new RequestOptions(); + return tsvWithResponse(colors, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The pipes operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 pipes(List colors) { + // Generated convenience method for pipesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return pipesWithResponse(colors, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 csv(List colors) { + // Generated convenience method for csvWithResponse + RequestOptions requestOptions = new RequestOptions(); + return csvWithResponse(colors, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/QueryClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/QueryClient.java new file mode 100644 index 000000000..e6fb8f8d9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/QueryClient.java @@ -0,0 +1,217 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.collectionformat; + +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.parameters.collectionformat.implementation.QueriesImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous CollectionFormatClient type. + */ +@ServiceClient(builder = CollectionFormatClientBuilder.class) +public final class QueryClient { + @Generated + private final QueriesImpl serviceClient; + + /** + * Initializes an instance of QueryClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + QueryClient(QueriesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The multi operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 multiWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.multiWithResponse(colors, requestOptions); + } + + /** + * The ssv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 ssvWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.ssvWithResponse(colors, requestOptions); + } + + /** + * The tsv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 tsvWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.tsvWithResponse(colors, requestOptions); + } + + /** + * The pipes operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 pipesWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.pipesWithResponse(colors, requestOptions); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 csvWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.csvWithResponse(colors, requestOptions); + } + + /** + * The multi operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 multi(List colors) { + // Generated convenience method for multiWithResponse + RequestOptions requestOptions = new RequestOptions(); + multiWithResponse(colors, requestOptions).getValue(); + } + + /** + * The ssv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 ssv(List colors) { + // Generated convenience method for ssvWithResponse + RequestOptions requestOptions = new RequestOptions(); + ssvWithResponse(colors, requestOptions).getValue(); + } + + /** + * The tsv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 tsv(List colors) { + // Generated convenience method for tsvWithResponse + RequestOptions requestOptions = new RequestOptions(); + tsvWithResponse(colors, requestOptions).getValue(); + } + + /** + * The pipes operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 pipes(List colors) { + // Generated convenience method for pipesWithResponse + RequestOptions requestOptions = new RequestOptions(); + pipesWithResponse(colors, requestOptions).getValue(); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 csv(List colors) { + // Generated convenience method for csvWithResponse + RequestOptions requestOptions = new RequestOptions(); + csvWithResponse(colors, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/implementation/CollectionFormatClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/implementation/CollectionFormatClientImpl.java new file mode 100644 index 000000000..aa16ca784 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/implementation/CollectionFormatClientImpl.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 com.parameters.collectionformat.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the CollectionFormatClient type. + */ +public final class CollectionFormatClientImpl { + /** + * 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; + } + + /** + * The QueriesImpl object to access its operations. + */ + private final QueriesImpl queries; + + /** + * Gets the QueriesImpl object to access its operations. + * + * @return the QueriesImpl object. + */ + public QueriesImpl getQueries() { + return this.queries; + } + + /** + * The HeadersImpl object to access its operations. + */ + private final HeadersImpl headers; + + /** + * Gets the HeadersImpl object to access its operations. + * + * @return the HeadersImpl object. + */ + public HeadersImpl getHeaders() { + return this.headers; + } + + /** + * Initializes an instance of CollectionFormatClient client. + * + * @param endpoint Service host. + */ + public CollectionFormatClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of CollectionFormatClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public CollectionFormatClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of CollectionFormatClient 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 CollectionFormatClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.queries = new QueriesImpl(this); + this.headers = new HeadersImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/implementation/HeadersImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/implementation/HeadersImpl.java new file mode 100644 index 000000000..49f15aeac --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/implementation/HeadersImpl.java @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.collectionformat.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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 java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Headers. + */ +public final class HeadersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final HeadersService service; + + /** + * The service client containing this operation class. + */ + private final CollectionFormatClientImpl client; + + /** + * Initializes an instance of HeadersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + HeadersImpl(CollectionFormatClientImpl client) { + this.service = RestProxy.create(HeadersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CollectionFormatClientHeaders to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CollectionFormatClie") + public interface HeadersService { + @Get("/parameters/collection-format/header/csv") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> csv(@HostParam("endpoint") String endpoint, @HeaderParam("colors") String colors, + RequestOptions requestOptions, Context context); + + @Get("/parameters/collection-format/header/csv") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response csvSync(@HostParam("endpoint") String endpoint, @HeaderParam("colors") String colors, + RequestOptions requestOptions, Context context); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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> csvWithResponseAsync(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return FluxUtil + .withContext(context -> service.csv(this.client.getEndpoint(), colorsConverted, requestOptions, context)); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 csvWithResponse(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.csvSync(this.client.getEndpoint(), colorsConverted, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/implementation/QueriesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/implementation/QueriesImpl.java new file mode 100644 index 000000000..b68ab5625 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/implementation/QueriesImpl.java @@ -0,0 +1,346 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.collectionformat.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 java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Queries. + */ +public final class QueriesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QueriesService service; + + /** + * The service client containing this operation class. + */ + private final CollectionFormatClientImpl client; + + /** + * Initializes an instance of QueriesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QueriesImpl(CollectionFormatClientImpl client) { + this.service = RestProxy.create(QueriesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CollectionFormatClientQueries to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CollectionFormatClie") + public interface QueriesService { + @Get("/parameters/collection-format/query/multi") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> multi(@HostParam("endpoint") String endpoint, + @QueryParam(value = "colors", multipleQueryParams = true) List colors, + RequestOptions requestOptions, Context context); + + @Get("/parameters/collection-format/query/multi") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response multiSync(@HostParam("endpoint") String endpoint, + @QueryParam(value = "colors", multipleQueryParams = true) List colors, + RequestOptions requestOptions, Context context); + + @Get("/parameters/collection-format/query/ssv") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> ssv(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, + RequestOptions requestOptions, Context context); + + @Get("/parameters/collection-format/query/ssv") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response ssvSync(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, + RequestOptions requestOptions, Context context); + + @Get("/parameters/collection-format/query/tsv") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> tsv(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, + RequestOptions requestOptions, Context context); + + @Get("/parameters/collection-format/query/tsv") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response tsvSync(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, + RequestOptions requestOptions, Context context); + + @Get("/parameters/collection-format/query/pipes") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> pipes(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, + RequestOptions requestOptions, Context context); + + @Get("/parameters/collection-format/query/pipes") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response pipesSync(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, + RequestOptions requestOptions, Context context); + + @Get("/parameters/collection-format/query/csv") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> csv(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, + RequestOptions requestOptions, Context context); + + @Get("/parameters/collection-format/query/csv") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response csvSync(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, + RequestOptions requestOptions, Context context); + } + + /** + * The multi operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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> multiWithResponseAsync(List colors, RequestOptions requestOptions) { + List colorsConverted + = colors.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return FluxUtil + .withContext(context -> service.multi(this.client.getEndpoint(), colorsConverted, requestOptions, context)); + } + + /** + * The multi operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 multiWithResponse(List colors, RequestOptions requestOptions) { + List colorsConverted + = colors.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return service.multiSync(this.client.getEndpoint(), colorsConverted, requestOptions, Context.NONE); + } + + /** + * The ssv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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> ssvWithResponseAsync(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(" ")); + return FluxUtil + .withContext(context -> service.ssv(this.client.getEndpoint(), colorsConverted, requestOptions, context)); + } + + /** + * The ssv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 ssvWithResponse(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(" ")); + return service.ssvSync(this.client.getEndpoint(), colorsConverted, requestOptions, Context.NONE); + } + + /** + * The tsv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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> tsvWithResponseAsync(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining("\t")); + return FluxUtil + .withContext(context -> service.tsv(this.client.getEndpoint(), colorsConverted, requestOptions, context)); + } + + /** + * The tsv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 tsvWithResponse(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining("\t")); + return service.tsvSync(this.client.getEndpoint(), colorsConverted, requestOptions, Context.NONE); + } + + /** + * The pipes operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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> pipesWithResponseAsync(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining("|")); + return FluxUtil + .withContext(context -> service.pipes(this.client.getEndpoint(), colorsConverted, requestOptions, context)); + } + + /** + * The pipes operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 pipesWithResponse(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining("|")); + return service.pipesSync(this.client.getEndpoint(), colorsConverted, requestOptions, Context.NONE); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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> csvWithResponseAsync(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return FluxUtil + .withContext(context -> service.csv(this.client.getEndpoint(), colorsConverted, requestOptions, context)); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @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 csvWithResponse(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.csvSync(this.client.getEndpoint(), colorsConverted, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/implementation/package-info.java new file mode 100644 index 000000000..b07d5dbac --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/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 CollectionFormat. + * Test for collectionFormat. + * + */ +package com.parameters.collectionformat.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/package-info.java new file mode 100644 index 000000000..0f4c2a344 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/collectionformat/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 CollectionFormat. + * Test for collectionFormat. + * + */ +package com.parameters.collectionformat; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/AliasAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/AliasAsyncClient.java new file mode 100644 index 000000000..cfd77d351 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/AliasAsyncClient.java @@ -0,0 +1,351 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread; + +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 com.parameters.spread.implementation.AliasImpl; +import com.parameters.spread.implementation.models.SpreadAsRequestBodyRequest1; +import com.parameters.spread.implementation.models.SpreadAsRequestParameterRequest; +import com.parameters.spread.implementation.models.SpreadParameterWithInnerAliasRequest; +import com.parameters.spread.implementation.models.SpreadParameterWithInnerModelRequest; +import com.parameters.spread.implementation.models.SpreadWithMultipleParametersRequest; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SpreadClient type. + */ +@ServiceClient(builder = SpreadClientBuilder.class, isAsync = true) +public final class AliasAsyncClient { + @Generated + private final AliasImpl serviceClient; + + /** + * Initializes an instance of AliasAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + AliasAsyncClient(AliasImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The spreadAsRequestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param spreadAsRequestBodyRequest The spreadAsRequestBodyRequest 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> spreadAsRequestBodyWithResponse(BinaryData spreadAsRequestBodyRequest, + RequestOptions requestOptions) { + return this.serviceClient.spreadAsRequestBodyWithResponseAsync(spreadAsRequestBodyRequest, requestOptions); + } + + /** + * The spreadParameterWithInnerModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadParameterWithInnerModelRequest The spreadParameterWithInnerModelRequest 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> spreadParameterWithInnerModelWithResponse(String id, String xMsTestHeader, + BinaryData spreadParameterWithInnerModelRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadParameterWithInnerModelWithResponseAsync(id, xMsTestHeader, + spreadParameterWithInnerModelRequest, requestOptions); + } + + /** + * The spreadAsRequestParameter operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadAsRequestParameterRequest The spreadAsRequestParameterRequest 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> spreadAsRequestParameterWithResponse(String id, String xMsTestHeader, + BinaryData spreadAsRequestParameterRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadAsRequestParameterWithResponseAsync(id, xMsTestHeader, + spreadAsRequestParameterRequest, requestOptions); + } + + /** + * The spreadWithMultipleParameters operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredString: String (Required)
+     *     optionalInt: Integer (Optional)
+     *     requiredIntList (Required): [
+     *         int (Required)
+     *     ]
+     *     optionalStringList (Optional): [
+     *         String (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadWithMultipleParametersRequest The spreadWithMultipleParametersRequest 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> spreadWithMultipleParametersWithResponse(String id, String xMsTestHeader, + BinaryData spreadWithMultipleParametersRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadWithMultipleParametersWithResponseAsync(id, xMsTestHeader, + spreadWithMultipleParametersRequest, requestOptions); + } + + /** + * spread an alias with contains another alias property as body. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadParameterWithInnerAliasRequest The spreadParameterWithInnerAliasRequest 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> spreadParameterWithInnerAliasWithResponse(String id, String xMsTestHeader, + BinaryData spreadParameterWithInnerAliasRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadParameterWithInnerAliasWithResponseAsync(id, xMsTestHeader, + spreadParameterWithInnerAliasRequest, requestOptions); + } + + /** + * The spreadAsRequestBody operation. + * + * @param name The name 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 spreadAsRequestBody(String name) { + // Generated convenience method for spreadAsRequestBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadAsRequestBodyRequest1 spreadAsRequestBodyRequestObj = new SpreadAsRequestBodyRequest1(name); + BinaryData spreadAsRequestBodyRequest = BinaryData.fromObject(spreadAsRequestBodyRequestObj); + return spreadAsRequestBodyWithResponse(spreadAsRequestBodyRequest, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The spreadParameterWithInnerModel operation. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param name The name 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 spreadParameterWithInnerModel(String id, String xMsTestHeader, String name) { + // Generated convenience method for spreadParameterWithInnerModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadParameterWithInnerModelRequest spreadParameterWithInnerModelRequestObj + = new SpreadParameterWithInnerModelRequest(name); + BinaryData spreadParameterWithInnerModelRequest + = BinaryData.fromObject(spreadParameterWithInnerModelRequestObj); + return spreadParameterWithInnerModelWithResponse(id, xMsTestHeader, spreadParameterWithInnerModelRequest, + requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The spreadAsRequestParameter operation. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param name The name 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 spreadAsRequestParameter(String id, String xMsTestHeader, String name) { + // Generated convenience method for spreadAsRequestParameterWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadAsRequestParameterRequest spreadAsRequestParameterRequestObj = new SpreadAsRequestParameterRequest(name); + BinaryData spreadAsRequestParameterRequest = BinaryData.fromObject(spreadAsRequestParameterRequestObj); + return spreadAsRequestParameterWithResponse(id, xMsTestHeader, spreadAsRequestParameterRequest, requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The spreadWithMultipleParameters operation. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param requiredString required string. + * @param requiredIntList required int. + * @param optionalInt optional int. + * @param optionalStringList optional string. + * @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 spreadWithMultipleParameters(String id, String xMsTestHeader, String requiredString, + List requiredIntList, Integer optionalInt, List optionalStringList) { + // Generated convenience method for spreadWithMultipleParametersWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadWithMultipleParametersRequest spreadWithMultipleParametersRequestObj + = new SpreadWithMultipleParametersRequest(requiredString, requiredIntList).setOptionalInt(optionalInt) + .setOptionalStringList(optionalStringList); + BinaryData spreadWithMultipleParametersRequest = BinaryData.fromObject(spreadWithMultipleParametersRequestObj); + return spreadWithMultipleParametersWithResponse(id, xMsTestHeader, spreadWithMultipleParametersRequest, + requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The spreadWithMultipleParameters operation. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param requiredString required string. + * @param requiredIntList required int. + * @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 spreadWithMultipleParameters(String id, String xMsTestHeader, String requiredString, + List requiredIntList) { + // Generated convenience method for spreadWithMultipleParametersWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadWithMultipleParametersRequest spreadWithMultipleParametersRequestObj + = new SpreadWithMultipleParametersRequest(requiredString, requiredIntList); + BinaryData spreadWithMultipleParametersRequest = BinaryData.fromObject(spreadWithMultipleParametersRequestObj); + return spreadWithMultipleParametersWithResponse(id, xMsTestHeader, spreadWithMultipleParametersRequest, + requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * spread an alias with contains another alias property as body. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param name name of the Thing. + * @param age age of the Thing. + * @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 spreadParameterWithInnerAlias(String id, String xMsTestHeader, String name, int age) { + // Generated convenience method for spreadParameterWithInnerAliasWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadParameterWithInnerAliasRequest spreadParameterWithInnerAliasRequestObj + = new SpreadParameterWithInnerAliasRequest(name, age); + BinaryData spreadParameterWithInnerAliasRequest + = BinaryData.fromObject(spreadParameterWithInnerAliasRequestObj); + return spreadParameterWithInnerAliasWithResponse(id, xMsTestHeader, spreadParameterWithInnerAliasRequest, + requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/AliasClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/AliasClient.java new file mode 100644 index 000000000..6964882f2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/AliasClient.java @@ -0,0 +1,343 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread; + +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.parameters.spread.implementation.AliasImpl; +import com.parameters.spread.implementation.models.SpreadAsRequestBodyRequest1; +import com.parameters.spread.implementation.models.SpreadAsRequestParameterRequest; +import com.parameters.spread.implementation.models.SpreadParameterWithInnerAliasRequest; +import com.parameters.spread.implementation.models.SpreadParameterWithInnerModelRequest; +import com.parameters.spread.implementation.models.SpreadWithMultipleParametersRequest; +import java.util.List; + +/** + * Initializes a new instance of the synchronous SpreadClient type. + */ +@ServiceClient(builder = SpreadClientBuilder.class) +public final class AliasClient { + @Generated + private final AliasImpl serviceClient; + + /** + * Initializes an instance of AliasClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + AliasClient(AliasImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The spreadAsRequestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param spreadAsRequestBodyRequest The spreadAsRequestBodyRequest 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 spreadAsRequestBodyWithResponse(BinaryData spreadAsRequestBodyRequest, + RequestOptions requestOptions) { + return this.serviceClient.spreadAsRequestBodyWithResponse(spreadAsRequestBodyRequest, requestOptions); + } + + /** + * The spreadParameterWithInnerModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadParameterWithInnerModelRequest The spreadParameterWithInnerModelRequest 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 spreadParameterWithInnerModelWithResponse(String id, String xMsTestHeader, + BinaryData spreadParameterWithInnerModelRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadParameterWithInnerModelWithResponse(id, xMsTestHeader, + spreadParameterWithInnerModelRequest, requestOptions); + } + + /** + * The spreadAsRequestParameter operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadAsRequestParameterRequest The spreadAsRequestParameterRequest 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 spreadAsRequestParameterWithResponse(String id, String xMsTestHeader, + BinaryData spreadAsRequestParameterRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadAsRequestParameterWithResponse(id, xMsTestHeader, + spreadAsRequestParameterRequest, requestOptions); + } + + /** + * The spreadWithMultipleParameters operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredString: String (Required)
+     *     optionalInt: Integer (Optional)
+     *     requiredIntList (Required): [
+     *         int (Required)
+     *     ]
+     *     optionalStringList (Optional): [
+     *         String (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadWithMultipleParametersRequest The spreadWithMultipleParametersRequest 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 spreadWithMultipleParametersWithResponse(String id, String xMsTestHeader, + BinaryData spreadWithMultipleParametersRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadWithMultipleParametersWithResponse(id, xMsTestHeader, + spreadWithMultipleParametersRequest, requestOptions); + } + + /** + * spread an alias with contains another alias property as body. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadParameterWithInnerAliasRequest The spreadParameterWithInnerAliasRequest 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 spreadParameterWithInnerAliasWithResponse(String id, String xMsTestHeader, + BinaryData spreadParameterWithInnerAliasRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadParameterWithInnerAliasWithResponse(id, xMsTestHeader, + spreadParameterWithInnerAliasRequest, requestOptions); + } + + /** + * The spreadAsRequestBody operation. + * + * @param name The name 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 spreadAsRequestBody(String name) { + // Generated convenience method for spreadAsRequestBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadAsRequestBodyRequest1 spreadAsRequestBodyRequestObj = new SpreadAsRequestBodyRequest1(name); + BinaryData spreadAsRequestBodyRequest = BinaryData.fromObject(spreadAsRequestBodyRequestObj); + spreadAsRequestBodyWithResponse(spreadAsRequestBodyRequest, requestOptions).getValue(); + } + + /** + * The spreadParameterWithInnerModel operation. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param name The name 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 spreadParameterWithInnerModel(String id, String xMsTestHeader, String name) { + // Generated convenience method for spreadParameterWithInnerModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadParameterWithInnerModelRequest spreadParameterWithInnerModelRequestObj + = new SpreadParameterWithInnerModelRequest(name); + BinaryData spreadParameterWithInnerModelRequest + = BinaryData.fromObject(spreadParameterWithInnerModelRequestObj); + spreadParameterWithInnerModelWithResponse(id, xMsTestHeader, spreadParameterWithInnerModelRequest, + requestOptions).getValue(); + } + + /** + * The spreadAsRequestParameter operation. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param name The name 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 spreadAsRequestParameter(String id, String xMsTestHeader, String name) { + // Generated convenience method for spreadAsRequestParameterWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadAsRequestParameterRequest spreadAsRequestParameterRequestObj = new SpreadAsRequestParameterRequest(name); + BinaryData spreadAsRequestParameterRequest = BinaryData.fromObject(spreadAsRequestParameterRequestObj); + spreadAsRequestParameterWithResponse(id, xMsTestHeader, spreadAsRequestParameterRequest, requestOptions) + .getValue(); + } + + /** + * The spreadWithMultipleParameters operation. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param requiredString required string. + * @param requiredIntList required int. + * @param optionalInt optional int. + * @param optionalStringList optional string. + * @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 spreadWithMultipleParameters(String id, String xMsTestHeader, String requiredString, + List requiredIntList, Integer optionalInt, List optionalStringList) { + // Generated convenience method for spreadWithMultipleParametersWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadWithMultipleParametersRequest spreadWithMultipleParametersRequestObj + = new SpreadWithMultipleParametersRequest(requiredString, requiredIntList).setOptionalInt(optionalInt) + .setOptionalStringList(optionalStringList); + BinaryData spreadWithMultipleParametersRequest = BinaryData.fromObject(spreadWithMultipleParametersRequestObj); + spreadWithMultipleParametersWithResponse(id, xMsTestHeader, spreadWithMultipleParametersRequest, requestOptions) + .getValue(); + } + + /** + * The spreadWithMultipleParameters operation. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param requiredString required string. + * @param requiredIntList required int. + * @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 spreadWithMultipleParameters(String id, String xMsTestHeader, String requiredString, + List requiredIntList) { + // Generated convenience method for spreadWithMultipleParametersWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadWithMultipleParametersRequest spreadWithMultipleParametersRequestObj + = new SpreadWithMultipleParametersRequest(requiredString, requiredIntList); + BinaryData spreadWithMultipleParametersRequest = BinaryData.fromObject(spreadWithMultipleParametersRequestObj); + spreadWithMultipleParametersWithResponse(id, xMsTestHeader, spreadWithMultipleParametersRequest, requestOptions) + .getValue(); + } + + /** + * spread an alias with contains another alias property as body. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param name name of the Thing. + * @param age age of the Thing. + * @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 spreadParameterWithInnerAlias(String id, String xMsTestHeader, String name, int age) { + // Generated convenience method for spreadParameterWithInnerAliasWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadParameterWithInnerAliasRequest spreadParameterWithInnerAliasRequestObj + = new SpreadParameterWithInnerAliasRequest(name, age); + BinaryData spreadParameterWithInnerAliasRequest + = BinaryData.fromObject(spreadParameterWithInnerAliasRequestObj); + spreadParameterWithInnerAliasWithResponse(id, xMsTestHeader, spreadParameterWithInnerAliasRequest, + requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/ModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/ModelAsyncClient.java new file mode 100644 index 000000000..d1f6411eb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/ModelAsyncClient.java @@ -0,0 +1,280 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread; + +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 com.parameters.spread.implementation.ModelsImpl; +import com.parameters.spread.implementation.models.SpreadAsRequestBodyRequest; +import com.parameters.spread.implementation.models.SpreadCompositeRequestMixRequest; +import com.parameters.spread.models.BodyParameter; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SpreadClient type. + */ +@ServiceClient(builder = SpreadClientBuilder.class, isAsync = true) +public final class ModelAsyncClient { + @Generated + private final ModelsImpl serviceClient; + + /** + * Initializes an instance of ModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelAsyncClient(ModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The spreadAsRequestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param spreadAsRequestBodyRequest1 The spreadAsRequestBodyRequest1 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> spreadAsRequestBodyWithResponse(BinaryData spreadAsRequestBodyRequest1, + RequestOptions requestOptions) { + return this.serviceClient.spreadAsRequestBodyWithResponseAsync(spreadAsRequestBodyRequest1, requestOptions); + } + + /** + * The spreadCompositeRequestOnlyWithBody operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> spreadCompositeRequestOnlyWithBodyWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.spreadCompositeRequestOnlyWithBodyWithResponseAsync(body, requestOptions); + } + + /** + * The spreadCompositeRequestWithoutBody operation. + * + * @param name The name parameter. + * @param testHeader The testHeader 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> spreadCompositeRequestWithoutBodyWithResponse(String name, String testHeader, + RequestOptions requestOptions) { + return this.serviceClient.spreadCompositeRequestWithoutBodyWithResponseAsync(name, testHeader, requestOptions); + } + + /** + * The spreadCompositeRequest operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param body The body 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> spreadCompositeRequestWithResponse(String name, String testHeader, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.spreadCompositeRequestWithResponseAsync(name, testHeader, body, requestOptions); + } + + /** + * The spreadCompositeRequestMix operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param spreadCompositeRequestMixRequest The spreadCompositeRequestMixRequest 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> spreadCompositeRequestMixWithResponse(String name, String testHeader, + BinaryData spreadCompositeRequestMixRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadCompositeRequestMixWithResponseAsync(name, testHeader, + spreadCompositeRequestMixRequest, requestOptions); + } + + /** + * The spreadAsRequestBody operation. + * + * @param name The name 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 spreadAsRequestBody(String name) { + // Generated convenience method for spreadAsRequestBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadAsRequestBodyRequest spreadAsRequestBodyRequest1Obj = new SpreadAsRequestBodyRequest(name); + BinaryData spreadAsRequestBodyRequest1 = BinaryData.fromObject(spreadAsRequestBodyRequest1Obj); + return spreadAsRequestBodyWithResponse(spreadAsRequestBodyRequest1, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The spreadCompositeRequestOnlyWithBody operation. + * + * @param body The body 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 spreadCompositeRequestOnlyWithBody(BodyParameter body) { + // Generated convenience method for spreadCompositeRequestOnlyWithBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return spreadCompositeRequestOnlyWithBodyWithResponse(BinaryData.fromObject(body), requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The spreadCompositeRequestWithoutBody operation. + * + * @param name The name parameter. + * @param testHeader The testHeader 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 spreadCompositeRequestWithoutBody(String name, String testHeader) { + // Generated convenience method for spreadCompositeRequestWithoutBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return spreadCompositeRequestWithoutBodyWithResponse(name, testHeader, requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The spreadCompositeRequest operation. + * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param body The body 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 spreadCompositeRequest(String name, String testHeader, BodyParameter body) { + // Generated convenience method for spreadCompositeRequestWithResponse + RequestOptions requestOptions = new RequestOptions(); + return spreadCompositeRequestWithResponse(name, testHeader, BinaryData.fromObject(body), requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The spreadCompositeRequestMix operation. + * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param prop The prop 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 spreadCompositeRequestMix(String name, String testHeader, String prop) { + // Generated convenience method for spreadCompositeRequestMixWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadCompositeRequestMixRequest spreadCompositeRequestMixRequestObj + = new SpreadCompositeRequestMixRequest(prop); + BinaryData spreadCompositeRequestMixRequest = BinaryData.fromObject(spreadCompositeRequestMixRequestObj); + return spreadCompositeRequestMixWithResponse(name, testHeader, spreadCompositeRequestMixRequest, requestOptions) + .flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/ModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/ModelClient.java new file mode 100644 index 000000000..58eb3be14 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/ModelClient.java @@ -0,0 +1,270 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread; + +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.parameters.spread.implementation.ModelsImpl; +import com.parameters.spread.implementation.models.SpreadAsRequestBodyRequest; +import com.parameters.spread.implementation.models.SpreadCompositeRequestMixRequest; +import com.parameters.spread.models.BodyParameter; + +/** + * Initializes a new instance of the synchronous SpreadClient type. + */ +@ServiceClient(builder = SpreadClientBuilder.class) +public final class ModelClient { + @Generated + private final ModelsImpl serviceClient; + + /** + * Initializes an instance of ModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelClient(ModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The spreadAsRequestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param spreadAsRequestBodyRequest1 The spreadAsRequestBodyRequest1 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 spreadAsRequestBodyWithResponse(BinaryData spreadAsRequestBodyRequest1, + RequestOptions requestOptions) { + return this.serviceClient.spreadAsRequestBodyWithResponse(spreadAsRequestBodyRequest1, requestOptions); + } + + /** + * The spreadCompositeRequestOnlyWithBody operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 spreadCompositeRequestOnlyWithBodyWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.spreadCompositeRequestOnlyWithBodyWithResponse(body, requestOptions); + } + + /** + * The spreadCompositeRequestWithoutBody operation. + * + * @param name The name parameter. + * @param testHeader The testHeader 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 spreadCompositeRequestWithoutBodyWithResponse(String name, String testHeader, + RequestOptions requestOptions) { + return this.serviceClient.spreadCompositeRequestWithoutBodyWithResponse(name, testHeader, requestOptions); + } + + /** + * The spreadCompositeRequest operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param body The body 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 spreadCompositeRequestWithResponse(String name, String testHeader, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.spreadCompositeRequestWithResponse(name, testHeader, body, requestOptions); + } + + /** + * The spreadCompositeRequestMix operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param spreadCompositeRequestMixRequest The spreadCompositeRequestMixRequest 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 spreadCompositeRequestMixWithResponse(String name, String testHeader, + BinaryData spreadCompositeRequestMixRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadCompositeRequestMixWithResponse(name, testHeader, + spreadCompositeRequestMixRequest, requestOptions); + } + + /** + * The spreadAsRequestBody operation. + * + * @param name The name 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 spreadAsRequestBody(String name) { + // Generated convenience method for spreadAsRequestBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadAsRequestBodyRequest spreadAsRequestBodyRequest1Obj = new SpreadAsRequestBodyRequest(name); + BinaryData spreadAsRequestBodyRequest1 = BinaryData.fromObject(spreadAsRequestBodyRequest1Obj); + spreadAsRequestBodyWithResponse(spreadAsRequestBodyRequest1, requestOptions).getValue(); + } + + /** + * The spreadCompositeRequestOnlyWithBody operation. + * + * @param body The body 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 spreadCompositeRequestOnlyWithBody(BodyParameter body) { + // Generated convenience method for spreadCompositeRequestOnlyWithBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + spreadCompositeRequestOnlyWithBodyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The spreadCompositeRequestWithoutBody operation. + * + * @param name The name parameter. + * @param testHeader The testHeader 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 spreadCompositeRequestWithoutBody(String name, String testHeader) { + // Generated convenience method for spreadCompositeRequestWithoutBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + spreadCompositeRequestWithoutBodyWithResponse(name, testHeader, requestOptions).getValue(); + } + + /** + * The spreadCompositeRequest operation. + * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param body The body 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 spreadCompositeRequest(String name, String testHeader, BodyParameter body) { + // Generated convenience method for spreadCompositeRequestWithResponse + RequestOptions requestOptions = new RequestOptions(); + spreadCompositeRequestWithResponse(name, testHeader, BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The spreadCompositeRequestMix operation. + * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param prop The prop 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 spreadCompositeRequestMix(String name, String testHeader, String prop) { + // Generated convenience method for spreadCompositeRequestMixWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadCompositeRequestMixRequest spreadCompositeRequestMixRequestObj + = new SpreadCompositeRequestMixRequest(prop); + BinaryData spreadCompositeRequestMixRequest = BinaryData.fromObject(spreadCompositeRequestMixRequestObj); + spreadCompositeRequestMixWithResponse(name, testHeader, spreadCompositeRequestMixRequest, requestOptions) + .getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/SpreadClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/SpreadClientBuilder.java new file mode 100644 index 000000000..47711e460 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/SpreadClientBuilder.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.parameters.spread.implementation.SpreadClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the SpreadClient type. + */ +@ServiceClientBuilder( + serviceClients = { ModelClient.class, AliasClient.class, ModelAsyncClient.class, AliasAsyncClient.class }) +public final class SpreadClientBuilder 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-spread.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the SpreadClientBuilder. + */ + @Generated + public SpreadClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpreadClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpreadClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpreadClientBuilder 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 SpreadClientBuilder 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 SpreadClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpreadClientBuilder 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 SpreadClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpreadClientBuilder 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 SpreadClientBuilder. + */ + @Generated + public SpreadClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of SpreadClientImpl with the provided parameters. + * + * @return an instance of SpreadClientImpl. + */ + @Generated + private SpreadClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + SpreadClientImpl client + = new SpreadClientImpl(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 ModelAsyncClient class. + * + * @return an instance of ModelAsyncClient. + */ + @Generated + public ModelAsyncClient buildModelAsyncClient() { + return new ModelAsyncClient(buildInnerClient().getModels()); + } + + /** + * Builds an instance of AliasAsyncClient class. + * + * @return an instance of AliasAsyncClient. + */ + @Generated + public AliasAsyncClient buildAliasAsyncClient() { + return new AliasAsyncClient(buildInnerClient().getAlias()); + } + + /** + * Builds an instance of ModelClient class. + * + * @return an instance of ModelClient. + */ + @Generated + public ModelClient buildModelClient() { + return new ModelClient(buildInnerClient().getModels()); + } + + /** + * Builds an instance of AliasClient class. + * + * @return an instance of AliasClient. + */ + @Generated + public AliasClient buildAliasClient() { + return new AliasClient(buildInnerClient().getAlias()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SpreadClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/AliasImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/AliasImpl.java new file mode 100644 index 000000000..b99cea4e3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/AliasImpl.java @@ -0,0 +1,471 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread.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.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Alias. + */ +public final class AliasImpl { + /** + * The proxy service used to perform REST calls. + */ + private final AliasService service; + + /** + * The service client containing this operation class. + */ + private final SpreadClientImpl client; + + /** + * Initializes an instance of AliasImpl. + * + * @param client the instance of the service client containing this operation class. + */ + AliasImpl(SpreadClientImpl client) { + this.service = RestProxy.create(AliasService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SpreadClientAlias to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SpreadClientAlias") + public interface AliasService { + @Put("/parameters/spread/alias/request-body") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> spreadAsRequestBody(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadAsRequestBodyRequest, RequestOptions requestOptions, + Context context); + + @Put("/parameters/spread/alias/request-body") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response spreadAsRequestBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadAsRequestBodyRequest, RequestOptions requestOptions, + Context context); + + @Post("/parameters/spread/alias/inner-model-parameter/{id}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> spreadParameterWithInnerModel(@HostParam("endpoint") String endpoint, + @PathParam("id") String id, @HeaderParam("x-ms-test-header") String xMsTestHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadParameterWithInnerModelRequest, + RequestOptions requestOptions, Context context); + + @Post("/parameters/spread/alias/inner-model-parameter/{id}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response spreadParameterWithInnerModelSync(@HostParam("endpoint") String endpoint, + @PathParam("id") String id, @HeaderParam("x-ms-test-header") String xMsTestHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadParameterWithInnerModelRequest, + RequestOptions requestOptions, Context context); + + @Put("/parameters/spread/alias/request-parameter/{id}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> spreadAsRequestParameter(@HostParam("endpoint") String endpoint, + @PathParam("id") String id, @HeaderParam("x-ms-test-header") String xMsTestHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadAsRequestParameterRequest, RequestOptions requestOptions, + Context context); + + @Put("/parameters/spread/alias/request-parameter/{id}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response spreadAsRequestParameterSync(@HostParam("endpoint") String endpoint, @PathParam("id") String id, + @HeaderParam("x-ms-test-header") String xMsTestHeader, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadAsRequestParameterRequest, RequestOptions requestOptions, + Context context); + + @Put("/parameters/spread/alias/multiple-parameters/{id}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> spreadWithMultipleParameters(@HostParam("endpoint") String endpoint, + @PathParam("id") String id, @HeaderParam("x-ms-test-header") String xMsTestHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadWithMultipleParametersRequest, + RequestOptions requestOptions, Context context); + + @Put("/parameters/spread/alias/multiple-parameters/{id}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response spreadWithMultipleParametersSync(@HostParam("endpoint") String endpoint, + @PathParam("id") String id, @HeaderParam("x-ms-test-header") String xMsTestHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadWithMultipleParametersRequest, + RequestOptions requestOptions, Context context); + + @Post("/parameters/spread/alias/inner-alias-parameter/{id}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> spreadParameterWithInnerAlias(@HostParam("endpoint") String endpoint, + @PathParam("id") String id, @HeaderParam("x-ms-test-header") String xMsTestHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadParameterWithInnerAliasRequest, + RequestOptions requestOptions, Context context); + + @Post("/parameters/spread/alias/inner-alias-parameter/{id}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response spreadParameterWithInnerAliasSync(@HostParam("endpoint") String endpoint, + @PathParam("id") String id, @HeaderParam("x-ms-test-header") String xMsTestHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadParameterWithInnerAliasRequest, + RequestOptions requestOptions, Context context); + } + + /** + * The spreadAsRequestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param spreadAsRequestBodyRequest The spreadAsRequestBodyRequest 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> spreadAsRequestBodyWithResponseAsync(BinaryData spreadAsRequestBodyRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadAsRequestBody(this.client.getEndpoint(), contentType, + spreadAsRequestBodyRequest, requestOptions, context)); + } + + /** + * The spreadAsRequestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param spreadAsRequestBodyRequest The spreadAsRequestBodyRequest 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 spreadAsRequestBodyWithResponse(BinaryData spreadAsRequestBodyRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadAsRequestBodySync(this.client.getEndpoint(), contentType, spreadAsRequestBodyRequest, + requestOptions, Context.NONE); + } + + /** + * The spreadParameterWithInnerModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadParameterWithInnerModelRequest The spreadParameterWithInnerModelRequest 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> spreadParameterWithInnerModelWithResponseAsync(String id, String xMsTestHeader, + BinaryData spreadParameterWithInnerModelRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadParameterWithInnerModel(this.client.getEndpoint(), id, + xMsTestHeader, contentType, spreadParameterWithInnerModelRequest, requestOptions, context)); + } + + /** + * The spreadParameterWithInnerModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadParameterWithInnerModelRequest The spreadParameterWithInnerModelRequest 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 spreadParameterWithInnerModelWithResponse(String id, String xMsTestHeader, + BinaryData spreadParameterWithInnerModelRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadParameterWithInnerModelSync(this.client.getEndpoint(), id, xMsTestHeader, contentType, + spreadParameterWithInnerModelRequest, requestOptions, Context.NONE); + } + + /** + * The spreadAsRequestParameter operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadAsRequestParameterRequest The spreadAsRequestParameterRequest 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> spreadAsRequestParameterWithResponseAsync(String id, String xMsTestHeader, + BinaryData spreadAsRequestParameterRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadAsRequestParameter(this.client.getEndpoint(), id, + xMsTestHeader, contentType, spreadAsRequestParameterRequest, requestOptions, context)); + } + + /** + * The spreadAsRequestParameter operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadAsRequestParameterRequest The spreadAsRequestParameterRequest 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 spreadAsRequestParameterWithResponse(String id, String xMsTestHeader, + BinaryData spreadAsRequestParameterRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadAsRequestParameterSync(this.client.getEndpoint(), id, xMsTestHeader, contentType, + spreadAsRequestParameterRequest, requestOptions, Context.NONE); + } + + /** + * The spreadWithMultipleParameters operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredString: String (Required)
+     *     optionalInt: Integer (Optional)
+     *     requiredIntList (Required): [
+     *         int (Required)
+     *     ]
+     *     optionalStringList (Optional): [
+     *         String (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadWithMultipleParametersRequest The spreadWithMultipleParametersRequest 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> spreadWithMultipleParametersWithResponseAsync(String id, String xMsTestHeader, + BinaryData spreadWithMultipleParametersRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadWithMultipleParameters(this.client.getEndpoint(), id, + xMsTestHeader, contentType, spreadWithMultipleParametersRequest, requestOptions, context)); + } + + /** + * The spreadWithMultipleParameters operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredString: String (Required)
+     *     optionalInt: Integer (Optional)
+     *     requiredIntList (Required): [
+     *         int (Required)
+     *     ]
+     *     optionalStringList (Optional): [
+     *         String (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadWithMultipleParametersRequest The spreadWithMultipleParametersRequest 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 spreadWithMultipleParametersWithResponse(String id, String xMsTestHeader, + BinaryData spreadWithMultipleParametersRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadWithMultipleParametersSync(this.client.getEndpoint(), id, xMsTestHeader, contentType, + spreadWithMultipleParametersRequest, requestOptions, Context.NONE); + } + + /** + * spread an alias with contains another alias property as body. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadParameterWithInnerAliasRequest The spreadParameterWithInnerAliasRequest 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> spreadParameterWithInnerAliasWithResponseAsync(String id, String xMsTestHeader, + BinaryData spreadParameterWithInnerAliasRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadParameterWithInnerAlias(this.client.getEndpoint(), id, + xMsTestHeader, contentType, spreadParameterWithInnerAliasRequest, requestOptions, context)); + } + + /** + * spread an alias with contains another alias property as body. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadParameterWithInnerAliasRequest The spreadParameterWithInnerAliasRequest 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 spreadParameterWithInnerAliasWithResponse(String id, String xMsTestHeader, + BinaryData spreadParameterWithInnerAliasRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadParameterWithInnerAliasSync(this.client.getEndpoint(), id, xMsTestHeader, contentType, + spreadParameterWithInnerAliasRequest, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/ModelsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/ModelsImpl.java new file mode 100644 index 000000000..bd8d00820 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/ModelsImpl.java @@ -0,0 +1,423 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread.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.PathParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Models. + */ +public final class ModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelsService service; + + /** + * The service client containing this operation class. + */ + private final SpreadClientImpl client; + + /** + * Initializes an instance of ModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelsImpl(SpreadClientImpl client) { + this.service = RestProxy.create(ModelsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SpreadClientModels to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SpreadClientModels") + public interface ModelsService { + @Put("/parameters/spread/model/request-body") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> spreadAsRequestBody(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadAsRequestBodyRequest1, RequestOptions requestOptions, + Context context); + + @Put("/parameters/spread/model/request-body") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response spreadAsRequestBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadAsRequestBodyRequest1, RequestOptions requestOptions, + Context context); + + @Put("/parameters/spread/model/composite-request-only-with-body") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> spreadCompositeRequestOnlyWithBody(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/parameters/spread/model/composite-request-only-with-body") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response spreadCompositeRequestOnlyWithBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/parameters/spread/model/composite-request-without-body/{name}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> spreadCompositeRequestWithoutBody(@HostParam("endpoint") String endpoint, + @PathParam("name") String name, @HeaderParam("test-header") String testHeader, + RequestOptions requestOptions, Context context); + + @Put("/parameters/spread/model/composite-request-without-body/{name}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response spreadCompositeRequestWithoutBodySync(@HostParam("endpoint") String endpoint, + @PathParam("name") String name, @HeaderParam("test-header") String testHeader, + RequestOptions requestOptions, Context context); + + @Put("/parameters/spread/model/composite-request/{name}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> spreadCompositeRequest(@HostParam("endpoint") String endpoint, + @PathParam("name") String name, @HeaderParam("test-header") String testHeader, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/parameters/spread/model/composite-request/{name}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response spreadCompositeRequestSync(@HostParam("endpoint") String endpoint, + @PathParam("name") String name, @HeaderParam("test-header") String testHeader, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/parameters/spread/model/composite-request-mix/{name}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> spreadCompositeRequestMix(@HostParam("endpoint") String endpoint, + @PathParam("name") String name, @HeaderParam("test-header") String testHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadCompositeRequestMixRequest, RequestOptions requestOptions, + Context context); + + @Put("/parameters/spread/model/composite-request-mix/{name}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response spreadCompositeRequestMixSync(@HostParam("endpoint") String endpoint, + @PathParam("name") String name, @HeaderParam("test-header") String testHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadCompositeRequestMixRequest, RequestOptions requestOptions, + Context context); + } + + /** + * The spreadAsRequestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param spreadAsRequestBodyRequest1 The spreadAsRequestBodyRequest1 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> spreadAsRequestBodyWithResponseAsync(BinaryData spreadAsRequestBodyRequest1, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadAsRequestBody(this.client.getEndpoint(), contentType, + spreadAsRequestBodyRequest1, requestOptions, context)); + } + + /** + * The spreadAsRequestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param spreadAsRequestBodyRequest1 The spreadAsRequestBodyRequest1 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 spreadAsRequestBodyWithResponse(BinaryData spreadAsRequestBodyRequest1, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadAsRequestBodySync(this.client.getEndpoint(), contentType, spreadAsRequestBodyRequest1, + requestOptions, Context.NONE); + } + + /** + * The spreadCompositeRequestOnlyWithBody operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> spreadCompositeRequestOnlyWithBodyWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadCompositeRequestOnlyWithBody(this.client.getEndpoint(), + contentType, body, requestOptions, context)); + } + + /** + * The spreadCompositeRequestOnlyWithBody operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 spreadCompositeRequestOnlyWithBodyWithResponse(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadCompositeRequestOnlyWithBodySync(this.client.getEndpoint(), contentType, body, + requestOptions, Context.NONE); + } + + /** + * The spreadCompositeRequestWithoutBody operation. + * + * @param name The name parameter. + * @param testHeader The testHeader 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> spreadCompositeRequestWithoutBodyWithResponseAsync(String name, String testHeader, + RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.spreadCompositeRequestWithoutBody(this.client.getEndpoint(), + name, testHeader, requestOptions, context)); + } + + /** + * The spreadCompositeRequestWithoutBody operation. + * + * @param name The name parameter. + * @param testHeader The testHeader 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 spreadCompositeRequestWithoutBodyWithResponse(String name, String testHeader, + RequestOptions requestOptions) { + return service.spreadCompositeRequestWithoutBodySync(this.client.getEndpoint(), name, testHeader, + requestOptions, Context.NONE); + } + + /** + * The spreadCompositeRequest operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param body The body 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> spreadCompositeRequestWithResponseAsync(String name, String testHeader, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadCompositeRequest(this.client.getEndpoint(), name, + testHeader, contentType, body, requestOptions, context)); + } + + /** + * The spreadCompositeRequest operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param body The body 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 spreadCompositeRequestWithResponse(String name, String testHeader, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadCompositeRequestSync(this.client.getEndpoint(), name, testHeader, contentType, body, + requestOptions, Context.NONE); + } + + /** + * The spreadCompositeRequestMix operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param spreadCompositeRequestMixRequest The spreadCompositeRequestMixRequest 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> spreadCompositeRequestMixWithResponseAsync(String name, String testHeader, + BinaryData spreadCompositeRequestMixRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.spreadCompositeRequestMix(this.client.getEndpoint(), name, + testHeader, contentType, spreadCompositeRequestMixRequest, requestOptions, context)); + } + + /** + * The spreadCompositeRequestMix operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     * }
+     * }
+ * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param spreadCompositeRequestMixRequest The spreadCompositeRequestMixRequest 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 spreadCompositeRequestMixWithResponse(String name, String testHeader, + BinaryData spreadCompositeRequestMixRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadCompositeRequestMixSync(this.client.getEndpoint(), name, testHeader, contentType, + spreadCompositeRequestMixRequest, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/SpreadClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/SpreadClientImpl.java new file mode 100644 index 000000000..f9f10e5a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/SpreadClientImpl.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 com.parameters.spread.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the SpreadClient type. + */ +public final class SpreadClientImpl { + /** + * 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; + } + + /** + * The ModelsImpl object to access its operations. + */ + private final ModelsImpl models; + + /** + * Gets the ModelsImpl object to access its operations. + * + * @return the ModelsImpl object. + */ + public ModelsImpl getModels() { + return this.models; + } + + /** + * The AliasImpl object to access its operations. + */ + private final AliasImpl alias; + + /** + * Gets the AliasImpl object to access its operations. + * + * @return the AliasImpl object. + */ + public AliasImpl getAlias() { + return this.alias; + } + + /** + * Initializes an instance of SpreadClient client. + * + * @param endpoint Service host. + */ + public SpreadClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of SpreadClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public SpreadClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of SpreadClient 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 SpreadClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.models = new ModelsImpl(this); + this.alias = new AliasImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadAsRequestBodyRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadAsRequestBodyRequest.java new file mode 100644 index 000000000..78983e9b0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadAsRequestBodyRequest.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread.implementation.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; + +/** + * The SpreadAsRequestBodyRequest model. + */ +@Immutable +public final class SpreadAsRequestBodyRequest implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of SpreadAsRequestBodyRequest class. + * + * @param name the name value to set. + */ + @Generated + public SpreadAsRequestBodyRequest(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadAsRequestBodyRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadAsRequestBodyRequest 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 SpreadAsRequestBodyRequest. + */ + @Generated + public static SpreadAsRequestBodyRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SpreadAsRequestBodyRequest(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadAsRequestBodyRequest1.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadAsRequestBodyRequest1.java new file mode 100644 index 000000000..611708954 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadAsRequestBodyRequest1.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread.implementation.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; + +/** + * The SpreadAsRequestBodyRequest1 model. + */ +@Immutable +public final class SpreadAsRequestBodyRequest1 implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of SpreadAsRequestBodyRequest1 class. + * + * @param name the name value to set. + */ + @Generated + public SpreadAsRequestBodyRequest1(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadAsRequestBodyRequest1 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadAsRequestBodyRequest1 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 SpreadAsRequestBodyRequest1. + */ + @Generated + public static SpreadAsRequestBodyRequest1 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SpreadAsRequestBodyRequest1(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadAsRequestParameterRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadAsRequestParameterRequest.java new file mode 100644 index 000000000..f5fc735ed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadAsRequestParameterRequest.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread.implementation.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; + +/** + * The SpreadAsRequestParameterRequest model. + */ +@Immutable +public final class SpreadAsRequestParameterRequest implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of SpreadAsRequestParameterRequest class. + * + * @param name the name value to set. + */ + @Generated + public SpreadAsRequestParameterRequest(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadAsRequestParameterRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadAsRequestParameterRequest 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 SpreadAsRequestParameterRequest. + */ + @Generated + public static SpreadAsRequestParameterRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SpreadAsRequestParameterRequest(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadCompositeRequestMixRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadCompositeRequestMixRequest.java new file mode 100644 index 000000000..c893c0dd0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadCompositeRequestMixRequest.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread.implementation.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; + +/** + * The SpreadCompositeRequestMixRequest model. + */ +@Immutable +public final class SpreadCompositeRequestMixRequest implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final String prop; + + /** + * Creates an instance of SpreadCompositeRequestMixRequest class. + * + * @param prop the prop value to set. + */ + @Generated + public SpreadCompositeRequestMixRequest(String prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public String getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadCompositeRequestMixRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadCompositeRequestMixRequest 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 SpreadCompositeRequestMixRequest. + */ + @Generated + public static SpreadCompositeRequestMixRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SpreadCompositeRequestMixRequest(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadParameterWithInnerAliasRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadParameterWithInnerAliasRequest.java new file mode 100644 index 000000000..9eca0c1b3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadParameterWithInnerAliasRequest.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 com.parameters.spread.implementation.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; + +/** + * The SpreadParameterWithInnerAliasRequest model. + */ +@Immutable +public final class SpreadParameterWithInnerAliasRequest + implements JsonSerializable { + /* + * name of the Thing + */ + @Generated + private final String name; + + /* + * age of the Thing + */ + @Generated + private final int age; + + /** + * Creates an instance of SpreadParameterWithInnerAliasRequest class. + * + * @param name the name value to set. + * @param age the age value to set. + */ + @Generated + public SpreadParameterWithInnerAliasRequest(String name, int age) { + this.name = name; + this.age = age; + } + + /** + * Get the name property: name of the Thing. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the age property: age of the Thing. + * + * @return the age value. + */ + @Generated + public int getAge() { + return this.age; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeIntField("age", this.age); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadParameterWithInnerAliasRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadParameterWithInnerAliasRequest 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 SpreadParameterWithInnerAliasRequest. + */ + @Generated + public static SpreadParameterWithInnerAliasRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int age = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("age".equals(fieldName)) { + age = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new SpreadParameterWithInnerAliasRequest(name, age); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadParameterWithInnerModelRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadParameterWithInnerModelRequest.java new file mode 100644 index 000000000..c125393bb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadParameterWithInnerModelRequest.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread.implementation.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; + +/** + * The SpreadParameterWithInnerModelRequest model. + */ +@Immutable +public final class SpreadParameterWithInnerModelRequest + implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of SpreadParameterWithInnerModelRequest class. + * + * @param name the name value to set. + */ + @Generated + public SpreadParameterWithInnerModelRequest(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadParameterWithInnerModelRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadParameterWithInnerModelRequest 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 SpreadParameterWithInnerModelRequest. + */ + @Generated + public static SpreadParameterWithInnerModelRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SpreadParameterWithInnerModelRequest(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadWithMultipleParametersRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadWithMultipleParametersRequest.java new file mode 100644 index 000000000..5ab28e542 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/SpreadWithMultipleParametersRequest.java @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread.implementation.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; +import java.util.List; + +/** + * The SpreadWithMultipleParametersRequest model. + */ +@Fluent +public final class SpreadWithMultipleParametersRequest + implements JsonSerializable { + /* + * required string + */ + @Generated + private final String requiredString; + + /* + * optional int + */ + @Generated + private Integer optionalInt; + + /* + * required int + */ + @Generated + private final List requiredIntList; + + /* + * optional string + */ + @Generated + private List optionalStringList; + + /** + * Creates an instance of SpreadWithMultipleParametersRequest class. + * + * @param requiredString the requiredString value to set. + * @param requiredIntList the requiredIntList value to set. + */ + @Generated + public SpreadWithMultipleParametersRequest(String requiredString, List requiredIntList) { + this.requiredString = requiredString; + this.requiredIntList = requiredIntList; + } + + /** + * Get the requiredString property: required string. + * + * @return the requiredString value. + */ + @Generated + public String getRequiredString() { + return this.requiredString; + } + + /** + * Get the optionalInt property: optional int. + * + * @return the optionalInt value. + */ + @Generated + public Integer getOptionalInt() { + return this.optionalInt; + } + + /** + * Set the optionalInt property: optional int. + * + * @param optionalInt the optionalInt value to set. + * @return the SpreadWithMultipleParametersRequest object itself. + */ + @Generated + public SpreadWithMultipleParametersRequest setOptionalInt(Integer optionalInt) { + this.optionalInt = optionalInt; + return this; + } + + /** + * Get the requiredIntList property: required int. + * + * @return the requiredIntList value. + */ + @Generated + public List getRequiredIntList() { + return this.requiredIntList; + } + + /** + * Get the optionalStringList property: optional string. + * + * @return the optionalStringList value. + */ + @Generated + public List getOptionalStringList() { + return this.optionalStringList; + } + + /** + * Set the optionalStringList property: optional string. + * + * @param optionalStringList the optionalStringList value to set. + * @return the SpreadWithMultipleParametersRequest object itself. + */ + @Generated + public SpreadWithMultipleParametersRequest setOptionalStringList(List optionalStringList) { + this.optionalStringList = optionalStringList; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredString", this.requiredString); + jsonWriter.writeArrayField("requiredIntList", this.requiredIntList, + (writer, element) -> writer.writeInt(element)); + jsonWriter.writeNumberField("optionalInt", this.optionalInt); + jsonWriter.writeArrayField("optionalStringList", this.optionalStringList, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadWithMultipleParametersRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadWithMultipleParametersRequest 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 SpreadWithMultipleParametersRequest. + */ + @Generated + public static SpreadWithMultipleParametersRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String requiredString = null; + List requiredIntList = null; + Integer optionalInt = null; + List optionalStringList = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredString".equals(fieldName)) { + requiredString = reader.getString(); + } else if ("requiredIntList".equals(fieldName)) { + requiredIntList = reader.readArray(reader1 -> reader1.getInt()); + } else if ("optionalInt".equals(fieldName)) { + optionalInt = reader.getNullable(JsonReader::getInt); + } else if ("optionalStringList".equals(fieldName)) { + optionalStringList = reader.readArray(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + SpreadWithMultipleParametersRequest deserializedSpreadWithMultipleParametersRequest + = new SpreadWithMultipleParametersRequest(requiredString, requiredIntList); + deserializedSpreadWithMultipleParametersRequest.optionalInt = optionalInt; + deserializedSpreadWithMultipleParametersRequest.optionalStringList = optionalStringList; + + return deserializedSpreadWithMultipleParametersRequest; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/models/package-info.java new file mode 100644 index 000000000..b447d4458 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/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 Spread. + * Test for the spread operator. + * + */ +package com.parameters.spread.implementation.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/implementation/package-info.java new file mode 100644 index 000000000..37a3e1912 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/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 Spread. + * Test for the spread operator. + * + */ +package com.parameters.spread.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/models/BodyParameter.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/models/BodyParameter.java new file mode 100644 index 000000000..aeed38d75 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/models/BodyParameter.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread.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; + +/** + * This is a simple model. + */ +@Immutable +public final class BodyParameter implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of BodyParameter class. + * + * @param name the name value to set. + */ + @Generated + public BodyParameter(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BodyParameter from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BodyParameter 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 BodyParameter. + */ + @Generated + public static BodyParameter fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new BodyParameter(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/models/package-info.java new file mode 100644 index 000000000..08751dfb4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/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 Spread. + * Test for the spread operator. + * + */ +package com.parameters.spread.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/package-info.java new file mode 100644 index 000000000..e8bc218d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/parameters/spread/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 Spread. + * Test for the spread operator. + * + */ +package com.parameters.spread; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/ContentNegotiationClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/ContentNegotiationClientBuilder.java new file mode 100644 index 000000000..10d4aa52e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/ContentNegotiationClientBuilder.java @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.contentnegotiation; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.payload.contentnegotiation.implementation.ContentNegotiationClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ContentNegotiationClient type. + */ +@ServiceClientBuilder( + serviceClients = { + SameBodyClient.class, + DifferentBodyClient.class, + SameBodyAsyncClient.class, + DifferentBodyAsyncClient.class }) +public final class ContentNegotiationClientBuilder 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("payload-contentnegotiation.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ContentNegotiationClientBuilder. + */ + @Generated + public ContentNegotiationClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentNegotiationClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentNegotiationClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentNegotiationClientBuilder 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 ContentNegotiationClientBuilder 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 ContentNegotiationClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentNegotiationClientBuilder 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 ContentNegotiationClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ContentNegotiationClientBuilder 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 ContentNegotiationClientBuilder. + */ + @Generated + public ContentNegotiationClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ContentNegotiationClientImpl with the provided parameters. + * + * @return an instance of ContentNegotiationClientImpl. + */ + @Generated + private ContentNegotiationClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ContentNegotiationClientImpl client = new ContentNegotiationClientImpl(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 SameBodyAsyncClient class. + * + * @return an instance of SameBodyAsyncClient. + */ + @Generated + public SameBodyAsyncClient buildSameBodyAsyncClient() { + return new SameBodyAsyncClient(buildInnerClient().getSameBodies()); + } + + /** + * Builds an instance of DifferentBodyAsyncClient class. + * + * @return an instance of DifferentBodyAsyncClient. + */ + @Generated + public DifferentBodyAsyncClient buildDifferentBodyAsyncClient() { + return new DifferentBodyAsyncClient(buildInnerClient().getDifferentBodies()); + } + + /** + * Builds an instance of SameBodyClient class. + * + * @return an instance of SameBodyClient. + */ + @Generated + public SameBodyClient buildSameBodyClient() { + return new SameBodyClient(buildInnerClient().getSameBodies()); + } + + /** + * Builds an instance of DifferentBodyClient class. + * + * @return an instance of DifferentBodyClient. + */ + @Generated + public DifferentBodyClient buildDifferentBodyClient() { + return new DifferentBodyClient(buildInnerClient().getDifferentBodies()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ContentNegotiationClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/DifferentBodyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/DifferentBodyAsyncClient.java new file mode 100644 index 000000000..3c34076a7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/DifferentBodyAsyncClient.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.contentnegotiation; + +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 com.payload.contentnegotiation.implementation.DifferentBodiesImpl; +import com.payload.contentnegotiation.models.PngImageAsJson; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ContentNegotiationClient type. + */ +@ServiceClient(builder = ContentNegotiationClientBuilder.class, isAsync = true) +public final class DifferentBodyAsyncClient { + @Generated + private final DifferentBodiesImpl serviceClient; + + /** + * Initializes an instance of DifferentBodyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DifferentBodyAsyncClient(DifferentBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getAvatarAsPng operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAvatarAsPngWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAvatarAsPngWithResponseAsync(requestOptions); + } + + /** + * The getAvatarAsJson operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     content: byte[] (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAvatarAsJsonWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAvatarAsJsonWithResponseAsync(requestOptions); + } + + /** + * The getAvatarAsPng 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAvatarAsPng() { + // Generated convenience method for getAvatarAsPngWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAvatarAsPngWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getAvatarAsJson 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAvatarAsJson() { + // Generated convenience method for getAvatarAsJsonWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAvatarAsJsonWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PngImageAsJson.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/DifferentBodyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/DifferentBodyClient.java new file mode 100644 index 000000000..b08326099 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/DifferentBodyClient.java @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.contentnegotiation; + +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.payload.contentnegotiation.implementation.DifferentBodiesImpl; +import com.payload.contentnegotiation.models.PngImageAsJson; + +/** + * Initializes a new instance of the synchronous ContentNegotiationClient type. + */ +@ServiceClient(builder = ContentNegotiationClientBuilder.class) +public final class DifferentBodyClient { + @Generated + private final DifferentBodiesImpl serviceClient; + + /** + * Initializes an instance of DifferentBodyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DifferentBodyClient(DifferentBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getAvatarAsPng operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAvatarAsPngWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAvatarAsPngWithResponse(requestOptions); + } + + /** + * The getAvatarAsJson operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     content: byte[] (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAvatarAsJsonWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAvatarAsJsonWithResponse(requestOptions); + } + + /** + * The getAvatarAsPng 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData getAvatarAsPng() { + // Generated convenience method for getAvatarAsPngWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAvatarAsPngWithResponse(requestOptions).getValue(); + } + + /** + * The getAvatarAsJson 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PngImageAsJson getAvatarAsJson() { + // Generated convenience method for getAvatarAsJsonWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAvatarAsJsonWithResponse(requestOptions).getValue().toObject(PngImageAsJson.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/SameBodyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/SameBodyAsyncClient.java new file mode 100644 index 000000000..03d3d69c8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/SameBodyAsyncClient.java @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.contentnegotiation; + +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 com.payload.contentnegotiation.implementation.SameBodiesImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ContentNegotiationClient type. + */ +@ServiceClient(builder = ContentNegotiationClientBuilder.class, isAsync = true) +public final class SameBodyAsyncClient { + @Generated + private final SameBodiesImpl serviceClient; + + /** + * Initializes an instance of SameBodyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SameBodyAsyncClient(SameBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getAvatarAsPng operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAvatarAsPngWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAvatarAsPngWithResponseAsync(requestOptions); + } + + /** + * The getAvatarAsJpeg operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAvatarAsJpegWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAvatarAsJpegWithResponseAsync(requestOptions); + } + + /** + * The getAvatarAsPng 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAvatarAsPng() { + // Generated convenience method for getAvatarAsPngWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAvatarAsPngWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getAvatarAsJpeg 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAvatarAsJpeg() { + // Generated convenience method for getAvatarAsJpegWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAvatarAsJpegWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/SameBodyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/SameBodyClient.java new file mode 100644 index 000000000..a6f27a8e6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/SameBodyClient.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.contentnegotiation; + +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.payload.contentnegotiation.implementation.SameBodiesImpl; + +/** + * Initializes a new instance of the synchronous ContentNegotiationClient type. + */ +@ServiceClient(builder = ContentNegotiationClientBuilder.class) +public final class SameBodyClient { + @Generated + private final SameBodiesImpl serviceClient; + + /** + * Initializes an instance of SameBodyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SameBodyClient(SameBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getAvatarAsPng operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAvatarAsPngWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAvatarAsPngWithResponse(requestOptions); + } + + /** + * The getAvatarAsJpeg operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAvatarAsJpegWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAvatarAsJpegWithResponse(requestOptions); + } + + /** + * The getAvatarAsPng 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData getAvatarAsPng() { + // Generated convenience method for getAvatarAsPngWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAvatarAsPngWithResponse(requestOptions).getValue(); + } + + /** + * The getAvatarAsJpeg 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData getAvatarAsJpeg() { + // Generated convenience method for getAvatarAsJpegWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAvatarAsJpegWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/implementation/ContentNegotiationClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/implementation/ContentNegotiationClientImpl.java new file mode 100644 index 000000000..2b4d2ab94 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/implementation/ContentNegotiationClientImpl.java @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.contentnegotiation.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the ContentNegotiationClient type. + */ +public final class ContentNegotiationClientImpl { + /** + * 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; + } + + /** + * The SameBodiesImpl object to access its operations. + */ + private final SameBodiesImpl sameBodies; + + /** + * Gets the SameBodiesImpl object to access its operations. + * + * @return the SameBodiesImpl object. + */ + public SameBodiesImpl getSameBodies() { + return this.sameBodies; + } + + /** + * The DifferentBodiesImpl object to access its operations. + */ + private final DifferentBodiesImpl differentBodies; + + /** + * Gets the DifferentBodiesImpl object to access its operations. + * + * @return the DifferentBodiesImpl object. + */ + public DifferentBodiesImpl getDifferentBodies() { + return this.differentBodies; + } + + /** + * Initializes an instance of ContentNegotiationClient client. + * + * @param endpoint Service host. + */ + public ContentNegotiationClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ContentNegotiationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ContentNegotiationClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ContentNegotiationClient 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 ContentNegotiationClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.sameBodies = new SameBodiesImpl(this); + this.differentBodies = new DifferentBodiesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/implementation/DifferentBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/implementation/DifferentBodiesImpl.java new file mode 100644 index 000000000..feeb0ea89 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/implementation/DifferentBodiesImpl.java @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.contentnegotiation.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.BinaryData; +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 DifferentBodies. + */ +public final class DifferentBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DifferentBodiesService service; + + /** + * The service client containing this operation class. + */ + private final ContentNegotiationClientImpl client; + + /** + * Initializes an instance of DifferentBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DifferentBodiesImpl(ContentNegotiationClientImpl client) { + this.service + = RestProxy.create(DifferentBodiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ContentNegotiationClientDifferentBodies to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ContentNegotiationCl") + public interface DifferentBodiesService { + @Get("/content-negotiation/different-body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAvatarAsPng(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/content-negotiation/different-body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAvatarAsPngSync(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/content-negotiation/different-body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAvatarAsJson(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/content-negotiation/different-body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAvatarAsJsonSync(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * The getAvatarAsPng operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAvatarAsPngWithResponseAsync(RequestOptions requestOptions) { + final String accept = "image/png"; + return FluxUtil + .withContext(context -> service.getAvatarAsPng(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getAvatarAsPng operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAvatarAsPngWithResponse(RequestOptions requestOptions) { + final String accept = "image/png"; + return service.getAvatarAsPngSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The getAvatarAsJson operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     content: byte[] (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAvatarAsJsonWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getAvatarAsJson(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getAvatarAsJson operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     content: byte[] (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAvatarAsJsonWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAvatarAsJsonSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/implementation/SameBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/implementation/SameBodiesImpl.java new file mode 100644 index 000000000..ed0f15221 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/implementation/SameBodiesImpl.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.contentnegotiation.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.BinaryData; +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 SameBodies. + */ +public final class SameBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SameBodiesService service; + + /** + * The service client containing this operation class. + */ + private final ContentNegotiationClientImpl client; + + /** + * Initializes an instance of SameBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SameBodiesImpl(ContentNegotiationClientImpl client) { + this.service + = RestProxy.create(SameBodiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ContentNegotiationClientSameBodies to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ContentNegotiationCl") + public interface SameBodiesService { + @Get("/content-negotiation/same-body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAvatarAsPng(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/content-negotiation/same-body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAvatarAsPngSync(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/content-negotiation/same-body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAvatarAsJpeg(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/content-negotiation/same-body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAvatarAsJpegSync(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * The getAvatarAsPng operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAvatarAsPngWithResponseAsync(RequestOptions requestOptions) { + final String accept = "image/png"; + return FluxUtil + .withContext(context -> service.getAvatarAsPng(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getAvatarAsPng operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAvatarAsPngWithResponse(RequestOptions requestOptions) { + final String accept = "image/png"; + return service.getAvatarAsPngSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The getAvatarAsJpeg operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAvatarAsJpegWithResponseAsync(RequestOptions requestOptions) { + final String accept = "image/jpeg"; + return FluxUtil.withContext( + context -> service.getAvatarAsJpeg(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getAvatarAsJpeg operation. + *

Response Body Schema

+ * + *
{@code
+     * BinaryData
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAvatarAsJpegWithResponse(RequestOptions requestOptions) { + final String accept = "image/jpeg"; + return service.getAvatarAsJpegSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/implementation/package-info.java new file mode 100644 index 000000000..fad82d567 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/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 ContentNegotiation. + * Test describing optionality of the request body. + * + */ +package com.payload.contentnegotiation.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/models/PngImageAsJson.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/models/PngImageAsJson.java new file mode 100644 index 000000000..71c185335 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/models/PngImageAsJson.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.contentnegotiation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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 PngImageAsJson model. + */ +@Immutable +public final class PngImageAsJson implements JsonSerializable { + /* + * The content property. + */ + @Generated + private final byte[] content; + + /** + * Creates an instance of PngImageAsJson class. + * + * @param content the content value to set. + */ + @Generated + private PngImageAsJson(byte[] content) { + this.content = content; + } + + /** + * Get the content property: The content property. + * + * @return the content value. + */ + @Generated + public byte[] getContent() { + return CoreUtils.clone(this.content); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBinaryField("content", this.content); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PngImageAsJson from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PngImageAsJson 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 PngImageAsJson. + */ + @Generated + public static PngImageAsJson fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + byte[] content = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("content".equals(fieldName)) { + content = reader.getBinary(); + } else { + reader.skipChildren(); + } + } + return new PngImageAsJson(content); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/models/package-info.java new file mode 100644 index 000000000..f33d9ea40 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/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 ContentNegotiation. + * Test describing optionality of the request body. + * + */ +package com.payload.contentnegotiation.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/package-info.java new file mode 100644 index 000000000..d1478176e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/contentnegotiation/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 ContentNegotiation. + * Test describing optionality of the request body. + * + */ +package com.payload.contentnegotiation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/JsonMergePatchAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/JsonMergePatchAsyncClient.java new file mode 100644 index 000000000..ba33191a5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/JsonMergePatchAsyncClient.java @@ -0,0 +1,334 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.jsonmergepatch; + +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 com.payload.jsonmergepatch.implementation.JsonMergePatchClientImpl; +import com.payload.jsonmergepatch.implementation.JsonMergePatchHelper; +import com.payload.jsonmergepatch.models.Resource; +import com.payload.jsonmergepatch.models.ResourcePatch; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous JsonMergePatchClient type. + */ +@ServiceClient(builder = JsonMergePatchClientBuilder.class, isAsync = true) +public final class JsonMergePatchAsyncClient { + @Generated + private final JsonMergePatchClientImpl serviceClient; + + /** + * Initializes an instance of JsonMergePatchAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + JsonMergePatchAsyncClient(JsonMergePatchClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Test content-type: application/merge-patch+json with required body. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 details about a resource along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createResourceWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.createResourceWithResponseAsync(body, requestOptions); + } + + /** + * Test content-type: application/merge-patch+json with required body. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 details about a resource along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateResourceWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.updateResourceWithResponseAsync(body, requestOptions); + } + + /** + * Test content-type: application/merge-patch+json with optional body. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/merge-patch+json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + * @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 details about a resource along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateOptionalResourceWithResponse(RequestOptions requestOptions) { + return this.serviceClient.updateOptionalResourceWithResponseAsync(requestOptions); + } + + /** + * Test content-type: application/merge-patch+json with required body. + * + * @param body The body 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 details about a resource on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createResource(Resource body) { + // Generated convenience method for createResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createResourceWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * Test content-type: application/merge-patch+json with required body. + * + * @param body The body 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 details about a resource on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateResource(ResourcePatch body) { + // Generated convenience method for updateResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getResourcePatchAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getResourcePatchAccessor().prepareModelForJsonMergePatch(body, false); + return updateResourceWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * Test content-type: application/merge-patch+json with optional body. + * + * @param body The body 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 details about a resource on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateOptionalResource(ResourcePatch body) { + // Generated convenience method for updateOptionalResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (body != null) { + JsonMergePatchHelper.getResourcePatchAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getResourcePatchAccessor().prepareModelForJsonMergePatch(body, false); + requestOptions.setBody(bodyInBinaryData); + } + return updateOptionalResourceWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } + + /** + * Test content-type: application/merge-patch+json with optional body. + * + * @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 details about a resource on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateOptionalResource() { + // Generated convenience method for updateOptionalResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return updateOptionalResourceWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClient.java new file mode 100644 index 000000000..08acc09d0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClient.java @@ -0,0 +1,329 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.jsonmergepatch; + +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.payload.jsonmergepatch.implementation.JsonMergePatchClientImpl; +import com.payload.jsonmergepatch.implementation.JsonMergePatchHelper; +import com.payload.jsonmergepatch.models.Resource; +import com.payload.jsonmergepatch.models.ResourcePatch; + +/** + * Initializes a new instance of the synchronous JsonMergePatchClient type. + */ +@ServiceClient(builder = JsonMergePatchClientBuilder.class) +public final class JsonMergePatchClient { + @Generated + private final JsonMergePatchClientImpl serviceClient; + + /** + * Initializes an instance of JsonMergePatchClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + JsonMergePatchClient(JsonMergePatchClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Test content-type: application/merge-patch+json with required body. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 details about a resource along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createResourceWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.createResourceWithResponse(body, requestOptions); + } + + /** + * Test content-type: application/merge-patch+json with required body. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 details about a resource along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateResourceWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.updateResourceWithResponse(body, requestOptions); + } + + /** + * Test content-type: application/merge-patch+json with optional body. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/merge-patch+json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + * @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 details about a resource along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateOptionalResourceWithResponse(RequestOptions requestOptions) { + return this.serviceClient.updateOptionalResourceWithResponse(requestOptions); + } + + /** + * Test content-type: application/merge-patch+json with required body. + * + * @param body The body 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 details about a resource. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource createResource(Resource body) { + // Generated convenience method for createResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createResourceWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(Resource.class); + } + + /** + * Test content-type: application/merge-patch+json with required body. + * + * @param body The body 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 details about a resource. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource updateResource(ResourcePatch body) { + // Generated convenience method for updateResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getResourcePatchAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getResourcePatchAccessor().prepareModelForJsonMergePatch(body, false); + return updateResourceWithResponse(bodyInBinaryData, requestOptions).getValue().toObject(Resource.class); + } + + /** + * Test content-type: application/merge-patch+json with optional body. + * + * @param body The body 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 details about a resource. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource updateOptionalResource(ResourcePatch body) { + // Generated convenience method for updateOptionalResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (body != null) { + JsonMergePatchHelper.getResourcePatchAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getResourcePatchAccessor().prepareModelForJsonMergePatch(body, false); + requestOptions.setBody(bodyInBinaryData); + } + return updateOptionalResourceWithResponse(requestOptions).getValue().toObject(Resource.class); + } + + /** + * Test content-type: application/merge-patch+json with optional body. + * + * @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 details about a resource. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Resource updateOptionalResource() { + // Generated convenience method for updateOptionalResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return updateOptionalResourceWithResponse(requestOptions).getValue().toObject(Resource.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClientBuilder.java new file mode 100644 index 000000000..c669c6631 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/JsonMergePatchClientBuilder.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 com.payload.jsonmergepatch; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.payload.jsonmergepatch.implementation.JsonMergePatchClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the JsonMergePatchClient type. + */ +@ServiceClientBuilder(serviceClients = { JsonMergePatchClient.class, JsonMergePatchAsyncClient.class }) +public final class JsonMergePatchClientBuilder 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("payload-jsonmergepatch.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the JsonMergePatchClientBuilder. + */ + @Generated + public JsonMergePatchClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public JsonMergePatchClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public JsonMergePatchClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public JsonMergePatchClientBuilder 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 JsonMergePatchClientBuilder 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 JsonMergePatchClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public JsonMergePatchClientBuilder 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 JsonMergePatchClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public JsonMergePatchClientBuilder 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 JsonMergePatchClientBuilder. + */ + @Generated + public JsonMergePatchClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of JsonMergePatchClientImpl with the provided parameters. + * + * @return an instance of JsonMergePatchClientImpl. + */ + @Generated + private JsonMergePatchClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + JsonMergePatchClientImpl client = new JsonMergePatchClientImpl(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 JsonMergePatchAsyncClient class. + * + * @return an instance of JsonMergePatchAsyncClient. + */ + @Generated + public JsonMergePatchAsyncClient buildAsyncClient() { + return new JsonMergePatchAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of JsonMergePatchClient class. + * + * @return an instance of JsonMergePatchClient. + */ + @Generated + public JsonMergePatchClient buildClient() { + return new JsonMergePatchClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(JsonMergePatchClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/implementation/JsonMergePatchClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/implementation/JsonMergePatchClientImpl.java new file mode 100644 index 000000000..c83fd683c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/implementation/JsonMergePatchClientImpl.java @@ -0,0 +1,601 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.jsonmergepatch.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.Patch; +import com.azure.core.annotation.Put; +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.HttpHeaderName; +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 JsonMergePatchClient type. + */ +public final class JsonMergePatchClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final JsonMergePatchClientService 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 JsonMergePatchClient client. + * + * @param endpoint Service host. + */ + public JsonMergePatchClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of JsonMergePatchClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public JsonMergePatchClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of JsonMergePatchClient 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 JsonMergePatchClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service + = RestProxy.create(JsonMergePatchClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for JsonMergePatchClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "JsonMergePatchClient") + public interface JsonMergePatchClientService { + @Put("/json-merge-patch/create/resource") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createResource(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Put("/json-merge-patch/create/resource") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createResourceSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Patch("/json-merge-patch/update/resource") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> updateResource(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData body, RequestOptions requestOptions, Context context); + + @Patch("/json-merge-patch/update/resource") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response updateResourceSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData body, RequestOptions requestOptions, Context context); + + @Patch("/json-merge-patch/update/resource/optional") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> updateOptionalResource(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Patch("/json-merge-patch/update/resource/optional") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response updateOptionalResourceSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Test content-type: application/merge-patch+json with required body. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 details about a resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createResourceWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createResource(this.getEndpoint(), contentType, accept, body, requestOptions, context)); + } + + /** + * Test content-type: application/merge-patch+json with required body. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 details about a resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createResourceWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createResourceSync(this.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); + } + + /** + * Test content-type: application/merge-patch+json with required body. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 details about a resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateResourceWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.updateResource(this.getEndpoint(), contentType, accept, body, requestOptions, context)); + } + + /** + * Test content-type: application/merge-patch+json with required body. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 details about a resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateResourceWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return service.updateResourceSync(this.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); + } + + /** + * Test content-type: application/merge-patch+json with optional body. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/merge-patch+json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + * @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 details about a resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateOptionalResourceWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/merge-patch+json"); + } + }); + return FluxUtil.withContext( + context -> service.updateOptionalResource(this.getEndpoint(), accept, requestOptionsLocal, context)); + } + + /** + * Test content-type: application/merge-patch+json with optional body. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/merge-patch+json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+ * + * @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 details about a resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateOptionalResourceWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/merge-patch+json"); + } + }); + return service.updateOptionalResourceSync(this.getEndpoint(), accept, requestOptionsLocal, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/implementation/JsonMergePatchHelper.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/implementation/JsonMergePatchHelper.java new file mode 100644 index 000000000..303c8b6b5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/implementation/JsonMergePatchHelper.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.jsonmergepatch.implementation; + +import com.payload.jsonmergepatch.models.InnerModel; +import com.payload.jsonmergepatch.models.ResourcePatch; + +/** + * This is the Helper class to enable json merge patch serialization for a model. + */ +public class JsonMergePatchHelper { + private static InnerModelAccessor innerModelAccessor; + + public interface InnerModelAccessor { + InnerModel prepareModelForJsonMergePatch(InnerModel innerModel, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(InnerModel innerModel); + } + + public static void setInnerModelAccessor(InnerModelAccessor accessor) { + innerModelAccessor = accessor; + } + + public static InnerModelAccessor getInnerModelAccessor() { + return innerModelAccessor; + } + + private static ResourcePatchAccessor resourcePatchAccessor; + + public interface ResourcePatchAccessor { + ResourcePatch prepareModelForJsonMergePatch(ResourcePatch resourcePatch, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(ResourcePatch resourcePatch); + } + + public static void setResourcePatchAccessor(ResourcePatchAccessor accessor) { + resourcePatchAccessor = accessor; + } + + public static ResourcePatchAccessor getResourcePatchAccessor() { + return resourcePatchAccessor; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/implementation/package-info.java new file mode 100644 index 000000000..4ecdfd59c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/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 JsonMergePatch. + * Test for merge-patch+json content-type. + * + */ +package com.payload.jsonmergepatch.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/models/InnerModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/models/InnerModel.java new file mode 100644 index 000000000..b21ef5460 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/models/InnerModel.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.jsonmergepatch.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 com.payload.jsonmergepatch.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * It is the model used by Resource model. + */ +@Fluent +public final class InnerModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private String name; + + /* + * The description property. + */ + @Generated + private String description; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setInnerModelAccessor(new JsonMergePatchHelper.InnerModelAccessor() { + @Override + public InnerModel prepareModelForJsonMergePatch(InnerModel model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(InnerModel model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of InnerModel class. + */ + @Generated + public InnerModel() { + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The name property. + * + * @param name the name value to set. + * @return the InnerModel object itself. + */ + @Generated + public InnerModel setName(String name) { + this.name = name; + this.updatedProperties.add("name"); + return this; + } + + /** + * Get the description property: The description property. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The description property. + * + * @param description the description value to set. + * @return the InnerModel object itself. + */ + @Generated + public InnerModel setDescription(String description) { + this.description = description; + this.updatedProperties.add("description"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("name")) { + if (this.name == null) { + jsonWriter.writeNullField("name"); + } else { + jsonWriter.writeStringField("name", this.name); + } + } + if (updatedProperties.contains("description")) { + if (this.description == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", this.description); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerModel 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 InnerModel. + */ + @Generated + public static InnerModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + InnerModel deserializedInnerModel = new InnerModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedInnerModel.name = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedInnerModel.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedInnerModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/models/Resource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/models/Resource.java new file mode 100644 index 000000000..38f1a13ff --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/models/Resource.java @@ -0,0 +1,318 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.jsonmergepatch.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; +import java.util.List; +import java.util.Map; + +/** + * Details about a resource. + */ +@Fluent +public final class Resource implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The description property. + */ + @Generated + private String description; + + /* + * The map property. + */ + @Generated + private Map map; + + /* + * The array property. + */ + @Generated + private List array; + + /* + * The intValue property. + */ + @Generated + private Integer intValue; + + /* + * The floatValue property. + */ + @Generated + private Double floatValue; + + /* + * The innerModel property. + */ + @Generated + private InnerModel innerModel; + + /* + * The intArray property. + */ + @Generated + private List intArray; + + /** + * Creates an instance of Resource class. + * + * @param name the name value to set. + */ + @Generated + public Resource(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the description property: The description property. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The description property. + * + * @param description the description value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the map property: The map property. + * + * @return the map value. + */ + @Generated + public Map getMap() { + return this.map; + } + + /** + * Set the map property: The map property. + * + * @param map the map value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setMap(Map map) { + this.map = map; + return this; + } + + /** + * Get the array property: The array property. + * + * @return the array value. + */ + @Generated + public List getArray() { + return this.array; + } + + /** + * Set the array property: The array property. + * + * @param array the array value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setArray(List array) { + this.array = array; + return this; + } + + /** + * Get the intValue property: The intValue property. + * + * @return the intValue value. + */ + @Generated + public Integer getIntValue() { + return this.intValue; + } + + /** + * Set the intValue property: The intValue property. + * + * @param intValue the intValue value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setIntValue(Integer intValue) { + this.intValue = intValue; + return this; + } + + /** + * Get the floatValue property: The floatValue property. + * + * @return the floatValue value. + */ + @Generated + public Double getFloatValue() { + return this.floatValue; + } + + /** + * Set the floatValue property: The floatValue property. + * + * @param floatValue the floatValue value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setFloatValue(Double floatValue) { + this.floatValue = floatValue; + return this; + } + + /** + * Get the innerModel property: The innerModel property. + * + * @return the innerModel value. + */ + @Generated + public InnerModel getInnerModel() { + return this.innerModel; + } + + /** + * Set the innerModel property: The innerModel property. + * + * @param innerModel the innerModel value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setInnerModel(InnerModel innerModel) { + this.innerModel = innerModel; + return this; + } + + /** + * Get the intArray property: The intArray property. + * + * @return the intArray value. + */ + @Generated + public List getIntArray() { + return this.intArray; + } + + /** + * Set the intArray property: The intArray property. + * + * @param intArray the intArray value to set. + * @return the Resource object itself. + */ + @Generated + public Resource setIntArray(List intArray) { + this.intArray = intArray; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeMapField("map", this.map, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("array", this.array, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeNumberField("intValue", this.intValue); + jsonWriter.writeNumberField("floatValue", this.floatValue); + jsonWriter.writeJsonField("innerModel", this.innerModel); + jsonWriter.writeArrayField("intArray", this.intArray, (writer, element) -> writer.writeInt(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource 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 Resource. + */ + @Generated + public static Resource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String description = null; + Map map = null; + List array = null; + Integer intValue = null; + Double floatValue = null; + InnerModel innerModel = null; + List intArray = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("map".equals(fieldName)) { + map = reader.readMap(reader1 -> InnerModel.fromJson(reader1)); + } else if ("array".equals(fieldName)) { + array = reader.readArray(reader1 -> InnerModel.fromJson(reader1)); + } else if ("intValue".equals(fieldName)) { + intValue = reader.getNullable(JsonReader::getInt); + } else if ("floatValue".equals(fieldName)) { + floatValue = reader.getNullable(JsonReader::getDouble); + } else if ("innerModel".equals(fieldName)) { + innerModel = InnerModel.fromJson(reader); + } else if ("intArray".equals(fieldName)) { + intArray = reader.readArray(reader1 -> reader1.getInt()); + } else { + reader.skipChildren(); + } + } + Resource deserializedResource = new Resource(name); + deserializedResource.description = description; + deserializedResource.map = map; + deserializedResource.array = array; + deserializedResource.intValue = intValue; + deserializedResource.floatValue = floatValue; + deserializedResource.innerModel = innerModel; + deserializedResource.intArray = intArray; + + return deserializedResource; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/models/ResourcePatch.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/models/ResourcePatch.java new file mode 100644 index 000000000..a55bd12eb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/models/ResourcePatch.java @@ -0,0 +1,391 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.jsonmergepatch.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 com.payload.jsonmergepatch.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Details about a resource for patch operation. + */ +@Fluent +public final class ResourcePatch implements JsonSerializable { + /* + * The description property. + */ + @Generated + private String description; + + /* + * The map property. + */ + @Generated + private Map map; + + /* + * The array property. + */ + @Generated + private List array; + + /* + * The intValue property. + */ + @Generated + private Integer intValue; + + /* + * The floatValue property. + */ + @Generated + private Double floatValue; + + /* + * The innerModel property. + */ + @Generated + private InnerModel innerModel; + + /* + * The intArray property. + */ + @Generated + private List intArray; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setResourcePatchAccessor(new JsonMergePatchHelper.ResourcePatchAccessor() { + @Override + public ResourcePatch prepareModelForJsonMergePatch(ResourcePatch model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(ResourcePatch model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of ResourcePatch class. + */ + @Generated + public ResourcePatch() { + } + + /** + * Get the description property: The description property. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The description property. + * + * @param description the description value to set. + * @return the ResourcePatch object itself. + */ + @Generated + public ResourcePatch setDescription(String description) { + this.description = description; + this.updatedProperties.add("description"); + return this; + } + + /** + * Get the map property: The map property. + * + * @return the map value. + */ + @Generated + public Map getMap() { + return this.map; + } + + /** + * Set the map property: The map property. + * + * @param map the map value to set. + * @return the ResourcePatch object itself. + */ + @Generated + public ResourcePatch setMap(Map map) { + this.map = map; + this.updatedProperties.add("map"); + return this; + } + + /** + * Get the array property: The array property. + * + * @return the array value. + */ + @Generated + public List getArray() { + return this.array; + } + + /** + * Set the array property: The array property. + * + * @param array the array value to set. + * @return the ResourcePatch object itself. + */ + @Generated + public ResourcePatch setArray(List array) { + this.array = array; + this.updatedProperties.add("array"); + return this; + } + + /** + * Get the intValue property: The intValue property. + * + * @return the intValue value. + */ + @Generated + public Integer getIntValue() { + return this.intValue; + } + + /** + * Set the intValue property: The intValue property. + * + * @param intValue the intValue value to set. + * @return the ResourcePatch object itself. + */ + @Generated + public ResourcePatch setIntValue(Integer intValue) { + this.intValue = intValue; + this.updatedProperties.add("intValue"); + return this; + } + + /** + * Get the floatValue property: The floatValue property. + * + * @return the floatValue value. + */ + @Generated + public Double getFloatValue() { + return this.floatValue; + } + + /** + * Set the floatValue property: The floatValue property. + * + * @param floatValue the floatValue value to set. + * @return the ResourcePatch object itself. + */ + @Generated + public ResourcePatch setFloatValue(Double floatValue) { + this.floatValue = floatValue; + this.updatedProperties.add("floatValue"); + return this; + } + + /** + * Get the innerModel property: The innerModel property. + * + * @return the innerModel value. + */ + @Generated + public InnerModel getInnerModel() { + return this.innerModel; + } + + /** + * Set the innerModel property: The innerModel property. + * + * @param innerModel the innerModel value to set. + * @return the ResourcePatch object itself. + */ + @Generated + public ResourcePatch setInnerModel(InnerModel innerModel) { + this.innerModel = innerModel; + this.updatedProperties.add("innerModel"); + return this; + } + + /** + * Get the intArray property: The intArray property. + * + * @return the intArray value. + */ + @Generated + public List getIntArray() { + return this.intArray; + } + + /** + * Set the intArray property: The intArray property. + * + * @param intArray the intArray value to set. + * @return the ResourcePatch object itself. + */ + @Generated + public ResourcePatch setIntArray(List intArray) { + this.intArray = intArray; + this.updatedProperties.add("intArray"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeMapField("map", this.map, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("array", this.array, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeNumberField("intValue", this.intValue); + jsonWriter.writeNumberField("floatValue", this.floatValue); + jsonWriter.writeJsonField("innerModel", this.innerModel); + jsonWriter.writeArrayField("intArray", this.intArray, (writer, element) -> writer.writeInt(element)); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("description")) { + if (this.description == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", this.description); + } + } + if (updatedProperties.contains("map")) { + if (this.map == null) { + jsonWriter.writeNullField("map"); + } else { + jsonWriter.writeMapField("map", this.map, (writer, element) -> { + if (element != null) { + JsonMergePatchHelper.getInnerModelAccessor().prepareModelForJsonMergePatch(element, true); + writer.writeJson(element); + JsonMergePatchHelper.getInnerModelAccessor().prepareModelForJsonMergePatch(element, false); + } else { + writer.writeNull(); + } + }); + } + } + if (updatedProperties.contains("array")) { + if (this.array == null) { + jsonWriter.writeNullField("array"); + } else { + jsonWriter.writeArrayField("array", this.array, (writer, element) -> writer.writeJson(element)); + } + } + if (updatedProperties.contains("intValue")) { + if (this.intValue == null) { + jsonWriter.writeNullField("intValue"); + } else { + jsonWriter.writeNumberField("intValue", this.intValue); + } + } + if (updatedProperties.contains("floatValue")) { + if (this.floatValue == null) { + jsonWriter.writeNullField("floatValue"); + } else { + jsonWriter.writeNumberField("floatValue", this.floatValue); + } + } + if (updatedProperties.contains("innerModel")) { + if (this.innerModel == null) { + jsonWriter.writeNullField("innerModel"); + } else { + JsonMergePatchHelper.getInnerModelAccessor().prepareModelForJsonMergePatch(this.innerModel, true); + jsonWriter.writeJsonField("innerModel", this.innerModel); + JsonMergePatchHelper.getInnerModelAccessor().prepareModelForJsonMergePatch(this.innerModel, false); + } + } + if (updatedProperties.contains("intArray")) { + if (this.intArray == null) { + jsonWriter.writeNullField("intArray"); + } else { + jsonWriter.writeArrayField("intArray", this.intArray, (writer, element) -> writer.writeInt(element)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourcePatch from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourcePatch 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 ResourcePatch. + */ + @Generated + public static ResourcePatch fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourcePatch deserializedResourcePatch = new ResourcePatch(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("description".equals(fieldName)) { + deserializedResourcePatch.description = reader.getString(); + } else if ("map".equals(fieldName)) { + Map map = reader.readMap(reader1 -> InnerModel.fromJson(reader1)); + deserializedResourcePatch.map = map; + } else if ("array".equals(fieldName)) { + List array = reader.readArray(reader1 -> InnerModel.fromJson(reader1)); + deserializedResourcePatch.array = array; + } else if ("intValue".equals(fieldName)) { + deserializedResourcePatch.intValue = reader.getNullable(JsonReader::getInt); + } else if ("floatValue".equals(fieldName)) { + deserializedResourcePatch.floatValue = reader.getNullable(JsonReader::getDouble); + } else if ("innerModel".equals(fieldName)) { + deserializedResourcePatch.innerModel = InnerModel.fromJson(reader); + } else if ("intArray".equals(fieldName)) { + List intArray = reader.readArray(reader1 -> reader1.getInt()); + deserializedResourcePatch.intArray = intArray; + } else { + reader.skipChildren(); + } + } + + return deserializedResourcePatch; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/models/package-info.java new file mode 100644 index 000000000..fabdbd32f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/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 JsonMergePatch. + * Test for merge-patch+json content-type. + * + */ +package com.payload.jsonmergepatch.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/package-info.java new file mode 100644 index 000000000..573d55119 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/jsonmergepatch/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 JsonMergePatch. + * Test for merge-patch+json content-type. + * + */ +package com.payload.jsonmergepatch; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/MediaTypeAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/MediaTypeAsyncClient.java new file mode 100644 index 000000000..5efbab264 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/MediaTypeAsyncClient.java @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.mediatype; + +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 com.payload.mediatype.implementation.StringBodiesImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous MediaTypeClient type. + */ +@ServiceClient(builder = MediaTypeClientBuilder.class, isAsync = true) +public final class MediaTypeAsyncClient { + @Generated + private final StringBodiesImpl serviceClient; + + /** + * Initializes an instance of MediaTypeAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MediaTypeAsyncClient(StringBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The sendAsText operation. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param text The text 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> sendAsTextWithResponse(BinaryData text, RequestOptions requestOptions) { + return this.serviceClient.sendAsTextWithResponseAsync(text, requestOptions); + } + + /** + * The getAsText operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAsTextWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAsTextWithResponseAsync(requestOptions); + } + + /** + * The sendAsJson operation. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param text The text 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> sendAsJsonWithResponse(BinaryData text, RequestOptions requestOptions) { + return this.serviceClient.sendAsJsonWithResponseAsync(text, requestOptions); + } + + /** + * The getAsJson operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAsJsonWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAsJsonWithResponseAsync(requestOptions); + } + + /** + * The sendAsText operation. + * + * @param text The text 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 sendAsText(String text) { + // Generated convenience method for sendAsTextWithResponse + RequestOptions requestOptions = new RequestOptions(); + return sendAsTextWithResponse(BinaryData.fromString(text), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getAsText 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAsText() { + // Generated convenience method for getAsTextWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAsTextWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toString()); + } + + /** + * The sendAsJson operation. + * + * @param text The text 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 sendAsJson(String text) { + // Generated convenience method for sendAsJsonWithResponse + RequestOptions requestOptions = new RequestOptions(); + return sendAsJsonWithResponse(BinaryData.fromObject(text), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getAsJson 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAsJson() { + // Generated convenience method for getAsJsonWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAsJsonWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/MediaTypeClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/MediaTypeClient.java new file mode 100644 index 000000000..c228fb286 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/MediaTypeClient.java @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.mediatype; + +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.payload.mediatype.implementation.StringBodiesImpl; + +/** + * Initializes a new instance of the synchronous MediaTypeClient type. + */ +@ServiceClient(builder = MediaTypeClientBuilder.class) +public final class MediaTypeClient { + @Generated + private final StringBodiesImpl serviceClient; + + /** + * Initializes an instance of MediaTypeClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MediaTypeClient(StringBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The sendAsText operation. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param text The text 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 sendAsTextWithResponse(BinaryData text, RequestOptions requestOptions) { + return this.serviceClient.sendAsTextWithResponse(text, requestOptions); + } + + /** + * The getAsText operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 sequence of textual characters along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAsTextWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAsTextWithResponse(requestOptions); + } + + /** + * The sendAsJson operation. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param text The text 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 sendAsJsonWithResponse(BinaryData text, RequestOptions requestOptions) { + return this.serviceClient.sendAsJsonWithResponse(text, requestOptions); + } + + /** + * The getAsJson operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 sequence of textual characters along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAsJsonWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAsJsonWithResponse(requestOptions); + } + + /** + * The sendAsText operation. + * + * @param text The text 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 sendAsText(String text) { + // Generated convenience method for sendAsTextWithResponse + RequestOptions requestOptions = new RequestOptions(); + sendAsTextWithResponse(BinaryData.fromString(text), requestOptions).getValue(); + } + + /** + * The getAsText 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String getAsText() { + // Generated convenience method for getAsTextWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAsTextWithResponse(requestOptions).getValue().toString(); + } + + /** + * The sendAsJson operation. + * + * @param text The text 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 sendAsJson(String text) { + // Generated convenience method for sendAsJsonWithResponse + RequestOptions requestOptions = new RequestOptions(); + sendAsJsonWithResponse(BinaryData.fromObject(text), requestOptions).getValue(); + } + + /** + * The getAsJson 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String getAsJson() { + // Generated convenience method for getAsJsonWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAsJsonWithResponse(requestOptions).getValue().toObject(String.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/MediaTypeClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/MediaTypeClientBuilder.java new file mode 100644 index 000000000..c2efd2827 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/MediaTypeClientBuilder.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 com.payload.mediatype; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.payload.mediatype.implementation.MediaTypeClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the MediaTypeClient type. + */ +@ServiceClientBuilder(serviceClients = { MediaTypeClient.class, MediaTypeAsyncClient.class }) +public final class MediaTypeClientBuilder 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("payload-mediatype.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the MediaTypeClientBuilder. + */ + @Generated + public MediaTypeClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MediaTypeClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MediaTypeClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MediaTypeClientBuilder 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 MediaTypeClientBuilder 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 MediaTypeClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MediaTypeClientBuilder 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 MediaTypeClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MediaTypeClientBuilder 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 MediaTypeClientBuilder. + */ + @Generated + public MediaTypeClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of MediaTypeClientImpl with the provided parameters. + * + * @return an instance of MediaTypeClientImpl. + */ + @Generated + private MediaTypeClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + MediaTypeClientImpl client + = new MediaTypeClientImpl(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 MediaTypeAsyncClient class. + * + * @return an instance of MediaTypeAsyncClient. + */ + @Generated + public MediaTypeAsyncClient buildAsyncClient() { + return new MediaTypeAsyncClient(buildInnerClient().getStringBodies()); + } + + /** + * Builds an instance of MediaTypeClient class. + * + * @return an instance of MediaTypeClient. + */ + @Generated + public MediaTypeClient buildClient() { + return new MediaTypeClient(buildInnerClient().getStringBodies()); + } + + private static final ClientLogger LOGGER = new ClientLogger(MediaTypeClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/implementation/MediaTypeClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/implementation/MediaTypeClientImpl.java new file mode 100644 index 000000000..98398c253 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/implementation/MediaTypeClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.mediatype.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the MediaTypeClient type. + */ +public final class MediaTypeClientImpl { + /** + * 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; + } + + /** + * The StringBodiesImpl object to access its operations. + */ + private final StringBodiesImpl stringBodies; + + /** + * Gets the StringBodiesImpl object to access its operations. + * + * @return the StringBodiesImpl object. + */ + public StringBodiesImpl getStringBodies() { + return this.stringBodies; + } + + /** + * Initializes an instance of MediaTypeClient client. + * + * @param endpoint Service host. + */ + public MediaTypeClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of MediaTypeClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public MediaTypeClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of MediaTypeClient 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 MediaTypeClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.stringBodies = new StringBodiesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/implementation/StringBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/implementation/StringBodiesImpl.java new file mode 100644 index 000000000..4acde5ace --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/implementation/StringBodiesImpl.java @@ -0,0 +1,314 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.mediatype.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in StringBodies. + */ +public final class StringBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringBodiesService service; + + /** + * The service client containing this operation class. + */ + private final MediaTypeClientImpl client; + + /** + * Initializes an instance of StringBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringBodiesImpl(MediaTypeClientImpl client) { + this.service + = RestProxy.create(StringBodiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MediaTypeClientStringBodies to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "MediaTypeClientStrin") + public interface StringBodiesService { + @Post("/payload/media-type/string-body/sendAsText") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> sendAsText(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("text/plain") BinaryData text, + RequestOptions requestOptions, Context context); + + @Post("/payload/media-type/string-body/sendAsText") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendAsTextSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("text/plain") BinaryData text, + RequestOptions requestOptions, Context context); + + @Get("/payload/media-type/string-body/getAsText") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAsText(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/payload/media-type/string-body/getAsText") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAsTextSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/payload/media-type/string-body/sendAsJson") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> sendAsJson(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData text, + RequestOptions requestOptions, Context context); + + @Post("/payload/media-type/string-body/sendAsJson") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendAsJsonSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData text, + RequestOptions requestOptions, Context context); + + @Get("/payload/media-type/string-body/getAsJson") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAsJson(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/payload/media-type/string-body/getAsJson") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAsJsonSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * The sendAsText operation. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param text The text 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> sendAsTextWithResponseAsync(BinaryData text, RequestOptions requestOptions) { + final String contentType = "text/plain"; + return FluxUtil.withContext( + context -> service.sendAsText(this.client.getEndpoint(), contentType, text, requestOptions, context)); + } + + /** + * The sendAsText operation. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param text The text 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 sendAsTextWithResponse(BinaryData text, RequestOptions requestOptions) { + final String contentType = "text/plain"; + return service.sendAsTextSync(this.client.getEndpoint(), contentType, text, requestOptions, Context.NONE); + } + + /** + * The getAsText operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAsTextWithResponseAsync(RequestOptions requestOptions) { + final String accept = "text/plain"; + return FluxUtil + .withContext(context -> service.getAsText(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getAsText operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 sequence of textual characters along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAsTextWithResponse(RequestOptions requestOptions) { + final String accept = "text/plain"; + return service.getAsTextSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The sendAsJson operation. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param text The text 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> sendAsJsonWithResponseAsync(BinaryData text, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.sendAsJson(this.client.getEndpoint(), contentType, text, requestOptions, context)); + } + + /** + * The sendAsJson operation. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param text The text 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 sendAsJsonWithResponse(BinaryData text, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendAsJsonSync(this.client.getEndpoint(), contentType, text, requestOptions, Context.NONE); + } + + /** + * The getAsJson operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAsJsonWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAsJson(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getAsJson operation. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 sequence of textual characters along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAsJsonWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAsJsonSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/implementation/package-info.java new file mode 100644 index 000000000..98e8ea30e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/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 MediaType. + * Test the payload with different media types and different types of the payload itself. + * + */ +package com.payload.mediatype.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/package-info.java new file mode 100644 index 000000000..d1337c19c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/mediatype/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 MediaType. + * Test the payload with different media types and different types of the payload itself. + * + */ +package com.payload.mediatype; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/MultiPartAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/MultiPartAsyncClient.java new file mode 100644 index 000000000..a9998c3c2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/MultiPartAsyncClient.java @@ -0,0 +1,416 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart; + +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 com.payload.multipart.implementation.FormDatasImpl; +import com.payload.multipart.implementation.MultipartFormDataHelper; +import com.payload.multipart.implementation.models.AnonymousModelRequest; +import com.payload.multipart.models.BinaryArrayPartsRequest; +import com.payload.multipart.models.ComplexPartsRequest; +import com.payload.multipart.models.JsonArrayPartsRequest; +import com.payload.multipart.models.JsonPartRequest; +import com.payload.multipart.models.MultiBinaryPartsRequest; +import com.payload.multipart.models.MultiPartRequest; +import com.payload.multipart.models.PicturesFileDetails; +import com.payload.multipart.models.ProfileImageFileDetails; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous MultiPartClient type. + */ +@ServiceClient(builder = MultiPartClientBuilder.class, isAsync = true) +public final class MultiPartAsyncClient { + @Generated + private final FormDatasImpl serviceClient; + + /** + * Initializes an instance of MultiPartAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MultiPartAsyncClient(FormDatasImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body 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) + Mono> basicWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'basic' is + // 'multipart/form-data' + return this.serviceClient.basicWithResponseAsync(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for mixed scenarios. + * + * @param body The body 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) + Mono> complexWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'complex' is + // 'multipart/form-data' + return this.serviceClient.complexWithResponseAsync(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains json part and binary part. + * + * @param body The body 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) + Mono> jsonPartWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'jsonPart' is + // 'multipart/form-data' + return this.serviceClient.jsonPartWithResponseAsync(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body 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) + Mono> binaryArrayPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'binaryArrayParts' is 'multipart/form-data' + return this.serviceClient.binaryArrayPartsWithResponseAsync(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi json parts. + * + * @param body The body 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) + Mono> jsonArrayPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'jsonArrayParts' + // is 'multipart/form-data' + return this.serviceClient.jsonArrayPartsWithResponseAsync(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body 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) + Mono> multiBinaryPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'multiBinaryParts' is 'multipart/form-data' + return this.serviceClient.multiBinaryPartsWithResponseAsync(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body 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) + Mono> checkFileNameAndContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'checkFileNameAndContentType' is 'multipart/form-data' + return this.serviceClient.checkFileNameAndContentTypeWithResponseAsync(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param anonymousModelRequest The anonymousModelRequest 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) + Mono> anonymousModelWithResponse(BinaryData anonymousModelRequest, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'anonymousModel' + // is 'multipart/form-data' + return this.serviceClient.anonymousModelWithResponseAsync(anonymousModelRequest, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body 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 basic(MultiPartRequest body) { + // Generated convenience method for basicWithResponse + RequestOptions requestOptions = new RequestOptions(); + return basicWithResponse(new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .end() + .getRequestBody(), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Test content-type: multipart/form-data for mixed scenarios. + * + * @param body The body 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 complex(ComplexPartsRequest body) { + // Generated convenience method for complexWithResponse + RequestOptions requestOptions = new RequestOptions(); + return complexWithResponse(new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeJsonField("address", body.getAddress()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .serializeJsonField("previousAddresses", body.getPreviousAddresses()) + .serializeFileFields("pictures", + body.getPictures().stream().map(PicturesFileDetails::getContent).collect(Collectors.toList()), + body.getPictures().stream().map(PicturesFileDetails::getContentType).collect(Collectors.toList()), + body.getPictures().stream().map(PicturesFileDetails::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Test content-type: multipart/form-data for scenario contains json part and binary part. + * + * @param body The body 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 jsonPart(JsonPartRequest body) { + // Generated convenience method for jsonPartWithResponse + RequestOptions requestOptions = new RequestOptions(); + return jsonPartWithResponse( + new MultipartFormDataHelper(requestOptions).serializeJsonField("address", body.getAddress()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .end() + .getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body 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 binaryArrayParts(BinaryArrayPartsRequest body) { + // Generated convenience method for binaryArrayPartsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return binaryArrayPartsWithResponse( + new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeFileFields("pictures", + body.getPictures().stream().map(PicturesFileDetails::getContent).collect(Collectors.toList()), + body.getPictures().stream().map(PicturesFileDetails::getContentType).collect(Collectors.toList()), + body.getPictures().stream().map(PicturesFileDetails::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi json parts. + * + * @param body The body 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 jsonArrayParts(JsonArrayPartsRequest body) { + // Generated convenience method for jsonArrayPartsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return jsonArrayPartsWithResponse(new MultipartFormDataHelper(requestOptions) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .serializeJsonField("previousAddresses", body.getPreviousAddresses()) + .end() + .getRequestBody(), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body 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 multiBinaryParts(MultiBinaryPartsRequest body) { + // Generated convenience method for multiBinaryPartsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return multiBinaryPartsWithResponse(new MultipartFormDataHelper(requestOptions) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .serializeFileField("picture", body.getPicture() == null ? null : body.getPicture().getContent(), + body.getPicture() == null ? null : body.getPicture().getContentType(), + body.getPicture() == null ? null : body.getPicture().getFilename()) + .end() + .getRequestBody(), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body 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 checkFileNameAndContentType(MultiPartRequest body) { + // Generated convenience method for checkFileNameAndContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return checkFileNameAndContentTypeWithResponse( + new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .end() + .getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Test content-type: multipart/form-data. + * + * @param profileImage The profileImage 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 anonymousModel(ProfileImageFileDetails profileImage) { + // Generated convenience method for anonymousModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + AnonymousModelRequest anonymousModelRequestObj = new AnonymousModelRequest(profileImage); + BinaryData anonymousModelRequest + = new MultipartFormDataHelper(requestOptions) + .serializeFileField("profileImage", anonymousModelRequestObj.getProfileImage().getContent(), + anonymousModelRequestObj.getProfileImage().getContentType(), + anonymousModelRequestObj.getProfileImage().getFilename()) + .end() + .getRequestBody(); + return anonymousModelWithResponse(anonymousModelRequest, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/MultiPartClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/MultiPartClient.java new file mode 100644 index 000000000..ee58a1c55 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/MultiPartClient.java @@ -0,0 +1,404 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart; + +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.payload.multipart.implementation.FormDatasImpl; +import com.payload.multipart.implementation.MultipartFormDataHelper; +import com.payload.multipart.implementation.models.AnonymousModelRequest; +import com.payload.multipart.models.BinaryArrayPartsRequest; +import com.payload.multipart.models.ComplexPartsRequest; +import com.payload.multipart.models.JsonArrayPartsRequest; +import com.payload.multipart.models.JsonPartRequest; +import com.payload.multipart.models.MultiBinaryPartsRequest; +import com.payload.multipart.models.MultiPartRequest; +import com.payload.multipart.models.PicturesFileDetails; +import com.payload.multipart.models.ProfileImageFileDetails; +import java.util.stream.Collectors; + +/** + * Initializes a new instance of the synchronous MultiPartClient type. + */ +@ServiceClient(builder = MultiPartClientBuilder.class) +public final class MultiPartClient { + @Generated + private final FormDatasImpl serviceClient; + + /** + * Initializes an instance of MultiPartClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MultiPartClient(FormDatasImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body 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) + Response basicWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'basic' is + // 'multipart/form-data' + return this.serviceClient.basicWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for mixed scenarios. + * + * @param body The body 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) + Response complexWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'complex' is + // 'multipart/form-data' + return this.serviceClient.complexWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains json part and binary part. + * + * @param body The body 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) + Response jsonPartWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'jsonPart' is + // 'multipart/form-data' + return this.serviceClient.jsonPartWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body 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) + Response binaryArrayPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'binaryArrayParts' is 'multipart/form-data' + return this.serviceClient.binaryArrayPartsWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi json parts. + * + * @param body The body 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) + Response jsonArrayPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'jsonArrayParts' + // is 'multipart/form-data' + return this.serviceClient.jsonArrayPartsWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body 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) + Response multiBinaryPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'multiBinaryParts' is 'multipart/form-data' + return this.serviceClient.multiBinaryPartsWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body 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) + Response checkFileNameAndContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'checkFileNameAndContentType' is 'multipart/form-data' + return this.serviceClient.checkFileNameAndContentTypeWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param anonymousModelRequest The anonymousModelRequest 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) + Response anonymousModelWithResponse(BinaryData anonymousModelRequest, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'anonymousModel' + // is 'multipart/form-data' + return this.serviceClient.anonymousModelWithResponse(anonymousModelRequest, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body 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 basic(MultiPartRequest body) { + // Generated convenience method for basicWithResponse + RequestOptions requestOptions = new RequestOptions(); + basicWithResponse(new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .end() + .getRequestBody(), requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data for mixed scenarios. + * + * @param body The body 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 complex(ComplexPartsRequest body) { + // Generated convenience method for complexWithResponse + RequestOptions requestOptions = new RequestOptions(); + complexWithResponse(new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeJsonField("address", body.getAddress()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .serializeJsonField("previousAddresses", body.getPreviousAddresses()) + .serializeFileFields("pictures", + body.getPictures().stream().map(PicturesFileDetails::getContent).collect(Collectors.toList()), + body.getPictures().stream().map(PicturesFileDetails::getContentType).collect(Collectors.toList()), + body.getPictures().stream().map(PicturesFileDetails::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data for scenario contains json part and binary part. + * + * @param body The body 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 jsonPart(JsonPartRequest body) { + // Generated convenience method for jsonPartWithResponse + RequestOptions requestOptions = new RequestOptions(); + jsonPartWithResponse( + new MultipartFormDataHelper(requestOptions).serializeJsonField("address", body.getAddress()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body 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 binaryArrayParts(BinaryArrayPartsRequest body) { + // Generated convenience method for binaryArrayPartsWithResponse + RequestOptions requestOptions = new RequestOptions(); + binaryArrayPartsWithResponse(new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeFileFields("pictures", + body.getPictures().stream().map(PicturesFileDetails::getContent).collect(Collectors.toList()), + body.getPictures().stream().map(PicturesFileDetails::getContentType).collect(Collectors.toList()), + body.getPictures().stream().map(PicturesFileDetails::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi json parts. + * + * @param body The body 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 jsonArrayParts(JsonArrayPartsRequest body) { + // Generated convenience method for jsonArrayPartsWithResponse + RequestOptions requestOptions = new RequestOptions(); + jsonArrayPartsWithResponse(new MultipartFormDataHelper(requestOptions) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .serializeJsonField("previousAddresses", body.getPreviousAddresses()) + .end() + .getRequestBody(), requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body 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 multiBinaryParts(MultiBinaryPartsRequest body) { + // Generated convenience method for multiBinaryPartsWithResponse + RequestOptions requestOptions = new RequestOptions(); + multiBinaryPartsWithResponse(new MultipartFormDataHelper(requestOptions) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .serializeFileField("picture", body.getPicture() == null ? null : body.getPicture().getContent(), + body.getPicture() == null ? null : body.getPicture().getContentType(), + body.getPicture() == null ? null : body.getPicture().getFilename()) + .end() + .getRequestBody(), requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body 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 checkFileNameAndContentType(MultiPartRequest body) { + // Generated convenience method for checkFileNameAndContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + checkFileNameAndContentTypeWithResponse( + new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data. + * + * @param profileImage The profileImage 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 anonymousModel(ProfileImageFileDetails profileImage) { + // Generated convenience method for anonymousModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + AnonymousModelRequest anonymousModelRequestObj = new AnonymousModelRequest(profileImage); + BinaryData anonymousModelRequest + = new MultipartFormDataHelper(requestOptions) + .serializeFileField("profileImage", anonymousModelRequestObj.getProfileImage().getContent(), + anonymousModelRequestObj.getProfileImage().getContentType(), + anonymousModelRequestObj.getProfileImage().getFilename()) + .end() + .getRequestBody(); + anonymousModelWithResponse(anonymousModelRequest, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/MultiPartClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/MultiPartClientBuilder.java new file mode 100644 index 000000000..b1734e648 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/MultiPartClientBuilder.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 com.payload.multipart; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.payload.multipart.implementation.MultiPartClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the MultiPartClient type. + */ +@ServiceClientBuilder(serviceClients = { MultiPartClient.class, MultiPartAsyncClient.class }) +public final class MultiPartClientBuilder 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("payload-multipart.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the MultiPartClientBuilder. + */ + @Generated + public MultiPartClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultiPartClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultiPartClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultiPartClientBuilder 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 MultiPartClientBuilder 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 MultiPartClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultiPartClientBuilder 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 MultiPartClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultiPartClientBuilder 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 MultiPartClientBuilder. + */ + @Generated + public MultiPartClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of MultiPartClientImpl with the provided parameters. + * + * @return an instance of MultiPartClientImpl. + */ + @Generated + private MultiPartClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + MultiPartClientImpl client + = new MultiPartClientImpl(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 MultiPartAsyncClient class. + * + * @return an instance of MultiPartAsyncClient. + */ + @Generated + public MultiPartAsyncClient buildAsyncClient() { + return new MultiPartAsyncClient(buildInnerClient().getFormDatas()); + } + + /** + * Builds an instance of MultiPartClient class. + * + * @return an instance of MultiPartClient. + */ + @Generated + public MultiPartClient buildClient() { + return new MultiPartClient(buildInnerClient().getFormDatas()); + } + + private static final ClientLogger LOGGER = new ClientLogger(MultiPartClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/FormDatasImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/FormDatasImpl.java new file mode 100644 index 000000000..90ac80838 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/FormDatasImpl.java @@ -0,0 +1,523 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in FormDatas. + */ +public final class FormDatasImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FormDatasService service; + + /** + * The service client containing this operation class. + */ + private final MultiPartClientImpl client; + + /** + * Initializes an instance of FormDatasImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FormDatasImpl(MultiPartClientImpl client) { + this.service + = RestProxy.create(FormDatasService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MultiPartClientFormDatas to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "MultiPartClientFormD") + public interface FormDatasService { + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/mixed-parts") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> basic(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/mixed-parts") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response basicSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/complex-parts") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> complex(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/complex-parts") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response complexSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/json-part") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> jsonPart(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/json-part") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response jsonPartSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/binary-array-parts") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> binaryArrayParts(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/binary-array-parts") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response binaryArrayPartsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/json-array-parts") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> jsonArrayParts(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/json-array-parts") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response jsonArrayPartsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/multi-binary-parts") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> multiBinaryParts(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/multi-binary-parts") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response multiBinaryPartsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/check-filename-and-content-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> checkFileNameAndContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/check-filename-and-content-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response checkFileNameAndContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/anonymous-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> anonymousModel(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, + @BodyParam("multipart/form-data") BinaryData anonymousModelRequest, RequestOptions requestOptions, + Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/anonymous-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 anonymousModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, + @BodyParam("multipart/form-data") BinaryData anonymousModelRequest, RequestOptions requestOptions, + Context context); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body 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> basicWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext( + context -> service.basic(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body 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 basicWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.basicSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Test content-type: multipart/form-data for mixed scenarios. + * + * @param body The body 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> complexWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext( + context -> service.complex(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Test content-type: multipart/form-data for mixed scenarios. + * + * @param body The body 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 complexWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.complexSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Test content-type: multipart/form-data for scenario contains json part and binary part. + * + * @param body The body 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> jsonPartWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext( + context -> service.jsonPart(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Test content-type: multipart/form-data for scenario contains json part and binary part. + * + * @param body The body 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 jsonPartWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.jsonPartSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body 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> binaryArrayPartsWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext( + context -> service.binaryArrayParts(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body 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 binaryArrayPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.binaryArrayPartsSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi json parts. + * + * @param body The body 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> jsonArrayPartsWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext( + context -> service.jsonArrayParts(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi json parts. + * + * @param body The body 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 jsonArrayPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.jsonArrayPartsSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body 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> multiBinaryPartsWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext( + context -> service.multiBinaryParts(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body 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 multiBinaryPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.multiBinaryPartsSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body 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> checkFileNameAndContentTypeWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext(context -> service.checkFileNameAndContentType(this.client.getEndpoint(), + contentType, body, requestOptions, context)); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body 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 checkFileNameAndContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.checkFileNameAndContentTypeSync(this.client.getEndpoint(), contentType, body, requestOptions, + Context.NONE); + } + + /** + * Test content-type: multipart/form-data. + * + * @param anonymousModelRequest The anonymousModelRequest 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> anonymousModelWithResponseAsync(BinaryData anonymousModelRequest, + RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext(context -> service.anonymousModel(this.client.getEndpoint(), contentType, + anonymousModelRequest, requestOptions, context)); + } + + /** + * Test content-type: multipart/form-data. + * + * @param anonymousModelRequest The anonymousModelRequest 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 anonymousModelWithResponse(BinaryData anonymousModelRequest, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.anonymousModelSync(this.client.getEndpoint(), contentType, anonymousModelRequest, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/MultiPartClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/MultiPartClientImpl.java new file mode 100644 index 000000000..b09a3bf8d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/MultiPartClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the MultiPartClient type. + */ +public final class MultiPartClientImpl { + /** + * 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; + } + + /** + * The FormDatasImpl object to access its operations. + */ + private final FormDatasImpl formDatas; + + /** + * Gets the FormDatasImpl object to access its operations. + * + * @return the FormDatasImpl object. + */ + public FormDatasImpl getFormDatas() { + return this.formDatas; + } + + /** + * Initializes an instance of MultiPartClient client. + * + * @param endpoint Service host. + */ + public MultiPartClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of MultiPartClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public MultiPartClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of MultiPartClient 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 MultiPartClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.formDatas = new FormDatasImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/MultipartFormDataHelper.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/MultipartFormDataHelper.java new file mode 100644 index 000000000..306ae3e65 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/MultipartFormDataHelper.java @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.SequenceInputStream; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.UUID; + +// DO NOT modify this helper class + +public final class MultipartFormDataHelper { + /** + * Line separator for the multipart HTTP request. + */ + private static final String CRLF = "\r\n"; + + private static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + /** + * Value to be used as part of the divider for the multipart requests. + */ + private final String boundary; + + /** + * The actual part separator in the request. This is obtained by prepending "--" to the "boundary". + */ + private final String partSeparator; + + /** + * The marker for the ending of a multipart request. This is obtained by post-pending "--" to the "partSeparator". + */ + private final String endMarker; + + /** + * Charset used for encoding the multipart HTTP request. + */ + private final Charset encoderCharset = StandardCharsets.UTF_8; + + private InputStream requestDataStream = new ByteArrayInputStream(new byte[0]); + private long requestLength = 0; + + private RequestOptions requestOptions; + private BinaryData requestBody; + + /** + * Default constructor used in the code. The boundary is a random value. + * + * @param requestOptions the RequestOptions to update + */ + public MultipartFormDataHelper(RequestOptions requestOptions) { + this(requestOptions, UUID.randomUUID().toString().substring(0, 16)); + } + + private MultipartFormDataHelper(RequestOptions requestOptions, String boundary) { + this.requestOptions = requestOptions; + this.boundary = boundary; + this.partSeparator = "--" + boundary; + this.endMarker = this.partSeparator + "--"; + } + + /** + * Gets the multipart HTTP request body. + * + * @return the BinaryData of the multipart HTTP request body + */ + public BinaryData getRequestBody() { + return requestBody; + } + + // text/plain + /** + * Formats a text/plain field for a multipart HTTP request. + * + * @param fieldName the field name + * @param value the value of the text/plain field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeTextField(String fieldName, String value) { + if (value != null) { + String serialized = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + + "\"" + CRLF + CRLF + value + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + // application/json + /** + * Formats a application/json field for a multipart HTTP request. + * + * @param fieldName the field name + * @param jsonObject the object of the application/json field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeJsonField(String fieldName, Object jsonObject) { + if (jsonObject != null) { + String serialized + = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + CRLF + + "Content-Type: application/json" + CRLF + CRLF + BinaryData.fromObject(jsonObject) + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + /** + * Formats a file field for a multipart HTTP request. + * + * @param fieldName the field name + * @param file the BinaryData of the file + * @param contentType the content-type of the file + * @param filename the filename + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileField(String fieldName, BinaryData file, String contentType, + String filename) { + if (file != null) { + if (CoreUtils.isNullOrEmpty(contentType)) { + contentType = APPLICATION_OCTET_STREAM; + } + writeFileField(fieldName, file, contentType, filename); + } + return this; + } + + /** + * Formats a file field (potentially multiple files) for a multipart HTTP request. + * + * @param fieldName the field name + * @param files the List of BinaryData of the files + * @param contentTypes the List of content-type of the files + * @param filenames the List of filenames + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileFields(String fieldName, List files, + List contentTypes, List filenames) { + if (files != null) { + for (int i = 0; i < files.size(); ++i) { + BinaryData file = files.get(i); + String contentType = contentTypes.get(i); + if (CoreUtils.isNullOrEmpty(contentType)) { + contentType = APPLICATION_OCTET_STREAM; + } + String filename = filenames.get(i); + writeFileField(fieldName, file, contentType, filename); + } + } + return this; + } + + /** + * Ends the serialization of the multipart HTTP request. + * + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper end() { + byte[] data = endMarker.getBytes(encoderCharset); + appendBytes(data); + + requestBody = BinaryData.fromStream(requestDataStream, requestLength); + + requestOptions.setHeader(HttpHeaderName.CONTENT_TYPE, "multipart/form-data; boundary=" + this.boundary) + .setHeader(HttpHeaderName.CONTENT_LENGTH, String.valueOf(requestLength)); + + return this; + } + + private void writeFileField(String fieldName, BinaryData file, String contentType, String filename) { + String contentDispositionFilename = ""; + if (!CoreUtils.isNullOrEmpty(filename)) { + contentDispositionFilename = "; filename=\"" + escapeName(filename) + "\""; + } + + // Multipart preamble + String fileFieldPreamble + = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + + contentDispositionFilename + CRLF + "Content-Type: " + contentType + CRLF + CRLF; + byte[] data = fileFieldPreamble.getBytes(encoderCharset); + appendBytes(data); + + // Writing the file into the request as a byte stream + requestLength += file.getLength(); + requestDataStream = new SequenceInputStream(requestDataStream, file.toStream()); + + // CRLF + data = CRLF.getBytes(encoderCharset); + appendBytes(data); + } + + private void appendBytes(byte[] bytes) { + requestLength += bytes.length; + requestDataStream = new SequenceInputStream(requestDataStream, new ByteArrayInputStream(bytes)); + } + + private static String escapeName(String name) { + return name.replace("\n", "%0A").replace("\r", "%0D").replace("\"", "%22"); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/models/AnonymousModelRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/models/AnonymousModelRequest.java new file mode 100644 index 000000000..bd07b00fb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/models/AnonymousModelRequest.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.payload.multipart.models.ProfileImageFileDetails; + +/** + * The AnonymousModelRequest model. + */ +@Immutable +public final class AnonymousModelRequest { + /* + * The profileImage property. + */ + @Generated + private final ProfileImageFileDetails profileImage; + + /** + * Creates an instance of AnonymousModelRequest class. + * + * @param profileImage the profileImage value to set. + */ + @Generated + public AnonymousModelRequest(ProfileImageFileDetails profileImage) { + this.profileImage = profileImage; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Generated + public ProfileImageFileDetails getProfileImage() { + return this.profileImage; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/models/package-info.java new file mode 100644 index 000000000..c3c8f869c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/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 MultiPart. + * Test for multipart. + * + */ +package com.payload.multipart.implementation.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/implementation/package-info.java new file mode 100644 index 000000000..a368d33cd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/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 MultiPart. + * Test for multipart. + * + */ +package com.payload.multipart.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/Address.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/Address.java new file mode 100644 index 000000000..000d1cc4c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/Address.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.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; + +/** + * The Address model. + */ +@Immutable +public final class Address implements JsonSerializable
{ + /* + * The city property. + */ + @Generated + private final String city; + + /** + * Creates an instance of Address class. + * + * @param city the city value to set. + */ + @Generated + public Address(String city) { + this.city = city; + } + + /** + * Get the city property: The city property. + * + * @return the city value. + */ + @Generated + public String getCity() { + return this.city; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("city", this.city); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Address from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Address 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 Address. + */ + @Generated + public static Address fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String city = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("city".equals(fieldName)) { + city = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Address(city); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/BinaryArrayPartsRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/BinaryArrayPartsRequest.java new file mode 100644 index 000000000..e7d2b13e3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/BinaryArrayPartsRequest.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import java.util.List; + +/** + * The BinaryArrayPartsRequest model. + */ +@Immutable +public final class BinaryArrayPartsRequest { + /* + * The id property. + */ + @Generated + private final String id; + + /* + * The pictures property. + */ + @Generated + private final List pictures; + + /** + * Creates an instance of BinaryArrayPartsRequest class. + * + * @param id the id value to set. + * @param pictures the pictures value to set. + */ + @Generated + public BinaryArrayPartsRequest(String id, List pictures) { + this.id = id; + this.pictures = pictures; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the pictures property: The pictures property. + * + * @return the pictures value. + */ + @Generated + public List getPictures() { + return this.pictures; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/ComplexPartsRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/ComplexPartsRequest.java new file mode 100644 index 000000000..59e2ed120 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/ComplexPartsRequest.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import java.util.List; + +/** + * The ComplexPartsRequest model. + */ +@Immutable +public final class ComplexPartsRequest { + /* + * The id property. + */ + @Generated + private final String id; + + /* + * The address property. + */ + @Generated + private final Address address; + + /* + * The profileImage property. + */ + @Generated + private final ProfileImageFileDetails profileImage; + + /* + * The previousAddresses property. + */ + @Generated + private final List
previousAddresses; + + /* + * The pictures property. + */ + @Generated + private final List pictures; + + /** + * Creates an instance of ComplexPartsRequest class. + * + * @param id the id value to set. + * @param address the address value to set. + * @param profileImage the profileImage value to set. + * @param previousAddresses the previousAddresses value to set. + * @param pictures the pictures value to set. + */ + @Generated + public ComplexPartsRequest(String id, Address address, ProfileImageFileDetails profileImage, + List
previousAddresses, List pictures) { + this.id = id; + this.address = address; + this.profileImage = profileImage; + this.previousAddresses = previousAddresses; + this.pictures = pictures; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the address property: The address property. + * + * @return the address value. + */ + @Generated + public Address getAddress() { + return this.address; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Generated + public ProfileImageFileDetails getProfileImage() { + return this.profileImage; + } + + /** + * Get the previousAddresses property: The previousAddresses property. + * + * @return the previousAddresses value. + */ + @Generated + public List
getPreviousAddresses() { + return this.previousAddresses; + } + + /** + * Get the pictures property: The pictures property. + * + * @return the pictures value. + */ + @Generated + public List getPictures() { + return this.pictures; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/JsonArrayPartsRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/JsonArrayPartsRequest.java new file mode 100644 index 000000000..6af4fba82 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/JsonArrayPartsRequest.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import java.util.List; + +/** + * The JsonArrayPartsRequest model. + */ +@Immutable +public final class JsonArrayPartsRequest { + /* + * The profileImage property. + */ + @Generated + private final ProfileImageFileDetails profileImage; + + /* + * The previousAddresses property. + */ + @Generated + private final List
previousAddresses; + + /** + * Creates an instance of JsonArrayPartsRequest class. + * + * @param profileImage the profileImage value to set. + * @param previousAddresses the previousAddresses value to set. + */ + @Generated + public JsonArrayPartsRequest(ProfileImageFileDetails profileImage, List
previousAddresses) { + this.profileImage = profileImage; + this.previousAddresses = previousAddresses; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Generated + public ProfileImageFileDetails getProfileImage() { + return this.profileImage; + } + + /** + * Get the previousAddresses property: The previousAddresses property. + * + * @return the previousAddresses value. + */ + @Generated + public List
getPreviousAddresses() { + return this.previousAddresses; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/JsonPartRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/JsonPartRequest.java new file mode 100644 index 000000000..3315968d3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/JsonPartRequest.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; + +/** + * The JsonPartRequest model. + */ +@Immutable +public final class JsonPartRequest { + /* + * The address property. + */ + @Generated + private final Address address; + + /* + * The profileImage property. + */ + @Generated + private final ProfileImageFileDetails profileImage; + + /** + * Creates an instance of JsonPartRequest class. + * + * @param address the address value to set. + * @param profileImage the profileImage value to set. + */ + @Generated + public JsonPartRequest(Address address, ProfileImageFileDetails profileImage) { + this.address = address; + this.profileImage = profileImage; + } + + /** + * Get the address property: The address property. + * + * @return the address value. + */ + @Generated + public Address getAddress() { + return this.address; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Generated + public ProfileImageFileDetails getProfileImage() { + return this.profileImage; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/MultiBinaryPartsRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/MultiBinaryPartsRequest.java new file mode 100644 index 000000000..359358898 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/MultiBinaryPartsRequest.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; + +/** + * The MultiBinaryPartsRequest model. + */ +@Fluent +public final class MultiBinaryPartsRequest { + /* + * The profileImage property. + */ + @Generated + private final ProfileImageFileDetails profileImage; + + /* + * The picture property. + */ + @Generated + private PictureFileDetails picture; + + /** + * Creates an instance of MultiBinaryPartsRequest class. + * + * @param profileImage the profileImage value to set. + */ + @Generated + public MultiBinaryPartsRequest(ProfileImageFileDetails profileImage) { + this.profileImage = profileImage; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Generated + public ProfileImageFileDetails getProfileImage() { + return this.profileImage; + } + + /** + * Get the picture property: The picture property. + * + * @return the picture value. + */ + @Generated + public PictureFileDetails getPicture() { + return this.picture; + } + + /** + * Set the picture property: The picture property. + * + * @param picture the picture value to set. + * @return the MultiBinaryPartsRequest object itself. + */ + @Generated + public MultiBinaryPartsRequest setPicture(PictureFileDetails picture) { + this.picture = picture; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/MultiPartRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/MultiPartRequest.java new file mode 100644 index 000000000..8a3f9877f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/MultiPartRequest.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; + +/** + * The MultiPartRequest model. + */ +@Immutable +public final class MultiPartRequest { + /* + * The id property. + */ + @Generated + private final String id; + + /* + * The profileImage property. + */ + @Generated + private final ProfileImageFileDetails profileImage; + + /** + * Creates an instance of MultiPartRequest class. + * + * @param id the id value to set. + * @param profileImage the profileImage value to set. + */ + @Generated + public MultiPartRequest(String id, ProfileImageFileDetails profileImage) { + this.id = id; + this.profileImage = profileImage; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Generated + public ProfileImageFileDetails getProfileImage() { + return this.profileImage; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/PictureFileDetails.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/PictureFileDetails.java new file mode 100644 index 000000000..67d325eaf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/PictureFileDetails.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; + +/** + * The file details for the "picture" field. + */ +@Fluent +public final class PictureFileDetails { + /* + * The content of the file. + */ + @Generated + private final BinaryData content; + + /* + * The filename of the file. + */ + @Generated + private String filename; + + /* + * The content-type of the file. + */ + @Generated + private String contentType = "application/octet-stream"; + + /** + * Creates an instance of PictureFileDetails class. + * + * @param content the content value to set. + */ + @Generated + public PictureFileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the PictureFileDetails object itself. + */ + @Generated + public PictureFileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the PictureFileDetails object itself. + */ + @Generated + public PictureFileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/PicturesFileDetails.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/PicturesFileDetails.java new file mode 100644 index 000000000..c6f4ac265 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/PicturesFileDetails.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; + +/** + * The file details for the "pictures" field. + */ +@Fluent +public final class PicturesFileDetails { + /* + * The content of the file. + */ + @Generated + private final BinaryData content; + + /* + * The filename of the file. + */ + @Generated + private String filename; + + /* + * The content-type of the file. + */ + @Generated + private String contentType = "application/octet-stream"; + + /** + * Creates an instance of PicturesFileDetails class. + * + * @param content the content value to set. + */ + @Generated + public PicturesFileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the PicturesFileDetails object itself. + */ + @Generated + public PicturesFileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the PicturesFileDetails object itself. + */ + @Generated + public PicturesFileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/ProfileImageFileDetails.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/ProfileImageFileDetails.java new file mode 100644 index 000000000..f65ee80ed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/ProfileImageFileDetails.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; + +/** + * The file details for the "profileImage" field. + */ +@Fluent +public final class ProfileImageFileDetails { + /* + * The content of the file. + */ + @Generated + private final BinaryData content; + + /* + * The filename of the file. + */ + @Generated + private String filename; + + /* + * The content-type of the file. + */ + @Generated + private String contentType = "application/octet-stream"; + + /** + * Creates an instance of ProfileImageFileDetails class. + * + * @param content the content value to set. + */ + @Generated + public ProfileImageFileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the ProfileImageFileDetails object itself. + */ + @Generated + public ProfileImageFileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the ProfileImageFileDetails object itself. + */ + @Generated + public ProfileImageFileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/models/package-info.java new file mode 100644 index 000000000..a468d0a39 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/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 MultiPart. + * Test for multipart. + * + */ +package com.payload.multipart.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/package-info.java new file mode 100644 index 000000000..84e15992e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/multipart/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 MultiPart. + * Test for multipart. + * + */ +package com.payload.multipart; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/PageableAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/PageableAsyncClient.java new file mode 100644 index 000000000..1aab73bd4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/PageableAsyncClient.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.pageable; + +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.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.payload.pageable.implementation.PageableClientImpl; +import com.payload.pageable.models.User; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; + +/** + * Initializes a new instance of the asynchronous PageableClient type. + */ +@ServiceClient(builder = PageableClientBuilder.class, isAsync = true) +public final class PageableAsyncClient { + @Generated + private final PageableClientImpl serviceClient; + + /** + * Initializes an instance of PageableAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PageableAsyncClient(PageableClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List users. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list(RequestOptions requestOptions) { + return this.serviceClient.listAsync(requestOptions); + } + + /** + * List users. + * + * @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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = list(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(User.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/PageableClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/PageableClient.java new file mode 100644 index 000000000..2f81f2ef1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/PageableClient.java @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.pageable; + +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.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.payload.pageable.implementation.PageableClientImpl; +import com.payload.pageable.models.User; + +/** + * Initializes a new instance of the synchronous PageableClient type. + */ +@ServiceClient(builder = PageableClientBuilder.class) +public final class PageableClient { + @Generated + private final PageableClientImpl serviceClient; + + /** + * Initializes an instance of PageableClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PageableClient(PageableClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * List users. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + return this.serviceClient.list(requestOptions); + } + + /** + * List users. + * + * @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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + // Generated convenience method for list + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.list(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(User.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/PageableClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/PageableClientBuilder.java new file mode 100644 index 000000000..5e4da1687 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/PageableClientBuilder.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 com.payload.pageable; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.payload.pageable.implementation.PageableClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the PageableClient type. + */ +@ServiceClientBuilder(serviceClients = { PageableClient.class, PageableAsyncClient.class }) +public final class PageableClientBuilder 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("payload-pageable.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the PageableClientBuilder. + */ + @Generated + public PageableClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PageableClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PageableClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PageableClientBuilder 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 PageableClientBuilder 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 PageableClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PageableClientBuilder 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 PageableClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PageableClientBuilder 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 PageableClientBuilder. + */ + @Generated + public PageableClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of PageableClientImpl with the provided parameters. + * + * @return an instance of PageableClientImpl. + */ + @Generated + private PageableClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + PageableClientImpl client + = new PageableClientImpl(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 PageableAsyncClient class. + * + * @return an instance of PageableAsyncClient. + */ + @Generated + public PageableAsyncClient buildAsyncClient() { + return new PageableAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of PageableClient class. + * + * @return an instance of PageableClient. + */ + @Generated + public PageableClient buildClient() { + return new PageableClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(PageableClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/implementation/PageableClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/implementation/PageableClientImpl.java new file mode 100644 index 000000000..bc5106cec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/implementation/PageableClientImpl.java @@ -0,0 +1,419 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.pageable.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +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.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.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.UrlBuilder; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the PageableClient type. + */ +public final class PageableClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PageableClientService 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 PageableClient client. + * + * @param endpoint Service host. + */ + public PageableClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of PageableClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public PageableClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of PageableClient 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 PageableClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(PageableClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for PageableClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PageableClient") + public interface PageableClientService { + @Get("/payload/pageable") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> list(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/payload/pageable") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * List users. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 paged collection of User items along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.list(this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List users. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 paged collection of User items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePageAsync(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * List users. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 paged collection of User items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List users. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (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 paged collection of User items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listSinglePage(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * List users + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of User items along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List users + * + * Get the next page of items. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items. + * @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 paged collection of User items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/implementation/package-info.java new file mode 100644 index 000000000..dd1fdae3d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/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 Pageable. + * Test describing pageable. + * + */ +package com.payload.pageable.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/models/User.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/models/User.java new file mode 100644 index 000000000..ab7f1b0b8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/models/User.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.pageable.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; + +/** + * User model. + */ +@Immutable +public final class User implements JsonSerializable { + /* + * User name + */ + @Generated + private final String name; + + /** + * Creates an instance of User class. + * + * @param name the name value to set. + */ + @Generated + private User(String name) { + this.name = name; + } + + /** + * Get the name property: User name. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of User from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of User 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 User. + */ + @Generated + public static User fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new User(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/models/package-info.java new file mode 100644 index 000000000..fdfc97b06 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/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 Pageable. + * Test describing pageable. + * + */ +package com.payload.pageable.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/package-info.java new file mode 100644 index 000000000..dc43c69a9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/payload/pageable/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 Pageable. + * Test describing pageable. + * + */ +package com.payload.pageable; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/ResiliencyServiceDrivenAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/ResiliencyServiceDrivenAsyncClient.java new file mode 100644 index 000000000..1de4a5497 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/ResiliencyServiceDrivenAsyncClient.java @@ -0,0 +1,316 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.resiliency.servicedriven; + +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 com.resiliency.servicedriven.implementation.ResiliencyServiceDrivenClientImpl; +import java.util.Arrays; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ResiliencyServiceDrivenClient type. + */ +@ServiceClient(builder = ResiliencyServiceDrivenClientBuilder.class, isAsync = true) +public final class ResiliencyServiceDrivenAsyncClient { + @Generated + private final ResiliencyServiceDrivenClientImpl serviceClient; + + /** + * Initializes an instance of ResiliencyServiceDrivenAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ResiliencyServiceDrivenAsyncClient(ResiliencyServiceDrivenClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Added operation. + * + * @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> addOperationWithResponse(RequestOptions requestOptions) { + return this.serviceClient.addOperationWithResponseAsync(requestOptions); + } + + /** + * Test that grew up from accepting no parameters to an optional input parameter. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
new-parameterStringNoI'm a new input optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> fromNoneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fromNoneWithResponseAsync(requestOptions); + } + + /** + * Operation that grew up from accepting one required parameter to accepting a required parameter and an optional + * parameter. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
new-parameterStringNoI'm a new input optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param parameter I am a required 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> fromOneRequiredWithResponse(String parameter, RequestOptions requestOptions) { + return this.serviceClient.fromOneRequiredWithResponseAsync(parameter, requestOptions); + } + + /** + * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional + * parameters. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
parameterStringNoI am an optional parameter
new-parameterStringNoI'm a new input optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> fromOneOptionalWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fromOneOptionalWithResponseAsync(requestOptions); + } + + /** + * Added 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono addOperation() { + // Generated convenience method for addOperationWithResponse + RequestOptions requestOptions = new RequestOptions(); + return addOperationWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Test that grew up from accepting no parameters to an optional input parameter. + * + * @param newParameter I'm a new input optional 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 fromNone(String newParameter) { + // Generated convenience method for fromNoneWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (!Arrays.asList("v2").contains(serviceClient.getServiceVersion().getVersion())) { + return Mono + .error(new IllegalArgumentException("Parameter newParameter is only available in api-version v2.")); + } + if (newParameter != null) { + requestOptions.addQueryParam("new-parameter", newParameter, false); + } + return fromNoneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Test that grew up from accepting no parameters to an optional input parameter. + * + * @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 fromNone() { + // Generated convenience method for fromNoneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return fromNoneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Operation that grew up from accepting one required parameter to accepting a required parameter and an optional + * parameter. + * + * @param parameter I am a required parameter. + * @param newParameter I'm a new input optional 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 fromOneRequired(String parameter, String newParameter) { + // Generated convenience method for fromOneRequiredWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (!Arrays.asList("v2").contains(serviceClient.getServiceVersion().getVersion())) { + return Mono + .error(new IllegalArgumentException("Parameter newParameter is only available in api-version v2.")); + } + if (newParameter != null) { + requestOptions.addQueryParam("new-parameter", newParameter, false); + } + return fromOneRequiredWithResponse(parameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Operation that grew up from accepting one required parameter to accepting a required parameter and an optional + * parameter. + * + * @param parameter I am a required 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 fromOneRequired(String parameter) { + // Generated convenience method for fromOneRequiredWithResponse + RequestOptions requestOptions = new RequestOptions(); + return fromOneRequiredWithResponse(parameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional + * parameters. + * + * @param parameter I am an optional parameter. + * @param newParameter I'm a new input optional 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 fromOneOptional(String parameter, String newParameter) { + // Generated convenience method for fromOneOptionalWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (!Arrays.asList("v2").contains(serviceClient.getServiceVersion().getVersion())) { + return Mono + .error(new IllegalArgumentException("Parameter newParameter is only available in api-version v2.")); + } + if (parameter != null) { + requestOptions.addQueryParam("parameter", parameter, false); + } + if (newParameter != null) { + requestOptions.addQueryParam("new-parameter", newParameter, false); + } + return fromOneOptionalWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional + * parameters. + * + * @param parameter I am an optional 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 fromOneOptional(String parameter) { + // Generated convenience method for fromOneOptionalWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (parameter != null) { + requestOptions.addQueryParam("parameter", parameter, false); + } + return fromOneOptionalWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional + * parameters. + * + * @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 fromOneOptional() { + // Generated convenience method for fromOneOptionalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return fromOneOptionalWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/ResiliencyServiceDrivenClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/ResiliencyServiceDrivenClient.java new file mode 100644 index 000000000..91835d22f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/ResiliencyServiceDrivenClient.java @@ -0,0 +1,309 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.resiliency.servicedriven; + +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.logging.ClientLogger; +import com.resiliency.servicedriven.implementation.ResiliencyServiceDrivenClientImpl; +import java.util.Arrays; + +/** + * Initializes a new instance of the synchronous ResiliencyServiceDrivenClient type. + */ +@ServiceClient(builder = ResiliencyServiceDrivenClientBuilder.class) +public final class ResiliencyServiceDrivenClient { + @Generated + private final ResiliencyServiceDrivenClientImpl serviceClient; + + /** + * Initializes an instance of ResiliencyServiceDrivenClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Added operation. + * + * @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 addOperationWithResponse(RequestOptions requestOptions) { + return this.serviceClient.addOperationWithResponse(requestOptions); + } + + /** + * Test that grew up from accepting no parameters to an optional input parameter. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
new-parameterStringNoI'm a new input optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 fromNoneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fromNoneWithResponse(requestOptions); + } + + /** + * Operation that grew up from accepting one required parameter to accepting a required parameter and an optional + * parameter. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
new-parameterStringNoI'm a new input optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param parameter I am a required 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 fromOneRequiredWithResponse(String parameter, RequestOptions requestOptions) { + return this.serviceClient.fromOneRequiredWithResponse(parameter, requestOptions); + } + + /** + * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional + * parameters. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
parameterStringNoI am an optional parameter
new-parameterStringNoI'm a new input optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 fromOneOptionalWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fromOneOptionalWithResponse(requestOptions); + } + + /** + * Added 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void addOperation() { + // Generated convenience method for addOperationWithResponse + RequestOptions requestOptions = new RequestOptions(); + addOperationWithResponse(requestOptions).getValue(); + } + + /** + * Test that grew up from accepting no parameters to an optional input parameter. + * + * @param newParameter I'm a new input optional 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 fromNone(String newParameter) { + // Generated convenience method for fromNoneWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (!Arrays.asList("v2").contains(serviceClient.getServiceVersion().getVersion())) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter newParameter is only available in api-version v2.")); + } + if (newParameter != null) { + requestOptions.addQueryParam("new-parameter", newParameter, false); + } + fromNoneWithResponse(requestOptions).getValue(); + } + + /** + * Test that grew up from accepting no parameters to an optional input parameter. + * + * @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 fromNone() { + // Generated convenience method for fromNoneWithResponse + RequestOptions requestOptions = new RequestOptions(); + fromNoneWithResponse(requestOptions).getValue(); + } + + /** + * Operation that grew up from accepting one required parameter to accepting a required parameter and an optional + * parameter. + * + * @param parameter I am a required parameter. + * @param newParameter I'm a new input optional 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 fromOneRequired(String parameter, String newParameter) { + // Generated convenience method for fromOneRequiredWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (!Arrays.asList("v2").contains(serviceClient.getServiceVersion().getVersion())) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter newParameter is only available in api-version v2.")); + } + if (newParameter != null) { + requestOptions.addQueryParam("new-parameter", newParameter, false); + } + fromOneRequiredWithResponse(parameter, requestOptions).getValue(); + } + + /** + * Operation that grew up from accepting one required parameter to accepting a required parameter and an optional + * parameter. + * + * @param parameter I am a required 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 fromOneRequired(String parameter) { + // Generated convenience method for fromOneRequiredWithResponse + RequestOptions requestOptions = new RequestOptions(); + fromOneRequiredWithResponse(parameter, requestOptions).getValue(); + } + + /** + * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional + * parameters. + * + * @param parameter I am an optional parameter. + * @param newParameter I'm a new input optional 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 fromOneOptional(String parameter, String newParameter) { + // Generated convenience method for fromOneOptionalWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (!Arrays.asList("v2").contains(serviceClient.getServiceVersion().getVersion())) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Parameter newParameter is only available in api-version v2.")); + } + if (parameter != null) { + requestOptions.addQueryParam("parameter", parameter, false); + } + if (newParameter != null) { + requestOptions.addQueryParam("new-parameter", newParameter, false); + } + fromOneOptionalWithResponse(requestOptions).getValue(); + } + + /** + * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional + * parameters. + * + * @param parameter I am an optional 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 fromOneOptional(String parameter) { + // Generated convenience method for fromOneOptionalWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (parameter != null) { + requestOptions.addQueryParam("parameter", parameter, false); + } + fromOneOptionalWithResponse(requestOptions).getValue(); + } + + /** + * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional + * parameters. + * + * @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 fromOneOptional() { + // Generated convenience method for fromOneOptionalWithResponse + RequestOptions requestOptions = new RequestOptions(); + fromOneOptionalWithResponse(requestOptions).getValue(); + } + + private static final ClientLogger LOGGER = new ClientLogger(ResiliencyServiceDrivenClient.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/ResiliencyServiceDrivenClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/ResiliencyServiceDrivenClientBuilder.java new file mode 100644 index 000000000..e56acf864 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/ResiliencyServiceDrivenClientBuilder.java @@ -0,0 +1,333 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.resiliency.servicedriven; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.resiliency.servicedriven.implementation.ResiliencyServiceDrivenClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ResiliencyServiceDrivenClient type. + */ +@ServiceClientBuilder( + serviceClients = { ResiliencyServiceDrivenClient.class, ResiliencyServiceDrivenAsyncClient.class }) +public final class ResiliencyServiceDrivenClientBuilder 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("resiliency-servicedriven.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ResiliencyServiceDrivenClientBuilder. + */ + @Generated + public ResiliencyServiceDrivenClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResiliencyServiceDrivenClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResiliencyServiceDrivenClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResiliencyServiceDrivenClientBuilder 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 ResiliencyServiceDrivenClientBuilder 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 ResiliencyServiceDrivenClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResiliencyServiceDrivenClientBuilder 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 ResiliencyServiceDrivenClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResiliencyServiceDrivenClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Pass in either 'v1' or 'v2'. This represents a version of the service deployment in history. 'v1' is for the + * deployment when the service had only one api version. 'v2' is for the deployment when the service had + * api-versions 'v1' and 'v2'. + */ + @Generated + private String serviceDeploymentVersion; + + /** + * Sets Pass in either 'v1' or 'v2'. This represents a version of the service deployment in history. 'v1' is for the + * deployment when the service had only one api version. 'v2' is for the deployment when the service had + * api-versions 'v1' and 'v2'. + * + * @param serviceDeploymentVersion the serviceDeploymentVersion value. + * @return the ResiliencyServiceDrivenClientBuilder. + */ + @Generated + public ResiliencyServiceDrivenClientBuilder serviceDeploymentVersion(String serviceDeploymentVersion) { + this.serviceDeploymentVersion = serviceDeploymentVersion; + return this; + } + + /* + * Service version + */ + @Generated + private ServiceDrivenServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the ResiliencyServiceDrivenClientBuilder. + */ + @Generated + public ResiliencyServiceDrivenClientBuilder serviceVersion(ServiceDrivenServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 ResiliencyServiceDrivenClientBuilder. + */ + @Generated + public ResiliencyServiceDrivenClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ResiliencyServiceDrivenClientImpl with the provided parameters. + * + * @return an instance of ResiliencyServiceDrivenClientImpl. + */ + @Generated + private ResiliencyServiceDrivenClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ServiceDrivenServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ServiceDrivenServiceVersion.getLatest(); + ResiliencyServiceDrivenClientImpl client + = new ResiliencyServiceDrivenClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, this.serviceDeploymentVersion, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(serviceDeploymentVersion, "'serviceDeploymentVersion' cannot be null."); + } + + @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 ResiliencyServiceDrivenAsyncClient class. + * + * @return an instance of ResiliencyServiceDrivenAsyncClient. + */ + @Generated + public ResiliencyServiceDrivenAsyncClient buildAsyncClient() { + return new ResiliencyServiceDrivenAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ResiliencyServiceDrivenClient class. + * + * @return an instance of ResiliencyServiceDrivenClient. + */ + @Generated + public ResiliencyServiceDrivenClient buildClient() { + return new ResiliencyServiceDrivenClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ResiliencyServiceDrivenClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/ServiceDrivenServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/ServiceDrivenServiceVersion.java new file mode 100644 index 000000000..d4138fd48 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/ServiceDrivenServiceVersion.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.resiliency.servicedriven; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of ServiceDrivenClient. + */ +public enum ServiceDrivenServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + ServiceDrivenServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link ServiceDrivenServiceVersion}. + */ + public static ServiceDrivenServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/implementation/ResiliencyServiceDrivenClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/implementation/ResiliencyServiceDrivenClientImpl.java new file mode 100644 index 000000000..a5f1b3eb2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/implementation/ResiliencyServiceDrivenClientImpl.java @@ -0,0 +1,440 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.resiliency.servicedriven.implementation; + +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.Head; +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.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.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.resiliency.servicedriven.ServiceDrivenServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the ResiliencyServiceDrivenClient type. + */ +public final class ResiliencyServiceDrivenClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ResiliencyServiceDrivenClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Pass in either 'v1' or 'v2'. This represents a version of the service deployment in history. 'v1' is for the + * deployment when the service had only one api version. 'v2' is for the deployment when the service had + * api-versions 'v1' and 'v2'. + */ + private final String serviceDeploymentVersion; + + /** + * Gets Pass in either 'v1' or 'v2'. This represents a version of the service deployment in history. 'v1' is for the + * deployment when the service had only one api version. 'v2' is for the deployment when the service had + * api-versions 'v1' and 'v2'. + * + * @return the serviceDeploymentVersion value. + */ + public String getServiceDeploymentVersion() { + return this.serviceDeploymentVersion; + } + + /** + * Service version. + */ + private final ServiceDrivenServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ServiceDrivenServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 ResiliencyServiceDrivenClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param serviceDeploymentVersion Pass in either 'v1' or 'v2'. This represents a version of the service deployment + * in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when + * the service had api-versions 'v1' and 'v2'. + * @param serviceVersion Service version. + */ + public ResiliencyServiceDrivenClientImpl(String endpoint, String serviceDeploymentVersion, + ServiceDrivenServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceDeploymentVersion, serviceVersion); + } + + /** + * Initializes an instance of ResiliencyServiceDrivenClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param serviceDeploymentVersion Pass in either 'v1' or 'v2'. This represents a version of the service deployment + * in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when + * the service had api-versions 'v1' and 'v2'. + * @param serviceVersion Service version. + */ + public ResiliencyServiceDrivenClientImpl(HttpPipeline httpPipeline, String endpoint, + String serviceDeploymentVersion, ServiceDrivenServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceDeploymentVersion, + serviceVersion); + } + + /** + * Initializes an instance of ResiliencyServiceDrivenClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param serviceDeploymentVersion Pass in either 'v1' or 'v2'. This represents a version of the service deployment + * in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when + * the service had api-versions 'v1' and 'v2'. + * @param serviceVersion Service version. + */ + public ResiliencyServiceDrivenClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String serviceDeploymentVersion, ServiceDrivenServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceDeploymentVersion = serviceDeploymentVersion; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(ResiliencyServiceDrivenClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for ResiliencyServiceDrivenClient to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}/resiliency/service-driven/client:v2/service:{serviceDeploymentVersion}/api-version:{apiVersion}") + @ServiceInterface(name = "ResiliencyServiceDri") + public interface ResiliencyServiceDrivenClientService { + @Delete("/add-operation") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> addOperation(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Delete("/add-operation") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response addOperationSync(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Head("/add-optional-param/from-none") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> fromNone(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Head("/add-optional-param/from-none") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response fromNoneSync(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Get("/add-optional-param/from-one-required") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> fromOneRequired(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, @QueryParam("parameter") String parameter, + RequestOptions requestOptions, Context context); + + @Get("/add-optional-param/from-one-required") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response fromOneRequiredSync(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, @QueryParam("parameter") String parameter, + RequestOptions requestOptions, Context context); + + @Get("/add-optional-param/from-one-optional") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> fromOneOptional(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Get("/add-optional-param/from-one-optional") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response fromOneOptionalSync(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + } + + /** + * Added operation. + * + * @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> addOperationWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.addOperation(this.getEndpoint(), + this.getServiceDeploymentVersion(), this.getServiceVersion().getVersion(), requestOptions, context)); + } + + /** + * Added operation. + * + * @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 addOperationWithResponse(RequestOptions requestOptions) { + return service.addOperationSync(this.getEndpoint(), this.getServiceDeploymentVersion(), + this.getServiceVersion().getVersion(), requestOptions, Context.NONE); + } + + /** + * Test that grew up from accepting no parameters to an optional input parameter. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
new-parameterStringNoI'm a new input optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> fromNoneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.fromNone(this.getEndpoint(), this.getServiceDeploymentVersion(), + this.getServiceVersion().getVersion(), requestOptions, context)); + } + + /** + * Test that grew up from accepting no parameters to an optional input parameter. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
new-parameterStringNoI'm a new input optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 fromNoneWithResponse(RequestOptions requestOptions) { + return service.fromNoneSync(this.getEndpoint(), this.getServiceDeploymentVersion(), + this.getServiceVersion().getVersion(), requestOptions, Context.NONE); + } + + /** + * Operation that grew up from accepting one required parameter to accepting a required parameter and an optional + * parameter. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
new-parameterStringNoI'm a new input optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param parameter I am a required 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> fromOneRequiredWithResponseAsync(String parameter, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.fromOneRequired(this.getEndpoint(), this.getServiceDeploymentVersion(), + this.getServiceVersion().getVersion(), parameter, requestOptions, context)); + } + + /** + * Operation that grew up from accepting one required parameter to accepting a required parameter and an optional + * parameter. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
new-parameterStringNoI'm a new input optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param parameter I am a required 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 fromOneRequiredWithResponse(String parameter, RequestOptions requestOptions) { + return service.fromOneRequiredSync(this.getEndpoint(), this.getServiceDeploymentVersion(), + this.getServiceVersion().getVersion(), parameter, requestOptions, Context.NONE); + } + + /** + * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional + * parameters. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
parameterStringNoI am an optional parameter
new-parameterStringNoI'm a new input optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> fromOneOptionalWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.fromOneOptional(this.getEndpoint(), + this.getServiceDeploymentVersion(), this.getServiceVersion().getVersion(), requestOptions, context)); + } + + /** + * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional + * parameters. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
parameterStringNoI am an optional parameter
new-parameterStringNoI'm a new input optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 fromOneOptionalWithResponse(RequestOptions requestOptions) { + return service.fromOneOptionalSync(this.getEndpoint(), this.getServiceDeploymentVersion(), + this.getServiceVersion().getVersion(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/implementation/package-info.java new file mode 100644 index 000000000..a82e99a72 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/implementation/package-info.java @@ -0,0 +1,24 @@ +// 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 ServiceDriven. + * Test that we can grow up a service spec and service deployment into a multi-versioned service with full client + * support. + * + * There are three concepts that should be clarified: + * 1. Client spec version: refers to the spec that the client is generated from. 'v1' is a client generated from old.tsp + * and 'v2' is a client generated from main.tsp. + * 2. Service deployment version: refers to a deployment version of the service. 'v1' represents the initial deployment + * of the service with a single api version. 'v2' represents the new deployment of a service with multiple api versions + * 3. Api version: The initial deployment of the service only supports api version 'v1'. The new deployment of the + * service supports api versions 'v1' and 'v2'. + * + * We test the following configurations from this service spec: + * - A client generated from the second service spec can call the second deployment of a service with api version v1 + * - A client generated from the second service spec can call the second deployment of a service with api version v2. + * + */ +package com.resiliency.servicedriven.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/package-info.java new file mode 100644 index 000000000..ffec9e8ea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/package-info.java @@ -0,0 +1,24 @@ +// 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 ServiceDriven. + * Test that we can grow up a service spec and service deployment into a multi-versioned service with full client + * support. + * + * There are three concepts that should be clarified: + * 1. Client spec version: refers to the spec that the client is generated from. 'v1' is a client generated from old.tsp + * and 'v2' is a client generated from main.tsp. + * 2. Service deployment version: refers to a deployment version of the service. 'v1' represents the initial deployment + * of the service with a single api version. 'v2' represents the new deployment of a service with multiple api versions + * 3. Api version: The initial deployment of the service only supports api version 'v1'. The new deployment of the + * service supports api versions 'v1' and 'v2'. + * + * We test the following configurations from this service spec: + * - A client generated from the second service spec can call the second deployment of a service with api version v1 + * - A client generated from the second service spec can call the second deployment of a service with api version v2. + * + */ +package com.resiliency.servicedriven; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/ResiliencyServiceDrivenAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/ResiliencyServiceDrivenAsyncClient.java new file mode 100644 index 000000000..43fa06b14 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/ResiliencyServiceDrivenAsyncClient.java @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.resiliency.servicedriven.v1; + +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 com.resiliency.servicedriven.v1.implementation.ResiliencyServiceDrivenClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ResiliencyServiceDrivenClient type. + */ +@ServiceClient(builder = ResiliencyServiceDrivenClientBuilder.class, isAsync = true) +public final class ResiliencyServiceDrivenAsyncClient { + @Generated + private final ResiliencyServiceDrivenClientImpl serviceClient; + + /** + * Initializes an instance of ResiliencyServiceDrivenAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ResiliencyServiceDrivenAsyncClient(ResiliencyServiceDrivenClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Test that currently accepts no parameters, will be updated in next spec to accept a new optional parameter as + * well. + * + * @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> fromNoneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fromNoneWithResponseAsync(requestOptions); + } + + /** + * Test that currently accepts one required parameter, will be updated in next spec to accept a new optional + * parameter as well. + * + * @param parameter I am a required 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> fromOneRequiredWithResponse(String parameter, RequestOptions requestOptions) { + return this.serviceClient.fromOneRequiredWithResponseAsync(parameter, requestOptions); + } + + /** + * Test that currently accepts one optional parameter, will be updated in next spec to accept a new optional + * parameter as well. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
parameterStringNoI am an optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> fromOneOptionalWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fromOneOptionalWithResponseAsync(requestOptions); + } + + /** + * Test that currently accepts no parameters, will be updated in next spec to accept a new optional parameter as + * well. + * + * @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 fromNone() { + // Generated convenience method for fromNoneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return fromNoneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Test that currently accepts one required parameter, will be updated in next spec to accept a new optional + * parameter as well. + * + * @param parameter I am a required 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 fromOneRequired(String parameter) { + // Generated convenience method for fromOneRequiredWithResponse + RequestOptions requestOptions = new RequestOptions(); + return fromOneRequiredWithResponse(parameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Test that currently accepts one optional parameter, will be updated in next spec to accept a new optional + * parameter as well. + * + * @param parameter I am an optional 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 fromOneOptional(String parameter) { + // Generated convenience method for fromOneOptionalWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (parameter != null) { + requestOptions.addQueryParam("parameter", parameter, false); + } + return fromOneOptionalWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Test that currently accepts one optional parameter, will be updated in next spec to accept a new optional + * parameter as well. + * + * @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 fromOneOptional() { + // Generated convenience method for fromOneOptionalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return fromOneOptionalWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/ResiliencyServiceDrivenClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/ResiliencyServiceDrivenClient.java new file mode 100644 index 000000000..4a0ec6480 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/ResiliencyServiceDrivenClient.java @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.resiliency.servicedriven.v1; + +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.resiliency.servicedriven.v1.implementation.ResiliencyServiceDrivenClientImpl; + +/** + * Initializes a new instance of the synchronous ResiliencyServiceDrivenClient type. + */ +@ServiceClient(builder = ResiliencyServiceDrivenClientBuilder.class) +public final class ResiliencyServiceDrivenClient { + @Generated + private final ResiliencyServiceDrivenClientImpl serviceClient; + + /** + * Initializes an instance of ResiliencyServiceDrivenClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Test that currently accepts no parameters, will be updated in next spec to accept a new optional parameter as + * well. + * + * @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 fromNoneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fromNoneWithResponse(requestOptions); + } + + /** + * Test that currently accepts one required parameter, will be updated in next spec to accept a new optional + * parameter as well. + * + * @param parameter I am a required 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 fromOneRequiredWithResponse(String parameter, RequestOptions requestOptions) { + return this.serviceClient.fromOneRequiredWithResponse(parameter, requestOptions); + } + + /** + * Test that currently accepts one optional parameter, will be updated in next spec to accept a new optional + * parameter as well. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
parameterStringNoI am an optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 fromOneOptionalWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fromOneOptionalWithResponse(requestOptions); + } + + /** + * Test that currently accepts no parameters, will be updated in next spec to accept a new optional parameter as + * well. + * + * @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 fromNone() { + // Generated convenience method for fromNoneWithResponse + RequestOptions requestOptions = new RequestOptions(); + fromNoneWithResponse(requestOptions).getValue(); + } + + /** + * Test that currently accepts one required parameter, will be updated in next spec to accept a new optional + * parameter as well. + * + * @param parameter I am a required 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 fromOneRequired(String parameter) { + // Generated convenience method for fromOneRequiredWithResponse + RequestOptions requestOptions = new RequestOptions(); + fromOneRequiredWithResponse(parameter, requestOptions).getValue(); + } + + /** + * Test that currently accepts one optional parameter, will be updated in next spec to accept a new optional + * parameter as well. + * + * @param parameter I am an optional 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 fromOneOptional(String parameter) { + // Generated convenience method for fromOneOptionalWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (parameter != null) { + requestOptions.addQueryParam("parameter", parameter, false); + } + fromOneOptionalWithResponse(requestOptions).getValue(); + } + + /** + * Test that currently accepts one optional parameter, will be updated in next spec to accept a new optional + * parameter as well. + * + * @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 fromOneOptional() { + // Generated convenience method for fromOneOptionalWithResponse + RequestOptions requestOptions = new RequestOptions(); + fromOneOptionalWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/ResiliencyServiceDrivenClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/ResiliencyServiceDrivenClientBuilder.java new file mode 100644 index 000000000..4b851ce32 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/ResiliencyServiceDrivenClientBuilder.java @@ -0,0 +1,333 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.resiliency.servicedriven.v1; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.resiliency.servicedriven.v1.implementation.ResiliencyServiceDrivenClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ResiliencyServiceDrivenClient type. + */ +@ServiceClientBuilder( + serviceClients = { ResiliencyServiceDrivenClient.class, ResiliencyServiceDrivenAsyncClient.class }) +public final class ResiliencyServiceDrivenClientBuilder 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("resiliency-servicedriven-v1.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ResiliencyServiceDrivenClientBuilder. + */ + @Generated + public ResiliencyServiceDrivenClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResiliencyServiceDrivenClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResiliencyServiceDrivenClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResiliencyServiceDrivenClientBuilder 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 ResiliencyServiceDrivenClientBuilder 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 ResiliencyServiceDrivenClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResiliencyServiceDrivenClientBuilder 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 ResiliencyServiceDrivenClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ResiliencyServiceDrivenClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Pass in either 'v1' or 'v2'. This represents a version of the service deployment in history. 'v1' is for the + * deployment when the service had only one api version. 'v2' is for the deployment when the service had + * api-versions 'v1' and 'v2'. + */ + @Generated + private String serviceDeploymentVersion; + + /** + * Sets Pass in either 'v1' or 'v2'. This represents a version of the service deployment in history. 'v1' is for the + * deployment when the service had only one api version. 'v2' is for the deployment when the service had + * api-versions 'v1' and 'v2'. + * + * @param serviceDeploymentVersion the serviceDeploymentVersion value. + * @return the ResiliencyServiceDrivenClientBuilder. + */ + @Generated + public ResiliencyServiceDrivenClientBuilder serviceDeploymentVersion(String serviceDeploymentVersion) { + this.serviceDeploymentVersion = serviceDeploymentVersion; + return this; + } + + /* + * Service version + */ + @Generated + private ServiceDrivenServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the ResiliencyServiceDrivenClientBuilder. + */ + @Generated + public ResiliencyServiceDrivenClientBuilder serviceVersion(ServiceDrivenServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 ResiliencyServiceDrivenClientBuilder. + */ + @Generated + public ResiliencyServiceDrivenClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ResiliencyServiceDrivenClientImpl with the provided parameters. + * + * @return an instance of ResiliencyServiceDrivenClientImpl. + */ + @Generated + private ResiliencyServiceDrivenClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ServiceDrivenServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ServiceDrivenServiceVersion.getLatest(); + ResiliencyServiceDrivenClientImpl client + = new ResiliencyServiceDrivenClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, this.serviceDeploymentVersion, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(serviceDeploymentVersion, "'serviceDeploymentVersion' cannot be null."); + } + + @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 ResiliencyServiceDrivenAsyncClient class. + * + * @return an instance of ResiliencyServiceDrivenAsyncClient. + */ + @Generated + public ResiliencyServiceDrivenAsyncClient buildAsyncClient() { + return new ResiliencyServiceDrivenAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ResiliencyServiceDrivenClient class. + * + * @return an instance of ResiliencyServiceDrivenClient. + */ + @Generated + public ResiliencyServiceDrivenClient buildClient() { + return new ResiliencyServiceDrivenClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ResiliencyServiceDrivenClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/ServiceDrivenServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/ServiceDrivenServiceVersion.java new file mode 100644 index 000000000..78155a8dd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/ServiceDrivenServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.resiliency.servicedriven.v1; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of ServiceDrivenClient. + */ +public enum ServiceDrivenServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"); + + private final String version; + + ServiceDrivenServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link ServiceDrivenServiceVersion}. + */ + public static ServiceDrivenServiceVersion getLatest() { + return V1; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/implementation/ResiliencyServiceDrivenClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/implementation/ResiliencyServiceDrivenClientImpl.java new file mode 100644 index 000000000..e72894c31 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/implementation/ResiliencyServiceDrivenClientImpl.java @@ -0,0 +1,359 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.resiliency.servicedriven.v1.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.Head; +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.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.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.resiliency.servicedriven.v1.ServiceDrivenServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the ResiliencyServiceDrivenClient type. + */ +public final class ResiliencyServiceDrivenClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ResiliencyServiceDrivenClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Pass in either 'v1' or 'v2'. This represents a version of the service deployment in history. 'v1' is for the + * deployment when the service had only one api version. 'v2' is for the deployment when the service had + * api-versions 'v1' and 'v2'. + */ + private final String serviceDeploymentVersion; + + /** + * Gets Pass in either 'v1' or 'v2'. This represents a version of the service deployment in history. 'v1' is for the + * deployment when the service had only one api version. 'v2' is for the deployment when the service had + * api-versions 'v1' and 'v2'. + * + * @return the serviceDeploymentVersion value. + */ + public String getServiceDeploymentVersion() { + return this.serviceDeploymentVersion; + } + + /** + * Service version. + */ + private final ServiceDrivenServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ServiceDrivenServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 ResiliencyServiceDrivenClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param serviceDeploymentVersion Pass in either 'v1' or 'v2'. This represents a version of the service deployment + * in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when + * the service had api-versions 'v1' and 'v2'. + * @param serviceVersion Service version. + */ + public ResiliencyServiceDrivenClientImpl(String endpoint, String serviceDeploymentVersion, + ServiceDrivenServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceDeploymentVersion, serviceVersion); + } + + /** + * Initializes an instance of ResiliencyServiceDrivenClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param serviceDeploymentVersion Pass in either 'v1' or 'v2'. This represents a version of the service deployment + * in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when + * the service had api-versions 'v1' and 'v2'. + * @param serviceVersion Service version. + */ + public ResiliencyServiceDrivenClientImpl(HttpPipeline httpPipeline, String endpoint, + String serviceDeploymentVersion, ServiceDrivenServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceDeploymentVersion, + serviceVersion); + } + + /** + * Initializes an instance of ResiliencyServiceDrivenClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param serviceDeploymentVersion Pass in either 'v1' or 'v2'. This represents a version of the service deployment + * in history. 'v1' is for the deployment when the service had only one api version. 'v2' is for the deployment when + * the service had api-versions 'v1' and 'v2'. + * @param serviceVersion Service version. + */ + public ResiliencyServiceDrivenClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String serviceDeploymentVersion, ServiceDrivenServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceDeploymentVersion = serviceDeploymentVersion; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(ResiliencyServiceDrivenClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for ResiliencyServiceDrivenClient to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}/resiliency/service-driven/client:v1/service:{serviceDeploymentVersion}/api-version:{apiVersion}") + @ServiceInterface(name = "ResiliencyServiceDri") + public interface ResiliencyServiceDrivenClientService { + @Head("/add-optional-param/from-none") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> fromNone(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Head("/add-optional-param/from-none") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response fromNoneSync(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Get("/add-optional-param/from-one-required") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> fromOneRequired(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, @QueryParam("parameter") String parameter, + RequestOptions requestOptions, Context context); + + @Get("/add-optional-param/from-one-required") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response fromOneRequiredSync(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, @QueryParam("parameter") String parameter, + RequestOptions requestOptions, Context context); + + @Get("/add-optional-param/from-one-optional") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> fromOneOptional(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Get("/add-optional-param/from-one-optional") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response fromOneOptionalSync(@HostParam("endpoint") String endpoint, + @HostParam("serviceDeploymentVersion") String serviceDeploymentVersion, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + } + + /** + * Test that currently accepts no parameters, will be updated in next spec to accept a new optional parameter as + * well. + * + * @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> fromNoneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.fromNone(this.getEndpoint(), this.getServiceDeploymentVersion(), + this.getServiceVersion().getVersion(), requestOptions, context)); + } + + /** + * Test that currently accepts no parameters, will be updated in next spec to accept a new optional parameter as + * well. + * + * @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 fromNoneWithResponse(RequestOptions requestOptions) { + return service.fromNoneSync(this.getEndpoint(), this.getServiceDeploymentVersion(), + this.getServiceVersion().getVersion(), requestOptions, Context.NONE); + } + + /** + * Test that currently accepts one required parameter, will be updated in next spec to accept a new optional + * parameter as well. + * + * @param parameter I am a required 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> fromOneRequiredWithResponseAsync(String parameter, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.fromOneRequired(this.getEndpoint(), this.getServiceDeploymentVersion(), + this.getServiceVersion().getVersion(), parameter, requestOptions, context)); + } + + /** + * Test that currently accepts one required parameter, will be updated in next spec to accept a new optional + * parameter as well. + * + * @param parameter I am a required 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 fromOneRequiredWithResponse(String parameter, RequestOptions requestOptions) { + return service.fromOneRequiredSync(this.getEndpoint(), this.getServiceDeploymentVersion(), + this.getServiceVersion().getVersion(), parameter, requestOptions, Context.NONE); + } + + /** + * Test that currently accepts one optional parameter, will be updated in next spec to accept a new optional + * parameter as well. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
parameterStringNoI am an optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> fromOneOptionalWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.fromOneOptional(this.getEndpoint(), + this.getServiceDeploymentVersion(), this.getServiceVersion().getVersion(), requestOptions, context)); + } + + /** + * Test that currently accepts one optional parameter, will be updated in next spec to accept a new optional + * parameter as well. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
parameterStringNoI am an optional parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 fromOneOptionalWithResponse(RequestOptions requestOptions) { + return service.fromOneOptionalSync(this.getEndpoint(), this.getServiceDeploymentVersion(), + this.getServiceVersion().getVersion(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/implementation/package-info.java new file mode 100644 index 000000000..233d8e16c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/implementation/package-info.java @@ -0,0 +1,12 @@ +// 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 ServiceDriven. + * Test that we can grow up a service spec and service deployment into a multi-versioned service with full client + * support. + * + */ +package com.resiliency.servicedriven.v1.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/package-info.java new file mode 100644 index 000000000..1eb084ffa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/resiliency/servicedriven/v1/package-info.java @@ -0,0 +1,12 @@ +// 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 ServiceDriven. + * Test that we can grow up a service spec and service deployment into a multi-versioned service with full client + * support. + * + */ +package com.resiliency.servicedriven.v1; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/JsonAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/JsonAsyncClient.java new file mode 100644 index 000000000..c94c99c9d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/JsonAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.serialization.encodedname.json; + +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 com.serialization.encodedname.json.implementation.PropertiesImpl; +import com.serialization.encodedname.json.models.JsonEncodedNameModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous JsonClient type. + */ +@ServiceClient(builder = JsonClientBuilder.class, isAsync = true) +public final class JsonAsyncClient { + @Generated + private final PropertiesImpl serviceClient; + + /** + * Initializes an instance of JsonAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + JsonAsyncClient(PropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     wireName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> sendWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(body, requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     wireName: boolean (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The send operation. + * + * @param body The body 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 send(JsonEncodedNameModel body) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + return sendWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(JsonEncodedNameModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/JsonClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/JsonClient.java new file mode 100644 index 000000000..5a77458d3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/JsonClient.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 com.serialization.encodedname.json; + +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.serialization.encodedname.json.implementation.PropertiesImpl; +import com.serialization.encodedname.json.models.JsonEncodedNameModel; + +/** + * Initializes a new instance of the synchronous JsonClient type. + */ +@ServiceClient(builder = JsonClientBuilder.class) +public final class JsonClient { + @Generated + private final PropertiesImpl serviceClient; + + /** + * Initializes an instance of JsonClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + JsonClient(PropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     wireName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 sendWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(body, requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     wireName: boolean (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + * + * @param body The body 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 send(JsonEncodedNameModel body) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + sendWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public JsonEncodedNameModel get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(JsonEncodedNameModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/JsonClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/JsonClientBuilder.java new file mode 100644 index 000000000..6ff994329 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/JsonClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.serialization.encodedname.json; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.serialization.encodedname.json.implementation.JsonClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the JsonClient type. + */ +@ServiceClientBuilder(serviceClients = { JsonClient.class, JsonAsyncClient.class }) +public final class JsonClientBuilder + 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("serialization-encodedname-json.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the JsonClientBuilder. + */ + @Generated + public JsonClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public JsonClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public JsonClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public JsonClientBuilder 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 JsonClientBuilder 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 JsonClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public JsonClientBuilder 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 JsonClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public JsonClientBuilder 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 JsonClientBuilder. + */ + @Generated + public JsonClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of JsonClientImpl with the provided parameters. + * + * @return an instance of JsonClientImpl. + */ + @Generated + private JsonClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + JsonClientImpl client + = new JsonClientImpl(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 JsonAsyncClient class. + * + * @return an instance of JsonAsyncClient. + */ + @Generated + public JsonAsyncClient buildAsyncClient() { + return new JsonAsyncClient(buildInnerClient().getProperties()); + } + + /** + * Builds an instance of JsonClient class. + * + * @return an instance of JsonClient. + */ + @Generated + public JsonClient buildClient() { + return new JsonClient(buildInnerClient().getProperties()); + } + + private static final ClientLogger LOGGER = new ClientLogger(JsonClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/implementation/JsonClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/implementation/JsonClientImpl.java new file mode 100644 index 000000000..9d3972323 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/implementation/JsonClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.serialization.encodedname.json.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the JsonClient type. + */ +public final class JsonClientImpl { + /** + * 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; + } + + /** + * The PropertiesImpl object to access its operations. + */ + private final PropertiesImpl properties; + + /** + * Gets the PropertiesImpl object to access its operations. + * + * @return the PropertiesImpl object. + */ + public PropertiesImpl getProperties() { + return this.properties; + } + + /** + * Initializes an instance of JsonClient client. + * + * @param endpoint Service host. + */ + public JsonClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of JsonClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public JsonClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of JsonClient 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 JsonClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.properties = new PropertiesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/implementation/PropertiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/implementation/PropertiesImpl.java new file mode 100644 index 000000000..a72b2daa0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/implementation/PropertiesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.serialization.encodedname.json.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Properties. + */ +public final class PropertiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PropertiesService service; + + /** + * The service client containing this operation class. + */ + private final JsonClientImpl client; + + /** + * Initializes an instance of PropertiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PropertiesImpl(JsonClientImpl client) { + this.service + = RestProxy.create(PropertiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for JsonClientProperties to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "JsonClientProperties") + public interface PropertiesService { + @Post("/serialization/encoded-name/json/property") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/serialization/encoded-name/json/property") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Get("/serialization/encoded-name/json/property") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/serialization/encoded-name/json/property") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     wireName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> sendWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     wireName: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 sendWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     wireName: boolean (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     wireName: boolean (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/implementation/package-info.java new file mode 100644 index 000000000..c3398ff58 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/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 Json. + * Projection. + * + */ +package com.serialization.encodedname.json.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/models/JsonEncodedNameModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/models/JsonEncodedNameModel.java new file mode 100644 index 000000000..3a7293ea1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/models/JsonEncodedNameModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.serialization.encodedname.json.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; + +/** + * The JsonEncodedNameModel model. + */ +@Immutable +public final class JsonEncodedNameModel implements JsonSerializable { + /* + * Pass in true + */ + @Generated + private final boolean defaultName; + + /** + * Creates an instance of JsonEncodedNameModel class. + * + * @param defaultName the defaultName value to set. + */ + @Generated + public JsonEncodedNameModel(boolean defaultName) { + this.defaultName = defaultName; + } + + /** + * Get the defaultName property: Pass in true. + * + * @return the defaultName value. + */ + @Generated + public boolean isDefaultName() { + return this.defaultName; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("wireName", this.defaultName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of JsonEncodedNameModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of JsonEncodedNameModel 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 JsonEncodedNameModel. + */ + @Generated + public static JsonEncodedNameModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean defaultName = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wireName".equals(fieldName)) { + defaultName = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new JsonEncodedNameModel(defaultName); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/models/package-info.java new file mode 100644 index 000000000..ee69fd4b9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/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 Json. + * Projection. + * + */ +package com.serialization.encodedname.json.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/package-info.java new file mode 100644 index 000000000..0c883165c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/serialization/encodedname/json/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 Json. + * Projection. + * + */ +package com.serialization.encodedname.json; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/NotDefinedAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/NotDefinedAsyncClient.java new file mode 100644 index 000000000..24e2d51fd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/NotDefinedAsyncClient.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 com.server.endpoint.notdefined; + +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 com.server.endpoint.notdefined.implementation.NotDefinedClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NotDefinedClient type. + */ +@ServiceClient(builder = NotDefinedClientBuilder.class, isAsync = true) +public final class NotDefinedAsyncClient { + @Generated + private final NotDefinedClientImpl serviceClient; + + /** + * Initializes an instance of NotDefinedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NotDefinedAsyncClient(NotDefinedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The valid operation. + * + * @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> validWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validWithResponseAsync(requestOptions); + } + + /** + * The valid 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono valid() { + // Generated convenience method for validWithResponse + RequestOptions requestOptions = new RequestOptions(); + return validWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/NotDefinedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/NotDefinedClient.java new file mode 100644 index 000000000..40cdf2730 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/NotDefinedClient.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.endpoint.notdefined; + +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.server.endpoint.notdefined.implementation.NotDefinedClientImpl; + +/** + * Initializes a new instance of the synchronous NotDefinedClient type. + */ +@ServiceClient(builder = NotDefinedClientBuilder.class) +public final class NotDefinedClient { + @Generated + private final NotDefinedClientImpl serviceClient; + + /** + * Initializes an instance of NotDefinedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NotDefinedClient(NotDefinedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The valid operation. + * + * @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 validWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validWithResponse(requestOptions); + } + + /** + * The valid 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void valid() { + // Generated convenience method for validWithResponse + RequestOptions requestOptions = new RequestOptions(); + validWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/NotDefinedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/NotDefinedClientBuilder.java new file mode 100644 index 000000000..4b2debed2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/NotDefinedClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.endpoint.notdefined; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.server.endpoint.notdefined.implementation.NotDefinedClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the NotDefinedClient type. + */ +@ServiceClientBuilder(serviceClients = { NotDefinedClient.class, NotDefinedAsyncClient.class }) +public final class NotDefinedClientBuilder 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("server-endpoint-notdefined.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the NotDefinedClientBuilder. + */ + @Generated + public NotDefinedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotDefinedClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotDefinedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotDefinedClientBuilder 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 NotDefinedClientBuilder 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 NotDefinedClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotDefinedClientBuilder 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 NotDefinedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotDefinedClientBuilder 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 NotDefinedClientBuilder. + */ + @Generated + public NotDefinedClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of NotDefinedClientImpl with the provided parameters. + * + * @return an instance of NotDefinedClientImpl. + */ + @Generated + private NotDefinedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + NotDefinedClientImpl client + = new NotDefinedClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 NotDefinedAsyncClient class. + * + * @return an instance of NotDefinedAsyncClient. + */ + @Generated + public NotDefinedAsyncClient buildAsyncClient() { + return new NotDefinedAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of NotDefinedClient class. + * + * @return an instance of NotDefinedClient. + */ + @Generated + public NotDefinedClient buildClient() { + return new NotDefinedClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NotDefinedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/implementation/NotDefinedClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/implementation/NotDefinedClientImpl.java new file mode 100644 index 000000000..7cce6d257 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/implementation/NotDefinedClientImpl.java @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.endpoint.notdefined.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Head; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.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 NotDefinedClient type. + */ +public final class NotDefinedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NotDefinedClientService 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 NotDefinedClient client. + * + * @param endpoint Service host. + */ + public NotDefinedClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NotDefinedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public NotDefinedClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NotDefinedClient 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 NotDefinedClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(NotDefinedClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for NotDefinedClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NotDefinedClient") + public interface NotDefinedClientService { + @Head("/server/endpoint/not-defined/valid") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> valid(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Head("/server/endpoint/not-defined/valid") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response validSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + } + + /** + * The valid operation. + * + * @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> validWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.valid(this.getEndpoint(), requestOptions, context)); + } + + /** + * The valid operation. + * + * @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 validWithResponse(RequestOptions requestOptions) { + return service.validSync(this.getEndpoint(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/implementation/package-info.java new file mode 100644 index 000000000..3a0cde611 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/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 NotDefined. + * Illustrates server doesn't define endpoint. Client should automatically add an endpoint to let user pass in. + * + */ +package com.server.endpoint.notdefined.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/package-info.java new file mode 100644 index 000000000..a141c89a3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/endpoint/notdefined/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 NotDefined. + * Illustrates server doesn't define endpoint. Client should automatically add an endpoint to let user pass in. + * + */ +package com.server.endpoint.notdefined; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/MultipleAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/MultipleAsyncClient.java new file mode 100644 index 000000000..f11d8697d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/MultipleAsyncClient.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.path.multiple; + +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 com.server.path.multiple.implementation.MultipleClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous MultipleClient type. + */ +@ServiceClient(builder = MultipleClientBuilder.class, isAsync = true) +public final class MultipleAsyncClient { + @Generated + private final MultipleClientImpl serviceClient; + + /** + * Initializes an instance of MultipleAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MultipleAsyncClient(MultipleClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The noOperationParams operation. + * + * @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> noOperationParamsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.noOperationParamsWithResponseAsync(requestOptions); + } + + /** + * The withOperationPathParam operation. + * + * @param keyword The keyword 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> withOperationPathParamWithResponse(String keyword, RequestOptions requestOptions) { + return this.serviceClient.withOperationPathParamWithResponseAsync(keyword, requestOptions); + } + + /** + * The noOperationParams 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono noOperationParams() { + // Generated convenience method for noOperationParamsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return noOperationParamsWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withOperationPathParam operation. + * + * @param keyword The keyword 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 withOperationPathParam(String keyword) { + // Generated convenience method for withOperationPathParamWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withOperationPathParamWithResponse(keyword, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/MultipleClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/MultipleClient.java new file mode 100644 index 000000000..ca2694f10 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/MultipleClient.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.path.multiple; + +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.server.path.multiple.implementation.MultipleClientImpl; + +/** + * Initializes a new instance of the synchronous MultipleClient type. + */ +@ServiceClient(builder = MultipleClientBuilder.class) +public final class MultipleClient { + @Generated + private final MultipleClientImpl serviceClient; + + /** + * Initializes an instance of MultipleClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MultipleClient(MultipleClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The noOperationParams operation. + * + * @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 noOperationParamsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.noOperationParamsWithResponse(requestOptions); + } + + /** + * The withOperationPathParam operation. + * + * @param keyword The keyword 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 withOperationPathParamWithResponse(String keyword, RequestOptions requestOptions) { + return this.serviceClient.withOperationPathParamWithResponse(keyword, requestOptions); + } + + /** + * The noOperationParams 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void noOperationParams() { + // Generated convenience method for noOperationParamsWithResponse + RequestOptions requestOptions = new RequestOptions(); + noOperationParamsWithResponse(requestOptions).getValue(); + } + + /** + * The withOperationPathParam operation. + * + * @param keyword The keyword 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 withOperationPathParam(String keyword) { + // Generated convenience method for withOperationPathParamWithResponse + RequestOptions requestOptions = new RequestOptions(); + withOperationPathParamWithResponse(keyword, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/MultipleClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/MultipleClientBuilder.java new file mode 100644 index 000000000..1ebc0bd08 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/MultipleClientBuilder.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.path.multiple; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.server.path.multiple.implementation.MultipleClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the MultipleClient type. + */ +@ServiceClientBuilder(serviceClients = { MultipleClient.class, MultipleAsyncClient.class }) +public final class MultipleClientBuilder 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("server-path-multiple.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the MultipleClientBuilder. + */ + @Generated + public MultipleClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultipleClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultipleClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultipleClientBuilder 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 MultipleClientBuilder 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 MultipleClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultipleClientBuilder 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 MultipleClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MultipleClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private MultipleServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the MultipleClientBuilder. + */ + @Generated + public MultipleClientBuilder serviceVersion(MultipleServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 MultipleClientBuilder. + */ + @Generated + public MultipleClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of MultipleClientImpl with the provided parameters. + * + * @return an instance of MultipleClientImpl. + */ + @Generated + private MultipleClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + MultipleServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : MultipleServiceVersion.getLatest(); + MultipleClientImpl client = new MultipleClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 MultipleAsyncClient class. + * + * @return an instance of MultipleAsyncClient. + */ + @Generated + public MultipleAsyncClient buildAsyncClient() { + return new MultipleAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of MultipleClient class. + * + * @return an instance of MultipleClient. + */ + @Generated + public MultipleClient buildClient() { + return new MultipleClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(MultipleClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/MultipleServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/MultipleServiceVersion.java new file mode 100644 index 000000000..4f6219648 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/MultipleServiceVersion.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.path.multiple; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of MultipleClient. + */ +public enum MultipleServiceVersion implements ServiceVersion { + /** + * Enum value v1.0. + */ + V1_0("v1.0"); + + private final String version; + + MultipleServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link MultipleServiceVersion}. + */ + public static MultipleServiceVersion getLatest() { + return V1_0; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/implementation/MultipleClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/implementation/MultipleClientImpl.java new file mode 100644 index 000000000..629ed9a32 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/implementation/MultipleClientImpl.java @@ -0,0 +1,248 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.path.multiple.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.PathParam; +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.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.server.path.multiple.MultipleServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the MultipleClient type. + */ +public final class MultipleClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MultipleClientService service; + + /** + * Pass in http://localhost:3000 for endpoint. + */ + private final String endpoint; + + /** + * Gets Pass in http://localhost:3000 for endpoint. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final MultipleServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public MultipleServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 MultipleClient client. + * + * @param endpoint Pass in http://localhost:3000 for endpoint. + * @param serviceVersion Service version. + */ + public MultipleClientImpl(String endpoint, MultipleServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of MultipleClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Pass in http://localhost:3000 for endpoint. + * @param serviceVersion Service version. + */ + public MultipleClientImpl(HttpPipeline httpPipeline, String endpoint, MultipleServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of MultipleClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Pass in http://localhost:3000 for endpoint. + * @param serviceVersion Service version. + */ + public MultipleClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + MultipleServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(MultipleClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for MultipleClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}/server/path/multiple/{apiVersion}") + @ServiceInterface(name = "MultipleClient") + public interface MultipleClientService { + @Get("/") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> noOperationParams(@HostParam("endpoint") String endpoint, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Get("/") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response noOperationParamsSync(@HostParam("endpoint") String endpoint, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Get("/{keyword}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withOperationPathParam(@HostParam("endpoint") String endpoint, + @HostParam("apiVersion") String apiVersion, @PathParam("keyword") String keyword, + RequestOptions requestOptions, Context context); + + @Get("/{keyword}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withOperationPathParamSync(@HostParam("endpoint") String endpoint, + @HostParam("apiVersion") String apiVersion, @PathParam("keyword") String keyword, + RequestOptions requestOptions, Context context); + } + + /** + * The noOperationParams operation. + * + * @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> noOperationParamsWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.noOperationParams(this.getEndpoint(), + this.getServiceVersion().getVersion(), requestOptions, context)); + } + + /** + * The noOperationParams operation. + * + * @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 noOperationParamsWithResponse(RequestOptions requestOptions) { + return service.noOperationParamsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), requestOptions, + Context.NONE); + } + + /** + * The withOperationPathParam operation. + * + * @param keyword The keyword 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> withOperationPathParamWithResponseAsync(String keyword, RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withOperationPathParam(this.getEndpoint(), + this.getServiceVersion().getVersion(), keyword, requestOptions, context)); + } + + /** + * The withOperationPathParam operation. + * + * @param keyword The keyword 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 withOperationPathParamWithResponse(String keyword, RequestOptions requestOptions) { + return service.withOperationPathParamSync(this.getEndpoint(), this.getServiceVersion().getVersion(), keyword, + requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/implementation/package-info.java new file mode 100644 index 000000000..47e619302 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Multiple. + * + */ +package com.server.path.multiple.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/package-info.java new file mode 100644 index 000000000..42ef4c2a5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/multiple/package-info.java @@ -0,0 +1,10 @@ +// 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 Multiple. + * + */ +package com.server.path.multiple; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/SingleAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/SingleAsyncClient.java new file mode 100644 index 000000000..8d5410558 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/SingleAsyncClient.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 com.server.path.single; + +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 com.server.path.single.implementation.SingleClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SingleClient type. + */ +@ServiceClient(builder = SingleClientBuilder.class, isAsync = true) +public final class SingleAsyncClient { + @Generated + private final SingleClientImpl serviceClient; + + /** + * Initializes an instance of SingleAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SingleAsyncClient(SingleClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The myOp operation. + * + * @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> myOpWithResponse(RequestOptions requestOptions) { + return this.serviceClient.myOpWithResponseAsync(requestOptions); + } + + /** + * The myOp 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono myOp() { + // Generated convenience method for myOpWithResponse + RequestOptions requestOptions = new RequestOptions(); + return myOpWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/SingleClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/SingleClient.java new file mode 100644 index 000000000..e360c7932 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/SingleClient.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.path.single; + +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.server.path.single.implementation.SingleClientImpl; + +/** + * Initializes a new instance of the synchronous SingleClient type. + */ +@ServiceClient(builder = SingleClientBuilder.class) +public final class SingleClient { + @Generated + private final SingleClientImpl serviceClient; + + /** + * Initializes an instance of SingleClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SingleClient(SingleClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The myOp operation. + * + * @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 myOpWithResponse(RequestOptions requestOptions) { + return this.serviceClient.myOpWithResponse(requestOptions); + } + + /** + * The myOp 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void myOp() { + // Generated convenience method for myOpWithResponse + RequestOptions requestOptions = new RequestOptions(); + myOpWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/SingleClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/SingleClientBuilder.java new file mode 100644 index 000000000..c57813214 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/SingleClientBuilder.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 com.server.path.single; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.server.path.single.implementation.SingleClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the SingleClient type. + */ +@ServiceClientBuilder(serviceClients = { SingleClient.class, SingleAsyncClient.class }) +public final class SingleClientBuilder 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("server-path-single.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the SingleClientBuilder. + */ + @Generated + public SingleClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SingleClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SingleClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SingleClientBuilder 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 SingleClientBuilder 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 SingleClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SingleClientBuilder 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 SingleClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SingleClientBuilder 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 SingleClientBuilder. + */ + @Generated + public SingleClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of SingleClientImpl with the provided parameters. + * + * @return an instance of SingleClientImpl. + */ + @Generated + private SingleClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + SingleClientImpl client + = new SingleClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 SingleAsyncClient class. + * + * @return an instance of SingleAsyncClient. + */ + @Generated + public SingleAsyncClient buildAsyncClient() { + return new SingleAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of SingleClient class. + * + * @return an instance of SingleClient. + */ + @Generated + public SingleClient buildClient() { + return new SingleClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SingleClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/implementation/SingleClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/implementation/SingleClientImpl.java new file mode 100644 index 000000000..59c6962ad --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/implementation/SingleClientImpl.java @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.path.single.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Head; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.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 SingleClient type. + */ +public final class SingleClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SingleClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @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 SingleClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + */ + public SingleClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of SingleClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + */ + public SingleClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of SingleClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + */ + public SingleClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(SingleClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for SingleClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SingleClient") + public interface SingleClientService { + @Head("/server/path/single/myOp") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> myOp(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Head("/server/path/single/myOp") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response myOpSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + } + + /** + * The myOp operation. + * + * @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> myOpWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.myOp(this.getEndpoint(), requestOptions, context)); + } + + /** + * The myOp operation. + * + * @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 myOpWithResponse(RequestOptions requestOptions) { + return service.myOpSync(this.getEndpoint(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/implementation/package-info.java new file mode 100644 index 000000000..08cc2a8ab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/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 Single. + * Illustrates server with a single path parameter @server. + * + */ +package com.server.path.single.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/package-info.java new file mode 100644 index 000000000..2a44db394 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/path/single/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 Single. + * Illustrates server with a single path parameter @server. + * + */ +package com.server.path.single; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/NotVersionedAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/NotVersionedAsyncClient.java new file mode 100644 index 000000000..9b8a616fa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/NotVersionedAsyncClient.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 com.server.versions.notversioned; + +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 com.server.versions.notversioned.implementation.NotVersionedClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NotVersionedClient type. + */ +@ServiceClient(builder = NotVersionedClientBuilder.class, isAsync = true) +public final class NotVersionedAsyncClient { + @Generated + private final NotVersionedClientImpl serviceClient; + + /** + * Initializes an instance of NotVersionedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NotVersionedAsyncClient(NotVersionedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withoutApiVersion operation. + * + * @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> withoutApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withoutApiVersionWithResponseAsync(requestOptions); + } + + /** + * The withQueryApiVersion operation. + * + * @param apiVersion The apiVersion 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> withQueryApiVersionWithResponse(String apiVersion, RequestOptions requestOptions) { + return this.serviceClient.withQueryApiVersionWithResponseAsync(apiVersion, requestOptions); + } + + /** + * The withPathApiVersion operation. + * + * @param apiVersion The apiVersion 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> withPathApiVersionWithResponse(String apiVersion, RequestOptions requestOptions) { + return this.serviceClient.withPathApiVersionWithResponseAsync(apiVersion, requestOptions); + } + + /** + * The withoutApiVersion 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono withoutApiVersion() { + // Generated convenience method for withoutApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withoutApiVersionWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQueryApiVersion operation. + * + * @param apiVersion The apiVersion 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 withQueryApiVersion(String apiVersion) { + // Generated convenience method for withQueryApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryApiVersionWithResponse(apiVersion, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withPathApiVersion operation. + * + * @param apiVersion The apiVersion 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 withPathApiVersion(String apiVersion) { + // Generated convenience method for withPathApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withPathApiVersionWithResponse(apiVersion, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/NotVersionedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/NotVersionedClient.java new file mode 100644 index 000000000..291982cfa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/NotVersionedClient.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.versions.notversioned; + +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.server.versions.notversioned.implementation.NotVersionedClientImpl; + +/** + * Initializes a new instance of the synchronous NotVersionedClient type. + */ +@ServiceClient(builder = NotVersionedClientBuilder.class) +public final class NotVersionedClient { + @Generated + private final NotVersionedClientImpl serviceClient; + + /** + * Initializes an instance of NotVersionedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NotVersionedClient(NotVersionedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withoutApiVersion operation. + * + * @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 withoutApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withoutApiVersionWithResponse(requestOptions); + } + + /** + * The withQueryApiVersion operation. + * + * @param apiVersion The apiVersion 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 withQueryApiVersionWithResponse(String apiVersion, RequestOptions requestOptions) { + return this.serviceClient.withQueryApiVersionWithResponse(apiVersion, requestOptions); + } + + /** + * The withPathApiVersion operation. + * + * @param apiVersion The apiVersion 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 withPathApiVersionWithResponse(String apiVersion, RequestOptions requestOptions) { + return this.serviceClient.withPathApiVersionWithResponse(apiVersion, requestOptions); + } + + /** + * The withoutApiVersion 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void withoutApiVersion() { + // Generated convenience method for withoutApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withoutApiVersionWithResponse(requestOptions).getValue(); + } + + /** + * The withQueryApiVersion operation. + * + * @param apiVersion The apiVersion 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 withQueryApiVersion(String apiVersion) { + // Generated convenience method for withQueryApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryApiVersionWithResponse(apiVersion, requestOptions).getValue(); + } + + /** + * The withPathApiVersion operation. + * + * @param apiVersion The apiVersion 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 withPathApiVersion(String apiVersion) { + // Generated convenience method for withPathApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withPathApiVersionWithResponse(apiVersion, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/NotVersionedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/NotVersionedClientBuilder.java new file mode 100644 index 000000000..a45cce4ea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/NotVersionedClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.versions.notversioned; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.server.versions.notversioned.implementation.NotVersionedClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the NotVersionedClient type. + */ +@ServiceClientBuilder(serviceClients = { NotVersionedClient.class, NotVersionedAsyncClient.class }) +public final class NotVersionedClientBuilder 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("server-versions-notversioned.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the NotVersionedClientBuilder. + */ + @Generated + public NotVersionedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotVersionedClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotVersionedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotVersionedClientBuilder 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 NotVersionedClientBuilder 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 NotVersionedClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotVersionedClientBuilder 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 NotVersionedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotVersionedClientBuilder 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 NotVersionedClientBuilder. + */ + @Generated + public NotVersionedClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of NotVersionedClientImpl with the provided parameters. + * + * @return an instance of NotVersionedClientImpl. + */ + @Generated + private NotVersionedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + NotVersionedClientImpl client + = new NotVersionedClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 NotVersionedAsyncClient class. + * + * @return an instance of NotVersionedAsyncClient. + */ + @Generated + public NotVersionedAsyncClient buildAsyncClient() { + return new NotVersionedAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of NotVersionedClient class. + * + * @return an instance of NotVersionedClient. + */ + @Generated + public NotVersionedClient buildClient() { + return new NotVersionedClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NotVersionedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/implementation/NotVersionedClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/implementation/NotVersionedClientImpl.java new file mode 100644 index 000000000..eff9b16d9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/implementation/NotVersionedClientImpl.java @@ -0,0 +1,277 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.versions.notversioned.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Head; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +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.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.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 NotVersionedClient type. + */ +public final class NotVersionedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NotVersionedClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @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 NotVersionedClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + */ + public NotVersionedClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NotVersionedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + */ + public NotVersionedClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NotVersionedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + */ + public NotVersionedClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service + = RestProxy.create(NotVersionedClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for NotVersionedClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NotVersionedClient") + public interface NotVersionedClientService { + @Head("/server/versions/not-versioned/without-api-version") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withoutApiVersion(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Head("/server/versions/not-versioned/without-api-version") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withoutApiVersionSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Head("/server/versions/not-versioned/with-query-api-version") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQueryApiVersion(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions, Context context); + + @Head("/server/versions/not-versioned/with-query-api-version") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQueryApiVersionSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions, Context context); + + @Head("/server/versions/not-versioned/with-path-api-version/{apiVersion}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withPathApiVersion(@HostParam("endpoint") String endpoint, + @PathParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Head("/server/versions/not-versioned/with-path-api-version/{apiVersion}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withPathApiVersionSync(@HostParam("endpoint") String endpoint, + @PathParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + } + + /** + * The withoutApiVersion operation. + * + * @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> withoutApiVersionWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withoutApiVersion(this.getEndpoint(), requestOptions, context)); + } + + /** + * The withoutApiVersion operation. + * + * @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 withoutApiVersionWithResponse(RequestOptions requestOptions) { + return service.withoutApiVersionSync(this.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The withQueryApiVersion operation. + * + * @param apiVersion The apiVersion 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> withQueryApiVersionWithResponseAsync(String apiVersion, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withQueryApiVersion(this.getEndpoint(), apiVersion, requestOptions, context)); + } + + /** + * The withQueryApiVersion operation. + * + * @param apiVersion The apiVersion 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 withQueryApiVersionWithResponse(String apiVersion, RequestOptions requestOptions) { + return service.withQueryApiVersionSync(this.getEndpoint(), apiVersion, requestOptions, Context.NONE); + } + + /** + * The withPathApiVersion operation. + * + * @param apiVersion The apiVersion 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> withPathApiVersionWithResponseAsync(String apiVersion, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withPathApiVersion(this.getEndpoint(), apiVersion, requestOptions, context)); + } + + /** + * The withPathApiVersion operation. + * + * @param apiVersion The apiVersion 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 withPathApiVersionWithResponse(String apiVersion, RequestOptions requestOptions) { + return service.withPathApiVersionSync(this.getEndpoint(), apiVersion, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/implementation/package-info.java new file mode 100644 index 000000000..c8c8c4369 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/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 NotVersioned. + * Illustrates not-versioned server. + * + */ +package com.server.versions.notversioned.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/package-info.java new file mode 100644 index 000000000..50c43f8c2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/notversioned/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 NotVersioned. + * Illustrates not-versioned server. + * + */ +package com.server.versions.notversioned; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/VersionedAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/VersionedAsyncClient.java new file mode 100644 index 000000000..40ceb32cf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/VersionedAsyncClient.java @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.versions.versioned; + +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 com.server.versions.versioned.implementation.VersionedClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous VersionedClient type. + */ +@ServiceClient(builder = VersionedClientBuilder.class, isAsync = true) +public final class VersionedAsyncClient { + @Generated + private final VersionedClientImpl serviceClient; + + /** + * Initializes an instance of VersionedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VersionedAsyncClient(VersionedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withoutApiVersion operation. + * + * @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> withoutApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withoutApiVersionWithResponseAsync(requestOptions); + } + + /** + * The withQueryApiVersion operation. + * + * @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> withQueryApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryApiVersionWithResponseAsync(requestOptions); + } + + /** + * The withPathApiVersion operation. + * + * @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> withPathApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withPathApiVersionWithResponseAsync(requestOptions); + } + + /** + * The withQueryOldApiVersion operation. + * + * @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> withQueryOldApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryOldApiVersionWithResponseAsync(requestOptions); + } + + /** + * The withoutApiVersion 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono withoutApiVersion() { + // Generated convenience method for withoutApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withoutApiVersionWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQueryApiVersion 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono withQueryApiVersion() { + // Generated convenience method for withQueryApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryApiVersionWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withPathApiVersion 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono withPathApiVersion() { + // Generated convenience method for withPathApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withPathApiVersionWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQueryOldApiVersion 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono withQueryOldApiVersion() { + // Generated convenience method for withQueryOldApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryOldApiVersionWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/VersionedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/VersionedClient.java new file mode 100644 index 000000000..97a2d7fe5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/VersionedClient.java @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.versions.versioned; + +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.server.versions.versioned.implementation.VersionedClientImpl; + +/** + * Initializes a new instance of the synchronous VersionedClient type. + */ +@ServiceClient(builder = VersionedClientBuilder.class) +public final class VersionedClient { + @Generated + private final VersionedClientImpl serviceClient; + + /** + * Initializes an instance of VersionedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VersionedClient(VersionedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withoutApiVersion operation. + * + * @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 withoutApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withoutApiVersionWithResponse(requestOptions); + } + + /** + * The withQueryApiVersion operation. + * + * @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 withQueryApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryApiVersionWithResponse(requestOptions); + } + + /** + * The withPathApiVersion operation. + * + * @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 withPathApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withPathApiVersionWithResponse(requestOptions); + } + + /** + * The withQueryOldApiVersion operation. + * + * @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 withQueryOldApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryOldApiVersionWithResponse(requestOptions); + } + + /** + * The withoutApiVersion 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void withoutApiVersion() { + // Generated convenience method for withoutApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withoutApiVersionWithResponse(requestOptions).getValue(); + } + + /** + * The withQueryApiVersion 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void withQueryApiVersion() { + // Generated convenience method for withQueryApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryApiVersionWithResponse(requestOptions).getValue(); + } + + /** + * The withPathApiVersion 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void withPathApiVersion() { + // Generated convenience method for withPathApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withPathApiVersionWithResponse(requestOptions).getValue(); + } + + /** + * The withQueryOldApiVersion 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void withQueryOldApiVersion() { + // Generated convenience method for withQueryOldApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryOldApiVersionWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/VersionedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/VersionedClientBuilder.java new file mode 100644 index 000000000..e7196aa29 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/VersionedClientBuilder.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.versions.versioned; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.server.versions.versioned.implementation.VersionedClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the VersionedClient type. + */ +@ServiceClientBuilder(serviceClients = { VersionedClient.class, VersionedAsyncClient.class }) +public final class VersionedClientBuilder 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("server-versions-versioned.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the VersionedClientBuilder. + */ + @Generated + public VersionedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VersionedClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VersionedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VersionedClientBuilder 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 VersionedClientBuilder 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 VersionedClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VersionedClientBuilder 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 VersionedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VersionedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private VersionedServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the VersionedClientBuilder. + */ + @Generated + public VersionedClientBuilder serviceVersion(VersionedServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 VersionedClientBuilder. + */ + @Generated + public VersionedClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of VersionedClientImpl with the provided parameters. + * + * @return an instance of VersionedClientImpl. + */ + @Generated + private VersionedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + VersionedServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : VersionedServiceVersion.getLatest(); + VersionedClientImpl client = new VersionedClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @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 VersionedAsyncClient class. + * + * @return an instance of VersionedAsyncClient. + */ + @Generated + public VersionedAsyncClient buildAsyncClient() { + return new VersionedAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of VersionedClient class. + * + * @return an instance of VersionedClient. + */ + @Generated + public VersionedClient buildClient() { + return new VersionedClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(VersionedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/VersionedServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/VersionedServiceVersion.java new file mode 100644 index 000000000..b5aabdc9c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/VersionedServiceVersion.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.versions.versioned; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of VersionedClient. + */ +public enum VersionedServiceVersion implements ServiceVersion { + /** + * Enum value 2021-01-01-preview. + */ + V2021_01_01_PREVIEW("2021-01-01-preview"), + + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + VersionedServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link VersionedServiceVersion}. + */ + public static VersionedServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/implementation/VersionedClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/implementation/VersionedClientImpl.java new file mode 100644 index 000000000..70b6ff082 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/implementation/VersionedClientImpl.java @@ -0,0 +1,344 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.versions.versioned.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Head; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +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.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.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.server.versions.versioned.VersionedServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the VersionedClient type. + */ +public final class VersionedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final VersionedClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final VersionedServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public VersionedServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 VersionedClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param serviceVersion Service version. + */ + public VersionedClientImpl(String endpoint, VersionedServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of VersionedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param serviceVersion Service version. + */ + public VersionedClientImpl(HttpPipeline httpPipeline, String endpoint, VersionedServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of VersionedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param serviceVersion Service version. + */ + public VersionedClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + VersionedServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(VersionedClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for VersionedClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "VersionedClient") + public interface VersionedClientService { + @Head("/server/versions/versioned/without-api-version") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withoutApiVersion(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Head("/server/versions/versioned/without-api-version") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withoutApiVersionSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Head("/server/versions/versioned/with-query-api-version") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQueryApiVersion(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions, Context context); + + @Head("/server/versions/versioned/with-query-api-version") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQueryApiVersionSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions, Context context); + + @Head("/server/versions/versioned/with-path-api-version/{apiVersion}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withPathApiVersion(@HostParam("endpoint") String endpoint, + @PathParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Head("/server/versions/versioned/with-path-api-version/{apiVersion}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withPathApiVersionSync(@HostParam("endpoint") String endpoint, + @PathParam("apiVersion") String apiVersion, RequestOptions requestOptions, Context context); + + @Head("/server/versions/versioned/with-query-old-api-version") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQueryOldApiVersion(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions, Context context); + + @Head("/server/versions/versioned/with-query-old-api-version") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQueryOldApiVersionSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions, Context context); + } + + /** + * The withoutApiVersion operation. + * + * @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> withoutApiVersionWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withoutApiVersion(this.getEndpoint(), requestOptions, context)); + } + + /** + * The withoutApiVersion operation. + * + * @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 withoutApiVersionWithResponse(RequestOptions requestOptions) { + return service.withoutApiVersionSync(this.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The withQueryApiVersion operation. + * + * @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> withQueryApiVersionWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withQueryApiVersion(this.getEndpoint(), + this.getServiceVersion().getVersion(), requestOptions, context)); + } + + /** + * The withQueryApiVersion operation. + * + * @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 withQueryApiVersionWithResponse(RequestOptions requestOptions) { + return service.withQueryApiVersionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + requestOptions, Context.NONE); + } + + /** + * The withPathApiVersion operation. + * + * @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> withPathApiVersionWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withPathApiVersion(this.getEndpoint(), + this.getServiceVersion().getVersion(), requestOptions, context)); + } + + /** + * The withPathApiVersion operation. + * + * @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 withPathApiVersionWithResponse(RequestOptions requestOptions) { + return service.withPathApiVersionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), requestOptions, + Context.NONE); + } + + /** + * The withQueryOldApiVersion operation. + * + * @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> withQueryOldApiVersionWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withQueryOldApiVersion(this.getEndpoint(), + this.getServiceVersion().getVersion(), requestOptions, context)); + } + + /** + * The withQueryOldApiVersion operation. + * + * @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 withQueryOldApiVersionWithResponse(RequestOptions requestOptions) { + return service.withQueryOldApiVersionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/implementation/package-info.java new file mode 100644 index 000000000..c93169266 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/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 Versioned. + * Illustrates versioned server. + * + */ +package com.server.versions.versioned.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/package-info.java new file mode 100644 index 000000000..f135f19a1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/server/versions/versioned/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 Versioned. + * Illustrates versioned server. + * + */ +package com.server.versions.versioned; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestAsyncClient.java new file mode 100644 index 000000000..fc214ad0c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestAsyncClient.java @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialheaders.conditionalrequest; + +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.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.FluxUtil; +import com.specialheaders.conditionalrequest.implementation.ConditionalRequestClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ConditionalRequestClient type. + */ +@ServiceClient(builder = ConditionalRequestClientBuilder.class, isAsync = true) +public final class ConditionalRequestAsyncClient { + @Generated + private final ConditionalRequestClientImpl serviceClient; + + /** + * Initializes an instance of ConditionalRequestAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ConditionalRequestAsyncClient(ConditionalRequestClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check when only If-Match in header is defined. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @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> postIfMatchWithResponse(RequestOptions requestOptions) { + return this.serviceClient.postIfMatchWithResponseAsync(requestOptions); + } + + /** + * Check when only If-None-Match in header is defined. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @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> postIfNoneMatchWithResponse(RequestOptions requestOptions) { + return this.serviceClient.postIfNoneMatchWithResponseAsync(requestOptions); + } + + /** + * Check when only If-Match in header is defined. + * + * @param ifMatch The request should only proceed if an entity matches this string. + * @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 postIfMatch(String ifMatch) { + // Generated convenience method for postIfMatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + return postIfMatchWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Check when only If-Match in header is defined. + * + * @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 postIfMatch() { + // Generated convenience method for postIfMatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postIfMatchWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Check when only If-None-Match in header is defined. + * + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @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 postIfNoneMatch(String ifNoneMatch) { + // Generated convenience method for postIfNoneMatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + return postIfNoneMatchWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Check when only If-None-Match in header is defined. + * + * @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 postIfNoneMatch() { + // Generated convenience method for postIfNoneMatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postIfNoneMatchWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestClient.java new file mode 100644 index 000000000..4629ed4d3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestClient.java @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialheaders.conditionalrequest; + +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.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.specialheaders.conditionalrequest.implementation.ConditionalRequestClientImpl; + +/** + * Initializes a new instance of the synchronous ConditionalRequestClient type. + */ +@ServiceClient(builder = ConditionalRequestClientBuilder.class) +public final class ConditionalRequestClient { + @Generated + private final ConditionalRequestClientImpl serviceClient; + + /** + * Initializes an instance of ConditionalRequestClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ConditionalRequestClient(ConditionalRequestClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check when only If-Match in header is defined. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @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 postIfMatchWithResponse(RequestOptions requestOptions) { + return this.serviceClient.postIfMatchWithResponse(requestOptions); + } + + /** + * Check when only If-None-Match in header is defined. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @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 postIfNoneMatchWithResponse(RequestOptions requestOptions) { + return this.serviceClient.postIfNoneMatchWithResponse(requestOptions); + } + + /** + * Check when only If-Match in header is defined. + * + * @param ifMatch The request should only proceed if an entity matches this string. + * @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 postIfMatch(String ifMatch) { + // Generated convenience method for postIfMatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + postIfMatchWithResponse(requestOptions).getValue(); + } + + /** + * Check when only If-Match in header is defined. + * + * @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 postIfMatch() { + // Generated convenience method for postIfMatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + postIfMatchWithResponse(requestOptions).getValue(); + } + + /** + * Check when only If-None-Match in header is defined. + * + * @param ifNoneMatch The request should only proceed if no entity matches this string. + * @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 postIfNoneMatch(String ifNoneMatch) { + // Generated convenience method for postIfNoneMatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + postIfNoneMatchWithResponse(requestOptions).getValue(); + } + + /** + * Check when only If-None-Match in header is defined. + * + * @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 postIfNoneMatch() { + // Generated convenience method for postIfNoneMatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + postIfNoneMatchWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestClientBuilder.java new file mode 100644 index 000000000..422aefcef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/ConditionalRequestClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialheaders.conditionalrequest; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.specialheaders.conditionalrequest.implementation.ConditionalRequestClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ConditionalRequestClient type. + */ +@ServiceClientBuilder(serviceClients = { ConditionalRequestClient.class, ConditionalRequestAsyncClient.class }) +public final class ConditionalRequestClientBuilder 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("specialheaders-conditionalrequest.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ConditionalRequestClientBuilder. + */ + @Generated + public ConditionalRequestClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ConditionalRequestClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ConditionalRequestClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ConditionalRequestClientBuilder 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 ConditionalRequestClientBuilder 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 ConditionalRequestClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ConditionalRequestClientBuilder 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 ConditionalRequestClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ConditionalRequestClientBuilder 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 ConditionalRequestClientBuilder. + */ + @Generated + public ConditionalRequestClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ConditionalRequestClientImpl with the provided parameters. + * + * @return an instance of ConditionalRequestClientImpl. + */ + @Generated + private ConditionalRequestClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ConditionalRequestClientImpl client = new ConditionalRequestClientImpl(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 ConditionalRequestAsyncClient class. + * + * @return an instance of ConditionalRequestAsyncClient. + */ + @Generated + public ConditionalRequestAsyncClient buildAsyncClient() { + return new ConditionalRequestAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ConditionalRequestClient class. + * + * @return an instance of ConditionalRequestClient. + */ + @Generated + public ConditionalRequestClient buildClient() { + return new ConditionalRequestClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ConditionalRequestClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/implementation/ConditionalRequestClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/implementation/ConditionalRequestClientImpl.java new file mode 100644 index 000000000..a5d41b886 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/implementation/ConditionalRequestClientImpl.java @@ -0,0 +1,254 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialheaders.conditionalrequest.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.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 ConditionalRequestClient type. + */ +public final class ConditionalRequestClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ConditionalRequestClientService 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 ConditionalRequestClient client. + * + * @param endpoint Service host. + */ + public ConditionalRequestClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ConditionalRequestClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ConditionalRequestClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ConditionalRequestClient 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 ConditionalRequestClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service + = RestProxy.create(ConditionalRequestClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for ConditionalRequestClient to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ConditionalRequestCl") + public interface ConditionalRequestClientService { + @Post("/special-headers/conditional-request/if-match") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> postIfMatch(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Post("/special-headers/conditional-request/if-match") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response postIfMatchSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Post("/special-headers/conditional-request/if-none-match") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> postIfNoneMatch(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Post("/special-headers/conditional-request/if-none-match") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response postIfNoneMatchSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + } + + /** + * Check when only If-Match in header is defined. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @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> postIfMatchWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.postIfMatch(this.getEndpoint(), requestOptions, context)); + } + + /** + * Check when only If-Match in header is defined. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @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 postIfMatchWithResponse(RequestOptions requestOptions) { + return service.postIfMatchSync(this.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * Check when only If-None-Match in header is defined. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @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> postIfNoneMatchWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.postIfNoneMatch(this.getEndpoint(), requestOptions, context)); + } + + /** + * Check when only If-None-Match in header is defined. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @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 postIfNoneMatchWithResponse(RequestOptions requestOptions) { + return service.postIfNoneMatchSync(this.getEndpoint(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/implementation/package-info.java new file mode 100644 index 000000000..4528e8d9e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/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 ConditionalRequest. + * Illustrates conditional request headers. + * + */ +package com.specialheaders.conditionalrequest.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/package-info.java new file mode 100644 index 000000000..832c7acb5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/conditionalrequest/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 ConditionalRequest. + * Illustrates conditional request headers. + * + */ +package com.specialheaders.conditionalrequest; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/RepeatabilityAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/RepeatabilityAsyncClient.java new file mode 100644 index 000000000..a22ca9371 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/RepeatabilityAsyncClient.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialheaders.repeatability; + +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 com.specialheaders.repeatability.implementation.RepeatabilityClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous RepeatabilityClient type. + */ +@ServiceClient(builder = RepeatabilityClientBuilder.class, isAsync = true) +public final class RepeatabilityAsyncClient { + @Generated + private final RepeatabilityClientImpl serviceClient; + + /** + * Initializes an instance of RepeatabilityAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RepeatabilityAsyncClient(RepeatabilityClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check we recognize Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @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> immediateSuccessWithResponse(RequestOptions requestOptions) { + return this.serviceClient.immediateSuccessWithResponseAsync(requestOptions); + } + + /** + * Check we recognize Repeatability-Request-ID and Repeatability-First-Sent. + * + * @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 immediateSuccess() { + // Generated convenience method for immediateSuccessWithResponse + RequestOptions requestOptions = new RequestOptions(); + return immediateSuccessWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/RepeatabilityClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/RepeatabilityClient.java new file mode 100644 index 000000000..de4321b90 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/RepeatabilityClient.java @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialheaders.repeatability; + +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.specialheaders.repeatability.implementation.RepeatabilityClientImpl; + +/** + * Initializes a new instance of the synchronous RepeatabilityClient type. + */ +@ServiceClient(builder = RepeatabilityClientBuilder.class) +public final class RepeatabilityClient { + @Generated + private final RepeatabilityClientImpl serviceClient; + + /** + * Initializes an instance of RepeatabilityClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RepeatabilityClient(RepeatabilityClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check we recognize Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @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 immediateSuccessWithResponse(RequestOptions requestOptions) { + return this.serviceClient.immediateSuccessWithResponse(requestOptions); + } + + /** + * Check we recognize Repeatability-Request-ID and Repeatability-First-Sent. + * + * @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 immediateSuccess() { + // Generated convenience method for immediateSuccessWithResponse + RequestOptions requestOptions = new RequestOptions(); + immediateSuccessWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/RepeatabilityClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/RepeatabilityClientBuilder.java new file mode 100644 index 000000000..8502679f2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/RepeatabilityClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialheaders.repeatability; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.specialheaders.repeatability.implementation.RepeatabilityClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the RepeatabilityClient type. + */ +@ServiceClientBuilder(serviceClients = { RepeatabilityClient.class, RepeatabilityAsyncClient.class }) +public final class RepeatabilityClientBuilder 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("specialheaders-repeatability.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the RepeatabilityClientBuilder. + */ + @Generated + public RepeatabilityClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RepeatabilityClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RepeatabilityClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RepeatabilityClientBuilder 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 RepeatabilityClientBuilder 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 RepeatabilityClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RepeatabilityClientBuilder 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 RepeatabilityClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RepeatabilityClientBuilder 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 RepeatabilityClientBuilder. + */ + @Generated + public RepeatabilityClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of RepeatabilityClientImpl with the provided parameters. + * + * @return an instance of RepeatabilityClientImpl. + */ + @Generated + private RepeatabilityClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + RepeatabilityClientImpl client = new RepeatabilityClientImpl(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 RepeatabilityAsyncClient class. + * + * @return an instance of RepeatabilityAsyncClient. + */ + @Generated + public RepeatabilityAsyncClient buildAsyncClient() { + return new RepeatabilityAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of RepeatabilityClient class. + * + * @return an instance of RepeatabilityClient. + */ + @Generated + public RepeatabilityClient buildClient() { + return new RepeatabilityClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(RepeatabilityClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/implementation/RepeatabilityClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/implementation/RepeatabilityClientImpl.java new file mode 100644 index 000000000..d9263b183 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/implementation/RepeatabilityClientImpl.java @@ -0,0 +1,224 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialheaders.repeatability.implementation; + +import com.azure.core.annotation.ExpectedResponses; +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.HttpHeaderName; +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.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the RepeatabilityClient type. + */ +public final class RepeatabilityClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RepeatabilityClientService 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 RepeatabilityClient client. + * + * @param endpoint Service host. + */ + public RepeatabilityClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of RepeatabilityClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public RepeatabilityClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of RepeatabilityClient 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 RepeatabilityClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service + = RestProxy.create(RepeatabilityClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for RepeatabilityClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "RepeatabilityClient") + public interface RepeatabilityClientService { + @Post("/special-headers/repeatability/immediateSuccess") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> immediateSuccess(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Post("/special-headers/repeatability/immediateSuccess") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response immediateSuccessSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + } + + /** + * Check we recognize Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @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> immediateSuccessWithResponseAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-request-id"), CoreUtils.randomUuid().toString()); + } + }); + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-first-sent")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-first-sent"), + DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); + } + }); + return FluxUtil + .withContext(context -> service.immediateSuccess(this.getEndpoint(), requestOptionsLocal, context)); + } + + /** + * Check we recognize Repeatability-Request-ID and Repeatability-First-Sent. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
repeatability-request-idStringNoRepeatability request ID header
repeatability-first-sentStringNoRepeatability first sent header as + * HTTP-date
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @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 immediateSuccessWithResponse(RequestOptions requestOptions) { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-request-id")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-request-id"), CoreUtils.randomUuid().toString()); + } + }); + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getHeaders().get(HttpHeaderName.fromString("repeatability-first-sent")) == null) { + requestLocal.getHeaders() + .set(HttpHeaderName.fromString("repeatability-first-sent"), + DateTimeRfc1123.toRfc1123String(OffsetDateTime.now())); + } + }); + return service.immediateSuccessSync(this.getEndpoint(), requestOptionsLocal, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/implementation/package-info.java new file mode 100644 index 000000000..8f3bdefd9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/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 Repeatability. + * Illustrates OASIS repeatability headers. + * + */ +package com.specialheaders.repeatability.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/package-info.java new file mode 100644 index 000000000..8f8618564 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialheaders/repeatability/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 Repeatability. + * Illustrates OASIS repeatability headers. + * + */ +package com.specialheaders.repeatability; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ModelPropertiesAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ModelPropertiesAsyncClient.java new file mode 100644 index 000000000..724629b74 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ModelPropertiesAsyncClient.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords; + +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 com.specialwords.implementation.ModelPropertiesImpl; +import com.specialwords.models.SameAsModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SpecialWordsClient type. + */ +@ServiceClient(builder = SpecialWordsClientBuilder.class, isAsync = true) +public final class ModelPropertiesAsyncClient { + @Generated + private final ModelPropertiesImpl serviceClient; + + /** + * Initializes an instance of ModelPropertiesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelPropertiesAsyncClient(ModelPropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The sameAsModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     SameAsModel: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> sameAsModelWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.sameAsModelWithResponseAsync(body, requestOptions); + } + + /** + * The sameAsModel operation. + * + * @param body The body 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 sameAsModel(SameAsModel body) { + // Generated convenience method for sameAsModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return sameAsModelWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ModelPropertiesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ModelPropertiesClient.java new file mode 100644 index 000000000..80681b3a1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ModelPropertiesClient.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords; + +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.specialwords.implementation.ModelPropertiesImpl; +import com.specialwords.models.SameAsModel; + +/** + * Initializes a new instance of the synchronous SpecialWordsClient type. + */ +@ServiceClient(builder = SpecialWordsClientBuilder.class) +public final class ModelPropertiesClient { + @Generated + private final ModelPropertiesImpl serviceClient; + + /** + * Initializes an instance of ModelPropertiesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelPropertiesClient(ModelPropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The sameAsModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     SameAsModel: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 sameAsModelWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.sameAsModelWithResponse(body, requestOptions); + } + + /** + * The sameAsModel operation. + * + * @param body The body 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 sameAsModel(SameAsModel body) { + // Generated convenience method for sameAsModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + sameAsModelWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ModelsAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ModelsAsyncClient.java new file mode 100644 index 000000000..8636aae08 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ModelsAsyncClient.java @@ -0,0 +1,1524 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords; + +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 com.specialwords.implementation.ModelsImpl; +import com.specialwords.models.And; +import com.specialwords.models.As; +import com.specialwords.models.Assert; +import com.specialwords.models.Async; +import com.specialwords.models.Await; +import com.specialwords.models.Break; +import com.specialwords.models.ClassModel; +import com.specialwords.models.Constructor; +import com.specialwords.models.Continue; +import com.specialwords.models.Def; +import com.specialwords.models.Del; +import com.specialwords.models.Elif; +import com.specialwords.models.Else; +import com.specialwords.models.Except; +import com.specialwords.models.Exec; +import com.specialwords.models.Finally; +import com.specialwords.models.For; +import com.specialwords.models.From; +import com.specialwords.models.Global; +import com.specialwords.models.If; +import com.specialwords.models.Import; +import com.specialwords.models.In; +import com.specialwords.models.Is; +import com.specialwords.models.Lambda; +import com.specialwords.models.Not; +import com.specialwords.models.Or; +import com.specialwords.models.Pass; +import com.specialwords.models.Raise; +import com.specialwords.models.Return; +import com.specialwords.models.Try; +import com.specialwords.models.While; +import com.specialwords.models.With; +import com.specialwords.models.Yield; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SpecialWordsClient type. + */ +@ServiceClient(builder = SpecialWordsClientBuilder.class, isAsync = true) +public final class ModelsAsyncClient { + @Generated + private final ModelsImpl serviceClient; + + /** + * Initializes an instance of ModelsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelsAsyncClient(ModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withAnd operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withAndWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAndWithResponseAsync(body, requestOptions); + } + + /** + * The withAs operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withAsWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAsWithResponseAsync(body, requestOptions); + } + + /** + * The withAssert operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withAssertWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAssertWithResponseAsync(body, requestOptions); + } + + /** + * The withAsync operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withAsyncWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAsyncWithResponseAsync(body, requestOptions); + } + + /** + * The withAwait operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withAwaitWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAwaitWithResponseAsync(body, requestOptions); + } + + /** + * The withBreak operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withBreakWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withBreakWithResponseAsync(body, requestOptions); + } + + /** + * The withClass operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withClassWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withClassWithResponseAsync(body, requestOptions); + } + + /** + * The withConstructor operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withConstructorWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withConstructorWithResponseAsync(body, requestOptions); + } + + /** + * The withContinue operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withContinueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withContinueWithResponseAsync(body, requestOptions); + } + + /** + * The withDef operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withDefWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withDefWithResponseAsync(body, requestOptions); + } + + /** + * The withDel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withDelWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withDelWithResponseAsync(body, requestOptions); + } + + /** + * The withElif operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withElifWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withElifWithResponseAsync(body, requestOptions); + } + + /** + * The withElse operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withElseWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withElseWithResponseAsync(body, requestOptions); + } + + /** + * The withExcept operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withExceptWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withExceptWithResponseAsync(body, requestOptions); + } + + /** + * The withExec operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withExecWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withExecWithResponseAsync(body, requestOptions); + } + + /** + * The withFinally operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withFinallyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withFinallyWithResponseAsync(body, requestOptions); + } + + /** + * The withFor operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withForWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withForWithResponseAsync(body, requestOptions); + } + + /** + * The withFrom operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withFromWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withFromWithResponseAsync(body, requestOptions); + } + + /** + * The withGlobal operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withGlobalWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withGlobalWithResponseAsync(body, requestOptions); + } + + /** + * The withIf operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withIfWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withIfWithResponseAsync(body, requestOptions); + } + + /** + * The withImport operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withImportWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withImportWithResponseAsync(body, requestOptions); + } + + /** + * The withIn operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withInWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withInWithResponseAsync(body, requestOptions); + } + + /** + * The withIs operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withIsWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withIsWithResponseAsync(body, requestOptions); + } + + /** + * The withLambda operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withLambdaWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withLambdaWithResponseAsync(body, requestOptions); + } + + /** + * The withNot operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withNotWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withNotWithResponseAsync(body, requestOptions); + } + + /** + * The withOr operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withOrWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withOrWithResponseAsync(body, requestOptions); + } + + /** + * The withPass operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withPassWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withPassWithResponseAsync(body, requestOptions); + } + + /** + * The withRaise operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withRaiseWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withRaiseWithResponseAsync(body, requestOptions); + } + + /** + * The withReturn operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withReturnWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withReturnWithResponseAsync(body, requestOptions); + } + + /** + * The withTry operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withTryWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withTryWithResponseAsync(body, requestOptions); + } + + /** + * The withWhile operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withWhileWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withWhileWithResponseAsync(body, requestOptions); + } + + /** + * The withWith operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withWithWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withWithWithResponseAsync(body, requestOptions); + } + + /** + * The withYield operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withYieldWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withYieldWithResponseAsync(body, requestOptions); + } + + /** + * The withAnd operation. + * + * @param body The body 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 withAnd(And body) { + // Generated convenience method for withAndWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withAndWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withAs operation. + * + * @param body The body 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 withAs(As body) { + // Generated convenience method for withAsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withAsWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withAssert operation. + * + * @param body The body 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 withAssert(Assert body) { + // Generated convenience method for withAssertWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withAssertWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withAsync operation. + * + * @param body The body 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 withAsync(Async body) { + // Generated convenience method for withAsyncWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withAsyncWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withAwait operation. + * + * @param body The body 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 withAwait(Await body) { + // Generated convenience method for withAwaitWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withAwaitWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withBreak operation. + * + * @param body The body 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 withBreak(Break body) { + // Generated convenience method for withBreakWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withBreakWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withClass operation. + * + * @param body The body 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 withClass(ClassModel body) { + // Generated convenience method for withClassWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withClassWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withConstructor operation. + * + * @param body The body 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 withConstructor(Constructor body) { + // Generated convenience method for withConstructorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withConstructorWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withContinue operation. + * + * @param body The body 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 withContinue(Continue body) { + // Generated convenience method for withContinueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withContinueWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withDef operation. + * + * @param body The body 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 withDef(Def body) { + // Generated convenience method for withDefWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withDefWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withDel operation. + * + * @param body The body 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 withDel(Del body) { + // Generated convenience method for withDelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withDelWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withElif operation. + * + * @param body The body 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 withElif(Elif body) { + // Generated convenience method for withElifWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withElifWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withElse operation. + * + * @param body The body 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 withElse(Else body) { + // Generated convenience method for withElseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withElseWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withExcept operation. + * + * @param body The body 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 withExcept(Except body) { + // Generated convenience method for withExceptWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withExceptWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withExec operation. + * + * @param body The body 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 withExec(Exec body) { + // Generated convenience method for withExecWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withExecWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withFinally operation. + * + * @param body The body 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 withFinally(Finally body) { + // Generated convenience method for withFinallyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withFinallyWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withFor operation. + * + * @param body The body 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 withFor(For body) { + // Generated convenience method for withForWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withForWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withFrom operation. + * + * @param body The body 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 withFrom(From body) { + // Generated convenience method for withFromWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withFromWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withGlobal operation. + * + * @param body The body 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 withGlobal(Global body) { + // Generated convenience method for withGlobalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withGlobalWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withIf operation. + * + * @param body The body 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 withIf(If body) { + // Generated convenience method for withIfWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withIfWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withImport operation. + * + * @param body The body 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 withImport(Import body) { + // Generated convenience method for withImportWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withImportWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withIn operation. + * + * @param body The body 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 withIn(In body) { + // Generated convenience method for withInWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withInWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withIs operation. + * + * @param body The body 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 withIs(Is body) { + // Generated convenience method for withIsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withIsWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withLambda operation. + * + * @param body The body 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 withLambda(Lambda body) { + // Generated convenience method for withLambdaWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withLambdaWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withNot operation. + * + * @param body The body 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 withNot(Not body) { + // Generated convenience method for withNotWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withNotWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withOr operation. + * + * @param body The body 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 withOr(Or body) { + // Generated convenience method for withOrWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withOrWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withPass operation. + * + * @param body The body 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 withPass(Pass body) { + // Generated convenience method for withPassWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withPassWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withRaise operation. + * + * @param body The body 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 withRaise(Raise body) { + // Generated convenience method for withRaiseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withRaiseWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withReturn operation. + * + * @param body The body 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 withReturn(Return body) { + // Generated convenience method for withReturnWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withReturnWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withTry operation. + * + * @param body The body 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 withTry(Try body) { + // Generated convenience method for withTryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withTryWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withWhile operation. + * + * @param body The body 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 withWhile(While body) { + // Generated convenience method for withWhileWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withWhileWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withWith operation. + * + * @param body The body 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 withWith(With body) { + // Generated convenience method for withWithWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withWithWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withYield operation. + * + * @param body The body 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 withYield(Yield body) { + // Generated convenience method for withYieldWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withYieldWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ModelsClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ModelsClient.java new file mode 100644 index 000000000..9a27855c0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ModelsClient.java @@ -0,0 +1,1489 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords; + +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.specialwords.implementation.ModelsImpl; +import com.specialwords.models.And; +import com.specialwords.models.As; +import com.specialwords.models.Assert; +import com.specialwords.models.Async; +import com.specialwords.models.Await; +import com.specialwords.models.Break; +import com.specialwords.models.ClassModel; +import com.specialwords.models.Constructor; +import com.specialwords.models.Continue; +import com.specialwords.models.Def; +import com.specialwords.models.Del; +import com.specialwords.models.Elif; +import com.specialwords.models.Else; +import com.specialwords.models.Except; +import com.specialwords.models.Exec; +import com.specialwords.models.Finally; +import com.specialwords.models.For; +import com.specialwords.models.From; +import com.specialwords.models.Global; +import com.specialwords.models.If; +import com.specialwords.models.Import; +import com.specialwords.models.In; +import com.specialwords.models.Is; +import com.specialwords.models.Lambda; +import com.specialwords.models.Not; +import com.specialwords.models.Or; +import com.specialwords.models.Pass; +import com.specialwords.models.Raise; +import com.specialwords.models.Return; +import com.specialwords.models.Try; +import com.specialwords.models.While; +import com.specialwords.models.With; +import com.specialwords.models.Yield; + +/** + * Initializes a new instance of the synchronous SpecialWordsClient type. + */ +@ServiceClient(builder = SpecialWordsClientBuilder.class) +public final class ModelsClient { + @Generated + private final ModelsImpl serviceClient; + + /** + * Initializes an instance of ModelsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelsClient(ModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withAnd operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withAndWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAndWithResponse(body, requestOptions); + } + + /** + * The withAs operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withAsWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAsWithResponse(body, requestOptions); + } + + /** + * The withAssert operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withAssertWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAssertWithResponse(body, requestOptions); + } + + /** + * The withAsync operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withAsyncWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAsyncWithResponse(body, requestOptions); + } + + /** + * The withAwait operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withAwaitWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAwaitWithResponse(body, requestOptions); + } + + /** + * The withBreak operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withBreakWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withBreakWithResponse(body, requestOptions); + } + + /** + * The withClass operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withClassWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withClassWithResponse(body, requestOptions); + } + + /** + * The withConstructor operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withConstructorWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withConstructorWithResponse(body, requestOptions); + } + + /** + * The withContinue operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withContinueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withContinueWithResponse(body, requestOptions); + } + + /** + * The withDef operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withDefWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withDefWithResponse(body, requestOptions); + } + + /** + * The withDel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withDelWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withDelWithResponse(body, requestOptions); + } + + /** + * The withElif operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withElifWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withElifWithResponse(body, requestOptions); + } + + /** + * The withElse operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withElseWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withElseWithResponse(body, requestOptions); + } + + /** + * The withExcept operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withExceptWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withExceptWithResponse(body, requestOptions); + } + + /** + * The withExec operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withExecWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withExecWithResponse(body, requestOptions); + } + + /** + * The withFinally operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withFinallyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withFinallyWithResponse(body, requestOptions); + } + + /** + * The withFor operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withForWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withForWithResponse(body, requestOptions); + } + + /** + * The withFrom operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withFromWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withFromWithResponse(body, requestOptions); + } + + /** + * The withGlobal operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withGlobalWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withGlobalWithResponse(body, requestOptions); + } + + /** + * The withIf operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withIfWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withIfWithResponse(body, requestOptions); + } + + /** + * The withImport operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withImportWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withImportWithResponse(body, requestOptions); + } + + /** + * The withIn operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withInWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withInWithResponse(body, requestOptions); + } + + /** + * The withIs operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withIsWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withIsWithResponse(body, requestOptions); + } + + /** + * The withLambda operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withLambdaWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withLambdaWithResponse(body, requestOptions); + } + + /** + * The withNot operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withNotWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withNotWithResponse(body, requestOptions); + } + + /** + * The withOr operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withOrWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withOrWithResponse(body, requestOptions); + } + + /** + * The withPass operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withPassWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withPassWithResponse(body, requestOptions); + } + + /** + * The withRaise operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withRaiseWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withRaiseWithResponse(body, requestOptions); + } + + /** + * The withReturn operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withReturnWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withReturnWithResponse(body, requestOptions); + } + + /** + * The withTry operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withTryWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withTryWithResponse(body, requestOptions); + } + + /** + * The withWhile operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withWhileWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withWhileWithResponse(body, requestOptions); + } + + /** + * The withWith operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withWithWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withWithWithResponse(body, requestOptions); + } + + /** + * The withYield operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withYieldWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withYieldWithResponse(body, requestOptions); + } + + /** + * The withAnd operation. + * + * @param body The body 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 withAnd(And body) { + // Generated convenience method for withAndWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAndWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withAs operation. + * + * @param body The body 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 withAs(As body) { + // Generated convenience method for withAsWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAsWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withAssert operation. + * + * @param body The body 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 withAssert(Assert body) { + // Generated convenience method for withAssertWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAssertWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withAsync operation. + * + * @param body The body 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 withAsync(Async body) { + // Generated convenience method for withAsyncWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAsyncWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withAwait operation. + * + * @param body The body 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 withAwait(Await body) { + // Generated convenience method for withAwaitWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAwaitWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withBreak operation. + * + * @param body The body 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 withBreak(Break body) { + // Generated convenience method for withBreakWithResponse + RequestOptions requestOptions = new RequestOptions(); + withBreakWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withClass operation. + * + * @param body The body 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 withClass(ClassModel body) { + // Generated convenience method for withClassWithResponse + RequestOptions requestOptions = new RequestOptions(); + withClassWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withConstructor operation. + * + * @param body The body 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 withConstructor(Constructor body) { + // Generated convenience method for withConstructorWithResponse + RequestOptions requestOptions = new RequestOptions(); + withConstructorWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withContinue operation. + * + * @param body The body 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 withContinue(Continue body) { + // Generated convenience method for withContinueWithResponse + RequestOptions requestOptions = new RequestOptions(); + withContinueWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withDef operation. + * + * @param body The body 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 withDef(Def body) { + // Generated convenience method for withDefWithResponse + RequestOptions requestOptions = new RequestOptions(); + withDefWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withDel operation. + * + * @param body The body 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 withDel(Del body) { + // Generated convenience method for withDelWithResponse + RequestOptions requestOptions = new RequestOptions(); + withDelWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withElif operation. + * + * @param body The body 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 withElif(Elif body) { + // Generated convenience method for withElifWithResponse + RequestOptions requestOptions = new RequestOptions(); + withElifWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withElse operation. + * + * @param body The body 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 withElse(Else body) { + // Generated convenience method for withElseWithResponse + RequestOptions requestOptions = new RequestOptions(); + withElseWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withExcept operation. + * + * @param body The body 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 withExcept(Except body) { + // Generated convenience method for withExceptWithResponse + RequestOptions requestOptions = new RequestOptions(); + withExceptWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withExec operation. + * + * @param body The body 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 withExec(Exec body) { + // Generated convenience method for withExecWithResponse + RequestOptions requestOptions = new RequestOptions(); + withExecWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withFinally operation. + * + * @param body The body 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 withFinally(Finally body) { + // Generated convenience method for withFinallyWithResponse + RequestOptions requestOptions = new RequestOptions(); + withFinallyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withFor operation. + * + * @param body The body 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 withFor(For body) { + // Generated convenience method for withForWithResponse + RequestOptions requestOptions = new RequestOptions(); + withForWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withFrom operation. + * + * @param body The body 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 withFrom(From body) { + // Generated convenience method for withFromWithResponse + RequestOptions requestOptions = new RequestOptions(); + withFromWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withGlobal operation. + * + * @param body The body 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 withGlobal(Global body) { + // Generated convenience method for withGlobalWithResponse + RequestOptions requestOptions = new RequestOptions(); + withGlobalWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withIf operation. + * + * @param body The body 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 withIf(If body) { + // Generated convenience method for withIfWithResponse + RequestOptions requestOptions = new RequestOptions(); + withIfWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withImport operation. + * + * @param body The body 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 withImport(Import body) { + // Generated convenience method for withImportWithResponse + RequestOptions requestOptions = new RequestOptions(); + withImportWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withIn operation. + * + * @param body The body 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 withIn(In body) { + // Generated convenience method for withInWithResponse + RequestOptions requestOptions = new RequestOptions(); + withInWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withIs operation. + * + * @param body The body 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 withIs(Is body) { + // Generated convenience method for withIsWithResponse + RequestOptions requestOptions = new RequestOptions(); + withIsWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withLambda operation. + * + * @param body The body 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 withLambda(Lambda body) { + // Generated convenience method for withLambdaWithResponse + RequestOptions requestOptions = new RequestOptions(); + withLambdaWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withNot operation. + * + * @param body The body 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 withNot(Not body) { + // Generated convenience method for withNotWithResponse + RequestOptions requestOptions = new RequestOptions(); + withNotWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withOr operation. + * + * @param body The body 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 withOr(Or body) { + // Generated convenience method for withOrWithResponse + RequestOptions requestOptions = new RequestOptions(); + withOrWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withPass operation. + * + * @param body The body 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 withPass(Pass body) { + // Generated convenience method for withPassWithResponse + RequestOptions requestOptions = new RequestOptions(); + withPassWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withRaise operation. + * + * @param body The body 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 withRaise(Raise body) { + // Generated convenience method for withRaiseWithResponse + RequestOptions requestOptions = new RequestOptions(); + withRaiseWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withReturn operation. + * + * @param body The body 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 withReturn(Return body) { + // Generated convenience method for withReturnWithResponse + RequestOptions requestOptions = new RequestOptions(); + withReturnWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withTry operation. + * + * @param body The body 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 withTry(Try body) { + // Generated convenience method for withTryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withTryWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withWhile operation. + * + * @param body The body 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 withWhile(While body) { + // Generated convenience method for withWhileWithResponse + RequestOptions requestOptions = new RequestOptions(); + withWhileWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withWith operation. + * + * @param body The body 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 withWith(With body) { + // Generated convenience method for withWithWithResponse + RequestOptions requestOptions = new RequestOptions(); + withWithWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withYield operation. + * + * @param body The body 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 withYield(Yield body) { + // Generated convenience method for withYieldWithResponse + RequestOptions requestOptions = new RequestOptions(); + withYieldWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/OperationsAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/OperationsAsyncClient.java new file mode 100644 index 000000000..3c6608b44 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/OperationsAsyncClient.java @@ -0,0 +1,1160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords; + +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 com.specialwords.implementation.OperationsImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SpecialWordsClient type. + */ +@ServiceClient(builder = SpecialWordsClientBuilder.class, isAsync = true) +public final class OperationsAsyncClient { + @Generated + private final OperationsImpl serviceClient; + + /** + * Initializes an instance of OperationsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + OperationsAsyncClient(OperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The and operation. + * + * @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> andWithResponse(RequestOptions requestOptions) { + return this.serviceClient.andWithResponseAsync(requestOptions); + } + + /** + * The as operation. + * + * @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> asWithResponse(RequestOptions requestOptions) { + return this.serviceClient.asWithResponseAsync(requestOptions); + } + + /** + * The assertMethod operation. + * + * @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> assertMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.assertMethodWithResponseAsync(requestOptions); + } + + /** + * The async operation. + * + * @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> asyncWithResponse(RequestOptions requestOptions) { + return this.serviceClient.asyncWithResponseAsync(requestOptions); + } + + /** + * The await operation. + * + * @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> awaitWithResponse(RequestOptions requestOptions) { + return this.serviceClient.awaitWithResponseAsync(requestOptions); + } + + /** + * The breakMethod operation. + * + * @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> breakMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.breakMethodWithResponseAsync(requestOptions); + } + + /** + * The classMethod operation. + * + * @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> classMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.classMethodWithResponseAsync(requestOptions); + } + + /** + * The constructor operation. + * + * @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> constructorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.constructorWithResponseAsync(requestOptions); + } + + /** + * The continueMethod operation. + * + * @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> continueMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.continueMethodWithResponseAsync(requestOptions); + } + + /** + * The def operation. + * + * @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> defWithResponse(RequestOptions requestOptions) { + return this.serviceClient.defWithResponseAsync(requestOptions); + } + + /** + * The del operation. + * + * @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> delWithResponse(RequestOptions requestOptions) { + return this.serviceClient.delWithResponseAsync(requestOptions); + } + + /** + * The elif operation. + * + * @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> elifWithResponse(RequestOptions requestOptions) { + return this.serviceClient.elifWithResponseAsync(requestOptions); + } + + /** + * The elseMethod operation. + * + * @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> elseMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.elseMethodWithResponseAsync(requestOptions); + } + + /** + * The except operation. + * + * @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> exceptWithResponse(RequestOptions requestOptions) { + return this.serviceClient.exceptWithResponseAsync(requestOptions); + } + + /** + * The exec operation. + * + * @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> execWithResponse(RequestOptions requestOptions) { + return this.serviceClient.execWithResponseAsync(requestOptions); + } + + /** + * The finallyMethod operation. + * + * @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> finallyMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.finallyMethodWithResponseAsync(requestOptions); + } + + /** + * The forMethod operation. + * + * @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> forMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.forMethodWithResponseAsync(requestOptions); + } + + /** + * The from operation. + * + * @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> fromWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fromWithResponseAsync(requestOptions); + } + + /** + * The global operation. + * + * @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> globalWithResponse(RequestOptions requestOptions) { + return this.serviceClient.globalWithResponseAsync(requestOptions); + } + + /** + * The ifMethod operation. + * + * @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> ifMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.ifMethodWithResponseAsync(requestOptions); + } + + /** + * The importMethod operation. + * + * @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> importMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.importMethodWithResponseAsync(requestOptions); + } + + /** + * The in operation. + * + * @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> inWithResponse(RequestOptions requestOptions) { + return this.serviceClient.inWithResponseAsync(requestOptions); + } + + /** + * The is operation. + * + * @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> isWithResponse(RequestOptions requestOptions) { + return this.serviceClient.isWithResponseAsync(requestOptions); + } + + /** + * The lambda operation. + * + * @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> lambdaWithResponse(RequestOptions requestOptions) { + return this.serviceClient.lambdaWithResponseAsync(requestOptions); + } + + /** + * The not operation. + * + * @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> notWithResponse(RequestOptions requestOptions) { + return this.serviceClient.notWithResponseAsync(requestOptions); + } + + /** + * The or operation. + * + * @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> orWithResponse(RequestOptions requestOptions) { + return this.serviceClient.orWithResponseAsync(requestOptions); + } + + /** + * The pass operation. + * + * @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> passWithResponse(RequestOptions requestOptions) { + return this.serviceClient.passWithResponseAsync(requestOptions); + } + + /** + * The raise operation. + * + * @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> raiseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.raiseWithResponseAsync(requestOptions); + } + + /** + * The returnMethod operation. + * + * @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> returnMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.returnMethodWithResponseAsync(requestOptions); + } + + /** + * The tryMethod operation. + * + * @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> tryMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.tryMethodWithResponseAsync(requestOptions); + } + + /** + * The whileMethod operation. + * + * @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> whileMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.whileMethodWithResponseAsync(requestOptions); + } + + /** + * The with operation. + * + * @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> withWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withWithResponseAsync(requestOptions); + } + + /** + * The yield operation. + * + * @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> yieldWithResponse(RequestOptions requestOptions) { + return this.serviceClient.yieldWithResponseAsync(requestOptions); + } + + /** + * The and 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono and() { + // Generated convenience method for andWithResponse + RequestOptions requestOptions = new RequestOptions(); + return andWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The as 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono as() { + // Generated convenience method for asWithResponse + RequestOptions requestOptions = new RequestOptions(); + return asWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The assertMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono assertMethod() { + // Generated convenience method for assertMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return assertMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The async 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono async() { + // Generated convenience method for asyncWithResponse + RequestOptions requestOptions = new RequestOptions(); + return asyncWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The await 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono await() { + // Generated convenience method for awaitWithResponse + RequestOptions requestOptions = new RequestOptions(); + return awaitWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The breakMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono breakMethod() { + // Generated convenience method for breakMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return breakMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The classMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono classMethod() { + // Generated convenience method for classMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return classMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The constructor 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono constructor() { + // Generated convenience method for constructorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return constructorWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The continueMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono continueMethod() { + // Generated convenience method for continueMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return continueMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The def 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono def() { + // Generated convenience method for defWithResponse + RequestOptions requestOptions = new RequestOptions(); + return defWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The del 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono del() { + // Generated convenience method for delWithResponse + RequestOptions requestOptions = new RequestOptions(); + return delWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The elif 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono elif() { + // Generated convenience method for elifWithResponse + RequestOptions requestOptions = new RequestOptions(); + return elifWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The elseMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono elseMethod() { + // Generated convenience method for elseMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return elseMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The except 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono except() { + // Generated convenience method for exceptWithResponse + RequestOptions requestOptions = new RequestOptions(); + return exceptWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The exec 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono exec() { + // Generated convenience method for execWithResponse + RequestOptions requestOptions = new RequestOptions(); + return execWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The finallyMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono finallyMethod() { + // Generated convenience method for finallyMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return finallyMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The forMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono forMethod() { + // Generated convenience method for forMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return forMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The from 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono from() { + // Generated convenience method for fromWithResponse + RequestOptions requestOptions = new RequestOptions(); + return fromWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The global 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono global() { + // Generated convenience method for globalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return globalWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The ifMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono ifMethod() { + // Generated convenience method for ifMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return ifMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The importMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono importMethod() { + // Generated convenience method for importMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return importMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The in 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono in() { + // Generated convenience method for inWithResponse + RequestOptions requestOptions = new RequestOptions(); + return inWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The is 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono is() { + // Generated convenience method for isWithResponse + RequestOptions requestOptions = new RequestOptions(); + return isWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The lambda 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono lambda() { + // Generated convenience method for lambdaWithResponse + RequestOptions requestOptions = new RequestOptions(); + return lambdaWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The not 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono not() { + // Generated convenience method for notWithResponse + RequestOptions requestOptions = new RequestOptions(); + return notWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The or 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono or() { + // Generated convenience method for orWithResponse + RequestOptions requestOptions = new RequestOptions(); + return orWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The pass 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono pass() { + // Generated convenience method for passWithResponse + RequestOptions requestOptions = new RequestOptions(); + return passWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The raise 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono raise() { + // Generated convenience method for raiseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return raiseWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The returnMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono returnMethod() { + // Generated convenience method for returnMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return returnMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The tryMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono tryMethod() { + // Generated convenience method for tryMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return tryMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The whileMethod 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono whileMethod() { + // Generated convenience method for whileMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + return whileMethodWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The with 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono with() { + // Generated convenience method for withWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The yield 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 {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono yield() { + // Generated convenience method for yieldWithResponse + RequestOptions requestOptions = new RequestOptions(); + return yieldWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/OperationsClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/OperationsClient.java new file mode 100644 index 000000000..26bc4dbd1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/OperationsClient.java @@ -0,0 +1,1125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords; + +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.specialwords.implementation.OperationsImpl; + +/** + * Initializes a new instance of the synchronous SpecialWordsClient type. + */ +@ServiceClient(builder = SpecialWordsClientBuilder.class) +public final class OperationsClient { + @Generated + private final OperationsImpl serviceClient; + + /** + * Initializes an instance of OperationsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + OperationsClient(OperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The and operation. + * + * @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 andWithResponse(RequestOptions requestOptions) { + return this.serviceClient.andWithResponse(requestOptions); + } + + /** + * The as operation. + * + * @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 asWithResponse(RequestOptions requestOptions) { + return this.serviceClient.asWithResponse(requestOptions); + } + + /** + * The assertMethod operation. + * + * @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 assertMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.assertMethodWithResponse(requestOptions); + } + + /** + * The async operation. + * + * @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 asyncWithResponse(RequestOptions requestOptions) { + return this.serviceClient.asyncWithResponse(requestOptions); + } + + /** + * The await operation. + * + * @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 awaitWithResponse(RequestOptions requestOptions) { + return this.serviceClient.awaitWithResponse(requestOptions); + } + + /** + * The breakMethod operation. + * + * @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 breakMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.breakMethodWithResponse(requestOptions); + } + + /** + * The classMethod operation. + * + * @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 classMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.classMethodWithResponse(requestOptions); + } + + /** + * The constructor operation. + * + * @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 constructorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.constructorWithResponse(requestOptions); + } + + /** + * The continueMethod operation. + * + * @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 continueMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.continueMethodWithResponse(requestOptions); + } + + /** + * The def operation. + * + * @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 defWithResponse(RequestOptions requestOptions) { + return this.serviceClient.defWithResponse(requestOptions); + } + + /** + * The del operation. + * + * @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 delWithResponse(RequestOptions requestOptions) { + return this.serviceClient.delWithResponse(requestOptions); + } + + /** + * The elif operation. + * + * @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 elifWithResponse(RequestOptions requestOptions) { + return this.serviceClient.elifWithResponse(requestOptions); + } + + /** + * The elseMethod operation. + * + * @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 elseMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.elseMethodWithResponse(requestOptions); + } + + /** + * The except operation. + * + * @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 exceptWithResponse(RequestOptions requestOptions) { + return this.serviceClient.exceptWithResponse(requestOptions); + } + + /** + * The exec operation. + * + * @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 execWithResponse(RequestOptions requestOptions) { + return this.serviceClient.execWithResponse(requestOptions); + } + + /** + * The finallyMethod operation. + * + * @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 finallyMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.finallyMethodWithResponse(requestOptions); + } + + /** + * The forMethod operation. + * + * @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 forMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.forMethodWithResponse(requestOptions); + } + + /** + * The from operation. + * + * @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 fromWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fromWithResponse(requestOptions); + } + + /** + * The global operation. + * + * @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 globalWithResponse(RequestOptions requestOptions) { + return this.serviceClient.globalWithResponse(requestOptions); + } + + /** + * The ifMethod operation. + * + * @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 ifMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.ifMethodWithResponse(requestOptions); + } + + /** + * The importMethod operation. + * + * @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 importMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.importMethodWithResponse(requestOptions); + } + + /** + * The in operation. + * + * @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 inWithResponse(RequestOptions requestOptions) { + return this.serviceClient.inWithResponse(requestOptions); + } + + /** + * The is operation. + * + * @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 isWithResponse(RequestOptions requestOptions) { + return this.serviceClient.isWithResponse(requestOptions); + } + + /** + * The lambda operation. + * + * @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 lambdaWithResponse(RequestOptions requestOptions) { + return this.serviceClient.lambdaWithResponse(requestOptions); + } + + /** + * The not operation. + * + * @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 notWithResponse(RequestOptions requestOptions) { + return this.serviceClient.notWithResponse(requestOptions); + } + + /** + * The or operation. + * + * @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 orWithResponse(RequestOptions requestOptions) { + return this.serviceClient.orWithResponse(requestOptions); + } + + /** + * The pass operation. + * + * @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 passWithResponse(RequestOptions requestOptions) { + return this.serviceClient.passWithResponse(requestOptions); + } + + /** + * The raise operation. + * + * @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 raiseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.raiseWithResponse(requestOptions); + } + + /** + * The returnMethod operation. + * + * @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 returnMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.returnMethodWithResponse(requestOptions); + } + + /** + * The tryMethod operation. + * + * @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 tryMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.tryMethodWithResponse(requestOptions); + } + + /** + * The whileMethod operation. + * + * @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 whileMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.whileMethodWithResponse(requestOptions); + } + + /** + * The with operation. + * + * @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 withWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withWithResponse(requestOptions); + } + + /** + * The yield operation. + * + * @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 yieldWithResponse(RequestOptions requestOptions) { + return this.serviceClient.yieldWithResponse(requestOptions); + } + + /** + * The and 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void and() { + // Generated convenience method for andWithResponse + RequestOptions requestOptions = new RequestOptions(); + andWithResponse(requestOptions).getValue(); + } + + /** + * The as 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void as() { + // Generated convenience method for asWithResponse + RequestOptions requestOptions = new RequestOptions(); + asWithResponse(requestOptions).getValue(); + } + + /** + * The assertMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void assertMethod() { + // Generated convenience method for assertMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + assertMethodWithResponse(requestOptions).getValue(); + } + + /** + * The async 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void async() { + // Generated convenience method for asyncWithResponse + RequestOptions requestOptions = new RequestOptions(); + asyncWithResponse(requestOptions).getValue(); + } + + /** + * The await 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void await() { + // Generated convenience method for awaitWithResponse + RequestOptions requestOptions = new RequestOptions(); + awaitWithResponse(requestOptions).getValue(); + } + + /** + * The breakMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void breakMethod() { + // Generated convenience method for breakMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + breakMethodWithResponse(requestOptions).getValue(); + } + + /** + * The classMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void classMethod() { + // Generated convenience method for classMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + classMethodWithResponse(requestOptions).getValue(); + } + + /** + * The constructor 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void constructor() { + // Generated convenience method for constructorWithResponse + RequestOptions requestOptions = new RequestOptions(); + constructorWithResponse(requestOptions).getValue(); + } + + /** + * The continueMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void continueMethod() { + // Generated convenience method for continueMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + continueMethodWithResponse(requestOptions).getValue(); + } + + /** + * The def 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void def() { + // Generated convenience method for defWithResponse + RequestOptions requestOptions = new RequestOptions(); + defWithResponse(requestOptions).getValue(); + } + + /** + * The del 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void del() { + // Generated convenience method for delWithResponse + RequestOptions requestOptions = new RequestOptions(); + delWithResponse(requestOptions).getValue(); + } + + /** + * The elif 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void elif() { + // Generated convenience method for elifWithResponse + RequestOptions requestOptions = new RequestOptions(); + elifWithResponse(requestOptions).getValue(); + } + + /** + * The elseMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void elseMethod() { + // Generated convenience method for elseMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + elseMethodWithResponse(requestOptions).getValue(); + } + + /** + * The except 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void except() { + // Generated convenience method for exceptWithResponse + RequestOptions requestOptions = new RequestOptions(); + exceptWithResponse(requestOptions).getValue(); + } + + /** + * The exec 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void exec() { + // Generated convenience method for execWithResponse + RequestOptions requestOptions = new RequestOptions(); + execWithResponse(requestOptions).getValue(); + } + + /** + * The finallyMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void finallyMethod() { + // Generated convenience method for finallyMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + finallyMethodWithResponse(requestOptions).getValue(); + } + + /** + * The forMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void forMethod() { + // Generated convenience method for forMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + forMethodWithResponse(requestOptions).getValue(); + } + + /** + * The from 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void from() { + // Generated convenience method for fromWithResponse + RequestOptions requestOptions = new RequestOptions(); + fromWithResponse(requestOptions).getValue(); + } + + /** + * The global 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void global() { + // Generated convenience method for globalWithResponse + RequestOptions requestOptions = new RequestOptions(); + globalWithResponse(requestOptions).getValue(); + } + + /** + * The ifMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void ifMethod() { + // Generated convenience method for ifMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + ifMethodWithResponse(requestOptions).getValue(); + } + + /** + * The importMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void importMethod() { + // Generated convenience method for importMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + importMethodWithResponse(requestOptions).getValue(); + } + + /** + * The in 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void in() { + // Generated convenience method for inWithResponse + RequestOptions requestOptions = new RequestOptions(); + inWithResponse(requestOptions).getValue(); + } + + /** + * The is 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void is() { + // Generated convenience method for isWithResponse + RequestOptions requestOptions = new RequestOptions(); + isWithResponse(requestOptions).getValue(); + } + + /** + * The lambda 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void lambda() { + // Generated convenience method for lambdaWithResponse + RequestOptions requestOptions = new RequestOptions(); + lambdaWithResponse(requestOptions).getValue(); + } + + /** + * The not 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void not() { + // Generated convenience method for notWithResponse + RequestOptions requestOptions = new RequestOptions(); + notWithResponse(requestOptions).getValue(); + } + + /** + * The or 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void or() { + // Generated convenience method for orWithResponse + RequestOptions requestOptions = new RequestOptions(); + orWithResponse(requestOptions).getValue(); + } + + /** + * The pass 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void pass() { + // Generated convenience method for passWithResponse + RequestOptions requestOptions = new RequestOptions(); + passWithResponse(requestOptions).getValue(); + } + + /** + * The raise 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void raise() { + // Generated convenience method for raiseWithResponse + RequestOptions requestOptions = new RequestOptions(); + raiseWithResponse(requestOptions).getValue(); + } + + /** + * The returnMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void returnMethod() { + // Generated convenience method for returnMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + returnMethodWithResponse(requestOptions).getValue(); + } + + /** + * The tryMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void tryMethod() { + // Generated convenience method for tryMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + tryMethodWithResponse(requestOptions).getValue(); + } + + /** + * The whileMethod 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void whileMethod() { + // Generated convenience method for whileMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + whileMethodWithResponse(requestOptions).getValue(); + } + + /** + * The with 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void with() { + // Generated convenience method for withWithResponse + RequestOptions requestOptions = new RequestOptions(); + withWithResponse(requestOptions).getValue(); + } + + /** + * The yield 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void yield() { + // Generated convenience method for yieldWithResponse + RequestOptions requestOptions = new RequestOptions(); + yieldWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ParametersAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ParametersAsyncClient.java new file mode 100644 index 000000000..458637eb9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ParametersAsyncClient.java @@ -0,0 +1,1297 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords; + +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 com.specialwords.implementation.ParametersImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SpecialWordsClient type. + */ +@ServiceClient(builder = SpecialWordsClientBuilder.class, isAsync = true) +public final class ParametersAsyncClient { + @Generated + private final ParametersImpl serviceClient; + + /** + * Initializes an instance of ParametersAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ParametersAsyncClient(ParametersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withAnd operation. + * + * @param and The and 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> withAndWithResponse(String and, RequestOptions requestOptions) { + return this.serviceClient.withAndWithResponseAsync(and, requestOptions); + } + + /** + * The withAs operation. + * + * @param as The as 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> withAsWithResponse(String as, RequestOptions requestOptions) { + return this.serviceClient.withAsWithResponseAsync(as, requestOptions); + } + + /** + * The withAssert operation. + * + * @param assertParameter The assertParameter 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> withAssertWithResponse(String assertParameter, RequestOptions requestOptions) { + return this.serviceClient.withAssertWithResponseAsync(assertParameter, requestOptions); + } + + /** + * The withAsync operation. + * + * @param async The async 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> withAsyncWithResponse(String async, RequestOptions requestOptions) { + return this.serviceClient.withAsyncWithResponseAsync(async, requestOptions); + } + + /** + * The withAwait operation. + * + * @param await The await 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> withAwaitWithResponse(String await, RequestOptions requestOptions) { + return this.serviceClient.withAwaitWithResponseAsync(await, requestOptions); + } + + /** + * The withBreak operation. + * + * @param breakParameter The breakParameter 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> withBreakWithResponse(String breakParameter, RequestOptions requestOptions) { + return this.serviceClient.withBreakWithResponseAsync(breakParameter, requestOptions); + } + + /** + * The withClass operation. + * + * @param classParameter The classParameter 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> withClassWithResponse(String classParameter, RequestOptions requestOptions) { + return this.serviceClient.withClassWithResponseAsync(classParameter, requestOptions); + } + + /** + * The withConstructor operation. + * + * @param constructor The constructor 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> withConstructorWithResponse(String constructor, RequestOptions requestOptions) { + return this.serviceClient.withConstructorWithResponseAsync(constructor, requestOptions); + } + + /** + * The withContinue operation. + * + * @param continueParameter The continueParameter 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> withContinueWithResponse(String continueParameter, RequestOptions requestOptions) { + return this.serviceClient.withContinueWithResponseAsync(continueParameter, requestOptions); + } + + /** + * The withDef operation. + * + * @param def The def 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> withDefWithResponse(String def, RequestOptions requestOptions) { + return this.serviceClient.withDefWithResponseAsync(def, requestOptions); + } + + /** + * The withDel operation. + * + * @param del The del 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> withDelWithResponse(String del, RequestOptions requestOptions) { + return this.serviceClient.withDelWithResponseAsync(del, requestOptions); + } + + /** + * The withElif operation. + * + * @param elif The elif 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> withElifWithResponse(String elif, RequestOptions requestOptions) { + return this.serviceClient.withElifWithResponseAsync(elif, requestOptions); + } + + /** + * The withElse operation. + * + * @param elseParameter The elseParameter 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> withElseWithResponse(String elseParameter, RequestOptions requestOptions) { + return this.serviceClient.withElseWithResponseAsync(elseParameter, requestOptions); + } + + /** + * The withExcept operation. + * + * @param except The except 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> withExceptWithResponse(String except, RequestOptions requestOptions) { + return this.serviceClient.withExceptWithResponseAsync(except, requestOptions); + } + + /** + * The withExec operation. + * + * @param exec The exec 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> withExecWithResponse(String exec, RequestOptions requestOptions) { + return this.serviceClient.withExecWithResponseAsync(exec, requestOptions); + } + + /** + * The withFinally operation. + * + * @param finallyParameter The finallyParameter 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> withFinallyWithResponse(String finallyParameter, RequestOptions requestOptions) { + return this.serviceClient.withFinallyWithResponseAsync(finallyParameter, requestOptions); + } + + /** + * The withFor operation. + * + * @param forParameter The forParameter 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> withForWithResponse(String forParameter, RequestOptions requestOptions) { + return this.serviceClient.withForWithResponseAsync(forParameter, requestOptions); + } + + /** + * The withFrom operation. + * + * @param from The from 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> withFromWithResponse(String from, RequestOptions requestOptions) { + return this.serviceClient.withFromWithResponseAsync(from, requestOptions); + } + + /** + * The withGlobal operation. + * + * @param global The global 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> withGlobalWithResponse(String global, RequestOptions requestOptions) { + return this.serviceClient.withGlobalWithResponseAsync(global, requestOptions); + } + + /** + * The withIf operation. + * + * @param ifParameter The ifParameter 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> withIfWithResponse(String ifParameter, RequestOptions requestOptions) { + return this.serviceClient.withIfWithResponseAsync(ifParameter, requestOptions); + } + + /** + * The withImport operation. + * + * @param importParameter The importParameter 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> withImportWithResponse(String importParameter, RequestOptions requestOptions) { + return this.serviceClient.withImportWithResponseAsync(importParameter, requestOptions); + } + + /** + * The withIn operation. + * + * @param in The in 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> withInWithResponse(String in, RequestOptions requestOptions) { + return this.serviceClient.withInWithResponseAsync(in, requestOptions); + } + + /** + * The withIs operation. + * + * @param is The is 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> withIsWithResponse(String is, RequestOptions requestOptions) { + return this.serviceClient.withIsWithResponseAsync(is, requestOptions); + } + + /** + * The withLambda operation. + * + * @param lambda The lambda 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> withLambdaWithResponse(String lambda, RequestOptions requestOptions) { + return this.serviceClient.withLambdaWithResponseAsync(lambda, requestOptions); + } + + /** + * The withNot operation. + * + * @param not The not 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> withNotWithResponse(String not, RequestOptions requestOptions) { + return this.serviceClient.withNotWithResponseAsync(not, requestOptions); + } + + /** + * The withOr operation. + * + * @param or The or 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> withOrWithResponse(String or, RequestOptions requestOptions) { + return this.serviceClient.withOrWithResponseAsync(or, requestOptions); + } + + /** + * The withPass operation. + * + * @param pass The pass 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> withPassWithResponse(String pass, RequestOptions requestOptions) { + return this.serviceClient.withPassWithResponseAsync(pass, requestOptions); + } + + /** + * The withRaise operation. + * + * @param raise The raise 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> withRaiseWithResponse(String raise, RequestOptions requestOptions) { + return this.serviceClient.withRaiseWithResponseAsync(raise, requestOptions); + } + + /** + * The withReturn operation. + * + * @param returnParameter The returnParameter 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> withReturnWithResponse(String returnParameter, RequestOptions requestOptions) { + return this.serviceClient.withReturnWithResponseAsync(returnParameter, requestOptions); + } + + /** + * The withTry operation. + * + * @param tryParameter The tryParameter 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> withTryWithResponse(String tryParameter, RequestOptions requestOptions) { + return this.serviceClient.withTryWithResponseAsync(tryParameter, requestOptions); + } + + /** + * The withWhile operation. + * + * @param whileParameter The whileParameter 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> withWhileWithResponse(String whileParameter, RequestOptions requestOptions) { + return this.serviceClient.withWhileWithResponseAsync(whileParameter, requestOptions); + } + + /** + * The withWith operation. + * + * @param with The with 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> withWithWithResponse(String with, RequestOptions requestOptions) { + return this.serviceClient.withWithWithResponseAsync(with, requestOptions); + } + + /** + * The withYield operation. + * + * @param yield The yield 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> withYieldWithResponse(String yield, RequestOptions requestOptions) { + return this.serviceClient.withYieldWithResponseAsync(yield, requestOptions); + } + + /** + * The withCancellationToken operation. + * + * @param cancellationToken The cancellationToken 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> withCancellationTokenWithResponse(String cancellationToken, + RequestOptions requestOptions) { + return this.serviceClient.withCancellationTokenWithResponseAsync(cancellationToken, requestOptions); + } + + /** + * The withAnd operation. + * + * @param and The and 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 withAnd(String and) { + // Generated convenience method for withAndWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withAndWithResponse(and, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withAs operation. + * + * @param as The as 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 withAs(String as) { + // Generated convenience method for withAsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withAsWithResponse(as, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withAssert operation. + * + * @param assertParameter The assertParameter 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 withAssert(String assertParameter) { + // Generated convenience method for withAssertWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withAssertWithResponse(assertParameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withAsync operation. + * + * @param async The async 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 withAsync(String async) { + // Generated convenience method for withAsyncWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withAsyncWithResponse(async, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withAwait operation. + * + * @param await The await 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 withAwait(String await) { + // Generated convenience method for withAwaitWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withAwaitWithResponse(await, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withBreak operation. + * + * @param breakParameter The breakParameter 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 withBreak(String breakParameter) { + // Generated convenience method for withBreakWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withBreakWithResponse(breakParameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withClass operation. + * + * @param classParameter The classParameter 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 withClass(String classParameter) { + // Generated convenience method for withClassWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withClassWithResponse(classParameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withConstructor operation. + * + * @param constructor The constructor 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 withConstructor(String constructor) { + // Generated convenience method for withConstructorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withConstructorWithResponse(constructor, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withContinue operation. + * + * @param continueParameter The continueParameter 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 withContinue(String continueParameter) { + // Generated convenience method for withContinueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withContinueWithResponse(continueParameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withDef operation. + * + * @param def The def 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 withDef(String def) { + // Generated convenience method for withDefWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withDefWithResponse(def, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withDel operation. + * + * @param del The del 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 withDel(String del) { + // Generated convenience method for withDelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withDelWithResponse(del, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withElif operation. + * + * @param elif The elif 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 withElif(String elif) { + // Generated convenience method for withElifWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withElifWithResponse(elif, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withElse operation. + * + * @param elseParameter The elseParameter 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 withElse(String elseParameter) { + // Generated convenience method for withElseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withElseWithResponse(elseParameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withExcept operation. + * + * @param except The except 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 withExcept(String except) { + // Generated convenience method for withExceptWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withExceptWithResponse(except, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withExec operation. + * + * @param exec The exec 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 withExec(String exec) { + // Generated convenience method for withExecWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withExecWithResponse(exec, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withFinally operation. + * + * @param finallyParameter The finallyParameter 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 withFinally(String finallyParameter) { + // Generated convenience method for withFinallyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withFinallyWithResponse(finallyParameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withFor operation. + * + * @param forParameter The forParameter 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 withFor(String forParameter) { + // Generated convenience method for withForWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withForWithResponse(forParameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withFrom operation. + * + * @param from The from 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 withFrom(String from) { + // Generated convenience method for withFromWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withFromWithResponse(from, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withGlobal operation. + * + * @param global The global 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 withGlobal(String global) { + // Generated convenience method for withGlobalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withGlobalWithResponse(global, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withIf operation. + * + * @param ifParameter The ifParameter 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 withIf(String ifParameter) { + // Generated convenience method for withIfWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withIfWithResponse(ifParameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withImport operation. + * + * @param importParameter The importParameter 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 withImport(String importParameter) { + // Generated convenience method for withImportWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withImportWithResponse(importParameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withIn operation. + * + * @param in The in 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 withIn(String in) { + // Generated convenience method for withInWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withInWithResponse(in, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withIs operation. + * + * @param is The is 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 withIs(String is) { + // Generated convenience method for withIsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withIsWithResponse(is, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withLambda operation. + * + * @param lambda The lambda 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 withLambda(String lambda) { + // Generated convenience method for withLambdaWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withLambdaWithResponse(lambda, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withNot operation. + * + * @param not The not 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 withNot(String not) { + // Generated convenience method for withNotWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withNotWithResponse(not, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withOr operation. + * + * @param or The or 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 withOr(String or) { + // Generated convenience method for withOrWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withOrWithResponse(or, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withPass operation. + * + * @param pass The pass 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 withPass(String pass) { + // Generated convenience method for withPassWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withPassWithResponse(pass, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withRaise operation. + * + * @param raise The raise 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 withRaise(String raise) { + // Generated convenience method for withRaiseWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withRaiseWithResponse(raise, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withReturn operation. + * + * @param returnParameter The returnParameter 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 withReturn(String returnParameter) { + // Generated convenience method for withReturnWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withReturnWithResponse(returnParameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withTry operation. + * + * @param tryParameter The tryParameter 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 withTry(String tryParameter) { + // Generated convenience method for withTryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withTryWithResponse(tryParameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withWhile operation. + * + * @param whileParameter The whileParameter 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 withWhile(String whileParameter) { + // Generated convenience method for withWhileWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withWhileWithResponse(whileParameter, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withWith operation. + * + * @param with The with 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 withWith(String with) { + // Generated convenience method for withWithWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withWithWithResponse(with, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withYield operation. + * + * @param yield The yield 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 withYield(String yield) { + // Generated convenience method for withYieldWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withYieldWithResponse(yield, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withCancellationToken operation. + * + * @param cancellationToken The cancellationToken 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 withCancellationToken(String cancellationToken) { + // Generated convenience method for withCancellationTokenWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withCancellationTokenWithResponse(cancellationToken, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ParametersClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ParametersClient.java new file mode 100644 index 000000000..c71cd7a55 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/ParametersClient.java @@ -0,0 +1,1260 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords; + +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.specialwords.implementation.ParametersImpl; + +/** + * Initializes a new instance of the synchronous SpecialWordsClient type. + */ +@ServiceClient(builder = SpecialWordsClientBuilder.class) +public final class ParametersClient { + @Generated + private final ParametersImpl serviceClient; + + /** + * Initializes an instance of ParametersClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ParametersClient(ParametersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withAnd operation. + * + * @param and The and 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 withAndWithResponse(String and, RequestOptions requestOptions) { + return this.serviceClient.withAndWithResponse(and, requestOptions); + } + + /** + * The withAs operation. + * + * @param as The as 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 withAsWithResponse(String as, RequestOptions requestOptions) { + return this.serviceClient.withAsWithResponse(as, requestOptions); + } + + /** + * The withAssert operation. + * + * @param assertParameter The assertParameter 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 withAssertWithResponse(String assertParameter, RequestOptions requestOptions) { + return this.serviceClient.withAssertWithResponse(assertParameter, requestOptions); + } + + /** + * The withAsync operation. + * + * @param async The async 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 withAsyncWithResponse(String async, RequestOptions requestOptions) { + return this.serviceClient.withAsyncWithResponse(async, requestOptions); + } + + /** + * The withAwait operation. + * + * @param await The await 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 withAwaitWithResponse(String await, RequestOptions requestOptions) { + return this.serviceClient.withAwaitWithResponse(await, requestOptions); + } + + /** + * The withBreak operation. + * + * @param breakParameter The breakParameter 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 withBreakWithResponse(String breakParameter, RequestOptions requestOptions) { + return this.serviceClient.withBreakWithResponse(breakParameter, requestOptions); + } + + /** + * The withClass operation. + * + * @param classParameter The classParameter 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 withClassWithResponse(String classParameter, RequestOptions requestOptions) { + return this.serviceClient.withClassWithResponse(classParameter, requestOptions); + } + + /** + * The withConstructor operation. + * + * @param constructor The constructor 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 withConstructorWithResponse(String constructor, RequestOptions requestOptions) { + return this.serviceClient.withConstructorWithResponse(constructor, requestOptions); + } + + /** + * The withContinue operation. + * + * @param continueParameter The continueParameter 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 withContinueWithResponse(String continueParameter, RequestOptions requestOptions) { + return this.serviceClient.withContinueWithResponse(continueParameter, requestOptions); + } + + /** + * The withDef operation. + * + * @param def The def 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 withDefWithResponse(String def, RequestOptions requestOptions) { + return this.serviceClient.withDefWithResponse(def, requestOptions); + } + + /** + * The withDel operation. + * + * @param del The del 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 withDelWithResponse(String del, RequestOptions requestOptions) { + return this.serviceClient.withDelWithResponse(del, requestOptions); + } + + /** + * The withElif operation. + * + * @param elif The elif 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 withElifWithResponse(String elif, RequestOptions requestOptions) { + return this.serviceClient.withElifWithResponse(elif, requestOptions); + } + + /** + * The withElse operation. + * + * @param elseParameter The elseParameter 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 withElseWithResponse(String elseParameter, RequestOptions requestOptions) { + return this.serviceClient.withElseWithResponse(elseParameter, requestOptions); + } + + /** + * The withExcept operation. + * + * @param except The except 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 withExceptWithResponse(String except, RequestOptions requestOptions) { + return this.serviceClient.withExceptWithResponse(except, requestOptions); + } + + /** + * The withExec operation. + * + * @param exec The exec 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 withExecWithResponse(String exec, RequestOptions requestOptions) { + return this.serviceClient.withExecWithResponse(exec, requestOptions); + } + + /** + * The withFinally operation. + * + * @param finallyParameter The finallyParameter 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 withFinallyWithResponse(String finallyParameter, RequestOptions requestOptions) { + return this.serviceClient.withFinallyWithResponse(finallyParameter, requestOptions); + } + + /** + * The withFor operation. + * + * @param forParameter The forParameter 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 withForWithResponse(String forParameter, RequestOptions requestOptions) { + return this.serviceClient.withForWithResponse(forParameter, requestOptions); + } + + /** + * The withFrom operation. + * + * @param from The from 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 withFromWithResponse(String from, RequestOptions requestOptions) { + return this.serviceClient.withFromWithResponse(from, requestOptions); + } + + /** + * The withGlobal operation. + * + * @param global The global 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 withGlobalWithResponse(String global, RequestOptions requestOptions) { + return this.serviceClient.withGlobalWithResponse(global, requestOptions); + } + + /** + * The withIf operation. + * + * @param ifParameter The ifParameter 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 withIfWithResponse(String ifParameter, RequestOptions requestOptions) { + return this.serviceClient.withIfWithResponse(ifParameter, requestOptions); + } + + /** + * The withImport operation. + * + * @param importParameter The importParameter 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 withImportWithResponse(String importParameter, RequestOptions requestOptions) { + return this.serviceClient.withImportWithResponse(importParameter, requestOptions); + } + + /** + * The withIn operation. + * + * @param in The in 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 withInWithResponse(String in, RequestOptions requestOptions) { + return this.serviceClient.withInWithResponse(in, requestOptions); + } + + /** + * The withIs operation. + * + * @param is The is 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 withIsWithResponse(String is, RequestOptions requestOptions) { + return this.serviceClient.withIsWithResponse(is, requestOptions); + } + + /** + * The withLambda operation. + * + * @param lambda The lambda 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 withLambdaWithResponse(String lambda, RequestOptions requestOptions) { + return this.serviceClient.withLambdaWithResponse(lambda, requestOptions); + } + + /** + * The withNot operation. + * + * @param not The not 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 withNotWithResponse(String not, RequestOptions requestOptions) { + return this.serviceClient.withNotWithResponse(not, requestOptions); + } + + /** + * The withOr operation. + * + * @param or The or 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 withOrWithResponse(String or, RequestOptions requestOptions) { + return this.serviceClient.withOrWithResponse(or, requestOptions); + } + + /** + * The withPass operation. + * + * @param pass The pass 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 withPassWithResponse(String pass, RequestOptions requestOptions) { + return this.serviceClient.withPassWithResponse(pass, requestOptions); + } + + /** + * The withRaise operation. + * + * @param raise The raise 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 withRaiseWithResponse(String raise, RequestOptions requestOptions) { + return this.serviceClient.withRaiseWithResponse(raise, requestOptions); + } + + /** + * The withReturn operation. + * + * @param returnParameter The returnParameter 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 withReturnWithResponse(String returnParameter, RequestOptions requestOptions) { + return this.serviceClient.withReturnWithResponse(returnParameter, requestOptions); + } + + /** + * The withTry operation. + * + * @param tryParameter The tryParameter 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 withTryWithResponse(String tryParameter, RequestOptions requestOptions) { + return this.serviceClient.withTryWithResponse(tryParameter, requestOptions); + } + + /** + * The withWhile operation. + * + * @param whileParameter The whileParameter 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 withWhileWithResponse(String whileParameter, RequestOptions requestOptions) { + return this.serviceClient.withWhileWithResponse(whileParameter, requestOptions); + } + + /** + * The withWith operation. + * + * @param with The with 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 withWithWithResponse(String with, RequestOptions requestOptions) { + return this.serviceClient.withWithWithResponse(with, requestOptions); + } + + /** + * The withYield operation. + * + * @param yield The yield 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 withYieldWithResponse(String yield, RequestOptions requestOptions) { + return this.serviceClient.withYieldWithResponse(yield, requestOptions); + } + + /** + * The withCancellationToken operation. + * + * @param cancellationToken The cancellationToken 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 withCancellationTokenWithResponse(String cancellationToken, RequestOptions requestOptions) { + return this.serviceClient.withCancellationTokenWithResponse(cancellationToken, requestOptions); + } + + /** + * The withAnd operation. + * + * @param and The and 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 withAnd(String and) { + // Generated convenience method for withAndWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAndWithResponse(and, requestOptions).getValue(); + } + + /** + * The withAs operation. + * + * @param as The as 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 withAs(String as) { + // Generated convenience method for withAsWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAsWithResponse(as, requestOptions).getValue(); + } + + /** + * The withAssert operation. + * + * @param assertParameter The assertParameter 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 withAssert(String assertParameter) { + // Generated convenience method for withAssertWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAssertWithResponse(assertParameter, requestOptions).getValue(); + } + + /** + * The withAsync operation. + * + * @param async The async 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 withAsync(String async) { + // Generated convenience method for withAsyncWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAsyncWithResponse(async, requestOptions).getValue(); + } + + /** + * The withAwait operation. + * + * @param await The await 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 withAwait(String await) { + // Generated convenience method for withAwaitWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAwaitWithResponse(await, requestOptions).getValue(); + } + + /** + * The withBreak operation. + * + * @param breakParameter The breakParameter 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 withBreak(String breakParameter) { + // Generated convenience method for withBreakWithResponse + RequestOptions requestOptions = new RequestOptions(); + withBreakWithResponse(breakParameter, requestOptions).getValue(); + } + + /** + * The withClass operation. + * + * @param classParameter The classParameter 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 withClass(String classParameter) { + // Generated convenience method for withClassWithResponse + RequestOptions requestOptions = new RequestOptions(); + withClassWithResponse(classParameter, requestOptions).getValue(); + } + + /** + * The withConstructor operation. + * + * @param constructor The constructor 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 withConstructor(String constructor) { + // Generated convenience method for withConstructorWithResponse + RequestOptions requestOptions = new RequestOptions(); + withConstructorWithResponse(constructor, requestOptions).getValue(); + } + + /** + * The withContinue operation. + * + * @param continueParameter The continueParameter 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 withContinue(String continueParameter) { + // Generated convenience method for withContinueWithResponse + RequestOptions requestOptions = new RequestOptions(); + withContinueWithResponse(continueParameter, requestOptions).getValue(); + } + + /** + * The withDef operation. + * + * @param def The def 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 withDef(String def) { + // Generated convenience method for withDefWithResponse + RequestOptions requestOptions = new RequestOptions(); + withDefWithResponse(def, requestOptions).getValue(); + } + + /** + * The withDel operation. + * + * @param del The del 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 withDel(String del) { + // Generated convenience method for withDelWithResponse + RequestOptions requestOptions = new RequestOptions(); + withDelWithResponse(del, requestOptions).getValue(); + } + + /** + * The withElif operation. + * + * @param elif The elif 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 withElif(String elif) { + // Generated convenience method for withElifWithResponse + RequestOptions requestOptions = new RequestOptions(); + withElifWithResponse(elif, requestOptions).getValue(); + } + + /** + * The withElse operation. + * + * @param elseParameter The elseParameter 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 withElse(String elseParameter) { + // Generated convenience method for withElseWithResponse + RequestOptions requestOptions = new RequestOptions(); + withElseWithResponse(elseParameter, requestOptions).getValue(); + } + + /** + * The withExcept operation. + * + * @param except The except 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 withExcept(String except) { + // Generated convenience method for withExceptWithResponse + RequestOptions requestOptions = new RequestOptions(); + withExceptWithResponse(except, requestOptions).getValue(); + } + + /** + * The withExec operation. + * + * @param exec The exec 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 withExec(String exec) { + // Generated convenience method for withExecWithResponse + RequestOptions requestOptions = new RequestOptions(); + withExecWithResponse(exec, requestOptions).getValue(); + } + + /** + * The withFinally operation. + * + * @param finallyParameter The finallyParameter 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 withFinally(String finallyParameter) { + // Generated convenience method for withFinallyWithResponse + RequestOptions requestOptions = new RequestOptions(); + withFinallyWithResponse(finallyParameter, requestOptions).getValue(); + } + + /** + * The withFor operation. + * + * @param forParameter The forParameter 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 withFor(String forParameter) { + // Generated convenience method for withForWithResponse + RequestOptions requestOptions = new RequestOptions(); + withForWithResponse(forParameter, requestOptions).getValue(); + } + + /** + * The withFrom operation. + * + * @param from The from 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 withFrom(String from) { + // Generated convenience method for withFromWithResponse + RequestOptions requestOptions = new RequestOptions(); + withFromWithResponse(from, requestOptions).getValue(); + } + + /** + * The withGlobal operation. + * + * @param global The global 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 withGlobal(String global) { + // Generated convenience method for withGlobalWithResponse + RequestOptions requestOptions = new RequestOptions(); + withGlobalWithResponse(global, requestOptions).getValue(); + } + + /** + * The withIf operation. + * + * @param ifParameter The ifParameter 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 withIf(String ifParameter) { + // Generated convenience method for withIfWithResponse + RequestOptions requestOptions = new RequestOptions(); + withIfWithResponse(ifParameter, requestOptions).getValue(); + } + + /** + * The withImport operation. + * + * @param importParameter The importParameter 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 withImport(String importParameter) { + // Generated convenience method for withImportWithResponse + RequestOptions requestOptions = new RequestOptions(); + withImportWithResponse(importParameter, requestOptions).getValue(); + } + + /** + * The withIn operation. + * + * @param in The in 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 withIn(String in) { + // Generated convenience method for withInWithResponse + RequestOptions requestOptions = new RequestOptions(); + withInWithResponse(in, requestOptions).getValue(); + } + + /** + * The withIs operation. + * + * @param is The is 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 withIs(String is) { + // Generated convenience method for withIsWithResponse + RequestOptions requestOptions = new RequestOptions(); + withIsWithResponse(is, requestOptions).getValue(); + } + + /** + * The withLambda operation. + * + * @param lambda The lambda 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 withLambda(String lambda) { + // Generated convenience method for withLambdaWithResponse + RequestOptions requestOptions = new RequestOptions(); + withLambdaWithResponse(lambda, requestOptions).getValue(); + } + + /** + * The withNot operation. + * + * @param not The not 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 withNot(String not) { + // Generated convenience method for withNotWithResponse + RequestOptions requestOptions = new RequestOptions(); + withNotWithResponse(not, requestOptions).getValue(); + } + + /** + * The withOr operation. + * + * @param or The or 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 withOr(String or) { + // Generated convenience method for withOrWithResponse + RequestOptions requestOptions = new RequestOptions(); + withOrWithResponse(or, requestOptions).getValue(); + } + + /** + * The withPass operation. + * + * @param pass The pass 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 withPass(String pass) { + // Generated convenience method for withPassWithResponse + RequestOptions requestOptions = new RequestOptions(); + withPassWithResponse(pass, requestOptions).getValue(); + } + + /** + * The withRaise operation. + * + * @param raise The raise 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 withRaise(String raise) { + // Generated convenience method for withRaiseWithResponse + RequestOptions requestOptions = new RequestOptions(); + withRaiseWithResponse(raise, requestOptions).getValue(); + } + + /** + * The withReturn operation. + * + * @param returnParameter The returnParameter 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 withReturn(String returnParameter) { + // Generated convenience method for withReturnWithResponse + RequestOptions requestOptions = new RequestOptions(); + withReturnWithResponse(returnParameter, requestOptions).getValue(); + } + + /** + * The withTry operation. + * + * @param tryParameter The tryParameter 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 withTry(String tryParameter) { + // Generated convenience method for withTryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withTryWithResponse(tryParameter, requestOptions).getValue(); + } + + /** + * The withWhile operation. + * + * @param whileParameter The whileParameter 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 withWhile(String whileParameter) { + // Generated convenience method for withWhileWithResponse + RequestOptions requestOptions = new RequestOptions(); + withWhileWithResponse(whileParameter, requestOptions).getValue(); + } + + /** + * The withWith operation. + * + * @param with The with 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 withWith(String with) { + // Generated convenience method for withWithWithResponse + RequestOptions requestOptions = new RequestOptions(); + withWithWithResponse(with, requestOptions).getValue(); + } + + /** + * The withYield operation. + * + * @param yield The yield 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 withYield(String yield) { + // Generated convenience method for withYieldWithResponse + RequestOptions requestOptions = new RequestOptions(); + withYieldWithResponse(yield, requestOptions).getValue(); + } + + /** + * The withCancellationToken operation. + * + * @param cancellationToken The cancellationToken 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 withCancellationToken(String cancellationToken) { + // Generated convenience method for withCancellationTokenWithResponse + RequestOptions requestOptions = new RequestOptions(); + withCancellationTokenWithResponse(cancellationToken, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/SpecialWordsClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/SpecialWordsClientBuilder.java new file mode 100644 index 000000000..5dce7abed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/SpecialWordsClientBuilder.java @@ -0,0 +1,356 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.specialwords.implementation.SpecialWordsClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the SpecialWordsClient type. + */ +@ServiceClientBuilder( + serviceClients = { + ModelsClient.class, + ModelPropertiesClient.class, + OperationsClient.class, + ParametersClient.class, + ModelsAsyncClient.class, + ModelPropertiesAsyncClient.class, + OperationsAsyncClient.class, + ParametersAsyncClient.class }) +public final class SpecialWordsClientBuilder 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("specialwords.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the SpecialWordsClientBuilder. + */ + @Generated + public SpecialWordsClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialWordsClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialWordsClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialWordsClientBuilder 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 SpecialWordsClientBuilder 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 SpecialWordsClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialWordsClientBuilder 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 SpecialWordsClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SpecialWordsClientBuilder 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 SpecialWordsClientBuilder. + */ + @Generated + public SpecialWordsClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of SpecialWordsClientImpl with the provided parameters. + * + * @return an instance of SpecialWordsClientImpl. + */ + @Generated + private SpecialWordsClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + SpecialWordsClientImpl client + = new SpecialWordsClientImpl(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 ModelsAsyncClient class. + * + * @return an instance of ModelsAsyncClient. + */ + @Generated + public ModelsAsyncClient buildModelsAsyncClient() { + return new ModelsAsyncClient(buildInnerClient().getModels()); + } + + /** + * Builds an instance of ModelPropertiesAsyncClient class. + * + * @return an instance of ModelPropertiesAsyncClient. + */ + @Generated + public ModelPropertiesAsyncClient buildModelPropertiesAsyncClient() { + return new ModelPropertiesAsyncClient(buildInnerClient().getModelProperties()); + } + + /** + * Builds an instance of OperationsAsyncClient class. + * + * @return an instance of OperationsAsyncClient. + */ + @Generated + public OperationsAsyncClient buildOperationsAsyncClient() { + return new OperationsAsyncClient(buildInnerClient().getOperations()); + } + + /** + * Builds an instance of ParametersAsyncClient class. + * + * @return an instance of ParametersAsyncClient. + */ + @Generated + public ParametersAsyncClient buildParametersAsyncClient() { + return new ParametersAsyncClient(buildInnerClient().getParameters()); + } + + /** + * Builds an instance of ModelsClient class. + * + * @return an instance of ModelsClient. + */ + @Generated + public ModelsClient buildModelsClient() { + return new ModelsClient(buildInnerClient().getModels()); + } + + /** + * Builds an instance of ModelPropertiesClient class. + * + * @return an instance of ModelPropertiesClient. + */ + @Generated + public ModelPropertiesClient buildModelPropertiesClient() { + return new ModelPropertiesClient(buildInnerClient().getModelProperties()); + } + + /** + * Builds an instance of OperationsClient class. + * + * @return an instance of OperationsClient. + */ + @Generated + public OperationsClient buildOperationsClient() { + return new OperationsClient(buildInnerClient().getOperations()); + } + + /** + * Builds an instance of ParametersClient class. + * + * @return an instance of ParametersClient. + */ + @Generated + public ParametersClient buildParametersClient() { + return new ParametersClient(buildInnerClient().getParameters()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SpecialWordsClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/ModelPropertiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/ModelPropertiesImpl.java new file mode 100644 index 000000000..bdf0af054 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/ModelPropertiesImpl.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ModelProperties. + */ +public final class ModelPropertiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelPropertiesService service; + + /** + * The service client containing this operation class. + */ + private final SpecialWordsClientImpl client; + + /** + * Initializes an instance of ModelPropertiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelPropertiesImpl(SpecialWordsClientImpl client) { + this.service + = RestProxy.create(ModelPropertiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SpecialWordsClientModelProperties to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SpecialWordsClientMo") + public interface ModelPropertiesService { + @Post("/special-words/model-properties/same-as-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> sameAsModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/model-properties/same-as-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 sameAsModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The sameAsModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     SameAsModel: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> sameAsModelWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.sameAsModel(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The sameAsModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     SameAsModel: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 sameAsModelWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sameAsModelSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/ModelsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/ModelsImpl.java new file mode 100644 index 000000000..4b9e9e561 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/ModelsImpl.java @@ -0,0 +1,2337 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Models. + */ +public final class ModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelsService service; + + /** + * The service client containing this operation class. + */ + private final SpecialWordsClientImpl client; + + /** + * Initializes an instance of ModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelsImpl(SpecialWordsClientImpl client) { + this.service = RestProxy.create(ModelsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SpecialWordsClientModels to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SpecialWordsClientMo") + public interface ModelsService { + @Post("/special-words/models/and") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withAnd(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/and") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withAndSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/as") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withAs(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/as") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withAsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/assert") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withAssert(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/assert") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withAssertSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/async") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withAsync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/async") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withAsyncSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/await") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withAwait(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/await") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withAwaitSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/break") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withBreak(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/break") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withBreakSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/class") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withClass(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/class") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withClassSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/constructor") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withConstructor(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/constructor") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withConstructorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/continue") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withContinue(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/continue") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withContinueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/def") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withDef(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/def") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withDefSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/del") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withDel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/del") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withDelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/elif") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withElif(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/elif") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withElifSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/else") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withElse(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/else") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withElseSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/except") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withExcept(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/except") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withExceptSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/exec") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withExec(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/exec") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withExecSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/finally") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withFinally(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/finally") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withFinallySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/for") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withFor(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/for") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withForSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/from") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withFrom(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/from") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withFromSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/global") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withGlobal(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/global") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withGlobalSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/if") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withIf(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/if") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withIfSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/import") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withImport(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/import") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withImportSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/in") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withIn(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/in") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withInSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/is") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withIs(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/is") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withIsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/lambda") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withLambda(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/lambda") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withLambdaSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/not") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withNot(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/not") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withNotSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/or") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withOr(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/or") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withOrSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/pass") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withPass(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/pass") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withPassSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/raise") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withRaise(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/raise") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withRaiseSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/return") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withReturn(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/return") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withReturnSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/try") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withTry(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/try") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withTrySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/while") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withWhile(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/while") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withWhileSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/with") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withWith(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/with") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withWithSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/yield") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withYield(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/special-words/models/yield") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withYieldSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The withAnd operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withAndWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withAnd(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withAnd operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withAndWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withAndSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withAs operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withAsWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withAs(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withAs operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withAsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withAsSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withAssert operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withAssertWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withAssert(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withAssert operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withAssertWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withAssertSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withAsync operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withAsyncWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withAsync(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withAsync operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withAsyncWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withAsyncSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withAwait operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withAwaitWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withAwait(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withAwait operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withAwaitWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withAwaitSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withBreak operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withBreakWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withBreak(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withBreak operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withBreakWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withBreakSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withClass operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withClassWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withClass(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withClass operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withClassWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withClassSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withConstructor operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withConstructorWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withConstructor(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withConstructor operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withConstructorWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withConstructorSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withContinue operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withContinueWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withContinue(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withContinue operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withContinueWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withContinueSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withDef operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withDefWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withDef(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withDef operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withDefWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withDefSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withDel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withDelWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withDel(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withDel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withDelWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withDelSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withElif operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withElifWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withElif(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withElif operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withElifWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withElifSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withElse operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withElseWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withElse(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withElse operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withElseWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withElseSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withExcept operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withExceptWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withExcept(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withExcept operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withExceptWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withExceptSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withExec operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withExecWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withExec(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withExec operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withExecWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withExecSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withFinally operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withFinallyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withFinally(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withFinally operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withFinallyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withFinallySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withFor operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withForWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withFor(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withFor operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withForWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withForSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withFrom operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withFromWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withFrom(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withFrom operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withFromWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withFromSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withGlobal operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withGlobalWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withGlobal(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withGlobal operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withGlobalWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withGlobalSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withIf operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withIfWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withIf(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withIf operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withIfWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withIfSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withImport operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withImportWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withImport(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withImport operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withImportWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withImportSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withIn operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withInWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withIn(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withIn operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withInWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withInSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withIs operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withIsWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withIs(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withIs operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withIsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withIsSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withLambda operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withLambdaWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withLambda(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withLambda operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withLambdaWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withLambdaSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withNot operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withNotWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withNot(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withNot operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withNotWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withNotSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withOr operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withOrWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withOr(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withOr operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withOrWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withOrSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withPass operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withPassWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withPass(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withPass operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withPassWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withPassSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withRaise operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withRaiseWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withRaise(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withRaise operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withRaiseWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withRaiseSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withReturn operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withReturnWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withReturn(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withReturn operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withReturnWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withReturnSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withTry operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withTryWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withTry(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withTry operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withTryWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withTrySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withWhile operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withWhileWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withWhile(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withWhile operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withWhileWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withWhileSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withWith operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withWithWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withWith(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withWith operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withWithWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withWithSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The withYield operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> withYieldWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.withYield(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The withYield operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 withYieldWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withYieldSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/OperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/OperationsImpl.java new file mode 100644 index 000000000..6ab0be29c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/OperationsImpl.java @@ -0,0 +1,1630 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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.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 Operations. + */ +public final class OperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final OperationsService service; + + /** + * The service client containing this operation class. + */ + private final SpecialWordsClientImpl client; + + /** + * Initializes an instance of OperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsImpl(SpecialWordsClientImpl client) { + this.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SpecialWordsClientOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SpecialWordsClientOp") + public interface OperationsService { + @Get("/special-words/operations/and") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> and(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/and") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response andSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/as") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> as(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/as") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response asSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/assert") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> assertMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/assert") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response assertMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/async") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> async(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/async") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response asyncSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/await") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> await(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/await") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response awaitSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/break") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> breakMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/break") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response breakMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/class") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> classMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/class") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response classMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/constructor") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> constructor(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/constructor") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response constructorSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/continue") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> continueMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/continue") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response continueMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/def") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> def(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/def") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response defSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/del") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> del(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/del") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response delSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/elif") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> elif(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/elif") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response elifSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/else") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> elseMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/else") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response elseMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/except") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> except(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/except") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response exceptSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/exec") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> exec(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/exec") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response execSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/finally") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> finallyMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/finally") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response finallyMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/for") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> forMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/for") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response forMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/from") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> from(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/from") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response fromSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/global") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> global(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/global") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response globalSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/if") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> ifMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/if") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response ifMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/import") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> importMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/import") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response importMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/in") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> in(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/in") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response inSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/is") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> is(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/is") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response isSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/lambda") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> lambda(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/lambda") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response lambdaSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/not") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> not(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/not") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response notSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/or") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> or(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/or") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response orSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/pass") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> pass(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/pass") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response passSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/raise") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> raise(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/raise") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response raiseSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/return") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> returnMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/return") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response returnMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/try") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> tryMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/try") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response tryMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/while") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> whileMethod(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/while") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response whileMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/with") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> with(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/with") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, Context context); + + @Get("/special-words/operations/yield") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> yield(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + + @Get("/special-words/operations/yield") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response yieldSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, + Context context); + } + + /** + * The and operation. + * + * @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> andWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.and(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The and operation. + * + * @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 andWithResponse(RequestOptions requestOptions) { + return service.andSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The as operation. + * + * @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> asWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.as(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The as operation. + * + * @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 asWithResponse(RequestOptions requestOptions) { + return service.asSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The assertMethod operation. + * + * @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> assertMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.assertMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The assertMethod operation. + * + * @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 assertMethodWithResponse(RequestOptions requestOptions) { + return service.assertMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The async operation. + * + * @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> asyncWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.async(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The async operation. + * + * @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 asyncWithResponse(RequestOptions requestOptions) { + return service.asyncSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The await operation. + * + * @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> awaitWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.await(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The await operation. + * + * @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 awaitWithResponse(RequestOptions requestOptions) { + return service.awaitSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The breakMethod operation. + * + * @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> breakMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.breakMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The breakMethod operation. + * + * @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 breakMethodWithResponse(RequestOptions requestOptions) { + return service.breakMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The classMethod operation. + * + * @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> classMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.classMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The classMethod operation. + * + * @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 classMethodWithResponse(RequestOptions requestOptions) { + return service.classMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The constructor operation. + * + * @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> constructorWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.constructor(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The constructor operation. + * + * @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 constructorWithResponse(RequestOptions requestOptions) { + return service.constructorSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The continueMethod operation. + * + * @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> continueMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.continueMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The continueMethod operation. + * + * @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 continueMethodWithResponse(RequestOptions requestOptions) { + return service.continueMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The def operation. + * + * @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> defWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.def(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The def operation. + * + * @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 defWithResponse(RequestOptions requestOptions) { + return service.defSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The del operation. + * + * @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> delWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.del(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The del operation. + * + * @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 delWithResponse(RequestOptions requestOptions) { + return service.delSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The elif operation. + * + * @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> elifWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.elif(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The elif operation. + * + * @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 elifWithResponse(RequestOptions requestOptions) { + return service.elifSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The elseMethod operation. + * + * @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> elseMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.elseMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The elseMethod operation. + * + * @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 elseMethodWithResponse(RequestOptions requestOptions) { + return service.elseMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The except operation. + * + * @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> exceptWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.except(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The except operation. + * + * @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 exceptWithResponse(RequestOptions requestOptions) { + return service.exceptSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The exec operation. + * + * @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> execWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.exec(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The exec operation. + * + * @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 execWithResponse(RequestOptions requestOptions) { + return service.execSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The finallyMethod operation. + * + * @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> finallyMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.finallyMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The finallyMethod operation. + * + * @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 finallyMethodWithResponse(RequestOptions requestOptions) { + return service.finallyMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The forMethod operation. + * + * @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> forMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.forMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The forMethod operation. + * + * @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 forMethodWithResponse(RequestOptions requestOptions) { + return service.forMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The from operation. + * + * @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> fromWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.from(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The from operation. + * + * @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 fromWithResponse(RequestOptions requestOptions) { + return service.fromSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The global operation. + * + * @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> globalWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.global(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The global operation. + * + * @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 globalWithResponse(RequestOptions requestOptions) { + return service.globalSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The ifMethod operation. + * + * @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> ifMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.ifMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The ifMethod operation. + * + * @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 ifMethodWithResponse(RequestOptions requestOptions) { + return service.ifMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The importMethod operation. + * + * @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> importMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.importMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The importMethod operation. + * + * @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 importMethodWithResponse(RequestOptions requestOptions) { + return service.importMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The in operation. + * + * @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> inWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.in(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The in operation. + * + * @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 inWithResponse(RequestOptions requestOptions) { + return service.inSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The is operation. + * + * @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> isWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.is(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The is operation. + * + * @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 isWithResponse(RequestOptions requestOptions) { + return service.isSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The lambda operation. + * + * @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> lambdaWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.lambda(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The lambda operation. + * + * @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 lambdaWithResponse(RequestOptions requestOptions) { + return service.lambdaSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The not operation. + * + * @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> notWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.not(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The not operation. + * + * @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 notWithResponse(RequestOptions requestOptions) { + return service.notSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The or operation. + * + * @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> orWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.or(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The or operation. + * + * @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 orWithResponse(RequestOptions requestOptions) { + return service.orSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The pass operation. + * + * @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> passWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.pass(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The pass operation. + * + * @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 passWithResponse(RequestOptions requestOptions) { + return service.passSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The raise operation. + * + * @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> raiseWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.raise(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The raise operation. + * + * @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 raiseWithResponse(RequestOptions requestOptions) { + return service.raiseSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The returnMethod operation. + * + * @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> returnMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.returnMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The returnMethod operation. + * + * @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 returnMethodWithResponse(RequestOptions requestOptions) { + return service.returnMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The tryMethod operation. + * + * @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> tryMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.tryMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The tryMethod operation. + * + * @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 tryMethodWithResponse(RequestOptions requestOptions) { + return service.tryMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The whileMethod operation. + * + * @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> whileMethodWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.whileMethod(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The whileMethod operation. + * + * @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 whileMethodWithResponse(RequestOptions requestOptions) { + return service.whileMethodSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The with operation. + * + * @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> withWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.with(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The with operation. + * + * @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 withWithResponse(RequestOptions requestOptions) { + return service.withSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } + + /** + * The yield operation. + * + * @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> yieldWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.yield(this.client.getEndpoint(), requestOptions, context)); + } + + /** + * The yield operation. + * + * @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 yieldWithResponse(RequestOptions requestOptions) { + return service.yieldSync(this.client.getEndpoint(), requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/ParametersImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/ParametersImpl.java new file mode 100644 index 000000000..a848bcd27 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/ParametersImpl.java @@ -0,0 +1,1791 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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 Parameters. + */ +public final class ParametersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ParametersService service; + + /** + * The service client containing this operation class. + */ + private final SpecialWordsClientImpl client; + + /** + * Initializes an instance of ParametersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ParametersImpl(SpecialWordsClientImpl client) { + this.service + = RestProxy.create(ParametersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SpecialWordsClientParameters to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SpecialWordsClientPa") + public interface ParametersService { + @Get("/special-words/parameters/and") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withAnd(@HostParam("endpoint") String endpoint, @QueryParam("and") String and, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/and") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withAndSync(@HostParam("endpoint") String endpoint, @QueryParam("and") String and, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/as") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withAs(@HostParam("endpoint") String endpoint, @QueryParam("as") String as, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/as") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withAsSync(@HostParam("endpoint") String endpoint, @QueryParam("as") String as, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/assert") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withAssert(@HostParam("endpoint") String endpoint, + @QueryParam("assert") String assertParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/assert") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withAssertSync(@HostParam("endpoint") String endpoint, + @QueryParam("assert") String assertParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/async") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withAsync(@HostParam("endpoint") String endpoint, @QueryParam("async") String async, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/async") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withAsyncSync(@HostParam("endpoint") String endpoint, @QueryParam("async") String async, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/await") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withAwait(@HostParam("endpoint") String endpoint, @QueryParam("await") String await, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/await") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withAwaitSync(@HostParam("endpoint") String endpoint, @QueryParam("await") String await, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/break") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withBreak(@HostParam("endpoint") String endpoint, + @QueryParam("break") String breakParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/break") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withBreakSync(@HostParam("endpoint") String endpoint, @QueryParam("break") String breakParameter, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/class") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withClass(@HostParam("endpoint") String endpoint, + @QueryParam("class") String classParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/class") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withClassSync(@HostParam("endpoint") String endpoint, @QueryParam("class") String classParameter, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/constructor") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withConstructor(@HostParam("endpoint") String endpoint, + @QueryParam("constructor") String constructor, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/constructor") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withConstructorSync(@HostParam("endpoint") String endpoint, + @QueryParam("constructor") String constructor, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/continue") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withContinue(@HostParam("endpoint") String endpoint, + @QueryParam("continue") String continueParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/continue") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withContinueSync(@HostParam("endpoint") String endpoint, + @QueryParam("continue") String continueParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/def") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withDef(@HostParam("endpoint") String endpoint, @QueryParam("def") String def, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/def") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withDefSync(@HostParam("endpoint") String endpoint, @QueryParam("def") String def, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/del") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withDel(@HostParam("endpoint") String endpoint, @QueryParam("del") String del, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/del") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withDelSync(@HostParam("endpoint") String endpoint, @QueryParam("del") String del, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/elif") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withElif(@HostParam("endpoint") String endpoint, @QueryParam("elif") String elif, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/elif") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withElifSync(@HostParam("endpoint") String endpoint, @QueryParam("elif") String elif, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/else") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withElse(@HostParam("endpoint") String endpoint, @QueryParam("else") String elseParameter, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/else") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withElseSync(@HostParam("endpoint") String endpoint, @QueryParam("else") String elseParameter, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/except") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withExcept(@HostParam("endpoint") String endpoint, @QueryParam("except") String except, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/except") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withExceptSync(@HostParam("endpoint") String endpoint, @QueryParam("except") String except, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/exec") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withExec(@HostParam("endpoint") String endpoint, @QueryParam("exec") String exec, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/exec") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withExecSync(@HostParam("endpoint") String endpoint, @QueryParam("exec") String exec, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/finally") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withFinally(@HostParam("endpoint") String endpoint, + @QueryParam("finally") String finallyParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/finally") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withFinallySync(@HostParam("endpoint") String endpoint, + @QueryParam("finally") String finallyParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/for") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withFor(@HostParam("endpoint") String endpoint, @QueryParam("for") String forParameter, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/for") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withForSync(@HostParam("endpoint") String endpoint, @QueryParam("for") String forParameter, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/from") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withFrom(@HostParam("endpoint") String endpoint, @QueryParam("from") String from, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/from") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withFromSync(@HostParam("endpoint") String endpoint, @QueryParam("from") String from, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/global") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withGlobal(@HostParam("endpoint") String endpoint, @QueryParam("global") String global, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/global") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withGlobalSync(@HostParam("endpoint") String endpoint, @QueryParam("global") String global, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/if") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withIf(@HostParam("endpoint") String endpoint, @QueryParam("if") String ifParameter, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/if") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withIfSync(@HostParam("endpoint") String endpoint, @QueryParam("if") String ifParameter, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/import") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withImport(@HostParam("endpoint") String endpoint, + @QueryParam("import") String importParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/import") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withImportSync(@HostParam("endpoint") String endpoint, + @QueryParam("import") String importParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/in") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withIn(@HostParam("endpoint") String endpoint, @QueryParam("in") String in, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/in") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withInSync(@HostParam("endpoint") String endpoint, @QueryParam("in") String in, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/is") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withIs(@HostParam("endpoint") String endpoint, @QueryParam("is") String is, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/is") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withIsSync(@HostParam("endpoint") String endpoint, @QueryParam("is") String is, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/lambda") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withLambda(@HostParam("endpoint") String endpoint, @QueryParam("lambda") String lambda, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/lambda") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withLambdaSync(@HostParam("endpoint") String endpoint, @QueryParam("lambda") String lambda, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/not") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withNot(@HostParam("endpoint") String endpoint, @QueryParam("not") String not, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/not") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withNotSync(@HostParam("endpoint") String endpoint, @QueryParam("not") String not, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/or") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withOr(@HostParam("endpoint") String endpoint, @QueryParam("or") String or, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/or") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withOrSync(@HostParam("endpoint") String endpoint, @QueryParam("or") String or, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/pass") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withPass(@HostParam("endpoint") String endpoint, @QueryParam("pass") String pass, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/pass") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withPassSync(@HostParam("endpoint") String endpoint, @QueryParam("pass") String pass, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/raise") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withRaise(@HostParam("endpoint") String endpoint, @QueryParam("raise") String raise, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/raise") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withRaiseSync(@HostParam("endpoint") String endpoint, @QueryParam("raise") String raise, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/return") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withReturn(@HostParam("endpoint") String endpoint, + @QueryParam("return") String returnParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/return") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withReturnSync(@HostParam("endpoint") String endpoint, + @QueryParam("return") String returnParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/try") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withTry(@HostParam("endpoint") String endpoint, @QueryParam("try") String tryParameter, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/try") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withTrySync(@HostParam("endpoint") String endpoint, @QueryParam("try") String tryParameter, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/while") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withWhile(@HostParam("endpoint") String endpoint, + @QueryParam("while") String whileParameter, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/while") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withWhileSync(@HostParam("endpoint") String endpoint, @QueryParam("while") String whileParameter, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/with") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withWith(@HostParam("endpoint") String endpoint, @QueryParam("with") String with, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/with") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withWithSync(@HostParam("endpoint") String endpoint, @QueryParam("with") String with, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/yield") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withYield(@HostParam("endpoint") String endpoint, @QueryParam("yield") String yield, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/yield") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withYieldSync(@HostParam("endpoint") String endpoint, @QueryParam("yield") String yield, + RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/cancellationToken") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withCancellationToken(@HostParam("endpoint") String endpoint, + @QueryParam("cancellationToken") String cancellationToken, RequestOptions requestOptions, Context context); + + @Get("/special-words/parameters/cancellationToken") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withCancellationTokenSync(@HostParam("endpoint") String endpoint, + @QueryParam("cancellationToken") String cancellationToken, RequestOptions requestOptions, Context context); + } + + /** + * The withAnd operation. + * + * @param and The and 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> withAndWithResponseAsync(String and, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withAnd(this.client.getEndpoint(), and, requestOptions, context)); + } + + /** + * The withAnd operation. + * + * @param and The and 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 withAndWithResponse(String and, RequestOptions requestOptions) { + return service.withAndSync(this.client.getEndpoint(), and, requestOptions, Context.NONE); + } + + /** + * The withAs operation. + * + * @param as The as 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> withAsWithResponseAsync(String as, RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withAs(this.client.getEndpoint(), as, requestOptions, context)); + } + + /** + * The withAs operation. + * + * @param as The as 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 withAsWithResponse(String as, RequestOptions requestOptions) { + return service.withAsSync(this.client.getEndpoint(), as, requestOptions, Context.NONE); + } + + /** + * The withAssert operation. + * + * @param assertParameter The assertParameter 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> withAssertWithResponseAsync(String assertParameter, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withAssert(this.client.getEndpoint(), assertParameter, requestOptions, context)); + } + + /** + * The withAssert operation. + * + * @param assertParameter The assertParameter 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 withAssertWithResponse(String assertParameter, RequestOptions requestOptions) { + return service.withAssertSync(this.client.getEndpoint(), assertParameter, requestOptions, Context.NONE); + } + + /** + * The withAsync operation. + * + * @param async The async 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> withAsyncWithResponseAsync(String async, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withAsync(this.client.getEndpoint(), async, requestOptions, context)); + } + + /** + * The withAsync operation. + * + * @param async The async 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 withAsyncWithResponse(String async, RequestOptions requestOptions) { + return service.withAsyncSync(this.client.getEndpoint(), async, requestOptions, Context.NONE); + } + + /** + * The withAwait operation. + * + * @param await The await 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> withAwaitWithResponseAsync(String await, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withAwait(this.client.getEndpoint(), await, requestOptions, context)); + } + + /** + * The withAwait operation. + * + * @param await The await 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 withAwaitWithResponse(String await, RequestOptions requestOptions) { + return service.withAwaitSync(this.client.getEndpoint(), await, requestOptions, Context.NONE); + } + + /** + * The withBreak operation. + * + * @param breakParameter The breakParameter 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> withBreakWithResponseAsync(String breakParameter, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withBreak(this.client.getEndpoint(), breakParameter, requestOptions, context)); + } + + /** + * The withBreak operation. + * + * @param breakParameter The breakParameter 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 withBreakWithResponse(String breakParameter, RequestOptions requestOptions) { + return service.withBreakSync(this.client.getEndpoint(), breakParameter, requestOptions, Context.NONE); + } + + /** + * The withClass operation. + * + * @param classParameter The classParameter 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> withClassWithResponseAsync(String classParameter, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withClass(this.client.getEndpoint(), classParameter, requestOptions, context)); + } + + /** + * The withClass operation. + * + * @param classParameter The classParameter 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 withClassWithResponse(String classParameter, RequestOptions requestOptions) { + return service.withClassSync(this.client.getEndpoint(), classParameter, requestOptions, Context.NONE); + } + + /** + * The withConstructor operation. + * + * @param constructor The constructor 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> withConstructorWithResponseAsync(String constructor, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withConstructor(this.client.getEndpoint(), constructor, requestOptions, context)); + } + + /** + * The withConstructor operation. + * + * @param constructor The constructor 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 withConstructorWithResponse(String constructor, RequestOptions requestOptions) { + return service.withConstructorSync(this.client.getEndpoint(), constructor, requestOptions, Context.NONE); + } + + /** + * The withContinue operation. + * + * @param continueParameter The continueParameter 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> withContinueWithResponseAsync(String continueParameter, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withContinue(this.client.getEndpoint(), continueParameter, requestOptions, context)); + } + + /** + * The withContinue operation. + * + * @param continueParameter The continueParameter 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 withContinueWithResponse(String continueParameter, RequestOptions requestOptions) { + return service.withContinueSync(this.client.getEndpoint(), continueParameter, requestOptions, Context.NONE); + } + + /** + * The withDef operation. + * + * @param def The def 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> withDefWithResponseAsync(String def, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withDef(this.client.getEndpoint(), def, requestOptions, context)); + } + + /** + * The withDef operation. + * + * @param def The def 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 withDefWithResponse(String def, RequestOptions requestOptions) { + return service.withDefSync(this.client.getEndpoint(), def, requestOptions, Context.NONE); + } + + /** + * The withDel operation. + * + * @param del The del 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> withDelWithResponseAsync(String del, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withDel(this.client.getEndpoint(), del, requestOptions, context)); + } + + /** + * The withDel operation. + * + * @param del The del 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 withDelWithResponse(String del, RequestOptions requestOptions) { + return service.withDelSync(this.client.getEndpoint(), del, requestOptions, Context.NONE); + } + + /** + * The withElif operation. + * + * @param elif The elif 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> withElifWithResponseAsync(String elif, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withElif(this.client.getEndpoint(), elif, requestOptions, context)); + } + + /** + * The withElif operation. + * + * @param elif The elif 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 withElifWithResponse(String elif, RequestOptions requestOptions) { + return service.withElifSync(this.client.getEndpoint(), elif, requestOptions, Context.NONE); + } + + /** + * The withElse operation. + * + * @param elseParameter The elseParameter 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> withElseWithResponseAsync(String elseParameter, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withElse(this.client.getEndpoint(), elseParameter, requestOptions, context)); + } + + /** + * The withElse operation. + * + * @param elseParameter The elseParameter 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 withElseWithResponse(String elseParameter, RequestOptions requestOptions) { + return service.withElseSync(this.client.getEndpoint(), elseParameter, requestOptions, Context.NONE); + } + + /** + * The withExcept operation. + * + * @param except The except 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> withExceptWithResponseAsync(String except, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withExcept(this.client.getEndpoint(), except, requestOptions, context)); + } + + /** + * The withExcept operation. + * + * @param except The except 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 withExceptWithResponse(String except, RequestOptions requestOptions) { + return service.withExceptSync(this.client.getEndpoint(), except, requestOptions, Context.NONE); + } + + /** + * The withExec operation. + * + * @param exec The exec 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> withExecWithResponseAsync(String exec, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withExec(this.client.getEndpoint(), exec, requestOptions, context)); + } + + /** + * The withExec operation. + * + * @param exec The exec 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 withExecWithResponse(String exec, RequestOptions requestOptions) { + return service.withExecSync(this.client.getEndpoint(), exec, requestOptions, Context.NONE); + } + + /** + * The withFinally operation. + * + * @param finallyParameter The finallyParameter 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> withFinallyWithResponseAsync(String finallyParameter, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withFinally(this.client.getEndpoint(), finallyParameter, requestOptions, context)); + } + + /** + * The withFinally operation. + * + * @param finallyParameter The finallyParameter 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 withFinallyWithResponse(String finallyParameter, RequestOptions requestOptions) { + return service.withFinallySync(this.client.getEndpoint(), finallyParameter, requestOptions, Context.NONE); + } + + /** + * The withFor operation. + * + * @param forParameter The forParameter 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> withForWithResponseAsync(String forParameter, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withFor(this.client.getEndpoint(), forParameter, requestOptions, context)); + } + + /** + * The withFor operation. + * + * @param forParameter The forParameter 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 withForWithResponse(String forParameter, RequestOptions requestOptions) { + return service.withForSync(this.client.getEndpoint(), forParameter, requestOptions, Context.NONE); + } + + /** + * The withFrom operation. + * + * @param from The from 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> withFromWithResponseAsync(String from, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withFrom(this.client.getEndpoint(), from, requestOptions, context)); + } + + /** + * The withFrom operation. + * + * @param from The from 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 withFromWithResponse(String from, RequestOptions requestOptions) { + return service.withFromSync(this.client.getEndpoint(), from, requestOptions, Context.NONE); + } + + /** + * The withGlobal operation. + * + * @param global The global 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> withGlobalWithResponseAsync(String global, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withGlobal(this.client.getEndpoint(), global, requestOptions, context)); + } + + /** + * The withGlobal operation. + * + * @param global The global 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 withGlobalWithResponse(String global, RequestOptions requestOptions) { + return service.withGlobalSync(this.client.getEndpoint(), global, requestOptions, Context.NONE); + } + + /** + * The withIf operation. + * + * @param ifParameter The ifParameter 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> withIfWithResponseAsync(String ifParameter, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withIf(this.client.getEndpoint(), ifParameter, requestOptions, context)); + } + + /** + * The withIf operation. + * + * @param ifParameter The ifParameter 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 withIfWithResponse(String ifParameter, RequestOptions requestOptions) { + return service.withIfSync(this.client.getEndpoint(), ifParameter, requestOptions, Context.NONE); + } + + /** + * The withImport operation. + * + * @param importParameter The importParameter 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> withImportWithResponseAsync(String importParameter, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withImport(this.client.getEndpoint(), importParameter, requestOptions, context)); + } + + /** + * The withImport operation. + * + * @param importParameter The importParameter 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 withImportWithResponse(String importParameter, RequestOptions requestOptions) { + return service.withImportSync(this.client.getEndpoint(), importParameter, requestOptions, Context.NONE); + } + + /** + * The withIn operation. + * + * @param in The in 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> withInWithResponseAsync(String in, RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withIn(this.client.getEndpoint(), in, requestOptions, context)); + } + + /** + * The withIn operation. + * + * @param in The in 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 withInWithResponse(String in, RequestOptions requestOptions) { + return service.withInSync(this.client.getEndpoint(), in, requestOptions, Context.NONE); + } + + /** + * The withIs operation. + * + * @param is The is 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> withIsWithResponseAsync(String is, RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withIs(this.client.getEndpoint(), is, requestOptions, context)); + } + + /** + * The withIs operation. + * + * @param is The is 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 withIsWithResponse(String is, RequestOptions requestOptions) { + return service.withIsSync(this.client.getEndpoint(), is, requestOptions, Context.NONE); + } + + /** + * The withLambda operation. + * + * @param lambda The lambda 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> withLambdaWithResponseAsync(String lambda, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withLambda(this.client.getEndpoint(), lambda, requestOptions, context)); + } + + /** + * The withLambda operation. + * + * @param lambda The lambda 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 withLambdaWithResponse(String lambda, RequestOptions requestOptions) { + return service.withLambdaSync(this.client.getEndpoint(), lambda, requestOptions, Context.NONE); + } + + /** + * The withNot operation. + * + * @param not The not 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> withNotWithResponseAsync(String not, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withNot(this.client.getEndpoint(), not, requestOptions, context)); + } + + /** + * The withNot operation. + * + * @param not The not 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 withNotWithResponse(String not, RequestOptions requestOptions) { + return service.withNotSync(this.client.getEndpoint(), not, requestOptions, Context.NONE); + } + + /** + * The withOr operation. + * + * @param or The or 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> withOrWithResponseAsync(String or, RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withOr(this.client.getEndpoint(), or, requestOptions, context)); + } + + /** + * The withOr operation. + * + * @param or The or 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 withOrWithResponse(String or, RequestOptions requestOptions) { + return service.withOrSync(this.client.getEndpoint(), or, requestOptions, Context.NONE); + } + + /** + * The withPass operation. + * + * @param pass The pass 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> withPassWithResponseAsync(String pass, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withPass(this.client.getEndpoint(), pass, requestOptions, context)); + } + + /** + * The withPass operation. + * + * @param pass The pass 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 withPassWithResponse(String pass, RequestOptions requestOptions) { + return service.withPassSync(this.client.getEndpoint(), pass, requestOptions, Context.NONE); + } + + /** + * The withRaise operation. + * + * @param raise The raise 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> withRaiseWithResponseAsync(String raise, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withRaise(this.client.getEndpoint(), raise, requestOptions, context)); + } + + /** + * The withRaise operation. + * + * @param raise The raise 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 withRaiseWithResponse(String raise, RequestOptions requestOptions) { + return service.withRaiseSync(this.client.getEndpoint(), raise, requestOptions, Context.NONE); + } + + /** + * The withReturn operation. + * + * @param returnParameter The returnParameter 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> withReturnWithResponseAsync(String returnParameter, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withReturn(this.client.getEndpoint(), returnParameter, requestOptions, context)); + } + + /** + * The withReturn operation. + * + * @param returnParameter The returnParameter 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 withReturnWithResponse(String returnParameter, RequestOptions requestOptions) { + return service.withReturnSync(this.client.getEndpoint(), returnParameter, requestOptions, Context.NONE); + } + + /** + * The withTry operation. + * + * @param tryParameter The tryParameter 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> withTryWithResponseAsync(String tryParameter, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withTry(this.client.getEndpoint(), tryParameter, requestOptions, context)); + } + + /** + * The withTry operation. + * + * @param tryParameter The tryParameter 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 withTryWithResponse(String tryParameter, RequestOptions requestOptions) { + return service.withTrySync(this.client.getEndpoint(), tryParameter, requestOptions, Context.NONE); + } + + /** + * The withWhile operation. + * + * @param whileParameter The whileParameter 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> withWhileWithResponseAsync(String whileParameter, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withWhile(this.client.getEndpoint(), whileParameter, requestOptions, context)); + } + + /** + * The withWhile operation. + * + * @param whileParameter The whileParameter 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 withWhileWithResponse(String whileParameter, RequestOptions requestOptions) { + return service.withWhileSync(this.client.getEndpoint(), whileParameter, requestOptions, Context.NONE); + } + + /** + * The withWith operation. + * + * @param with The with 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> withWithWithResponseAsync(String with, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withWith(this.client.getEndpoint(), with, requestOptions, context)); + } + + /** + * The withWith operation. + * + * @param with The with 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 withWithWithResponse(String with, RequestOptions requestOptions) { + return service.withWithSync(this.client.getEndpoint(), with, requestOptions, Context.NONE); + } + + /** + * The withYield operation. + * + * @param yield The yield 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> withYieldWithResponseAsync(String yield, RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withYield(this.client.getEndpoint(), yield, requestOptions, context)); + } + + /** + * The withYield operation. + * + * @param yield The yield 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 withYieldWithResponse(String yield, RequestOptions requestOptions) { + return service.withYieldSync(this.client.getEndpoint(), yield, requestOptions, Context.NONE); + } + + /** + * The withCancellationToken operation. + * + * @param cancellationToken The cancellationToken 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> withCancellationTokenWithResponseAsync(String cancellationToken, + RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withCancellationToken(this.client.getEndpoint(), + cancellationToken, requestOptions, context)); + } + + /** + * The withCancellationToken operation. + * + * @param cancellationToken The cancellationToken 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 withCancellationTokenWithResponse(String cancellationToken, RequestOptions requestOptions) { + return service.withCancellationTokenSync(this.client.getEndpoint(), cancellationToken, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/SpecialWordsClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/SpecialWordsClientImpl.java new file mode 100644 index 000000000..8ffa09867 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/SpecialWordsClientImpl.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the SpecialWordsClient type. + */ +public final class SpecialWordsClientImpl { + /** + * 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; + } + + /** + * The ModelsImpl object to access its operations. + */ + private final ModelsImpl models; + + /** + * Gets the ModelsImpl object to access its operations. + * + * @return the ModelsImpl object. + */ + public ModelsImpl getModels() { + return this.models; + } + + /** + * The ModelPropertiesImpl object to access its operations. + */ + private final ModelPropertiesImpl modelProperties; + + /** + * Gets the ModelPropertiesImpl object to access its operations. + * + * @return the ModelPropertiesImpl object. + */ + public ModelPropertiesImpl getModelProperties() { + return this.modelProperties; + } + + /** + * The OperationsImpl object to access its operations. + */ + private final OperationsImpl operations; + + /** + * Gets the OperationsImpl object to access its operations. + * + * @return the OperationsImpl object. + */ + public OperationsImpl getOperations() { + return this.operations; + } + + /** + * The ParametersImpl object to access its operations. + */ + private final ParametersImpl parameters; + + /** + * Gets the ParametersImpl object to access its operations. + * + * @return the ParametersImpl object. + */ + public ParametersImpl getParameters() { + return this.parameters; + } + + /** + * Initializes an instance of SpecialWordsClient client. + * + * @param endpoint Service host. + */ + public SpecialWordsClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of SpecialWordsClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public SpecialWordsClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of SpecialWordsClient 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 SpecialWordsClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.models = new ModelsImpl(this); + this.modelProperties = new ModelPropertiesImpl(this); + this.operations = new OperationsImpl(this); + this.parameters = new ParametersImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/package-info.java new file mode 100644 index 000000000..33edefa92 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/implementation/package-info.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 containing the implementations for SpecialWords. + * Scenarios to verify that reserved words can be used in service and generators will handle it appropriately. + * + * Current list of special words + * ```txt + * and + * as + * assert + * async + * await + * break + * class + * constructor + * continue + * def + * del + * elif + * else + * except + * exec + * finally + * for + * from + * global + * if + * import + * in + * is + * lambda + * not + * or + * pass + * raise + * return + * try + * while + * with + * yield + * ```. + * + */ +package com.specialwords.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/And.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/And.java new file mode 100644 index 000000000..8b6ed94f8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/And.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The And model. + */ +@Immutable +public final class And implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of And class. + * + * @param name the name value to set. + */ + @Generated + public And(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of And from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of And 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 And. + */ + @Generated + public static And fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new And(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/As.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/As.java new file mode 100644 index 000000000..6c42e17fc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/As.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The As model. + */ +@Immutable +public final class As implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of As class. + * + * @param name the name value to set. + */ + @Generated + public As(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of As from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of As 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 As. + */ + @Generated + public static As fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new As(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Assert.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Assert.java new file mode 100644 index 000000000..857a22c52 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Assert.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Assert model. + */ +@Immutable +public final class Assert implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Assert class. + * + * @param name the name value to set. + */ + @Generated + public Assert(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Assert from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Assert 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 Assert. + */ + @Generated + public static Assert fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Assert(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Async.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Async.java new file mode 100644 index 000000000..b781bb1e4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Async.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Async model. + */ +@Immutable +public final class Async implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Async class. + * + * @param name the name value to set. + */ + @Generated + public Async(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Async from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Async 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 Async. + */ + @Generated + public static Async fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Async(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Await.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Await.java new file mode 100644 index 000000000..a1baa673e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Await.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Await model. + */ +@Immutable +public final class Await implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Await class. + * + * @param name the name value to set. + */ + @Generated + public Await(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Await from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Await 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 Await. + */ + @Generated + public static Await fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Await(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Break.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Break.java new file mode 100644 index 000000000..37e6804f8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Break.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Break model. + */ +@Immutable +public final class Break implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Break class. + * + * @param name the name value to set. + */ + @Generated + public Break(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Break from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Break 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 Break. + */ + @Generated + public static Break fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Break(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/ClassModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/ClassModel.java new file mode 100644 index 000000000..3c2021733 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/ClassModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The ClassModel model. + */ +@Immutable +public final class ClassModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ClassModel class. + * + * @param name the name value to set. + */ + @Generated + public ClassModel(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ClassModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ClassModel 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 ClassModel. + */ + @Generated + public static ClassModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ClassModel(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Constructor.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Constructor.java new file mode 100644 index 000000000..c468430e2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Constructor.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Constructor model. + */ +@Immutable +public final class Constructor implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Constructor class. + * + * @param name the name value to set. + */ + @Generated + public Constructor(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Constructor from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Constructor 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 Constructor. + */ + @Generated + public static Constructor fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Constructor(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Continue.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Continue.java new file mode 100644 index 000000000..451debd4f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Continue.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Continue model. + */ +@Immutable +public final class Continue implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Continue class. + * + * @param name the name value to set. + */ + @Generated + public Continue(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Continue from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Continue 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 Continue. + */ + @Generated + public static Continue fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Continue(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Def.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Def.java new file mode 100644 index 000000000..40a10f325 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Def.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Def model. + */ +@Immutable +public final class Def implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Def class. + * + * @param name the name value to set. + */ + @Generated + public Def(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Def from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Def 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 Def. + */ + @Generated + public static Def fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Def(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Del.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Del.java new file mode 100644 index 000000000..a0f1d38a8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Del.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Del model. + */ +@Immutable +public final class Del implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Del class. + * + * @param name the name value to set. + */ + @Generated + public Del(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Del from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Del 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 Del. + */ + @Generated + public static Del fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Del(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Elif.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Elif.java new file mode 100644 index 000000000..8b55d72d7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Elif.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Elif model. + */ +@Immutable +public final class Elif implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Elif class. + * + * @param name the name value to set. + */ + @Generated + public Elif(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Elif from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Elif 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 Elif. + */ + @Generated + public static Elif fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Elif(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Else.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Else.java new file mode 100644 index 000000000..993f03442 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Else.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Else model. + */ +@Immutable +public final class Else implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Else class. + * + * @param name the name value to set. + */ + @Generated + public Else(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Else from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Else 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 Else. + */ + @Generated + public static Else fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Else(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Except.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Except.java new file mode 100644 index 000000000..b582f00f8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Except.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Except model. + */ +@Immutable +public final class Except implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Except class. + * + * @param name the name value to set. + */ + @Generated + public Except(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Except from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Except 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 Except. + */ + @Generated + public static Except fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Except(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Exec.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Exec.java new file mode 100644 index 000000000..86abb0242 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Exec.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Exec model. + */ +@Immutable +public final class Exec implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Exec class. + * + * @param name the name value to set. + */ + @Generated + public Exec(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Exec from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Exec 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 Exec. + */ + @Generated + public static Exec fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Exec(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Finally.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Finally.java new file mode 100644 index 000000000..fde8f76a9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Finally.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Finally model. + */ +@Immutable +public final class Finally implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Finally class. + * + * @param name the name value to set. + */ + @Generated + public Finally(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Finally from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Finally 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 Finally. + */ + @Generated + public static Finally fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Finally(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/For.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/For.java new file mode 100644 index 000000000..f053a7d0b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/For.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The For model. + */ +@Immutable +public final class For implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of For class. + * + * @param name the name value to set. + */ + @Generated + public For(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of For from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of For 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 For. + */ + @Generated + public static For fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new For(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/From.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/From.java new file mode 100644 index 000000000..a03a4ffa8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/From.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The From model. + */ +@Immutable +public final class From implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of From class. + * + * @param name the name value to set. + */ + @Generated + public From(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of From from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of From 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 From. + */ + @Generated + public static From fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new From(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Global.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Global.java new file mode 100644 index 000000000..c75571359 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Global.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Global model. + */ +@Immutable +public final class Global implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Global class. + * + * @param name the name value to set. + */ + @Generated + public Global(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Global from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Global 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 Global. + */ + @Generated + public static Global fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Global(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/If.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/If.java new file mode 100644 index 000000000..389d02faa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/If.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The If model. + */ +@Immutable +public final class If implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of If class. + * + * @param name the name value to set. + */ + @Generated + public If(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of If from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of If 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 If. + */ + @Generated + public static If fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new If(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Import.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Import.java new file mode 100644 index 000000000..2ceeb5850 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Import.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Import model. + */ +@Immutable +public final class Import implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Import class. + * + * @param name the name value to set. + */ + @Generated + public Import(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Import from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Import 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 Import. + */ + @Generated + public static Import fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Import(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/In.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/In.java new file mode 100644 index 000000000..a10018807 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/In.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The In model. + */ +@Immutable +public final class In implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of In class. + * + * @param name the name value to set. + */ + @Generated + public In(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of In from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of In 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 In. + */ + @Generated + public static In fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new In(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Is.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Is.java new file mode 100644 index 000000000..b566efa9f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Is.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Is model. + */ +@Immutable +public final class Is implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Is class. + * + * @param name the name value to set. + */ + @Generated + public Is(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Is from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Is 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 Is. + */ + @Generated + public static Is fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Is(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Lambda.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Lambda.java new file mode 100644 index 000000000..9a8df9194 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Lambda.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Lambda model. + */ +@Immutable +public final class Lambda implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Lambda class. + * + * @param name the name value to set. + */ + @Generated + public Lambda(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Lambda from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Lambda 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 Lambda. + */ + @Generated + public static Lambda fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Lambda(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Not.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Not.java new file mode 100644 index 000000000..a1597c8ee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Not.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Not model. + */ +@Immutable +public final class Not implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Not class. + * + * @param name the name value to set. + */ + @Generated + public Not(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Not from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Not 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 Not. + */ + @Generated + public static Not fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Not(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Or.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Or.java new file mode 100644 index 000000000..61ea318a3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Or.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Or model. + */ +@Immutable +public final class Or implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Or class. + * + * @param name the name value to set. + */ + @Generated + public Or(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Or from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Or 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 Or. + */ + @Generated + public static Or fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Or(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Pass.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Pass.java new file mode 100644 index 000000000..de3b6e710 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Pass.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Pass model. + */ +@Immutable +public final class Pass implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Pass class. + * + * @param name the name value to set. + */ + @Generated + public Pass(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Pass from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Pass 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 Pass. + */ + @Generated + public static Pass fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Pass(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Raise.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Raise.java new file mode 100644 index 000000000..dd0f72ddd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Raise.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Raise model. + */ +@Immutable +public final class Raise implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Raise class. + * + * @param name the name value to set. + */ + @Generated + public Raise(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Raise from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Raise 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 Raise. + */ + @Generated + public static Raise fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Raise(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Return.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Return.java new file mode 100644 index 000000000..0578b68a5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Return.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Return model. + */ +@Immutable +public final class Return implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Return class. + * + * @param name the name value to set. + */ + @Generated + public Return(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Return from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Return 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 Return. + */ + @Generated + public static Return fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Return(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/SameAsModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/SameAsModel.java new file mode 100644 index 000000000..c50a50670 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/SameAsModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The SameAsModel model. + */ +@Immutable +public final class SameAsModel implements JsonSerializable { + /* + * The SameAsModel property. + */ + @Generated + private final String sameAsModel; + + /** + * Creates an instance of SameAsModel class. + * + * @param sameAsModel the sameAsModel value to set. + */ + @Generated + public SameAsModel(String sameAsModel) { + this.sameAsModel = sameAsModel; + } + + /** + * Get the sameAsModel property: The SameAsModel property. + * + * @return the sameAsModel value. + */ + @Generated + public String getSameAsModel() { + return this.sameAsModel; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("SameAsModel", this.sameAsModel); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SameAsModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SameAsModel 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 SameAsModel. + */ + @Generated + public static SameAsModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String sameAsModel = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("SameAsModel".equals(fieldName)) { + sameAsModel = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SameAsModel(sameAsModel); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Try.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Try.java new file mode 100644 index 000000000..b3f9f64a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Try.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Try model. + */ +@Immutable +public final class Try implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Try class. + * + * @param name the name value to set. + */ + @Generated + public Try(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Try from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Try 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 Try. + */ + @Generated + public static Try fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Try(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/While.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/While.java new file mode 100644 index 000000000..07be26329 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/While.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The While model. + */ +@Immutable +public final class While implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of While class. + * + * @param name the name value to set. + */ + @Generated + public While(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of While from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of While 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 While. + */ + @Generated + public static While fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new While(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/With.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/With.java new file mode 100644 index 000000000..de21df4d2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/With.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The With model. + */ +@Immutable +public final class With implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of With class. + * + * @param name the name value to set. + */ + @Generated + public With(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of With from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of With 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 With. + */ + @Generated + public static With fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new With(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Yield.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Yield.java new file mode 100644 index 000000000..6f293d4be --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/Yield.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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; + +/** + * The Yield model. + */ +@Immutable +public final class Yield implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Yield class. + * + * @param name the name value to set. + */ + @Generated + public Yield(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Yield from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Yield 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 Yield. + */ + @Generated + public static Yield fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Yield(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/package-info.java new file mode 100644 index 000000000..7330a36eb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/models/package-info.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 containing the data models for SpecialWords. + * Scenarios to verify that reserved words can be used in service and generators will handle it appropriately. + * + * Current list of special words + * ```txt + * and + * as + * assert + * async + * await + * break + * class + * constructor + * continue + * def + * del + * elif + * else + * except + * exec + * finally + * for + * from + * global + * if + * import + * in + * is + * lambda + * not + * or + * pass + * raise + * return + * try + * while + * with + * yield + * ```. + * + */ +package com.specialwords.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/package-info.java new file mode 100644 index 000000000..ede7d233d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/specialwords/package-info.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 containing the classes for SpecialWords. + * Scenarios to verify that reserved words can be used in service and generators will handle it appropriately. + * + * Current list of special words + * ```txt + * and + * as + * assert + * async + * await + * break + * class + * constructor + * continue + * def + * del + * elif + * else + * except + * exec + * finally + * for + * from + * global + * if + * import + * in + * is + * lambda + * not + * or + * pass + * raise + * return + * try + * while + * with + * yield + * ```. + * + */ +package com.specialwords; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/ArrayClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/ArrayClientBuilder.java new file mode 100644 index 000000000..ff37bf08e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/ArrayClientBuilder.java @@ -0,0 +1,576 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.array.implementation.ArrayClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ArrayClient type. + */ +@ServiceClientBuilder( + serviceClients = { + Int32ValueClient.class, + Int64ValueClient.class, + BooleanValueClient.class, + StringValueClient.class, + Float32ValueClient.class, + DatetimeValueClient.class, + DurationValueClient.class, + UnknownValueClient.class, + ModelValueClient.class, + NullableFloatValueClient.class, + NullableInt32ValueClient.class, + NullableBooleanValueClient.class, + NullableStringValueClient.class, + NullableModelValueClient.class, + Int32ValueAsyncClient.class, + Int64ValueAsyncClient.class, + BooleanValueAsyncClient.class, + StringValueAsyncClient.class, + Float32ValueAsyncClient.class, + DatetimeValueAsyncClient.class, + DurationValueAsyncClient.class, + UnknownValueAsyncClient.class, + ModelValueAsyncClient.class, + NullableFloatValueAsyncClient.class, + NullableInt32ValueAsyncClient.class, + NullableBooleanValueAsyncClient.class, + NullableStringValueAsyncClient.class, + NullableModelValueAsyncClient.class }) +public final class ArrayClientBuilder 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("type-array.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ArrayClientBuilder. + */ + @Generated + public ArrayClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ArrayClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ArrayClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ArrayClientBuilder 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 ArrayClientBuilder 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 ArrayClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ArrayClientBuilder 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 ArrayClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ArrayClientBuilder 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 ArrayClientBuilder. + */ + @Generated + public ArrayClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ArrayClientImpl with the provided parameters. + * + * @return an instance of ArrayClientImpl. + */ + @Generated + private ArrayClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ArrayClientImpl client + = new ArrayClientImpl(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 Int32ValueAsyncClient class. + * + * @return an instance of Int32ValueAsyncClient. + */ + @Generated + public Int32ValueAsyncClient buildInt32ValueAsyncClient() { + return new Int32ValueAsyncClient(buildInnerClient().getInt32Values()); + } + + /** + * Builds an instance of Int64ValueAsyncClient class. + * + * @return an instance of Int64ValueAsyncClient. + */ + @Generated + public Int64ValueAsyncClient buildInt64ValueAsyncClient() { + return new Int64ValueAsyncClient(buildInnerClient().getInt64Values()); + } + + /** + * Builds an instance of BooleanValueAsyncClient class. + * + * @return an instance of BooleanValueAsyncClient. + */ + @Generated + public BooleanValueAsyncClient buildBooleanValueAsyncClient() { + return new BooleanValueAsyncClient(buildInnerClient().getBooleanValues()); + } + + /** + * Builds an instance of StringValueAsyncClient class. + * + * @return an instance of StringValueAsyncClient. + */ + @Generated + public StringValueAsyncClient buildStringValueAsyncClient() { + return new StringValueAsyncClient(buildInnerClient().getStringValues()); + } + + /** + * Builds an instance of Float32ValueAsyncClient class. + * + * @return an instance of Float32ValueAsyncClient. + */ + @Generated + public Float32ValueAsyncClient buildFloat32ValueAsyncClient() { + return new Float32ValueAsyncClient(buildInnerClient().getFloat32Values()); + } + + /** + * Builds an instance of DatetimeValueAsyncClient class. + * + * @return an instance of DatetimeValueAsyncClient. + */ + @Generated + public DatetimeValueAsyncClient buildDatetimeValueAsyncClient() { + return new DatetimeValueAsyncClient(buildInnerClient().getDatetimeValues()); + } + + /** + * Builds an instance of DurationValueAsyncClient class. + * + * @return an instance of DurationValueAsyncClient. + */ + @Generated + public DurationValueAsyncClient buildDurationValueAsyncClient() { + return new DurationValueAsyncClient(buildInnerClient().getDurationValues()); + } + + /** + * Builds an instance of UnknownValueAsyncClient class. + * + * @return an instance of UnknownValueAsyncClient. + */ + @Generated + public UnknownValueAsyncClient buildUnknownValueAsyncClient() { + return new UnknownValueAsyncClient(buildInnerClient().getUnknownValues()); + } + + /** + * Builds an instance of ModelValueAsyncClient class. + * + * @return an instance of ModelValueAsyncClient. + */ + @Generated + public ModelValueAsyncClient buildModelValueAsyncClient() { + return new ModelValueAsyncClient(buildInnerClient().getModelValues()); + } + + /** + * Builds an instance of NullableFloatValueAsyncClient class. + * + * @return an instance of NullableFloatValueAsyncClient. + */ + @Generated + public NullableFloatValueAsyncClient buildNullableFloatValueAsyncClient() { + return new NullableFloatValueAsyncClient(buildInnerClient().getNullableFloatValues()); + } + + /** + * Builds an instance of NullableInt32ValueAsyncClient class. + * + * @return an instance of NullableInt32ValueAsyncClient. + */ + @Generated + public NullableInt32ValueAsyncClient buildNullableInt32ValueAsyncClient() { + return new NullableInt32ValueAsyncClient(buildInnerClient().getNullableInt32Values()); + } + + /** + * Builds an instance of NullableBooleanValueAsyncClient class. + * + * @return an instance of NullableBooleanValueAsyncClient. + */ + @Generated + public NullableBooleanValueAsyncClient buildNullableBooleanValueAsyncClient() { + return new NullableBooleanValueAsyncClient(buildInnerClient().getNullableBooleanValues()); + } + + /** + * Builds an instance of NullableStringValueAsyncClient class. + * + * @return an instance of NullableStringValueAsyncClient. + */ + @Generated + public NullableStringValueAsyncClient buildNullableStringValueAsyncClient() { + return new NullableStringValueAsyncClient(buildInnerClient().getNullableStringValues()); + } + + /** + * Builds an instance of NullableModelValueAsyncClient class. + * + * @return an instance of NullableModelValueAsyncClient. + */ + @Generated + public NullableModelValueAsyncClient buildNullableModelValueAsyncClient() { + return new NullableModelValueAsyncClient(buildInnerClient().getNullableModelValues()); + } + + /** + * Builds an instance of Int32ValueClient class. + * + * @return an instance of Int32ValueClient. + */ + @Generated + public Int32ValueClient buildInt32ValueClient() { + return new Int32ValueClient(buildInnerClient().getInt32Values()); + } + + /** + * Builds an instance of Int64ValueClient class. + * + * @return an instance of Int64ValueClient. + */ + @Generated + public Int64ValueClient buildInt64ValueClient() { + return new Int64ValueClient(buildInnerClient().getInt64Values()); + } + + /** + * Builds an instance of BooleanValueClient class. + * + * @return an instance of BooleanValueClient. + */ + @Generated + public BooleanValueClient buildBooleanValueClient() { + return new BooleanValueClient(buildInnerClient().getBooleanValues()); + } + + /** + * Builds an instance of StringValueClient class. + * + * @return an instance of StringValueClient. + */ + @Generated + public StringValueClient buildStringValueClient() { + return new StringValueClient(buildInnerClient().getStringValues()); + } + + /** + * Builds an instance of Float32ValueClient class. + * + * @return an instance of Float32ValueClient. + */ + @Generated + public Float32ValueClient buildFloat32ValueClient() { + return new Float32ValueClient(buildInnerClient().getFloat32Values()); + } + + /** + * Builds an instance of DatetimeValueClient class. + * + * @return an instance of DatetimeValueClient. + */ + @Generated + public DatetimeValueClient buildDatetimeValueClient() { + return new DatetimeValueClient(buildInnerClient().getDatetimeValues()); + } + + /** + * Builds an instance of DurationValueClient class. + * + * @return an instance of DurationValueClient. + */ + @Generated + public DurationValueClient buildDurationValueClient() { + return new DurationValueClient(buildInnerClient().getDurationValues()); + } + + /** + * Builds an instance of UnknownValueClient class. + * + * @return an instance of UnknownValueClient. + */ + @Generated + public UnknownValueClient buildUnknownValueClient() { + return new UnknownValueClient(buildInnerClient().getUnknownValues()); + } + + /** + * Builds an instance of ModelValueClient class. + * + * @return an instance of ModelValueClient. + */ + @Generated + public ModelValueClient buildModelValueClient() { + return new ModelValueClient(buildInnerClient().getModelValues()); + } + + /** + * Builds an instance of NullableFloatValueClient class. + * + * @return an instance of NullableFloatValueClient. + */ + @Generated + public NullableFloatValueClient buildNullableFloatValueClient() { + return new NullableFloatValueClient(buildInnerClient().getNullableFloatValues()); + } + + /** + * Builds an instance of NullableInt32ValueClient class. + * + * @return an instance of NullableInt32ValueClient. + */ + @Generated + public NullableInt32ValueClient buildNullableInt32ValueClient() { + return new NullableInt32ValueClient(buildInnerClient().getNullableInt32Values()); + } + + /** + * Builds an instance of NullableBooleanValueClient class. + * + * @return an instance of NullableBooleanValueClient. + */ + @Generated + public NullableBooleanValueClient buildNullableBooleanValueClient() { + return new NullableBooleanValueClient(buildInnerClient().getNullableBooleanValues()); + } + + /** + * Builds an instance of NullableStringValueClient class. + * + * @return an instance of NullableStringValueClient. + */ + @Generated + public NullableStringValueClient buildNullableStringValueClient() { + return new NullableStringValueClient(buildInnerClient().getNullableStringValues()); + } + + /** + * Builds an instance of NullableModelValueClient class. + * + * @return an instance of NullableModelValueClient. + */ + @Generated + public NullableModelValueClient buildNullableModelValueClient() { + return new NullableModelValueClient(buildInnerClient().getNullableModelValues()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ArrayClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/BooleanValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/BooleanValueAsyncClient.java new file mode 100644 index 000000000..7a748300c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/BooleanValueAsyncClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.BooleanValuesImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class BooleanValueAsyncClient { + @Generated + private final BooleanValuesImpl serviceClient; + + /** + * Initializes an instance of BooleanValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BooleanValueAsyncClient(BooleanValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     boolean (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_BOOLEAN)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_BOOLEAN = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/BooleanValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/BooleanValueClient.java new file mode 100644 index 000000000..4dbf50c26 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/BooleanValueClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.BooleanValuesImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class BooleanValueClient { + @Generated + private final BooleanValuesImpl serviceClient; + + /** + * Initializes an instance of BooleanValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BooleanValueClient(BooleanValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     boolean (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_BOOLEAN); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_BOOLEAN = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/DatetimeValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/DatetimeValueAsyncClient.java new file mode 100644 index 000000000..fbb96c2b9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/DatetimeValueAsyncClient.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.DatetimeValuesImpl; +import java.time.OffsetDateTime; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class DatetimeValueAsyncClient { + @Generated + private final DatetimeValuesImpl serviceClient; + + /** + * Initializes an instance of DatetimeValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DatetimeValueAsyncClient(DatetimeValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     OffsetDateTime (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     OffsetDateTime (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_OFFSET_DATE_TIME)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_OFFSET_DATE_TIME + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/DatetimeValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/DatetimeValueClient.java new file mode 100644 index 000000000..95839710b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/DatetimeValueClient.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.DatetimeValuesImpl; +import java.time.OffsetDateTime; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class DatetimeValueClient { + @Generated + private final DatetimeValuesImpl serviceClient; + + /** + * Initializes an instance of DatetimeValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DatetimeValueClient(DatetimeValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     OffsetDateTime (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     OffsetDateTime (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_OFFSET_DATE_TIME); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_OFFSET_DATE_TIME + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/DurationValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/DurationValueAsyncClient.java new file mode 100644 index 000000000..fbf823cf4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/DurationValueAsyncClient.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.DurationValuesImpl; +import java.time.Duration; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class DurationValueAsyncClient { + @Generated + private final DurationValuesImpl serviceClient; + + /** + * Initializes an instance of DurationValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DurationValueAsyncClient(DurationValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     Duration (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     Duration (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DURATION)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_DURATION + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/DurationValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/DurationValueClient.java new file mode 100644 index 000000000..3b12dee52 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/DurationValueClient.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.DurationValuesImpl; +import java.time.Duration; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class DurationValueClient { + @Generated + private final DurationValuesImpl serviceClient; + + /** + * Initializes an instance of DurationValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DurationValueClient(DurationValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     Duration (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     Duration (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_DURATION); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_DURATION + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Float32ValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Float32ValueAsyncClient.java new file mode 100644 index 000000000..cc11095fc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Float32ValueAsyncClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.Float32ValuesImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class Float32ValueAsyncClient { + @Generated + private final Float32ValuesImpl serviceClient; + + /** + * Initializes an instance of Float32ValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Float32ValueAsyncClient(Float32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     double (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DOUBLE)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_DOUBLE = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Float32ValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Float32ValueClient.java new file mode 100644 index 000000000..0a74949d2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Float32ValueClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.Float32ValuesImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class Float32ValueClient { + @Generated + private final Float32ValuesImpl serviceClient; + + /** + * Initializes an instance of Float32ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Float32ValueClient(Float32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     double (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_DOUBLE); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_DOUBLE = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Int32ValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Int32ValueAsyncClient.java new file mode 100644 index 000000000..4aec6f16f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Int32ValueAsyncClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.Int32ValuesImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class Int32ValueAsyncClient { + @Generated + private final Int32ValuesImpl serviceClient; + + /** + * Initializes an instance of Int32ValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Int32ValueAsyncClient(Int32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_INTEGER)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_INTEGER = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Int32ValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Int32ValueClient.java new file mode 100644 index 000000000..28a40ec73 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Int32ValueClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.Int32ValuesImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class Int32ValueClient { + @Generated + private final Int32ValuesImpl serviceClient; + + /** + * Initializes an instance of Int32ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Int32ValueClient(Int32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_INTEGER); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_INTEGER = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Int64ValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Int64ValueAsyncClient.java new file mode 100644 index 000000000..39d5d2416 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Int64ValueAsyncClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.Int64ValuesImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class Int64ValueAsyncClient { + @Generated + private final Int64ValuesImpl serviceClient; + + /** + * Initializes an instance of Int64ValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Int64ValueAsyncClient(Int64ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     long (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     long (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_LONG)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_LONG = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Int64ValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Int64ValueClient.java new file mode 100644 index 000000000..3df1210ef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/Int64ValueClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.Int64ValuesImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class Int64ValueClient { + @Generated + private final Int64ValuesImpl serviceClient; + + /** + * Initializes an instance of Int64ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Int64ValueClient(Int64ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     long (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     long (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_LONG); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_LONG = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/ModelValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/ModelValueAsyncClient.java new file mode 100644 index 000000000..5f2495a54 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/ModelValueAsyncClient.java @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.ModelValuesImpl; +import com.type.array.models.InnerModel; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class ModelValueAsyncClient { + @Generated + private final ModelValuesImpl serviceClient; + + /** + * Initializes an instance of ModelValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelValueAsyncClient(ModelValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_INNER_MODEL)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_INNER_MODEL + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/ModelValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/ModelValueClient.java new file mode 100644 index 000000000..40372f3b3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/ModelValueClient.java @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.ModelValuesImpl; +import com.type.array.models.InnerModel; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class ModelValueClient { + @Generated + private final ModelValuesImpl serviceClient; + + /** + * Initializes an instance of ModelValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelValueClient(ModelValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_INNER_MODEL); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_INNER_MODEL + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableBooleanValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableBooleanValueAsyncClient.java new file mode 100644 index 000000000..d28335000 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableBooleanValueAsyncClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.NullableBooleanValuesImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class NullableBooleanValueAsyncClient { + @Generated + private final NullableBooleanValuesImpl serviceClient; + + /** + * Initializes an instance of NullableBooleanValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NullableBooleanValueAsyncClient(NullableBooleanValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     boolean (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_BOOLEAN)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_BOOLEAN = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableBooleanValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableBooleanValueClient.java new file mode 100644 index 000000000..44278e6b0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableBooleanValueClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.NullableBooleanValuesImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class NullableBooleanValueClient { + @Generated + private final NullableBooleanValuesImpl serviceClient; + + /** + * Initializes an instance of NullableBooleanValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NullableBooleanValueClient(NullableBooleanValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     boolean (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_BOOLEAN); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_BOOLEAN = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableFloatValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableFloatValueAsyncClient.java new file mode 100644 index 000000000..16c5ffc27 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableFloatValueAsyncClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.NullableFloatValuesImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class NullableFloatValueAsyncClient { + @Generated + private final NullableFloatValuesImpl serviceClient; + + /** + * Initializes an instance of NullableFloatValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NullableFloatValueAsyncClient(NullableFloatValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     double (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DOUBLE)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_DOUBLE = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableFloatValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableFloatValueClient.java new file mode 100644 index 000000000..57bcb1188 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableFloatValueClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.NullableFloatValuesImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class NullableFloatValueClient { + @Generated + private final NullableFloatValuesImpl serviceClient; + + /** + * Initializes an instance of NullableFloatValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NullableFloatValueClient(NullableFloatValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     double (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_DOUBLE); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_DOUBLE = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableInt32ValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableInt32ValueAsyncClient.java new file mode 100644 index 000000000..edc2d3a5c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableInt32ValueAsyncClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.NullableInt32ValuesImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class NullableInt32ValueAsyncClient { + @Generated + private final NullableInt32ValuesImpl serviceClient; + + /** + * Initializes an instance of NullableInt32ValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NullableInt32ValueAsyncClient(NullableInt32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_INTEGER)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_INTEGER = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableInt32ValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableInt32ValueClient.java new file mode 100644 index 000000000..b4dc7b7a2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableInt32ValueClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.NullableInt32ValuesImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class NullableInt32ValueClient { + @Generated + private final NullableInt32ValuesImpl serviceClient; + + /** + * Initializes an instance of NullableInt32ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NullableInt32ValueClient(NullableInt32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_INTEGER); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_INTEGER = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableModelValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableModelValueAsyncClient.java new file mode 100644 index 000000000..b7bc9b38d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableModelValueAsyncClient.java @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.NullableModelValuesImpl; +import com.type.array.models.InnerModel; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class NullableModelValueAsyncClient { + @Generated + private final NullableModelValuesImpl serviceClient; + + /** + * Initializes an instance of NullableModelValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NullableModelValueAsyncClient(NullableModelValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_INNER_MODEL)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_INNER_MODEL + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableModelValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableModelValueClient.java new file mode 100644 index 000000000..bba70ab27 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableModelValueClient.java @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.NullableModelValuesImpl; +import com.type.array.models.InnerModel; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class NullableModelValueClient { + @Generated + private final NullableModelValuesImpl serviceClient; + + /** + * Initializes an instance of NullableModelValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NullableModelValueClient(NullableModelValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_INNER_MODEL); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_INNER_MODEL + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableStringValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableStringValueAsyncClient.java new file mode 100644 index 000000000..9c13b9f85 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableStringValueAsyncClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.NullableStringValuesImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class NullableStringValueAsyncClient { + @Generated + private final NullableStringValuesImpl serviceClient; + + /** + * Initializes an instance of NullableStringValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NullableStringValueAsyncClient(NullableStringValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_STRING)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_STRING = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableStringValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableStringValueClient.java new file mode 100644 index 000000000..974c49c1a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/NullableStringValueClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.NullableStringValuesImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class NullableStringValueClient { + @Generated + private final NullableStringValuesImpl serviceClient; + + /** + * Initializes an instance of NullableStringValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NullableStringValueClient(NullableStringValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_STRING); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_STRING = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/StringValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/StringValueAsyncClient.java new file mode 100644 index 000000000..33a539ea5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/StringValueAsyncClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.StringValuesImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class StringValueAsyncClient { + @Generated + private final StringValuesImpl serviceClient; + + /** + * Initializes an instance of StringValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringValueAsyncClient(StringValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_STRING)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_STRING = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/StringValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/StringValueClient.java new file mode 100644 index 000000000..9a7d3ca46 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/StringValueClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.StringValuesImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class StringValueClient { + @Generated + private final StringValuesImpl serviceClient; + + /** + * Initializes an instance of StringValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringValueClient(StringValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_STRING); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_STRING = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/UnknownValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/UnknownValueAsyncClient.java new file mode 100644 index 000000000..bde6794e9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/UnknownValueAsyncClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.array.implementation.UnknownValuesImpl; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class, isAsync = true) +public final class UnknownValueAsyncClient { + @Generated + private final UnknownValuesImpl serviceClient; + + /** + * Initializes an instance of UnknownValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownValueAsyncClient(UnknownValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     Object (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     Object (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_OBJECT)); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_OBJECT = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/UnknownValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/UnknownValueClient.java new file mode 100644 index 000000000..69ad478c3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/UnknownValueClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array; + +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.serializer.TypeReference; +import com.type.array.implementation.UnknownValuesImpl; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class UnknownValueClient { + @Generated + private final UnknownValuesImpl serviceClient; + + /** + * Initializes an instance of UnknownValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownValueClient(UnknownValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     Object (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     Object (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_OBJECT); + } + + /** + * The put operation. + * + * @param body The body 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 put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_OBJECT = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/ArrayClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/ArrayClientImpl.java new file mode 100644 index 000000000..f2cac991f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/ArrayClientImpl.java @@ -0,0 +1,302 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the ArrayClient type. + */ +public final class ArrayClientImpl { + /** + * 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; + } + + /** + * The Int32ValuesImpl object to access its operations. + */ + private final Int32ValuesImpl int32Values; + + /** + * Gets the Int32ValuesImpl object to access its operations. + * + * @return the Int32ValuesImpl object. + */ + public Int32ValuesImpl getInt32Values() { + return this.int32Values; + } + + /** + * The Int64ValuesImpl object to access its operations. + */ + private final Int64ValuesImpl int64Values; + + /** + * Gets the Int64ValuesImpl object to access its operations. + * + * @return the Int64ValuesImpl object. + */ + public Int64ValuesImpl getInt64Values() { + return this.int64Values; + } + + /** + * The BooleanValuesImpl object to access its operations. + */ + private final BooleanValuesImpl booleanValues; + + /** + * Gets the BooleanValuesImpl object to access its operations. + * + * @return the BooleanValuesImpl object. + */ + public BooleanValuesImpl getBooleanValues() { + return this.booleanValues; + } + + /** + * The StringValuesImpl object to access its operations. + */ + private final StringValuesImpl stringValues; + + /** + * Gets the StringValuesImpl object to access its operations. + * + * @return the StringValuesImpl object. + */ + public StringValuesImpl getStringValues() { + return this.stringValues; + } + + /** + * The Float32ValuesImpl object to access its operations. + */ + private final Float32ValuesImpl float32Values; + + /** + * Gets the Float32ValuesImpl object to access its operations. + * + * @return the Float32ValuesImpl object. + */ + public Float32ValuesImpl getFloat32Values() { + return this.float32Values; + } + + /** + * The DatetimeValuesImpl object to access its operations. + */ + private final DatetimeValuesImpl datetimeValues; + + /** + * Gets the DatetimeValuesImpl object to access its operations. + * + * @return the DatetimeValuesImpl object. + */ + public DatetimeValuesImpl getDatetimeValues() { + return this.datetimeValues; + } + + /** + * The DurationValuesImpl object to access its operations. + */ + private final DurationValuesImpl durationValues; + + /** + * Gets the DurationValuesImpl object to access its operations. + * + * @return the DurationValuesImpl object. + */ + public DurationValuesImpl getDurationValues() { + return this.durationValues; + } + + /** + * The UnknownValuesImpl object to access its operations. + */ + private final UnknownValuesImpl unknownValues; + + /** + * Gets the UnknownValuesImpl object to access its operations. + * + * @return the UnknownValuesImpl object. + */ + public UnknownValuesImpl getUnknownValues() { + return this.unknownValues; + } + + /** + * The ModelValuesImpl object to access its operations. + */ + private final ModelValuesImpl modelValues; + + /** + * Gets the ModelValuesImpl object to access its operations. + * + * @return the ModelValuesImpl object. + */ + public ModelValuesImpl getModelValues() { + return this.modelValues; + } + + /** + * The NullableFloatValuesImpl object to access its operations. + */ + private final NullableFloatValuesImpl nullableFloatValues; + + /** + * Gets the NullableFloatValuesImpl object to access its operations. + * + * @return the NullableFloatValuesImpl object. + */ + public NullableFloatValuesImpl getNullableFloatValues() { + return this.nullableFloatValues; + } + + /** + * The NullableInt32ValuesImpl object to access its operations. + */ + private final NullableInt32ValuesImpl nullableInt32Values; + + /** + * Gets the NullableInt32ValuesImpl object to access its operations. + * + * @return the NullableInt32ValuesImpl object. + */ + public NullableInt32ValuesImpl getNullableInt32Values() { + return this.nullableInt32Values; + } + + /** + * The NullableBooleanValuesImpl object to access its operations. + */ + private final NullableBooleanValuesImpl nullableBooleanValues; + + /** + * Gets the NullableBooleanValuesImpl object to access its operations. + * + * @return the NullableBooleanValuesImpl object. + */ + public NullableBooleanValuesImpl getNullableBooleanValues() { + return this.nullableBooleanValues; + } + + /** + * The NullableStringValuesImpl object to access its operations. + */ + private final NullableStringValuesImpl nullableStringValues; + + /** + * Gets the NullableStringValuesImpl object to access its operations. + * + * @return the NullableStringValuesImpl object. + */ + public NullableStringValuesImpl getNullableStringValues() { + return this.nullableStringValues; + } + + /** + * The NullableModelValuesImpl object to access its operations. + */ + private final NullableModelValuesImpl nullableModelValues; + + /** + * Gets the NullableModelValuesImpl object to access its operations. + * + * @return the NullableModelValuesImpl object. + */ + public NullableModelValuesImpl getNullableModelValues() { + return this.nullableModelValues; + } + + /** + * Initializes an instance of ArrayClient client. + * + * @param endpoint Service host. + */ + public ArrayClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ArrayClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ArrayClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ArrayClient 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 ArrayClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.int32Values = new Int32ValuesImpl(this); + this.int64Values = new Int64ValuesImpl(this); + this.booleanValues = new BooleanValuesImpl(this); + this.stringValues = new StringValuesImpl(this); + this.float32Values = new Float32ValuesImpl(this); + this.datetimeValues = new DatetimeValuesImpl(this); + this.durationValues = new DurationValuesImpl(this); + this.unknownValues = new UnknownValuesImpl(this); + this.modelValues = new ModelValuesImpl(this); + this.nullableFloatValues = new NullableFloatValuesImpl(this); + this.nullableInt32Values = new NullableInt32ValuesImpl(this); + this.nullableBooleanValues = new NullableBooleanValuesImpl(this); + this.nullableStringValues = new NullableStringValuesImpl(this); + this.nullableModelValues = new NullableModelValuesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/BooleanValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/BooleanValuesImpl.java new file mode 100644 index 000000000..3f0d5b06a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/BooleanValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 BooleanValues. + */ +public final class BooleanValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BooleanValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of BooleanValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BooleanValuesImpl(ArrayClientImpl client) { + this.service + = RestProxy.create(BooleanValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientBooleanValues to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientBooleanVa") + public interface BooleanValuesService { + @Get("/type/array/boolean") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/boolean") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/boolean") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/boolean") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     boolean (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     boolean (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/DatetimeValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/DatetimeValuesImpl.java new file mode 100644 index 000000000..7878448bf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/DatetimeValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 DatetimeValues. + */ +public final class DatetimeValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DatetimeValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of DatetimeValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DatetimeValuesImpl(ArrayClientImpl client) { + this.service + = RestProxy.create(DatetimeValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientDatetimeValues to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientDatetimeV") + public interface DatetimeValuesService { + @Get("/type/array/datetime") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/datetime") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/datetime") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/datetime") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     OffsetDateTime (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     OffsetDateTime (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     OffsetDateTime (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     OffsetDateTime (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/DurationValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/DurationValuesImpl.java new file mode 100644 index 000000000..bdb025310 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/DurationValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 DurationValues. + */ +public final class DurationValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DurationValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of DurationValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DurationValuesImpl(ArrayClientImpl client) { + this.service + = RestProxy.create(DurationValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientDurationValues to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientDurationV") + public interface DurationValuesService { + @Get("/type/array/duration") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/duration") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/duration") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/duration") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     Duration (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     Duration (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     Duration (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     Duration (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/Float32ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/Float32ValuesImpl.java new file mode 100644 index 000000000..3090e9b8c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/Float32ValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Float32Values. + */ +public final class Float32ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Float32ValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of Float32ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Float32ValuesImpl(ArrayClientImpl client) { + this.service + = RestProxy.create(Float32ValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientFloat32Values to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientFloat32Va") + public interface Float32ValuesService { + @Get("/type/array/float32") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/float32") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/float32") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/float32") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     double (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     double (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/Int32ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/Int32ValuesImpl.java new file mode 100644 index 000000000..7a32bda1c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/Int32ValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Int32Values. + */ +public final class Int32ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Int32ValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of Int32ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Int32ValuesImpl(ArrayClientImpl client) { + this.service + = RestProxy.create(Int32ValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientInt32Values to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientInt32Valu") + public interface Int32ValuesService { + @Get("/type/array/int32") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/int32") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/int32") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/int32") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/Int64ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/Int64ValuesImpl.java new file mode 100644 index 000000000..0ee68b417 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/Int64ValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Int64Values. + */ +public final class Int64ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Int64ValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of Int64ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Int64ValuesImpl(ArrayClientImpl client) { + this.service + = RestProxy.create(Int64ValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientInt64Values to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientInt64Valu") + public interface Int64ValuesService { + @Get("/type/array/int64") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/int64") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/int64") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/int64") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     long (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     long (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     long (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     long (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/ModelValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/ModelValuesImpl.java new file mode 100644 index 000000000..a9b4bbdf1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/ModelValuesImpl.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ModelValues. + */ +public final class ModelValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of ModelValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelValuesImpl(ArrayClientImpl client) { + this.service + = RestProxy.create(ModelValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientModelValues to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientModelValu") + public interface ModelValuesService { + @Get("/type/array/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> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/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 getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/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> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/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 putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableBooleanValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableBooleanValuesImpl.java new file mode 100644 index 000000000..4fdf0dd3e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableBooleanValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 NullableBooleanValues. + */ +public final class NullableBooleanValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NullableBooleanValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of NullableBooleanValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NullableBooleanValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(NullableBooleanValuesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientNullableBooleanValues to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientNullableB") + public interface NullableBooleanValuesService { + @Get("/type/array/nullable-boolean") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/nullable-boolean") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/nullable-boolean") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/nullable-boolean") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     boolean (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     boolean (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableFloatValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableFloatValuesImpl.java new file mode 100644 index 000000000..7c5932bec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableFloatValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 NullableFloatValues. + */ +public final class NullableFloatValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NullableFloatValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of NullableFloatValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NullableFloatValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(NullableFloatValuesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientNullableFloatValues to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientNullableF") + public interface NullableFloatValuesService { + @Get("/type/array/nullable-float") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/nullable-float") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/nullable-float") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/nullable-float") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     double (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     double (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableInt32ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableInt32ValuesImpl.java new file mode 100644 index 000000000..b4c447bfa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableInt32ValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 NullableInt32Values. + */ +public final class NullableInt32ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NullableInt32ValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of NullableInt32ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NullableInt32ValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(NullableInt32ValuesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientNullableInt32Values to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientNullableI") + public interface NullableInt32ValuesService { + @Get("/type/array/nullable-int32") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/nullable-int32") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/nullable-int32") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/nullable-int32") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableModelValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableModelValuesImpl.java new file mode 100644 index 000000000..643063bfb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableModelValuesImpl.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 NullableModelValues. + */ +public final class NullableModelValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NullableModelValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of NullableModelValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NullableModelValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(NullableModelValuesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientNullableModelValues to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientNullableM") + public interface NullableModelValuesService { + @Get("/type/array/nullable-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> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/nullable-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 getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/nullable-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> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/nullable-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 putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableStringValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableStringValuesImpl.java new file mode 100644 index 000000000..bbf0ce8b3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/NullableStringValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 NullableStringValues. + */ +public final class NullableStringValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NullableStringValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of NullableStringValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NullableStringValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(NullableStringValuesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientNullableStringValues to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientNullableS") + public interface NullableStringValuesService { + @Get("/type/array/nullable-string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/nullable-string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/nullable-string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/nullable-string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/StringValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/StringValuesImpl.java new file mode 100644 index 000000000..a4f654a3d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/StringValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 StringValues. + */ +public final class StringValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of StringValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringValuesImpl(ArrayClientImpl client) { + this.service + = RestProxy.create(StringValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientStringValues to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientStringVal") + public interface StringValuesService { + @Get("/type/array/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/UnknownValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/UnknownValuesImpl.java new file mode 100644 index 000000000..278340bf3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/UnknownValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnknownValues. + */ +public final class UnknownValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of UnknownValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownValuesImpl(ArrayClientImpl client) { + this.service + = RestProxy.create(UnknownValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientUnknownValues to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArrayClientUnknownVa") + public interface UnknownValuesService { + @Get("/type/array/unknown") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/array/unknown") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/array/unknown") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/array/unknown") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     Object (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     Object (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     Object (Required)
+     * ]
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * [
+     *     Object (Required)
+     * ]
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/implementation/package-info.java new file mode 100644 index 000000000..119788aee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/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 Array. + * Illustrates various types of arrays. + * + */ +package com.type.array.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/models/InnerModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/models/InnerModel.java new file mode 100644 index 000000000..824170778 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/models/InnerModel.java @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.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; +import java.util.List; + +/** + * Array inner model. + */ +@Fluent +public final class InnerModel implements JsonSerializable { + /* + * Required string property + */ + @Generated + private final String property; + + /* + * The children property. + */ + @Generated + private List children; + + /** + * Creates an instance of InnerModel class. + * + * @param property the property value to set. + */ + @Generated + public InnerModel(String property) { + this.property = property; + } + + /** + * Get the property property: Required string property. + * + * @return the property value. + */ + @Generated + public String getProperty() { + return this.property; + } + + /** + * Get the children property: The children property. + * + * @return the children value. + */ + @Generated + public List getChildren() { + return this.children; + } + + /** + * Set the children property: The children property. + * + * @param children the children value to set. + * @return the InnerModel object itself. + */ + @Generated + public InnerModel setChildren(List children) { + this.children = children; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + jsonWriter.writeArrayField("children", this.children, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerModel 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 InnerModel. + */ + @Generated + public static InnerModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String property = null; + List children = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getString(); + } else if ("children".equals(fieldName)) { + children = reader.readArray(reader1 -> InnerModel.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + InnerModel deserializedInnerModel = new InnerModel(property); + deserializedInnerModel.children = children; + + return deserializedInnerModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/models/package-info.java new file mode 100644 index 000000000..a9eabe4a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/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 Array. + * Illustrates various types of arrays. + * + */ +package com.type.array.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/package-info.java new file mode 100644 index 000000000..bcec7e927 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/array/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 Array. + * Illustrates various types of arrays. + * + */ +package com.type.array; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/BooleanValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/BooleanValueAsyncClient.java new file mode 100644 index 000000000..628a90cb7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/BooleanValueAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.dictionary.implementation.BooleanValuesImpl; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class, isAsync = true) +public final class BooleanValueAsyncClient { + @Generated + private final BooleanValuesImpl serviceClient; + + /** + * Initializes an instance of BooleanValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BooleanValueAsyncClient(BooleanValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: boolean (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_MAP_STRING_BOOLEAN)); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_BOOLEAN + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/BooleanValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/BooleanValueClient.java new file mode 100644 index 000000000..60aca2a38 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/BooleanValueClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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.serializer.TypeReference; +import com.type.dictionary.implementation.BooleanValuesImpl; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class BooleanValueClient { + @Generated + private final BooleanValuesImpl serviceClient; + + /** + * Initializes an instance of BooleanValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BooleanValueClient(BooleanValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: boolean (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_MAP_STRING_BOOLEAN); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_BOOLEAN + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DatetimeValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DatetimeValueAsyncClient.java new file mode 100644 index 000000000..7c7f770cc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DatetimeValueAsyncClient.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.dictionary.implementation.DatetimeValuesImpl; +import java.time.OffsetDateTime; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class, isAsync = true) +public final class DatetimeValueAsyncClient { + @Generated + private final DatetimeValuesImpl serviceClient; + + /** + * Initializes an instance of DatetimeValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DatetimeValueAsyncClient(DatetimeValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: OffsetDateTime (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_MAP_STRING_OFFSET_DATE_TIME)); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_OFFSET_DATE_TIME + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DatetimeValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DatetimeValueClient.java new file mode 100644 index 000000000..813caf422 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DatetimeValueClient.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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.serializer.TypeReference; +import com.type.dictionary.implementation.DatetimeValuesImpl; +import java.time.OffsetDateTime; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class DatetimeValueClient { + @Generated + private final DatetimeValuesImpl serviceClient; + + /** + * Initializes an instance of DatetimeValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DatetimeValueClient(DatetimeValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: OffsetDateTime (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_MAP_STRING_OFFSET_DATE_TIME); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_OFFSET_DATE_TIME + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DictionaryClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DictionaryClientBuilder.java new file mode 100644 index 000000000..d9c58a5c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DictionaryClientBuilder.java @@ -0,0 +1,510 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.dictionary.implementation.DictionaryClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the DictionaryClient type. + */ +@ServiceClientBuilder( + serviceClients = { + Int32ValueClient.class, + Int64ValueClient.class, + BooleanValueClient.class, + StringValueClient.class, + Float32ValueClient.class, + DatetimeValueClient.class, + DurationValueClient.class, + UnknownValueClient.class, + ModelValueClient.class, + RecursiveModelValueClient.class, + NullableFloatValueClient.class, + Int32ValueAsyncClient.class, + Int64ValueAsyncClient.class, + BooleanValueAsyncClient.class, + StringValueAsyncClient.class, + Float32ValueAsyncClient.class, + DatetimeValueAsyncClient.class, + DurationValueAsyncClient.class, + UnknownValueAsyncClient.class, + ModelValueAsyncClient.class, + RecursiveModelValueAsyncClient.class, + NullableFloatValueAsyncClient.class }) +public final class DictionaryClientBuilder 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("type-dictionary.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the DictionaryClientBuilder. + */ + @Generated + public DictionaryClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DictionaryClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DictionaryClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DictionaryClientBuilder 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 DictionaryClientBuilder 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 DictionaryClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DictionaryClientBuilder 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 DictionaryClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public DictionaryClientBuilder 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 DictionaryClientBuilder. + */ + @Generated + public DictionaryClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of DictionaryClientImpl with the provided parameters. + * + * @return an instance of DictionaryClientImpl. + */ + @Generated + private DictionaryClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + DictionaryClientImpl client + = new DictionaryClientImpl(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 Int32ValueAsyncClient class. + * + * @return an instance of Int32ValueAsyncClient. + */ + @Generated + public Int32ValueAsyncClient buildInt32ValueAsyncClient() { + return new Int32ValueAsyncClient(buildInnerClient().getInt32Values()); + } + + /** + * Builds an instance of Int64ValueAsyncClient class. + * + * @return an instance of Int64ValueAsyncClient. + */ + @Generated + public Int64ValueAsyncClient buildInt64ValueAsyncClient() { + return new Int64ValueAsyncClient(buildInnerClient().getInt64Values()); + } + + /** + * Builds an instance of BooleanValueAsyncClient class. + * + * @return an instance of BooleanValueAsyncClient. + */ + @Generated + public BooleanValueAsyncClient buildBooleanValueAsyncClient() { + return new BooleanValueAsyncClient(buildInnerClient().getBooleanValues()); + } + + /** + * Builds an instance of StringValueAsyncClient class. + * + * @return an instance of StringValueAsyncClient. + */ + @Generated + public StringValueAsyncClient buildStringValueAsyncClient() { + return new StringValueAsyncClient(buildInnerClient().getStringValues()); + } + + /** + * Builds an instance of Float32ValueAsyncClient class. + * + * @return an instance of Float32ValueAsyncClient. + */ + @Generated + public Float32ValueAsyncClient buildFloat32ValueAsyncClient() { + return new Float32ValueAsyncClient(buildInnerClient().getFloat32Values()); + } + + /** + * Builds an instance of DatetimeValueAsyncClient class. + * + * @return an instance of DatetimeValueAsyncClient. + */ + @Generated + public DatetimeValueAsyncClient buildDatetimeValueAsyncClient() { + return new DatetimeValueAsyncClient(buildInnerClient().getDatetimeValues()); + } + + /** + * Builds an instance of DurationValueAsyncClient class. + * + * @return an instance of DurationValueAsyncClient. + */ + @Generated + public DurationValueAsyncClient buildDurationValueAsyncClient() { + return new DurationValueAsyncClient(buildInnerClient().getDurationValues()); + } + + /** + * Builds an instance of UnknownValueAsyncClient class. + * + * @return an instance of UnknownValueAsyncClient. + */ + @Generated + public UnknownValueAsyncClient buildUnknownValueAsyncClient() { + return new UnknownValueAsyncClient(buildInnerClient().getUnknownValues()); + } + + /** + * Builds an instance of ModelValueAsyncClient class. + * + * @return an instance of ModelValueAsyncClient. + */ + @Generated + public ModelValueAsyncClient buildModelValueAsyncClient() { + return new ModelValueAsyncClient(buildInnerClient().getModelValues()); + } + + /** + * Builds an instance of RecursiveModelValueAsyncClient class. + * + * @return an instance of RecursiveModelValueAsyncClient. + */ + @Generated + public RecursiveModelValueAsyncClient buildRecursiveModelValueAsyncClient() { + return new RecursiveModelValueAsyncClient(buildInnerClient().getRecursiveModelValues()); + } + + /** + * Builds an instance of NullableFloatValueAsyncClient class. + * + * @return an instance of NullableFloatValueAsyncClient. + */ + @Generated + public NullableFloatValueAsyncClient buildNullableFloatValueAsyncClient() { + return new NullableFloatValueAsyncClient(buildInnerClient().getNullableFloatValues()); + } + + /** + * Builds an instance of Int32ValueClient class. + * + * @return an instance of Int32ValueClient. + */ + @Generated + public Int32ValueClient buildInt32ValueClient() { + return new Int32ValueClient(buildInnerClient().getInt32Values()); + } + + /** + * Builds an instance of Int64ValueClient class. + * + * @return an instance of Int64ValueClient. + */ + @Generated + public Int64ValueClient buildInt64ValueClient() { + return new Int64ValueClient(buildInnerClient().getInt64Values()); + } + + /** + * Builds an instance of BooleanValueClient class. + * + * @return an instance of BooleanValueClient. + */ + @Generated + public BooleanValueClient buildBooleanValueClient() { + return new BooleanValueClient(buildInnerClient().getBooleanValues()); + } + + /** + * Builds an instance of StringValueClient class. + * + * @return an instance of StringValueClient. + */ + @Generated + public StringValueClient buildStringValueClient() { + return new StringValueClient(buildInnerClient().getStringValues()); + } + + /** + * Builds an instance of Float32ValueClient class. + * + * @return an instance of Float32ValueClient. + */ + @Generated + public Float32ValueClient buildFloat32ValueClient() { + return new Float32ValueClient(buildInnerClient().getFloat32Values()); + } + + /** + * Builds an instance of DatetimeValueClient class. + * + * @return an instance of DatetimeValueClient. + */ + @Generated + public DatetimeValueClient buildDatetimeValueClient() { + return new DatetimeValueClient(buildInnerClient().getDatetimeValues()); + } + + /** + * Builds an instance of DurationValueClient class. + * + * @return an instance of DurationValueClient. + */ + @Generated + public DurationValueClient buildDurationValueClient() { + return new DurationValueClient(buildInnerClient().getDurationValues()); + } + + /** + * Builds an instance of UnknownValueClient class. + * + * @return an instance of UnknownValueClient. + */ + @Generated + public UnknownValueClient buildUnknownValueClient() { + return new UnknownValueClient(buildInnerClient().getUnknownValues()); + } + + /** + * Builds an instance of ModelValueClient class. + * + * @return an instance of ModelValueClient. + */ + @Generated + public ModelValueClient buildModelValueClient() { + return new ModelValueClient(buildInnerClient().getModelValues()); + } + + /** + * Builds an instance of RecursiveModelValueClient class. + * + * @return an instance of RecursiveModelValueClient. + */ + @Generated + public RecursiveModelValueClient buildRecursiveModelValueClient() { + return new RecursiveModelValueClient(buildInnerClient().getRecursiveModelValues()); + } + + /** + * Builds an instance of NullableFloatValueClient class. + * + * @return an instance of NullableFloatValueClient. + */ + @Generated + public NullableFloatValueClient buildNullableFloatValueClient() { + return new NullableFloatValueClient(buildInnerClient().getNullableFloatValues()); + } + + private static final ClientLogger LOGGER = new ClientLogger(DictionaryClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DurationValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DurationValueAsyncClient.java new file mode 100644 index 000000000..d13242142 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DurationValueAsyncClient.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.dictionary.implementation.DurationValuesImpl; +import java.time.Duration; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class, isAsync = true) +public final class DurationValueAsyncClient { + @Generated + private final DurationValuesImpl serviceClient; + + /** + * Initializes an instance of DurationValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DurationValueAsyncClient(DurationValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: Duration (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: Duration (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_MAP_STRING_DURATION)); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_DURATION + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DurationValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DurationValueClient.java new file mode 100644 index 000000000..184875c6c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/DurationValueClient.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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.serializer.TypeReference; +import com.type.dictionary.implementation.DurationValuesImpl; +import java.time.Duration; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class DurationValueClient { + @Generated + private final DurationValuesImpl serviceClient; + + /** + * Initializes an instance of DurationValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DurationValueClient(DurationValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: Duration (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: Duration (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_MAP_STRING_DURATION); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_DURATION + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Float32ValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Float32ValueAsyncClient.java new file mode 100644 index 000000000..2afb7881f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Float32ValueAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.dictionary.implementation.Float32ValuesImpl; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class, isAsync = true) +public final class Float32ValueAsyncClient { + @Generated + private final Float32ValuesImpl serviceClient; + + /** + * Initializes an instance of Float32ValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Float32ValueAsyncClient(Float32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: double (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: double (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_MAP_STRING_DOUBLE)); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_DOUBLE + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Float32ValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Float32ValueClient.java new file mode 100644 index 000000000..18a437616 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Float32ValueClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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.serializer.TypeReference; +import com.type.dictionary.implementation.Float32ValuesImpl; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class Float32ValueClient { + @Generated + private final Float32ValuesImpl serviceClient; + + /** + * Initializes an instance of Float32ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Float32ValueClient(Float32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: double (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: double (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_MAP_STRING_DOUBLE); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_DOUBLE + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Int32ValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Int32ValueAsyncClient.java new file mode 100644 index 000000000..7de6c0d72 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Int32ValueAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.dictionary.implementation.Int32ValuesImpl; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class, isAsync = true) +public final class Int32ValueAsyncClient { + @Generated + private final Int32ValuesImpl serviceClient; + + /** + * Initializes an instance of Int32ValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Int32ValueAsyncClient(Int32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: 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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: int (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_MAP_STRING_INTEGER)); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_INTEGER + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Int32ValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Int32ValueClient.java new file mode 100644 index 000000000..31bea0c39 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Int32ValueClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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.serializer.TypeReference; +import com.type.dictionary.implementation.Int32ValuesImpl; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class Int32ValueClient { + @Generated + private final Int32ValuesImpl serviceClient; + + /** + * Initializes an instance of Int32ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Int32ValueClient(Int32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: 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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: int (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_MAP_STRING_INTEGER); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_INTEGER + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Int64ValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Int64ValueAsyncClient.java new file mode 100644 index 000000000..2fea0d0ba --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Int64ValueAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.dictionary.implementation.Int64ValuesImpl; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class, isAsync = true) +public final class Int64ValueAsyncClient { + @Generated + private final Int64ValuesImpl serviceClient; + + /** + * Initializes an instance of Int64ValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Int64ValueAsyncClient(Int64ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: long (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: long (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_MAP_STRING_LONG)); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_LONG + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Int64ValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Int64ValueClient.java new file mode 100644 index 000000000..adedbeab0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/Int64ValueClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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.serializer.TypeReference; +import com.type.dictionary.implementation.Int64ValuesImpl; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class Int64ValueClient { + @Generated + private final Int64ValuesImpl serviceClient; + + /** + * Initializes an instance of Int64ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Int64ValueClient(Int64ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: long (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: long (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_MAP_STRING_LONG); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_LONG + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/ModelValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/ModelValueAsyncClient.java new file mode 100644 index 000000000..4b5b1abca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/ModelValueAsyncClient.java @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.dictionary.implementation.ModelValuesImpl; +import com.type.dictionary.models.InnerModel; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class, isAsync = true) +public final class ModelValueAsyncClient { + @Generated + private final ModelValuesImpl serviceClient; + + /** + * Initializes an instance of ModelValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelValueAsyncClient(ModelValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_MAP_STRING_INNER_MODEL)); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_INNER_MODEL + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/ModelValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/ModelValueClient.java new file mode 100644 index 000000000..4104c0c38 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/ModelValueClient.java @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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.serializer.TypeReference; +import com.type.dictionary.implementation.ModelValuesImpl; +import com.type.dictionary.models.InnerModel; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class ModelValueClient { + @Generated + private final ModelValuesImpl serviceClient; + + /** + * Initializes an instance of ModelValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelValueClient(ModelValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_MAP_STRING_INNER_MODEL); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_INNER_MODEL + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/NullableFloatValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/NullableFloatValueAsyncClient.java new file mode 100644 index 000000000..984f40996 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/NullableFloatValueAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.dictionary.implementation.NullableFloatValuesImpl; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class, isAsync = true) +public final class NullableFloatValueAsyncClient { + @Generated + private final NullableFloatValuesImpl serviceClient; + + /** + * Initializes an instance of NullableFloatValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NullableFloatValueAsyncClient(NullableFloatValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: Double (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: Double (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_MAP_STRING_DOUBLE)); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_DOUBLE + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/NullableFloatValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/NullableFloatValueClient.java new file mode 100644 index 000000000..47f9d893d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/NullableFloatValueClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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.serializer.TypeReference; +import com.type.dictionary.implementation.NullableFloatValuesImpl; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class NullableFloatValueClient { + @Generated + private final NullableFloatValuesImpl serviceClient; + + /** + * Initializes an instance of NullableFloatValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NullableFloatValueClient(NullableFloatValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: Double (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: Double (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_MAP_STRING_DOUBLE); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_DOUBLE + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/RecursiveModelValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/RecursiveModelValueAsyncClient.java new file mode 100644 index 000000000..ffd9257b4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/RecursiveModelValueAsyncClient.java @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.dictionary.implementation.RecursiveModelValuesImpl; +import com.type.dictionary.models.InnerModel; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class, isAsync = true) +public final class RecursiveModelValueAsyncClient { + @Generated + private final RecursiveModelValuesImpl serviceClient; + + /** + * Initializes an instance of RecursiveModelValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RecursiveModelValueAsyncClient(RecursiveModelValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_MAP_STRING_INNER_MODEL)); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_INNER_MODEL + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/RecursiveModelValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/RecursiveModelValueClient.java new file mode 100644 index 000000000..1eecfcbf8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/RecursiveModelValueClient.java @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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.serializer.TypeReference; +import com.type.dictionary.implementation.RecursiveModelValuesImpl; +import com.type.dictionary.models.InnerModel; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class RecursiveModelValueClient { + @Generated + private final RecursiveModelValuesImpl serviceClient; + + /** + * Initializes an instance of RecursiveModelValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RecursiveModelValueClient(RecursiveModelValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_MAP_STRING_INNER_MODEL); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_INNER_MODEL + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/StringValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/StringValueAsyncClient.java new file mode 100644 index 000000000..68e13d53a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/StringValueAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.dictionary.implementation.StringValuesImpl; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class, isAsync = true) +public final class StringValueAsyncClient { + @Generated + private final StringValuesImpl serviceClient; + + /** + * Initializes an instance of StringValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringValueAsyncClient(StringValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_MAP_STRING_STRING)); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_STRING + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/StringValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/StringValueClient.java new file mode 100644 index 000000000..4f37910bf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/StringValueClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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.serializer.TypeReference; +import com.type.dictionary.implementation.StringValuesImpl; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class StringValueClient { + @Generated + private final StringValuesImpl serviceClient; + + /** + * Initializes an instance of StringValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringValueClient(StringValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: String (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_MAP_STRING_STRING); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_STRING + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/UnknownValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/UnknownValueAsyncClient.java new file mode 100644 index 000000000..2c3ccd9f7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/UnknownValueAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.dictionary.implementation.UnknownValuesImpl; +import java.util.Map; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class, isAsync = true) +public final class UnknownValueAsyncClient { + @Generated + private final UnknownValuesImpl serviceClient; + + /** + * Initializes an instance of UnknownValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownValueAsyncClient(UnknownValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: Object (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: Object (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_MAP_STRING_OBJECT)); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_OBJECT + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/UnknownValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/UnknownValueClient.java new file mode 100644 index 000000000..68579d60a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/UnknownValueClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary; + +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.serializer.TypeReference; +import com.type.dictionary.implementation.UnknownValuesImpl; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class UnknownValueClient { + @Generated + private final UnknownValuesImpl serviceClient; + + /** + * Initializes an instance of UnknownValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownValueClient(UnknownValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: Object (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: Object (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_MAP_STRING_OBJECT); + } + + /** + * The put operation. + * + * @param body The body 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 put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_MAP_STRING_OBJECT + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/BooleanValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/BooleanValuesImpl.java new file mode 100644 index 000000000..4252c4d7f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/BooleanValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 BooleanValues. + */ +public final class BooleanValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BooleanValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of BooleanValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BooleanValuesImpl(DictionaryClientImpl client) { + this.service + = RestProxy.create(BooleanValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientBooleanValues to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DictionaryClientBool") + public interface BooleanValuesService { + @Get("/type/dictionary/boolean") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/dictionary/boolean") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/boolean") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/boolean") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: boolean (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: boolean (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: boolean (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/DatetimeValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/DatetimeValuesImpl.java new file mode 100644 index 000000000..c69e91000 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/DatetimeValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 DatetimeValues. + */ +public final class DatetimeValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DatetimeValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of DatetimeValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DatetimeValuesImpl(DictionaryClientImpl client) { + this.service + = RestProxy.create(DatetimeValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientDatetimeValues to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DictionaryClientDate") + public interface DatetimeValuesService { + @Get("/type/dictionary/datetime") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/dictionary/datetime") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/datetime") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/datetime") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: OffsetDateTime (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: OffsetDateTime (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/DictionaryClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/DictionaryClientImpl.java new file mode 100644 index 000000000..e102ac619 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/DictionaryClientImpl.java @@ -0,0 +1,257 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the DictionaryClient type. + */ +public final class DictionaryClientImpl { + /** + * 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; + } + + /** + * The Int32ValuesImpl object to access its operations. + */ + private final Int32ValuesImpl int32Values; + + /** + * Gets the Int32ValuesImpl object to access its operations. + * + * @return the Int32ValuesImpl object. + */ + public Int32ValuesImpl getInt32Values() { + return this.int32Values; + } + + /** + * The Int64ValuesImpl object to access its operations. + */ + private final Int64ValuesImpl int64Values; + + /** + * Gets the Int64ValuesImpl object to access its operations. + * + * @return the Int64ValuesImpl object. + */ + public Int64ValuesImpl getInt64Values() { + return this.int64Values; + } + + /** + * The BooleanValuesImpl object to access its operations. + */ + private final BooleanValuesImpl booleanValues; + + /** + * Gets the BooleanValuesImpl object to access its operations. + * + * @return the BooleanValuesImpl object. + */ + public BooleanValuesImpl getBooleanValues() { + return this.booleanValues; + } + + /** + * The StringValuesImpl object to access its operations. + */ + private final StringValuesImpl stringValues; + + /** + * Gets the StringValuesImpl object to access its operations. + * + * @return the StringValuesImpl object. + */ + public StringValuesImpl getStringValues() { + return this.stringValues; + } + + /** + * The Float32ValuesImpl object to access its operations. + */ + private final Float32ValuesImpl float32Values; + + /** + * Gets the Float32ValuesImpl object to access its operations. + * + * @return the Float32ValuesImpl object. + */ + public Float32ValuesImpl getFloat32Values() { + return this.float32Values; + } + + /** + * The DatetimeValuesImpl object to access its operations. + */ + private final DatetimeValuesImpl datetimeValues; + + /** + * Gets the DatetimeValuesImpl object to access its operations. + * + * @return the DatetimeValuesImpl object. + */ + public DatetimeValuesImpl getDatetimeValues() { + return this.datetimeValues; + } + + /** + * The DurationValuesImpl object to access its operations. + */ + private final DurationValuesImpl durationValues; + + /** + * Gets the DurationValuesImpl object to access its operations. + * + * @return the DurationValuesImpl object. + */ + public DurationValuesImpl getDurationValues() { + return this.durationValues; + } + + /** + * The UnknownValuesImpl object to access its operations. + */ + private final UnknownValuesImpl unknownValues; + + /** + * Gets the UnknownValuesImpl object to access its operations. + * + * @return the UnknownValuesImpl object. + */ + public UnknownValuesImpl getUnknownValues() { + return this.unknownValues; + } + + /** + * The ModelValuesImpl object to access its operations. + */ + private final ModelValuesImpl modelValues; + + /** + * Gets the ModelValuesImpl object to access its operations. + * + * @return the ModelValuesImpl object. + */ + public ModelValuesImpl getModelValues() { + return this.modelValues; + } + + /** + * The RecursiveModelValuesImpl object to access its operations. + */ + private final RecursiveModelValuesImpl recursiveModelValues; + + /** + * Gets the RecursiveModelValuesImpl object to access its operations. + * + * @return the RecursiveModelValuesImpl object. + */ + public RecursiveModelValuesImpl getRecursiveModelValues() { + return this.recursiveModelValues; + } + + /** + * The NullableFloatValuesImpl object to access its operations. + */ + private final NullableFloatValuesImpl nullableFloatValues; + + /** + * Gets the NullableFloatValuesImpl object to access its operations. + * + * @return the NullableFloatValuesImpl object. + */ + public NullableFloatValuesImpl getNullableFloatValues() { + return this.nullableFloatValues; + } + + /** + * Initializes an instance of DictionaryClient client. + * + * @param endpoint Service host. + */ + public DictionaryClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of DictionaryClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public DictionaryClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of DictionaryClient 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 DictionaryClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.int32Values = new Int32ValuesImpl(this); + this.int64Values = new Int64ValuesImpl(this); + this.booleanValues = new BooleanValuesImpl(this); + this.stringValues = new StringValuesImpl(this); + this.float32Values = new Float32ValuesImpl(this); + this.datetimeValues = new DatetimeValuesImpl(this); + this.durationValues = new DurationValuesImpl(this); + this.unknownValues = new UnknownValuesImpl(this); + this.modelValues = new ModelValuesImpl(this); + this.recursiveModelValues = new RecursiveModelValuesImpl(this); + this.nullableFloatValues = new NullableFloatValuesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/DurationValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/DurationValuesImpl.java new file mode 100644 index 000000000..fd34b374c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/DurationValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 DurationValues. + */ +public final class DurationValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DurationValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of DurationValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DurationValuesImpl(DictionaryClientImpl client) { + this.service + = RestProxy.create(DurationValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientDurationValues to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DictionaryClientDura") + public interface DurationValuesService { + @Get("/type/dictionary/duration") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/dictionary/duration") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/duration") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/duration") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: Duration (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: Duration (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: Duration (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: Duration (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/Float32ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/Float32ValuesImpl.java new file mode 100644 index 000000000..31c0c48d5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/Float32ValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Float32Values. + */ +public final class Float32ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Float32ValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of Float32ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Float32ValuesImpl(DictionaryClientImpl client) { + this.service + = RestProxy.create(Float32ValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientFloat32Values to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DictionaryClientFloa") + public interface Float32ValuesService { + @Get("/type/dictionary/float32") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/dictionary/float32") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/float32") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/float32") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: double (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: double (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: double (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: double (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/Int32ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/Int32ValuesImpl.java new file mode 100644 index 000000000..218a66342 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/Int32ValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Int32Values. + */ +public final class Int32ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Int32ValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of Int32ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Int32ValuesImpl(DictionaryClientImpl client) { + this.service + = RestProxy.create(Int32ValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientInt32Values to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DictionaryClientInt3") + public interface Int32ValuesService { + @Get("/type/dictionary/int32") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/dictionary/int32") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/int32") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/int32") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: 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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: 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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: int (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: int (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/Int64ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/Int64ValuesImpl.java new file mode 100644 index 000000000..0a4f18ef6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/Int64ValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Int64Values. + */ +public final class Int64ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Int64ValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of Int64ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Int64ValuesImpl(DictionaryClientImpl client) { + this.service + = RestProxy.create(Int64ValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientInt64Values to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DictionaryClientInt6") + public interface Int64ValuesService { + @Get("/type/dictionary/int64") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/dictionary/int64") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/int64") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/int64") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: long (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: long (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: long (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: long (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/ModelValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/ModelValuesImpl.java new file mode 100644 index 000000000..67b28966e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/ModelValuesImpl.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ModelValues. + */ +public final class ModelValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of ModelValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelValuesImpl(DictionaryClientImpl client) { + this.service + = RestProxy.create(ModelValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientModelValues to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DictionaryClientMode") + public interface ModelValuesService { + @Get("/type/dictionary/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> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/dictionary/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 getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/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> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/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 putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/NullableFloatValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/NullableFloatValuesImpl.java new file mode 100644 index 000000000..4bbec7bc7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/NullableFloatValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 NullableFloatValues. + */ +public final class NullableFloatValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NullableFloatValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of NullableFloatValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NullableFloatValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(NullableFloatValuesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientNullableFloatValues to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DictionaryClientNull") + public interface NullableFloatValuesService { + @Get("/type/dictionary/nullable-float") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/dictionary/nullable-float") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/nullable-float") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/nullable-float") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: Double (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: Double (Optional)
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: Double (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: Double (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/RecursiveModelValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/RecursiveModelValuesImpl.java new file mode 100644 index 000000000..ee8fad64f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/RecursiveModelValuesImpl.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 RecursiveModelValues. + */ +public final class RecursiveModelValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RecursiveModelValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of RecursiveModelValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + RecursiveModelValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(RecursiveModelValuesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientRecursiveModelValues to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DictionaryClientRecu") + public interface RecursiveModelValuesService { + @Get("/type/dictionary/model/recursive") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/dictionary/model/recursive") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/model/recursive") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/model/recursive") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/StringValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/StringValuesImpl.java new file mode 100644 index 000000000..185d11e41 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/StringValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 StringValues. + */ +public final class StringValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of StringValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringValuesImpl(DictionaryClientImpl client) { + this.service + = RestProxy.create(StringValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientStringValues to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DictionaryClientStri") + public interface StringValuesService { + @Get("/type/dictionary/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/dictionary/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: String (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: String (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: String (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/UnknownValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/UnknownValuesImpl.java new file mode 100644 index 000000000..c8669d7a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/UnknownValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnknownValues. + */ +public final class UnknownValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of UnknownValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownValuesImpl(DictionaryClientImpl client) { + this.service + = RestProxy.create(UnknownValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientUnknownValues to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DictionaryClientUnkn") + public interface UnknownValuesService { + @Get("/type/dictionary/unknown") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/dictionary/unknown") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/unknown") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/dictionary/unknown") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: Object (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     String: Object (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: Object (Required)
+     * }
+     * }
+ * + * @param body The body 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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     String: Object (Required)
+     * }
+     * }
+ * + * @param body The body 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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/implementation/package-info.java new file mode 100644 index 000000000..c75d1a51c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/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 Dictionary. + * Illustrates various of dictionaries. + * + */ +package com.type.dictionary.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/models/InnerModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/models/InnerModel.java new file mode 100644 index 000000000..c5383b592 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/models/InnerModel.java @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.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; +import java.util.Map; + +/** + * Dictionary inner model. + */ +@Fluent +public final class InnerModel implements JsonSerializable { + /* + * Required string property + */ + @Generated + private final String property; + + /* + * The children property. + */ + @Generated + private Map children; + + /** + * Creates an instance of InnerModel class. + * + * @param property the property value to set. + */ + @Generated + public InnerModel(String property) { + this.property = property; + } + + /** + * Get the property property: Required string property. + * + * @return the property value. + */ + @Generated + public String getProperty() { + return this.property; + } + + /** + * Get the children property: The children property. + * + * @return the children value. + */ + @Generated + public Map getChildren() { + return this.children; + } + + /** + * Set the children property: The children property. + * + * @param children the children value to set. + * @return the InnerModel object itself. + */ + @Generated + public InnerModel setChildren(Map children) { + this.children = children; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + jsonWriter.writeMapField("children", this.children, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerModel 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 InnerModel. + */ + @Generated + public static InnerModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String property = null; + Map children = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getString(); + } else if ("children".equals(fieldName)) { + children = reader.readMap(reader1 -> InnerModel.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + InnerModel deserializedInnerModel = new InnerModel(property); + deserializedInnerModel.children = children; + + return deserializedInnerModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/models/package-info.java new file mode 100644 index 000000000..fabc85f9e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/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 Dictionary. + * Illustrates various of dictionaries. + * + */ +package com.type.dictionary.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/package-info.java new file mode 100644 index 000000000..9e3449f5c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/dictionary/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 Dictionary. + * Illustrates various of dictionaries. + * + */ +package com.type.dictionary; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/ExtensibleAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/ExtensibleAsyncClient.java new file mode 100644 index 000000000..15b1e2eea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/ExtensibleAsyncClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.enums.extensible; + +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 com.type.enums.extensible.implementation.StringOperationsImpl; +import com.type.enums.extensible.models.DaysOfWeekExtensibleEnum; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ExtensibleClient type. + */ +@ServiceClient(builder = ExtensibleClientBuilder.class, isAsync = true) +public final class ExtensibleAsyncClient { + @Generated + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of ExtensibleAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtensibleAsyncClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getKnownValue operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @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 days of the week along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getKnownValueWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getKnownValueWithResponseAsync(requestOptions); + } + + /** + * The getUnknownValue operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @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 days of the week along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getUnknownValueWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getUnknownValueWithResponseAsync(requestOptions); + } + + /** + * The putKnownValue operation. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body The body 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> putKnownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putKnownValueWithResponseAsync(body, requestOptions); + } + + /** + * The putUnknownValue operation. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body The body 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> putUnknownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putUnknownValueWithResponseAsync(body, requestOptions); + } + + /** + * The getKnownValue 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 days of the week on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getKnownValue() { + // Generated convenience method for getKnownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getKnownValueWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> DaysOfWeekExtensibleEnum.fromString(protocolMethodData.toObject(String.class))); + } + + /** + * The getUnknownValue 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 days of the week on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getUnknownValue() { + // Generated convenience method for getUnknownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getUnknownValueWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> DaysOfWeekExtensibleEnum.fromString(protocolMethodData.toObject(String.class))); + } + + /** + * The putKnownValue operation. + * + * @param body The body 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 putKnownValue(DaysOfWeekExtensibleEnum body) { + // Generated convenience method for putKnownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putKnownValueWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * The putUnknownValue operation. + * + * @param body The body 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 putUnknownValue(DaysOfWeekExtensibleEnum body) { + // Generated convenience method for putUnknownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putUnknownValueWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/ExtensibleClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/ExtensibleClient.java new file mode 100644 index 000000000..1fb59042b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/ExtensibleClient.java @@ -0,0 +1,202 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.enums.extensible; + +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.type.enums.extensible.implementation.StringOperationsImpl; +import com.type.enums.extensible.models.DaysOfWeekExtensibleEnum; + +/** + * Initializes a new instance of the synchronous ExtensibleClient type. + */ +@ServiceClient(builder = ExtensibleClientBuilder.class) +public final class ExtensibleClient { + @Generated + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of ExtensibleClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtensibleClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getKnownValue operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @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 days of the week along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getKnownValueWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getKnownValueWithResponse(requestOptions); + } + + /** + * The getUnknownValue operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @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 days of the week along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getUnknownValueWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getUnknownValueWithResponse(requestOptions); + } + + /** + * The putKnownValue operation. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body The body 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 putKnownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putKnownValueWithResponse(body, requestOptions); + } + + /** + * The putUnknownValue operation. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body The body 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 putUnknownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putUnknownValueWithResponse(body, requestOptions); + } + + /** + * The getKnownValue 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 days of the week. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DaysOfWeekExtensibleEnum getKnownValue() { + // Generated convenience method for getKnownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return DaysOfWeekExtensibleEnum + .fromString(getKnownValueWithResponse(requestOptions).getValue().toObject(String.class)); + } + + /** + * The getUnknownValue 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 days of the week. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DaysOfWeekExtensibleEnum getUnknownValue() { + // Generated convenience method for getUnknownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return DaysOfWeekExtensibleEnum + .fromString(getUnknownValueWithResponse(requestOptions).getValue().toObject(String.class)); + } + + /** + * The putKnownValue operation. + * + * @param body The body 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 putKnownValue(DaysOfWeekExtensibleEnum body) { + // Generated convenience method for putKnownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + putKnownValueWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .getValue(); + } + + /** + * The putUnknownValue operation. + * + * @param body The body 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 putUnknownValue(DaysOfWeekExtensibleEnum body) { + // Generated convenience method for putUnknownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + putUnknownValueWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/ExtensibleClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/ExtensibleClientBuilder.java new file mode 100644 index 000000000..a97dfecb8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/ExtensibleClientBuilder.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 com.type.enums.extensible; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.enums.extensible.implementation.ExtensibleClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ExtensibleClient type. + */ +@ServiceClientBuilder(serviceClients = { ExtensibleClient.class, ExtensibleAsyncClient.class }) +public final class ExtensibleClientBuilder 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("type-enums-extensible.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ExtensibleClientBuilder. + */ + @Generated + public ExtensibleClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ExtensibleClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ExtensibleClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ExtensibleClientBuilder 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 ExtensibleClientBuilder 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 ExtensibleClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ExtensibleClientBuilder 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 ExtensibleClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ExtensibleClientBuilder 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 ExtensibleClientBuilder. + */ + @Generated + public ExtensibleClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ExtensibleClientImpl with the provided parameters. + * + * @return an instance of ExtensibleClientImpl. + */ + @Generated + private ExtensibleClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ExtensibleClientImpl client + = new ExtensibleClientImpl(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 ExtensibleAsyncClient class. + * + * @return an instance of ExtensibleAsyncClient. + */ + @Generated + public ExtensibleAsyncClient buildAsyncClient() { + return new ExtensibleAsyncClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of ExtensibleClient class. + * + * @return an instance of ExtensibleClient. + */ + @Generated + public ExtensibleClient buildClient() { + return new ExtensibleClient(buildInnerClient().getStringOperations()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ExtensibleClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/implementation/ExtensibleClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/implementation/ExtensibleClientImpl.java new file mode 100644 index 000000000..6f5732026 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/implementation/ExtensibleClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.enums.extensible.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the ExtensibleClient type. + */ +public final class ExtensibleClientImpl { + /** + * 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; + } + + /** + * The StringOperationsImpl object to access its operations. + */ + private final StringOperationsImpl stringOperations; + + /** + * Gets the StringOperationsImpl object to access its operations. + * + * @return the StringOperationsImpl object. + */ + public StringOperationsImpl getStringOperations() { + return this.stringOperations; + } + + /** + * Initializes an instance of ExtensibleClient client. + * + * @param endpoint Service host. + */ + public ExtensibleClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ExtensibleClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ExtensibleClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ExtensibleClient 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 ExtensibleClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.stringOperations = new StringOperationsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/implementation/StringOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/implementation/StringOperationsImpl.java new file mode 100644 index 000000000..fa6ded7ce --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/implementation/StringOperationsImpl.java @@ -0,0 +1,314 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.enums.extensible.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 StringOperations. + */ +public final class StringOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ExtensibleClientImpl client; + + /** + * Initializes an instance of StringOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringOperationsImpl(ExtensibleClientImpl client) { + this.service + = RestProxy.create(StringOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ExtensibleClientStringOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ExtensibleClientStri") + public interface StringOperationsService { + @Get("/type/enum/extensible/string/known-value") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getKnownValue(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/enum/extensible/string/known-value") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getKnownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/enum/extensible/string/unknown-value") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getUnknownValue(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/enum/extensible/string/unknown-value") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getUnknownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/enum/extensible/string/known-value") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putKnownValue(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/enum/extensible/string/known-value") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putKnownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/enum/extensible/string/unknown-value") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putUnknownValue(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/enum/extensible/string/unknown-value") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putUnknownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The getKnownValue operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @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 days of the week along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getKnownValueWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getKnownValue(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getKnownValue operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @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 days of the week along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getKnownValueWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getKnownValueSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The getUnknownValue operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @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 days of the week along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getUnknownValueWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getUnknownValue(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getUnknownValue operation. + *

Response Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @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 days of the week along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getUnknownValueWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getUnknownValueSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The putKnownValue operation. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body The body 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> putKnownValueWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putKnownValue(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The putKnownValue operation. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body The body 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 putKnownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putKnownValueSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The putUnknownValue operation. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body The body 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> putUnknownValueWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putUnknownValue(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The putUnknownValue operation. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body The body 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 putUnknownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putUnknownValueSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/implementation/package-info.java new file mode 100644 index 000000000..efa784d1b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Extensible. + * + */ +package com.type.enums.extensible.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/models/DaysOfWeekExtensibleEnum.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/models/DaysOfWeekExtensibleEnum.java new file mode 100644 index 000000000..fb87b5032 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/models/DaysOfWeekExtensibleEnum.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.enums.extensible.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Days of the week. + */ +public final class DaysOfWeekExtensibleEnum extends ExpandableStringEnum { + /** + * Monday. + */ + @Generated + public static final DaysOfWeekExtensibleEnum MONDAY = fromString("Monday"); + + /** + * Tuesday. + */ + @Generated + public static final DaysOfWeekExtensibleEnum TUESDAY = fromString("Tuesday"); + + /** + * Wednesday. + */ + @Generated + public static final DaysOfWeekExtensibleEnum WEDNESDAY = fromString("Wednesday"); + + /** + * Thursday. + */ + @Generated + public static final DaysOfWeekExtensibleEnum THURSDAY = fromString("Thursday"); + + /** + * Friday. + */ + @Generated + public static final DaysOfWeekExtensibleEnum FRIDAY = fromString("Friday"); + + /** + * Saturday. + */ + @Generated + public static final DaysOfWeekExtensibleEnum SATURDAY = fromString("Saturday"); + + /** + * Sunday. + */ + @Generated + public static final DaysOfWeekExtensibleEnum SUNDAY = fromString("Sunday"); + + /** + * Creates a new instance of DaysOfWeekExtensibleEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DaysOfWeekExtensibleEnum() { + } + + /** + * Creates or finds a DaysOfWeekExtensibleEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding DaysOfWeekExtensibleEnum. + */ + @Generated + public static DaysOfWeekExtensibleEnum fromString(String name) { + return fromString(name, DaysOfWeekExtensibleEnum.class); + } + + /** + * Gets known DaysOfWeekExtensibleEnum values. + * + * @return known DaysOfWeekExtensibleEnum values. + */ + @Generated + public static Collection values() { + return values(DaysOfWeekExtensibleEnum.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/models/package-info.java new file mode 100644 index 000000000..8628947e0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Extensible. + * + */ +package com.type.enums.extensible.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/package-info.java new file mode 100644 index 000000000..6e4bc1f7c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/extensible/package-info.java @@ -0,0 +1,10 @@ +// 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 Extensible. + * + */ +package com.type.enums.extensible; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/FixedAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/FixedAsyncClient.java new file mode 100644 index 000000000..6fce7b873 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/FixedAsyncClient.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.enums.fixed; + +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 com.type.enums.fixed.implementation.StringOperationsImpl; +import com.type.enums.fixed.models.DaysOfWeekEnum; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous FixedClient type. + */ +@ServiceClient(builder = FixedClientBuilder.class, isAsync = true) +public final class FixedAsyncClient { + @Generated + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of FixedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FixedAsyncClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * getKnownValue. + *

Response Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @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 days of the week along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getKnownValueWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getKnownValueWithResponseAsync(requestOptions); + } + + /** + * putKnownValue. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body _. + * @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> putKnownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putKnownValueWithResponseAsync(body, requestOptions); + } + + /** + * putUnknownValue. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body _. + * @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> putUnknownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putUnknownValueWithResponseAsync(body, requestOptions); + } + + /** + * getKnownValue. + * + * @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 days of the week on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getKnownValue() { + // Generated convenience method for getKnownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getKnownValueWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> DaysOfWeekEnum.fromString(protocolMethodData.toObject(String.class))); + } + + /** + * putKnownValue. + * + * @param body _. + * @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 putKnownValue(DaysOfWeekEnum body) { + // Generated convenience method for putKnownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putKnownValueWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * putUnknownValue. + * + * @param body _. + * @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 putUnknownValue(DaysOfWeekEnum body) { + // Generated convenience method for putUnknownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putUnknownValueWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/FixedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/FixedClient.java new file mode 100644 index 000000000..3831007ca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/FixedClient.java @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.enums.fixed; + +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.type.enums.fixed.implementation.StringOperationsImpl; +import com.type.enums.fixed.models.DaysOfWeekEnum; + +/** + * Initializes a new instance of the synchronous FixedClient type. + */ +@ServiceClient(builder = FixedClientBuilder.class) +public final class FixedClient { + @Generated + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of FixedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FixedClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * getKnownValue. + *

Response Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @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 days of the week along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getKnownValueWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getKnownValueWithResponse(requestOptions); + } + + /** + * putKnownValue. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body _. + * @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 putKnownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putKnownValueWithResponse(body, requestOptions); + } + + /** + * putUnknownValue. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body _. + * @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 putUnknownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putUnknownValueWithResponse(body, requestOptions); + } + + /** + * getKnownValue. + * + * @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 days of the week. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DaysOfWeekEnum getKnownValue() { + // Generated convenience method for getKnownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return DaysOfWeekEnum.fromString(getKnownValueWithResponse(requestOptions).getValue().toObject(String.class)); + } + + /** + * putKnownValue. + * + * @param body _. + * @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 putKnownValue(DaysOfWeekEnum body) { + // Generated convenience method for putKnownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + putKnownValueWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .getValue(); + } + + /** + * putUnknownValue. + * + * @param body _. + * @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 putUnknownValue(DaysOfWeekEnum body) { + // Generated convenience method for putUnknownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + putUnknownValueWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/FixedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/FixedClientBuilder.java new file mode 100644 index 000000000..f6976efa4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/FixedClientBuilder.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 com.type.enums.fixed; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.enums.fixed.implementation.FixedClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the FixedClient type. + */ +@ServiceClientBuilder(serviceClients = { FixedClient.class, FixedAsyncClient.class }) +public final class FixedClientBuilder 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("type-enums-fixed.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the FixedClientBuilder. + */ + @Generated + public FixedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FixedClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FixedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FixedClientBuilder 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 FixedClientBuilder 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 FixedClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FixedClientBuilder 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 FixedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FixedClientBuilder 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 FixedClientBuilder. + */ + @Generated + public FixedClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of FixedClientImpl with the provided parameters. + * + * @return an instance of FixedClientImpl. + */ + @Generated + private FixedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + FixedClientImpl client + = new FixedClientImpl(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 FixedAsyncClient class. + * + * @return an instance of FixedAsyncClient. + */ + @Generated + public FixedAsyncClient buildAsyncClient() { + return new FixedAsyncClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of FixedClient class. + * + * @return an instance of FixedClient. + */ + @Generated + public FixedClient buildClient() { + return new FixedClient(buildInnerClient().getStringOperations()); + } + + private static final ClientLogger LOGGER = new ClientLogger(FixedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/implementation/FixedClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/implementation/FixedClientImpl.java new file mode 100644 index 000000000..361d8fa83 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/implementation/FixedClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.enums.fixed.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the FixedClient type. + */ +public final class FixedClientImpl { + /** + * 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; + } + + /** + * The StringOperationsImpl object to access its operations. + */ + private final StringOperationsImpl stringOperations; + + /** + * Gets the StringOperationsImpl object to access its operations. + * + * @return the StringOperationsImpl object. + */ + public StringOperationsImpl getStringOperations() { + return this.stringOperations; + } + + /** + * Initializes an instance of FixedClient client. + * + * @param endpoint Service host. + */ + public FixedClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of FixedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public FixedClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of FixedClient 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 FixedClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.stringOperations = new StringOperationsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/implementation/StringOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/implementation/StringOperationsImpl.java new file mode 100644 index 000000000..0bf97bfa4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/implementation/StringOperationsImpl.java @@ -0,0 +1,253 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.enums.fixed.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 StringOperations. + */ +public final class StringOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringOperationsService service; + + /** + * The service client containing this operation class. + */ + private final FixedClientImpl client; + + /** + * Initializes an instance of StringOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringOperationsImpl(FixedClientImpl client) { + this.service + = RestProxy.create(StringOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for FixedClientStringOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "FixedClientStringOpe") + public interface StringOperationsService { + @Get("/type/enum/fixed/string/known-value") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getKnownValue(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/enum/fixed/string/known-value") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getKnownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/enum/fixed/string/known-value") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putKnownValue(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/enum/fixed/string/known-value") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putKnownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/enum/fixed/string/unknown-value") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putUnknownValue(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/enum/fixed/string/unknown-value") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putUnknownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * getKnownValue. + *

Response Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @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 days of the week along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getKnownValueWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getKnownValue(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * getKnownValue. + *

Response Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @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 days of the week along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getKnownValueWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getKnownValueSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * putKnownValue. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body _. + * @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> putKnownValueWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putKnownValue(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * putKnownValue. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body _. + * @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 putKnownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putKnownValueSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * putUnknownValue. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body _. + * @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> putUnknownValueWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putUnknownValue(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * putUnknownValue. + *

Request Body Schema

+ * + *
{@code
+     * String(Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday)
+     * }
+ * + * @param body _. + * @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 putUnknownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putUnknownValueSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/implementation/package-info.java new file mode 100644 index 000000000..0699b87ff --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Fixed. + * + */ +package com.type.enums.fixed.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/models/DaysOfWeekEnum.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/models/DaysOfWeekEnum.java new file mode 100644 index 000000000..372aa5b9a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/models/DaysOfWeekEnum.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.enums.fixed.models; + +/** + * Days of the week. + */ +public enum DaysOfWeekEnum { + /** + * Monday. + */ + MONDAY("Monday"), + + /** + * Tuesday. + */ + TUESDAY("Tuesday"), + + /** + * Wednesday. + */ + WEDNESDAY("Wednesday"), + + /** + * Thursday. + */ + THURSDAY("Thursday"), + + /** + * Friday. + */ + FRIDAY("Friday"), + + /** + * Saturday. + */ + SATURDAY("Saturday"), + + /** + * Sunday. + */ + SUNDAY("Sunday"); + + /** + * The actual serialized value for a DaysOfWeekEnum instance. + */ + private final String value; + + DaysOfWeekEnum(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a DaysOfWeekEnum instance. + * + * @param value the serialized value to parse. + * @return the parsed DaysOfWeekEnum object, or null if unable to parse. + */ + public static DaysOfWeekEnum fromString(String value) { + if (value == null) { + return null; + } + DaysOfWeekEnum[] items = DaysOfWeekEnum.values(); + for (DaysOfWeekEnum item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/models/package-info.java new file mode 100644 index 000000000..571586243 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Fixed. + * + */ +package com.type.enums.fixed.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/package-info.java new file mode 100644 index 000000000..2b5f71a7c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/enums/fixed/package-info.java @@ -0,0 +1,10 @@ +// 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 Fixed. + * + */ +package com.type.enums.fixed; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/EmptyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/EmptyAsyncClient.java new file mode 100644 index 000000000..8c7a7085e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/EmptyAsyncClient.java @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.empty; + +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 com.type.model.empty.implementation.EmptyClientImpl; +import com.type.model.empty.models.EmptyInput; +import com.type.model.empty.models.EmptyInputOutput; +import com.type.model.empty.models.EmptyOutput; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous EmptyClient type. + */ +@ServiceClient(builder = EmptyClientBuilder.class, isAsync = true) +public final class EmptyAsyncClient { + @Generated + private final EmptyClientImpl serviceClient; + + /** + * Initializes an instance of EmptyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EmptyAsyncClient(EmptyClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The putEmpty operation. + *

Request Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @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> putEmptyWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putEmptyWithResponseAsync(input, requestOptions); + } + + /** + * The getEmpty operation. + *

Response Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @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 empty model used in operation return type along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getEmptyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getEmptyWithResponseAsync(requestOptions); + } + + /** + * The postRoundTripEmpty operation. + *

Request Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @param body The body 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 empty model used in both parameter and return type along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postRoundTripEmptyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postRoundTripEmptyWithResponseAsync(body, requestOptions); + } + + /** + * The putEmpty 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 putEmpty(EmptyInput input) { + // Generated convenience method for putEmptyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putEmptyWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getEmpty 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 empty model used in operation return type on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getEmpty() { + // Generated convenience method for getEmptyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getEmptyWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(EmptyOutput.class)); + } + + /** + * The postRoundTripEmpty operation. + * + * @param body The body 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 empty model used in both parameter and return type on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono postRoundTripEmpty(EmptyInputOutput body) { + // Generated convenience method for postRoundTripEmptyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postRoundTripEmptyWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(EmptyInputOutput.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/EmptyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/EmptyClient.java new file mode 100644 index 000000000..d83cabc5c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/EmptyClient.java @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.empty; + +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.type.model.empty.implementation.EmptyClientImpl; +import com.type.model.empty.models.EmptyInput; +import com.type.model.empty.models.EmptyInputOutput; +import com.type.model.empty.models.EmptyOutput; + +/** + * Initializes a new instance of the synchronous EmptyClient type. + */ +@ServiceClient(builder = EmptyClientBuilder.class) +public final class EmptyClient { + @Generated + private final EmptyClientImpl serviceClient; + + /** + * Initializes an instance of EmptyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EmptyClient(EmptyClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The putEmpty operation. + *

Request Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @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 putEmptyWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putEmptyWithResponse(input, requestOptions); + } + + /** + * The getEmpty operation. + *

Response Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @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 empty model used in operation return type along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getEmptyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getEmptyWithResponse(requestOptions); + } + + /** + * The postRoundTripEmpty operation. + *

Request Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @param body The body 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 empty model used in both parameter and return type along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postRoundTripEmptyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postRoundTripEmptyWithResponse(body, requestOptions); + } + + /** + * The putEmpty 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 putEmpty(EmptyInput input) { + // Generated convenience method for putEmptyWithResponse + RequestOptions requestOptions = new RequestOptions(); + putEmptyWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getEmpty 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 empty model used in operation return type. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public EmptyOutput getEmpty() { + // Generated convenience method for getEmptyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getEmptyWithResponse(requestOptions).getValue().toObject(EmptyOutput.class); + } + + /** + * The postRoundTripEmpty operation. + * + * @param body The body 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 empty model used in both parameter and return type. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public EmptyInputOutput postRoundTripEmpty(EmptyInputOutput body) { + // Generated convenience method for postRoundTripEmptyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postRoundTripEmptyWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(EmptyInputOutput.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/EmptyClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/EmptyClientBuilder.java new file mode 100644 index 000000000..169491e89 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/EmptyClientBuilder.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 com.type.model.empty; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.model.empty.implementation.EmptyClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the EmptyClient type. + */ +@ServiceClientBuilder(serviceClients = { EmptyClient.class, EmptyAsyncClient.class }) +public final class EmptyClientBuilder 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("type-model-empty.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the EmptyClientBuilder. + */ + @Generated + public EmptyClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EmptyClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EmptyClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EmptyClientBuilder 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 EmptyClientBuilder 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 EmptyClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EmptyClientBuilder 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 EmptyClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EmptyClientBuilder 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 EmptyClientBuilder. + */ + @Generated + public EmptyClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of EmptyClientImpl with the provided parameters. + * + * @return an instance of EmptyClientImpl. + */ + @Generated + private EmptyClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + EmptyClientImpl client + = new EmptyClientImpl(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 EmptyAsyncClient class. + * + * @return an instance of EmptyAsyncClient. + */ + @Generated + public EmptyAsyncClient buildAsyncClient() { + return new EmptyAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of EmptyClient class. + * + * @return an instance of EmptyClient. + */ + @Generated + public EmptyClient buildClient() { + return new EmptyClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(EmptyClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/implementation/EmptyClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/implementation/EmptyClientImpl.java new file mode 100644 index 000000000..1efee1de4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/implementation/EmptyClientImpl.java @@ -0,0 +1,336 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.empty.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.Put; +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 EmptyClient type. + */ +public final class EmptyClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EmptyClientService 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 EmptyClient client. + * + * @param endpoint Service host. + */ + public EmptyClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of EmptyClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public EmptyClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of EmptyClient 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 EmptyClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(EmptyClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for EmptyClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "EmptyClient") + public interface EmptyClientService { + @Put("/type/model/empty/alone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putEmpty(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/empty/alone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putEmptySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Get("/type/model/empty/alone") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getEmpty(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/empty/alone") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getEmptySync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/type/model/empty/round-trip") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> postRoundTripEmpty(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/type/model/empty/round-trip") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response postRoundTripEmptySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The putEmpty operation. + *

Request Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @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> putEmptyWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.putEmpty(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The putEmpty operation. + *

Request Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @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 putEmptyWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putEmptySync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The getEmpty operation. + *

Response Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @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 empty model used in operation return type along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getEmptyWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getEmpty(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getEmpty operation. + *

Response Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @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 empty model used in operation return type along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getEmptyWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getEmptySync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The postRoundTripEmpty operation. + *

Request Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @param body The body 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 empty model used in both parameter and return type along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> postRoundTripEmptyWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.postRoundTripEmpty(this.getEndpoint(), contentType, accept, body, + requestOptions, context)); + } + + /** + * The postRoundTripEmpty operation. + *

Request Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @param body The body 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 empty model used in both parameter and return type along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response postRoundTripEmptyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.postRoundTripEmptySync(this.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/implementation/package-info.java new file mode 100644 index 000000000..01d4f0238 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/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 Empty. + * Illustrates usage of empty model used in operation's parameters and responses. + * + */ +package com.type.model.empty.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/models/EmptyInput.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/models/EmptyInput.java new file mode 100644 index 000000000..712d9e27b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/models/EmptyInput.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.empty.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; + +/** + * Empty model used in operation parameters. + */ +@Immutable +public final class EmptyInput implements JsonSerializable { + /** + * Creates an instance of EmptyInput class. + */ + @Generated + public EmptyInput() { + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EmptyInput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EmptyInput 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 EmptyInput. + */ + @Generated + public static EmptyInput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EmptyInput deserializedEmptyInput = new EmptyInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedEmptyInput; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/models/EmptyInputOutput.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/models/EmptyInputOutput.java new file mode 100644 index 000000000..a904d8d61 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/models/EmptyInputOutput.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.empty.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; + +/** + * Empty model used in both parameter and return type. + */ +@Immutable +public final class EmptyInputOutput implements JsonSerializable { + /** + * Creates an instance of EmptyInputOutput class. + */ + @Generated + public EmptyInputOutput() { + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EmptyInputOutput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EmptyInputOutput 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 EmptyInputOutput. + */ + @Generated + public static EmptyInputOutput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EmptyInputOutput deserializedEmptyInputOutput = new EmptyInputOutput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedEmptyInputOutput; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/models/EmptyOutput.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/models/EmptyOutput.java new file mode 100644 index 000000000..73e490155 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/models/EmptyOutput.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.empty.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; + +/** + * Empty model used in operation return type. + */ +@Immutable +public final class EmptyOutput implements JsonSerializable { + /** + * Creates an instance of EmptyOutput class. + */ + @Generated + private EmptyOutput() { + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EmptyOutput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EmptyOutput 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 EmptyOutput. + */ + @Generated + public static EmptyOutput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EmptyOutput deserializedEmptyOutput = new EmptyOutput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedEmptyOutput; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/models/package-info.java new file mode 100644 index 000000000..ab952de10 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/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 Empty. + * Illustrates usage of empty model used in operation's parameters and responses. + * + */ +package com.type.model.empty.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/package-info.java new file mode 100644 index 000000000..e6e6e5aae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/empty/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 Empty. + * Illustrates usage of empty model used in operation's parameters and responses. + * + */ +package com.type.model.empty; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/FlattenAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/FlattenAsyncClient.java new file mode 100644 index 000000000..6859609a3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/FlattenAsyncClient.java @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.flatten; + +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 com.type.model.flatten.implementation.FlattenClientImpl; +import com.type.model.flatten.models.FlattenModel; +import com.type.model.flatten.models.NestedFlattenModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous FlattenClient type. + */ +@ServiceClient(builder = FlattenClientBuilder.class, isAsync = true) +public final class FlattenAsyncClient { + @Generated + private final FlattenClientImpl serviceClient; + + /** + * Initializes an instance of FlattenAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FlattenAsyncClient(FlattenClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The putFlattenModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         description: String (Required)
+     *         age: int (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         description: String (Required)
+     *         age: 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 this is the model with one level of flattening along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putFlattenModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putFlattenModelWithResponseAsync(input, requestOptions); + } + + /** + * The putNestedFlattenModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         summary: String (Required)
+     *         properties (Required): {
+     *             description: String (Required)
+     *             age: int (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         summary: String (Required)
+     *         properties (Required): {
+     *             description: String (Required)
+     *             age: 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 this is the model with two levels of flattening along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putNestedFlattenModelWithResponse(BinaryData input, + RequestOptions requestOptions) { + return this.serviceClient.putNestedFlattenModelWithResponseAsync(input, requestOptions); + } + + /** + * The putFlattenModel 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 this is the model with one level of flattening on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putFlattenModel(FlattenModel input) { + // Generated convenience method for putFlattenModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putFlattenModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FlattenModel.class)); + } + + /** + * The putNestedFlattenModel 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 this is the model with two levels of flattening on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putNestedFlattenModel(NestedFlattenModel input) { + // Generated convenience method for putNestedFlattenModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putNestedFlattenModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(NestedFlattenModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/FlattenClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/FlattenClient.java new file mode 100644 index 000000000..fac28c807 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/FlattenClient.java @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.flatten; + +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.type.model.flatten.implementation.FlattenClientImpl; +import com.type.model.flatten.models.FlattenModel; +import com.type.model.flatten.models.NestedFlattenModel; + +/** + * Initializes a new instance of the synchronous FlattenClient type. + */ +@ServiceClient(builder = FlattenClientBuilder.class) +public final class FlattenClient { + @Generated + private final FlattenClientImpl serviceClient; + + /** + * Initializes an instance of FlattenClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FlattenClient(FlattenClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The putFlattenModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         description: String (Required)
+     *         age: int (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         description: String (Required)
+     *         age: 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 this is the model with one level of flattening along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putFlattenModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putFlattenModelWithResponse(input, requestOptions); + } + + /** + * The putNestedFlattenModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         summary: String (Required)
+     *         properties (Required): {
+     *             description: String (Required)
+     *             age: int (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         summary: String (Required)
+     *         properties (Required): {
+     *             description: String (Required)
+     *             age: 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 this is the model with two levels of flattening along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putNestedFlattenModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putNestedFlattenModelWithResponse(input, requestOptions); + } + + /** + * The putFlattenModel 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 this is the model with one level of flattening. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FlattenModel putFlattenModel(FlattenModel input) { + // Generated convenience method for putFlattenModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putFlattenModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue() + .toObject(FlattenModel.class); + } + + /** + * The putNestedFlattenModel 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 this is the model with two levels of flattening. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public NestedFlattenModel putNestedFlattenModel(NestedFlattenModel input) { + // Generated convenience method for putNestedFlattenModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putNestedFlattenModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue() + .toObject(NestedFlattenModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/FlattenClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/FlattenClientBuilder.java new file mode 100644 index 000000000..eb2bb843c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/FlattenClientBuilder.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 com.type.model.flatten; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.model.flatten.implementation.FlattenClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the FlattenClient type. + */ +@ServiceClientBuilder(serviceClients = { FlattenClient.class, FlattenAsyncClient.class }) +public final class FlattenClientBuilder 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("type-model-flatten.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the FlattenClientBuilder. + */ + @Generated + public FlattenClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FlattenClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FlattenClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FlattenClientBuilder 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 FlattenClientBuilder 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 FlattenClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FlattenClientBuilder 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 FlattenClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public FlattenClientBuilder 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 FlattenClientBuilder. + */ + @Generated + public FlattenClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of FlattenClientImpl with the provided parameters. + * + * @return an instance of FlattenClientImpl. + */ + @Generated + private FlattenClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + FlattenClientImpl client + = new FlattenClientImpl(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 FlattenAsyncClient class. + * + * @return an instance of FlattenAsyncClient. + */ + @Generated + public FlattenAsyncClient buildAsyncClient() { + return new FlattenAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of FlattenClient class. + * + * @return an instance of FlattenClient. + */ + @Generated + public FlattenClient buildClient() { + return new FlattenClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(FlattenClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/implementation/FlattenClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/implementation/FlattenClientImpl.java new file mode 100644 index 000000000..b80ac47c8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/implementation/FlattenClientImpl.java @@ -0,0 +1,350 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.flatten.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.Put; +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 FlattenClient type. + */ +public final class FlattenClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FlattenClientService 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 FlattenClient client. + * + * @param endpoint Service host. + */ + public FlattenClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of FlattenClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public FlattenClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of FlattenClient 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 FlattenClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(FlattenClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for FlattenClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "FlattenClient") + public interface FlattenClientService { + @Put("/type/model/flatten/flattenModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putFlattenModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + + @Put("/type/model/flatten/flattenModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putFlattenModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + + @Put("/type/model/flatten/nestedFlattenModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putNestedFlattenModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + + @Put("/type/model/flatten/nestedFlattenModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putNestedFlattenModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + } + + /** + * The putFlattenModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         description: String (Required)
+     *         age: int (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         description: String (Required)
+     *         age: 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 this is the model with one level of flattening along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putFlattenModelWithResponseAsync(BinaryData input, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.putFlattenModel(this.getEndpoint(), contentType, accept, input, + requestOptions, context)); + } + + /** + * The putFlattenModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         description: String (Required)
+     *         age: int (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         description: String (Required)
+     *         age: 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 this is the model with one level of flattening along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putFlattenModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.putFlattenModelSync(this.getEndpoint(), contentType, accept, input, requestOptions, + Context.NONE); + } + + /** + * The putNestedFlattenModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         summary: String (Required)
+     *         properties (Required): {
+     *             description: String (Required)
+     *             age: int (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         summary: String (Required)
+     *         properties (Required): {
+     *             description: String (Required)
+     *             age: 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 this is the model with two levels of flattening along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putNestedFlattenModelWithResponseAsync(BinaryData input, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.putNestedFlattenModel(this.getEndpoint(), contentType, accept, + input, requestOptions, context)); + } + + /** + * The putNestedFlattenModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         summary: String (Required)
+     *         properties (Required): {
+     *             description: String (Required)
+     *             age: int (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     properties (Required): {
+     *         summary: String (Required)
+     *         properties (Required): {
+     *             description: String (Required)
+     *             age: 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 this is the model with two levels of flattening along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putNestedFlattenModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.putNestedFlattenModelSync(this.getEndpoint(), contentType, accept, input, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/implementation/package-info.java new file mode 100644 index 000000000..d56715037 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/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 Flatten. + * Illustrates the model flatten cases. + * + */ +package com.type.model.flatten.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/ChildFlattenModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/ChildFlattenModel.java new file mode 100644 index 000000000..8235a70ad --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/ChildFlattenModel.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.flatten.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; + +/** + * This is the child model to be flattened. And it has flattened property as well. + */ +@Immutable +public final class ChildFlattenModel implements JsonSerializable { + /* + * The summary property. + */ + @Generated + private final String summary; + + /* + * The properties property. + */ + @Generated + private final ChildModel properties; + + /** + * Creates an instance of ChildFlattenModel class. + * + * @param summary the summary value to set. + * @param properties the properties value to set. + */ + @Generated + public ChildFlattenModel(String summary, ChildModel properties) { + this.summary = summary; + this.properties = properties; + } + + /** + * Get the summary property: The summary property. + * + * @return the summary value. + */ + @Generated + public String getSummary() { + return this.summary; + } + + /** + * Get the properties property: The properties property. + * + * @return the properties value. + */ + @Generated + public ChildModel getProperties() { + return this.properties; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("summary", this.summary); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ChildFlattenModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ChildFlattenModel 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 ChildFlattenModel. + */ + @Generated + public static ChildFlattenModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String summary = null; + ChildModel properties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("summary".equals(fieldName)) { + summary = reader.getString(); + } else if ("properties".equals(fieldName)) { + properties = ChildModel.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new ChildFlattenModel(summary, properties); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/ChildModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/ChildModel.java new file mode 100644 index 000000000..caaa34c2f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/ChildModel.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.flatten.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; + +/** + * This is the child model to be flattened. + */ +@Immutable +public final class ChildModel implements JsonSerializable { + /* + * The description property. + */ + @Generated + private final String description; + + /* + * The age property. + */ + @Generated + private final int age; + + /** + * Creates an instance of ChildModel class. + * + * @param description the description value to set. + * @param age the age value to set. + */ + @Generated + public ChildModel(String description, int age) { + this.description = description; + this.age = age; + } + + /** + * Get the description property: The description property. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Generated + public int getAge() { + return this.age; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeIntField("age", this.age); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ChildModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ChildModel 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 ChildModel. + */ + @Generated + public static ChildModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String description = null; + int age = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("age".equals(fieldName)) { + age = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new ChildModel(description, age); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/FlattenModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/FlattenModel.java new file mode 100644 index 000000000..cd4501821 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/FlattenModel.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.flatten.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; + +/** + * This is the model with one level of flattening. + */ +@Immutable +public final class FlattenModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The properties property. + */ + @Generated + private final ChildModel properties; + + /** + * Creates an instance of FlattenModel class. + * + * @param name the name value to set. + * @param properties the properties value to set. + */ + @Generated + public FlattenModel(String name, ChildModel properties) { + this.name = name; + this.properties = properties; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the properties property: The properties property. + * + * @return the properties value. + */ + @Generated + public ChildModel getProperties() { + return this.properties; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FlattenModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FlattenModel 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 FlattenModel. + */ + @Generated + public static FlattenModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + ChildModel properties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("properties".equals(fieldName)) { + properties = ChildModel.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new FlattenModel(name, properties); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/NestedFlattenModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/NestedFlattenModel.java new file mode 100644 index 000000000..088e4c5ab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/NestedFlattenModel.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.flatten.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; + +/** + * This is the model with two levels of flattening. + */ +@Immutable +public final class NestedFlattenModel implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The properties property. + */ + @Generated + private final ChildFlattenModel properties; + + /** + * Creates an instance of NestedFlattenModel class. + * + * @param name the name value to set. + * @param properties the properties value to set. + */ + @Generated + public NestedFlattenModel(String name, ChildFlattenModel properties) { + this.name = name; + this.properties = properties; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the properties property: The properties property. + * + * @return the properties value. + */ + @Generated + public ChildFlattenModel getProperties() { + return this.properties; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NestedFlattenModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NestedFlattenModel 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 NestedFlattenModel. + */ + @Generated + public static NestedFlattenModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + ChildFlattenModel properties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("properties".equals(fieldName)) { + properties = ChildFlattenModel.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new NestedFlattenModel(name, properties); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/models/package-info.java new file mode 100644 index 000000000..8e567fccf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/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 Flatten. + * Illustrates the model flatten cases. + * + */ +package com.type.model.flatten.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/package-info.java new file mode 100644 index 000000000..44364791b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/flatten/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 Flatten. + * Illustrates the model flatten cases. + * + */ +package com.type.model.flatten; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorAsyncClient.java new file mode 100644 index 000000000..f75a57cca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorAsyncClient.java @@ -0,0 +1,394 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumdiscriminator; + +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 com.type.model.inheritance.enumdiscriminator.implementation.EnumDiscriminatorClientImpl; +import com.type.model.inheritance.enumdiscriminator.models.Dog; +import com.type.model.inheritance.enumdiscriminator.models.Snake; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous EnumDiscriminatorClient type. + */ +@ServiceClient(builder = EnumDiscriminatorClientBuilder.class, isAsync = true) +public final class EnumDiscriminatorAsyncClient { + @Generated + private final EnumDiscriminatorClientImpl serviceClient; + + /** + * Initializes an instance of EnumDiscriminatorAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EnumDiscriminatorAsyncClient(EnumDiscriminatorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Receive model with extensible enum discriminator type. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: 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 test extensible enum type for discriminator along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getExtensibleModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getExtensibleModelWithResponseAsync(requestOptions); + } + + /** + * Send model with extensible enum discriminator type. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: int (Required)
+     * }
+     * }
+ * + * @param input Dog to create. + * @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> putExtensibleModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putExtensibleModelWithResponseAsync(input, requestOptions); + } + + /** + * Get a model omitting the discriminator. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: 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 model omitting the discriminator along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> + getExtensibleModelMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getExtensibleModelMissingDiscriminatorWithResponseAsync(requestOptions); + } + + /** + * Get a model containing discriminator value never defined. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: 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 model containing discriminator value never defined along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getExtensibleModelWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getExtensibleModelWrongDiscriminatorWithResponseAsync(requestOptions); + } + + /** + * Receive model with fixed enum discriminator type. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: 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 test fixed enum type for discriminator along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getFixedModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getFixedModelWithResponseAsync(requestOptions); + } + + /** + * Send model with fixed enum discriminator type. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: int (Required)
+     * }
+     * }
+ * + * @param input Snake to create. + * @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> putFixedModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putFixedModelWithResponseAsync(input, requestOptions); + } + + /** + * Get a model omitting the discriminator. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: 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 model omitting the discriminator along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getFixedModelMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getFixedModelMissingDiscriminatorWithResponseAsync(requestOptions); + } + + /** + * Get a model containing discriminator value never defined. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: 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 model containing discriminator value never defined along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getFixedModelWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getFixedModelWrongDiscriminatorWithResponseAsync(requestOptions); + } + + /** + * Receive model with extensible enum discriminator type. + * + * @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 test extensible enum type for discriminator on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getExtensibleModel() { + // Generated convenience method for getExtensibleModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getExtensibleModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Dog.class)); + } + + /** + * Send model with extensible enum discriminator type. + * + * @param input Dog to create. + * @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 putExtensibleModel(Dog input) { + // Generated convenience method for putExtensibleModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putExtensibleModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Get a model omitting the discriminator. + * + * @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 model omitting the discriminator on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getExtensibleModelMissingDiscriminator() { + // Generated convenience method for getExtensibleModelMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getExtensibleModelMissingDiscriminatorWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Dog.class)); + } + + /** + * Get a model containing discriminator value never defined. + * + * @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 model containing discriminator value never defined on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getExtensibleModelWrongDiscriminator() { + // Generated convenience method for getExtensibleModelWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getExtensibleModelWrongDiscriminatorWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Dog.class)); + } + + /** + * Receive model with fixed enum discriminator type. + * + * @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 test fixed enum type for discriminator on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getFixedModel() { + // Generated convenience method for getFixedModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFixedModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Snake.class)); + } + + /** + * Send model with fixed enum discriminator type. + * + * @param input Snake to create. + * @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 putFixedModel(Snake input) { + // Generated convenience method for putFixedModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putFixedModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Get a model omitting the discriminator. + * + * @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 model omitting the discriminator on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getFixedModelMissingDiscriminator() { + // Generated convenience method for getFixedModelMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFixedModelMissingDiscriminatorWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Snake.class)); + } + + /** + * Get a model containing discriminator value never defined. + * + * @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 model containing discriminator value never defined on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getFixedModelWrongDiscriminator() { + // Generated convenience method for getFixedModelWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFixedModelWrongDiscriminatorWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Snake.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClient.java new file mode 100644 index 000000000..5ab61e86e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClient.java @@ -0,0 +1,379 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumdiscriminator; + +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.type.model.inheritance.enumdiscriminator.implementation.EnumDiscriminatorClientImpl; +import com.type.model.inheritance.enumdiscriminator.models.Dog; +import com.type.model.inheritance.enumdiscriminator.models.Snake; + +/** + * Initializes a new instance of the synchronous EnumDiscriminatorClient type. + */ +@ServiceClient(builder = EnumDiscriminatorClientBuilder.class) +public final class EnumDiscriminatorClient { + @Generated + private final EnumDiscriminatorClientImpl serviceClient; + + /** + * Initializes an instance of EnumDiscriminatorClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EnumDiscriminatorClient(EnumDiscriminatorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Receive model with extensible enum discriminator type. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: 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 test extensible enum type for discriminator along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getExtensibleModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getExtensibleModelWithResponse(requestOptions); + } + + /** + * Send model with extensible enum discriminator type. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: int (Required)
+     * }
+     * }
+ * + * @param input Dog to create. + * @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 putExtensibleModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putExtensibleModelWithResponse(input, requestOptions); + } + + /** + * Get a model omitting the discriminator. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: 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 model omitting the discriminator along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getExtensibleModelMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getExtensibleModelMissingDiscriminatorWithResponse(requestOptions); + } + + /** + * Get a model containing discriminator value never defined. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: 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 model containing discriminator value never defined along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getExtensibleModelWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getExtensibleModelWrongDiscriminatorWithResponse(requestOptions); + } + + /** + * Receive model with fixed enum discriminator type. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: 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 test fixed enum type for discriminator along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getFixedModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getFixedModelWithResponse(requestOptions); + } + + /** + * Send model with fixed enum discriminator type. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: int (Required)
+     * }
+     * }
+ * + * @param input Snake to create. + * @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 putFixedModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putFixedModelWithResponse(input, requestOptions); + } + + /** + * Get a model omitting the discriminator. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: 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 model omitting the discriminator along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getFixedModelMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getFixedModelMissingDiscriminatorWithResponse(requestOptions); + } + + /** + * Get a model containing discriminator value never defined. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: 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 model containing discriminator value never defined along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getFixedModelWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getFixedModelWrongDiscriminatorWithResponse(requestOptions); + } + + /** + * Receive model with extensible enum discriminator type. + * + * @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 test extensible enum type for discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Dog getExtensibleModel() { + // Generated convenience method for getExtensibleModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getExtensibleModelWithResponse(requestOptions).getValue().toObject(Dog.class); + } + + /** + * Send model with extensible enum discriminator type. + * + * @param input Dog to create. + * @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 putExtensibleModel(Dog input) { + // Generated convenience method for putExtensibleModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putExtensibleModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * Get a model omitting the discriminator. + * + * @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 model omitting the discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Dog getExtensibleModelMissingDiscriminator() { + // Generated convenience method for getExtensibleModelMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getExtensibleModelMissingDiscriminatorWithResponse(requestOptions).getValue().toObject(Dog.class); + } + + /** + * Get a model containing discriminator value never defined. + * + * @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 model containing discriminator value never defined. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Dog getExtensibleModelWrongDiscriminator() { + // Generated convenience method for getExtensibleModelWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getExtensibleModelWrongDiscriminatorWithResponse(requestOptions).getValue().toObject(Dog.class); + } + + /** + * Receive model with fixed enum discriminator type. + * + * @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 test fixed enum type for discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Snake getFixedModel() { + // Generated convenience method for getFixedModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFixedModelWithResponse(requestOptions).getValue().toObject(Snake.class); + } + + /** + * Send model with fixed enum discriminator type. + * + * @param input Snake to create. + * @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 putFixedModel(Snake input) { + // Generated convenience method for putFixedModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putFixedModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * Get a model omitting the discriminator. + * + * @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 model omitting the discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Snake getFixedModelMissingDiscriminator() { + // Generated convenience method for getFixedModelMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFixedModelMissingDiscriminatorWithResponse(requestOptions).getValue().toObject(Snake.class); + } + + /** + * Get a model containing discriminator value never defined. + * + * @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 model containing discriminator value never defined. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Snake getFixedModelWrongDiscriminator() { + // Generated convenience method for getFixedModelWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFixedModelWrongDiscriminatorWithResponse(requestOptions).getValue().toObject(Snake.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClientBuilder.java new file mode 100644 index 000000000..2b53d0698 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumdiscriminator; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.model.inheritance.enumdiscriminator.implementation.EnumDiscriminatorClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the EnumDiscriminatorClient type. + */ +@ServiceClientBuilder(serviceClients = { EnumDiscriminatorClient.class, EnumDiscriminatorAsyncClient.class }) +public final class EnumDiscriminatorClientBuilder 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("type-model-inheritance-enumdiscriminator.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the EnumDiscriminatorClientBuilder. + */ + @Generated + public EnumDiscriminatorClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumDiscriminatorClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumDiscriminatorClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumDiscriminatorClientBuilder 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 EnumDiscriminatorClientBuilder 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 EnumDiscriminatorClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumDiscriminatorClientBuilder 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 EnumDiscriminatorClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumDiscriminatorClientBuilder 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 EnumDiscriminatorClientBuilder. + */ + @Generated + public EnumDiscriminatorClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of EnumDiscriminatorClientImpl with the provided parameters. + * + * @return an instance of EnumDiscriminatorClientImpl. + */ + @Generated + private EnumDiscriminatorClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + EnumDiscriminatorClientImpl client = new EnumDiscriminatorClientImpl(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 EnumDiscriminatorAsyncClient class. + * + * @return an instance of EnumDiscriminatorAsyncClient. + */ + @Generated + public EnumDiscriminatorAsyncClient buildAsyncClient() { + return new EnumDiscriminatorAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of EnumDiscriminatorClient class. + * + * @return an instance of EnumDiscriminatorClient. + */ + @Generated + public EnumDiscriminatorClient buildClient() { + return new EnumDiscriminatorClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(EnumDiscriminatorClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/implementation/EnumDiscriminatorClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/implementation/EnumDiscriminatorClientImpl.java new file mode 100644 index 000000000..7fd484ee8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/implementation/EnumDiscriminatorClientImpl.java @@ -0,0 +1,683 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumdiscriminator.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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 EnumDiscriminatorClient type. + */ +public final class EnumDiscriminatorClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EnumDiscriminatorClientService 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 EnumDiscriminatorClient client. + * + * @param endpoint Service host. + */ + public EnumDiscriminatorClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of EnumDiscriminatorClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public EnumDiscriminatorClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of EnumDiscriminatorClient 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 EnumDiscriminatorClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service + = RestProxy.create(EnumDiscriminatorClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for EnumDiscriminatorClient to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "EnumDiscriminatorCli") + public interface EnumDiscriminatorClientService { + @Get("/type/model/inheritance/enum-discriminator/extensible-enum") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getExtensibleModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-discriminator/extensible-enum") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getExtensibleModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/enum-discriminator/extensible-enum") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putExtensibleModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/enum-discriminator/extensible-enum") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putExtensibleModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-discriminator/extensible-enum/missingdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getExtensibleModelMissingDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-discriminator/extensible-enum/missingdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getExtensibleModelMissingDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-discriminator/extensible-enum/wrongdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getExtensibleModelWrongDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-discriminator/extensible-enum/wrongdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getExtensibleModelWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-discriminator/fixed-enum") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getFixedModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-discriminator/fixed-enum") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getFixedModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/enum-discriminator/fixed-enum") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putFixedModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/enum-discriminator/fixed-enum") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putFixedModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-discriminator/fixed-enum/missingdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getFixedModelMissingDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-discriminator/fixed-enum/missingdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getFixedModelMissingDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-discriminator/fixed-enum/wrongdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getFixedModelWrongDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-discriminator/fixed-enum/wrongdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getFixedModelWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Receive model with extensible enum discriminator type. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: 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 test extensible enum type for discriminator along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getExtensibleModelWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getExtensibleModel(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Receive model with extensible enum discriminator type. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: 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 test extensible enum type for discriminator along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getExtensibleModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getExtensibleModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Send model with extensible enum discriminator type. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: int (Required)
+     * }
+     * }
+ * + * @param input Dog to create. + * @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> putExtensibleModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putExtensibleModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * Send model with extensible enum discriminator type. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: int (Required)
+     * }
+     * }
+ * + * @param input Dog to create. + * @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 putExtensibleModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putExtensibleModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * Get a model omitting the discriminator. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: 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 model omitting the discriminator along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> + getExtensibleModelMissingDiscriminatorWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getExtensibleModelMissingDiscriminator(this.getEndpoint(), + accept, requestOptions, context)); + } + + /** + * Get a model omitting the discriminator. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: 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 model omitting the discriminator along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getExtensibleModelMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getExtensibleModelMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions, + Context.NONE); + } + + /** + * Get a model containing discriminator value never defined. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: 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 model containing discriminator value never defined along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> + getExtensibleModelWrongDiscriminatorWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getExtensibleModelWrongDiscriminator(this.getEndpoint(), accept, + requestOptions, context)); + } + + /** + * Get a model containing discriminator value never defined. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: 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 model containing discriminator value never defined along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getExtensibleModelWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getExtensibleModelWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions, + Context.NONE); + } + + /** + * Receive model with fixed enum discriminator type. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: 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 test fixed enum type for discriminator along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getFixedModelWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getFixedModel(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Receive model with fixed enum discriminator type. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: 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 test fixed enum type for discriminator along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getFixedModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getFixedModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Send model with fixed enum discriminator type. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: int (Required)
+     * }
+     * }
+ * + * @param input Snake to create. + * @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> putFixedModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putFixedModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * Send model with fixed enum discriminator type. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: int (Required)
+     * }
+     * }
+ * + * @param input Snake to create. + * @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 putFixedModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putFixedModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * Get a model omitting the discriminator. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: 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 model omitting the discriminator along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> + getFixedModelMissingDiscriminatorWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getFixedModelMissingDiscriminator(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get a model omitting the discriminator. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: 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 model omitting the discriminator along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getFixedModelMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getFixedModelMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get a model containing discriminator value never defined. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: 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 model containing discriminator value never defined along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getFixedModelWrongDiscriminatorWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getFixedModelWrongDiscriminator(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get a model containing discriminator value never defined. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: 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 model containing discriminator value never defined along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getFixedModelWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getFixedModelWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/implementation/package-info.java new file mode 100644 index 000000000..5e4b20cc9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/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 EnumDiscriminator. + * Illustrates inheritance with enum discriminator. + * + */ +package com.type.model.inheritance.enumdiscriminator.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/Cobra.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/Cobra.java new file mode 100644 index 000000000..e1a2e3096 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/Cobra.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumdiscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Cobra model. + */ +@Immutable +public final class Cobra extends Snake { + /** + * Creates an instance of Cobra class. + * + * @param length the length value to set. + */ + @Generated + public Cobra(int length) { + super(length); + this.kind = SnakeKind.COBRA; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Cobra from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Cobra 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 Cobra. + */ + @Generated + public static Cobra fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int length = 0; + SnakeKind kind = SnakeKind.COBRA; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("length".equals(fieldName)) { + length = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = SnakeKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + Cobra deserializedCobra = new Cobra(length); + deserializedCobra.kind = kind; + + return deserializedCobra; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/Dog.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/Dog.java new file mode 100644 index 000000000..ed5732e97 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/Dog.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumdiscriminator.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; + +/** + * Test extensible enum type for discriminator. + */ +@Immutable +public class Dog implements JsonSerializable { + /* + * discriminator property + */ + @Generated + DogKind kind; + + /* + * Weight of the dog + */ + @Generated + private final int weight; + + /** + * Creates an instance of Dog class. + * + * @param weight the weight value to set. + */ + @Generated + public Dog(int weight) { + this.weight = weight; + this.kind = DogKind.fromString("Dog"); + } + + /** + * Get the kind property: discriminator property. + * + * @return the kind value. + */ + @Generated + public DogKind getKind() { + return this.kind; + } + + /** + * Get the weight property: Weight of the dog. + * + * @return the weight value. + */ + @Generated + public int getWeight() { + return this.weight; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + void toJsonShared(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeIntField("weight", this.weight); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); + } + + /** + * Reads an instance of Dog from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Dog 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 Dog. + */ + @Generated + public static Dog fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("golden".equals(discriminatorValue)) { + return Golden.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Dog fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int weight = 0; + DogKind kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("weight".equals(fieldName)) { + weight = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = DogKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + Dog deserializedDog = new Dog(weight); + deserializedDog.kind = kind; + + return deserializedDog; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/DogKind.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/DogKind.java new file mode 100644 index 000000000..594fcf9f9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/DogKind.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumdiscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * extensible enum type for discriminator. + */ +public final class DogKind extends ExpandableStringEnum { + /** + * Species golden. + */ + @Generated + public static final DogKind GOLDEN = fromString("golden"); + + /** + * Creates a new instance of DogKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DogKind() { + } + + /** + * Creates or finds a DogKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding DogKind. + */ + @Generated + public static DogKind fromString(String name) { + return fromString(name, DogKind.class); + } + + /** + * Gets known DogKind values. + * + * @return known DogKind values. + */ + @Generated + public static Collection values() { + return values(DogKind.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/Golden.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/Golden.java new file mode 100644 index 000000000..6e0b67105 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/Golden.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumdiscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Golden dog model. + */ +@Immutable +public final class Golden extends Dog { + /** + * Creates an instance of Golden class. + * + * @param weight the weight value to set. + */ + @Generated + public Golden(int weight) { + super(weight); + this.kind = DogKind.GOLDEN; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Golden from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Golden 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 Golden. + */ + @Generated + public static Golden fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int weight = 0; + DogKind kind = DogKind.GOLDEN; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("weight".equals(fieldName)) { + weight = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = DogKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + Golden deserializedGolden = new Golden(weight); + deserializedGolden.kind = kind; + + return deserializedGolden; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/Snake.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/Snake.java new file mode 100644 index 000000000..b92d6efba --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/Snake.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumdiscriminator.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; + +/** + * Test fixed enum type for discriminator. + */ +@Immutable +public class Snake implements JsonSerializable { + /* + * discriminator property + */ + @Generated + SnakeKind kind; + + /* + * Length of the snake + */ + @Generated + private final int length; + + /** + * Creates an instance of Snake class. + * + * @param length the length value to set. + */ + @Generated + public Snake(int length) { + this.length = length; + this.kind = SnakeKind.fromString("Snake"); + } + + /** + * Get the kind property: discriminator property. + * + * @return the kind value. + */ + @Generated + public SnakeKind getKind() { + return this.kind; + } + + /** + * Get the length property: Length of the snake. + * + * @return the length value. + */ + @Generated + public int getLength() { + return this.length; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + void toJsonShared(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeIntField("length", this.length); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); + } + + /** + * Reads an instance of Snake from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Snake 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 Snake. + */ + @Generated + public static Snake fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("cobra".equals(discriminatorValue)) { + return Cobra.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Snake fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int length = 0; + SnakeKind kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("length".equals(fieldName)) { + length = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = SnakeKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + Snake deserializedSnake = new Snake(length); + deserializedSnake.kind = kind; + + return deserializedSnake; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/SnakeKind.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/SnakeKind.java new file mode 100644 index 000000000..8023a74e8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/SnakeKind.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumdiscriminator.models; + +/** + * fixed enum type for discriminator. + */ +public enum SnakeKind { + /** + * Species cobra. + */ + COBRA("cobra"); + + /** + * The actual serialized value for a SnakeKind instance. + */ + private final String value; + + SnakeKind(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a SnakeKind instance. + * + * @param value the serialized value to parse. + * @return the parsed SnakeKind object, or null if unable to parse. + */ + public static SnakeKind fromString(String value) { + if (value == null) { + return null; + } + SnakeKind[] items = SnakeKind.values(); + for (SnakeKind item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/models/package-info.java new file mode 100644 index 000000000..224ffd3f9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/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 EnumDiscriminator. + * Illustrates inheritance with enum discriminator. + * + */ +package com.type.model.inheritance.enumdiscriminator.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/package-info.java new file mode 100644 index 000000000..1e56960c4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumdiscriminator/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 EnumDiscriminator. + * Illustrates inheritance with enum discriminator. + * + */ +package com.type.model.inheritance.enumdiscriminator; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorAsyncClient.java new file mode 100644 index 000000000..4a05fd20e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorAsyncClient.java @@ -0,0 +1,310 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumnesteddiscriminator; + +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 com.type.model.inheritance.enumnesteddiscriminator.implementation.EnumNestedDiscriminatorClientImpl; +import com.type.model.inheritance.enumnesteddiscriminator.models.Fish; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous EnumNestedDiscriminatorClient type. + */ +@ServiceClient(builder = EnumNestedDiscriminatorClientBuilder.class, isAsync = true) +public final class EnumNestedDiscriminatorAsyncClient { + @Generated + private final EnumNestedDiscriminatorClientImpl serviceClient; + + /** + * Initializes an instance of EnumNestedDiscriminatorAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EnumNestedDiscriminatorAsyncClient(EnumNestedDiscriminatorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponseAsync(requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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> putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putModelWithResponseAsync(input, requestOptions); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRecursiveModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRecursiveModelWithResponseAsync(requestOptions); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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> putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putRecursiveModelWithResponseAsync(input, requestOptions); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getMissingDiscriminatorWithResponseAsync(requestOptions); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWrongDiscriminatorWithResponseAsync(requestOptions); + } + + /** + * The getModel 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 this is base model for polymorphic multiple levels inheritance with a discriminator on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getModel() { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Fish.class)); + } + + /** + * The putModel 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 putModel(Fish input) { + // Generated convenience method for putModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getRecursiveModel 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 this is base model for polymorphic multiple levels inheritance with a discriminator on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getRecursiveModel() { + // Generated convenience method for getRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRecursiveModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Fish.class)); + } + + /** + * The putRecursiveModel 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 putRecursiveModel(Fish input) { + // Generated convenience method for putRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putRecursiveModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getMissingDiscriminator 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 this is base model for polymorphic multiple levels inheritance with a discriminator on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getMissingDiscriminator() { + // Generated convenience method for getMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMissingDiscriminatorWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Fish.class)); + } + + /** + * The getWrongDiscriminator 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 this is base model for polymorphic multiple levels inheritance with a discriminator on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getWrongDiscriminator() { + // Generated convenience method for getWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWrongDiscriminatorWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Fish.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorClient.java new file mode 100644 index 000000000..0e8bf8134 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorClient.java @@ -0,0 +1,298 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumnesteddiscriminator; + +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.type.model.inheritance.enumnesteddiscriminator.implementation.EnumNestedDiscriminatorClientImpl; +import com.type.model.inheritance.enumnesteddiscriminator.models.Fish; + +/** + * Initializes a new instance of the synchronous EnumNestedDiscriminatorClient type. + */ +@ServiceClient(builder = EnumNestedDiscriminatorClientBuilder.class) +public final class EnumNestedDiscriminatorClient { + @Generated + private final EnumNestedDiscriminatorClientImpl serviceClient; + + /** + * Initializes an instance of EnumNestedDiscriminatorClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EnumNestedDiscriminatorClient(EnumNestedDiscriminatorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponse(requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putModelWithResponse(input, requestOptions); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRecursiveModelWithResponse(requestOptions); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putRecursiveModelWithResponse(input, requestOptions); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getMissingDiscriminatorWithResponse(requestOptions); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWrongDiscriminatorWithResponse(requestOptions); + } + + /** + * The getModel 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 this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish getModel() { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(requestOptions).getValue().toObject(Fish.class); + } + + /** + * The putModel 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 putModel(Fish input) { + // Generated convenience method for putModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getRecursiveModel 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 this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish getRecursiveModel() { + // Generated convenience method for getRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRecursiveModelWithResponse(requestOptions).getValue().toObject(Fish.class); + } + + /** + * The putRecursiveModel 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 putRecursiveModel(Fish input) { + // Generated convenience method for putRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putRecursiveModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getMissingDiscriminator 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 this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish getMissingDiscriminator() { + // Generated convenience method for getMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMissingDiscriminatorWithResponse(requestOptions).getValue().toObject(Fish.class); + } + + /** + * The getWrongDiscriminator 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 this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish getWrongDiscriminator() { + // Generated convenience method for getWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWrongDiscriminatorWithResponse(requestOptions).getValue().toObject(Fish.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorClientBuilder.java new file mode 100644 index 000000000..277df8872 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/EnumNestedDiscriminatorClientBuilder.java @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumnesteddiscriminator; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.model.inheritance.enumnesteddiscriminator.implementation.EnumNestedDiscriminatorClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the EnumNestedDiscriminatorClient type. + */ +@ServiceClientBuilder( + serviceClients = { EnumNestedDiscriminatorClient.class, EnumNestedDiscriminatorAsyncClient.class }) +public final class EnumNestedDiscriminatorClientBuilder 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("type-model-inheritance-enumnesteddiscriminator.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the EnumNestedDiscriminatorClientBuilder. + */ + @Generated + public EnumNestedDiscriminatorClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumNestedDiscriminatorClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumNestedDiscriminatorClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumNestedDiscriminatorClientBuilder 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 EnumNestedDiscriminatorClientBuilder 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 EnumNestedDiscriminatorClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumNestedDiscriminatorClientBuilder 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 EnumNestedDiscriminatorClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public EnumNestedDiscriminatorClientBuilder 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 EnumNestedDiscriminatorClientBuilder. + */ + @Generated + public EnumNestedDiscriminatorClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of EnumNestedDiscriminatorClientImpl with the provided parameters. + * + * @return an instance of EnumNestedDiscriminatorClientImpl. + */ + @Generated + private EnumNestedDiscriminatorClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + EnumNestedDiscriminatorClientImpl client = new EnumNestedDiscriminatorClientImpl(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 EnumNestedDiscriminatorAsyncClient class. + * + * @return an instance of EnumNestedDiscriminatorAsyncClient. + */ + @Generated + public EnumNestedDiscriminatorAsyncClient buildAsyncClient() { + return new EnumNestedDiscriminatorAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of EnumNestedDiscriminatorClient class. + * + * @return an instance of EnumNestedDiscriminatorClient. + */ + @Generated + public EnumNestedDiscriminatorClient buildClient() { + return new EnumNestedDiscriminatorClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(EnumNestedDiscriminatorClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/implementation/EnumNestedDiscriminatorClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/implementation/EnumNestedDiscriminatorClientImpl.java new file mode 100644 index 000000000..b98c4ecb0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/implementation/EnumNestedDiscriminatorClientImpl.java @@ -0,0 +1,547 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumnesteddiscriminator.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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 EnumNestedDiscriminatorClient type. + */ +public final class EnumNestedDiscriminatorClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EnumNestedDiscriminatorClientService 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 EnumNestedDiscriminatorClient client. + * + * @param endpoint Service host. + */ + public EnumNestedDiscriminatorClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of EnumNestedDiscriminatorClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public EnumNestedDiscriminatorClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of EnumNestedDiscriminatorClient 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 EnumNestedDiscriminatorClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(EnumNestedDiscriminatorClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for EnumNestedDiscriminatorClient to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "EnumNestedDiscrimina") + public interface EnumNestedDiscriminatorClientService { + @Get("/type/model/inheritance/enum-nested-discriminator/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> getModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-nested-discriminator/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 getModelSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/enum-nested-discriminator/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> putModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/enum-nested-discriminator/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 putModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-nested-discriminator/recursivemodel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getRecursiveModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-nested-discriminator/recursivemodel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/enum-nested-discriminator/recursivemodel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putRecursiveModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/enum-nested-discriminator/recursivemodel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-nested-discriminator/missingdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getMissingDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-nested-discriminator/missingdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getMissingDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-nested-discriminator/wrongdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getWrongDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/enum-nested-discriminator/wrongdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getModelWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getModel(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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> putModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.putModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRecursiveModelWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getRecursiveModel(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getRecursiveModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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> putRecursiveModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putRecursiveModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putRecursiveModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getMissingDiscriminatorWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getMissingDiscriminator(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWrongDiscriminatorWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getWrongDiscriminator(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String(shark/salmon) (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/implementation/package-info.java new file mode 100644 index 000000000..c47052b31 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/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 EnumNestedDiscriminator. + * Illustrates multiple level inheritance with multiple enum discriminators. + * + */ +package com.type.model.inheritance.enumnesteddiscriminator.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/Fish.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/Fish.java new file mode 100644 index 000000000..7fe697f6c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/Fish.java @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumnesteddiscriminator.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; + +/** + * This is base model for polymorphic multiple levels inheritance with a discriminator. + */ +@Immutable +public class Fish implements JsonSerializable { + /* + * discriminator property + */ + @Generated + FishKind kind; + + /* + * The age property. + */ + @Generated + private final int age; + + /** + * Creates an instance of Fish class. + * + * @param age the age value to set. + */ + @Generated + public Fish(int age) { + this.age = age; + this.kind = FishKind.fromString("Fish"); + } + + /** + * Get the kind property: discriminator property. + * + * @return the kind value. + */ + @Generated + public FishKind getKind() { + return this.kind; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Generated + public int getAge() { + return this.age; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + void toJsonShared(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeIntField("age", this.age); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); + } + + /** + * 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 -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("shark".equals(discriminatorValue)) { + return Shark.fromJson(readerToUse.reset()); + } else if ("salmon".equals(discriminatorValue)) { + return Salmon.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Fish fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + FishKind kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = FishKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + Fish deserializedFish = new Fish(age); + deserializedFish.kind = kind; + + return deserializedFish; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/FishKind.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/FishKind.java new file mode 100644 index 000000000..6c30a8a21 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/FishKind.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumnesteddiscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * extensible enum type for discriminator. + */ +public final class FishKind extends ExpandableStringEnum { + /** + * The kind of fish is shark. + */ + @Generated + public static final FishKind SHARK = fromString("shark"); + + /** + * The kind of fish is salmon. + */ + @Generated + public static final FishKind SALMON = fromString("salmon"); + + /** + * Creates a new instance of FishKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public FishKind() { + } + + /** + * Creates or finds a FishKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding FishKind. + */ + @Generated + public static FishKind fromString(String name) { + return fromString(name, FishKind.class); + } + + /** + * Gets known FishKind values. + * + * @return known FishKind values. + */ + @Generated + public static Collection values() { + return values(FishKind.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/GoblinShark.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/GoblinShark.java new file mode 100644 index 000000000..4eacca66e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/GoblinShark.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumnesteddiscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The third level model GoblinShark in polymorphic multiple levels inheritance. + */ +@Immutable +public final class GoblinShark extends Shark { + /** + * Creates an instance of GoblinShark class. + * + * @param age the age value to set. + */ + @Generated + public GoblinShark(int age) { + super(age); + this.kind = FishKind.SHARK; + this.sharktype = SharkKind.GOBLIN; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GoblinShark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GoblinShark 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 GoblinShark. + */ + @Generated + public static GoblinShark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + SharkKind sharktype = SharkKind.GOBLIN; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("sharktype".equals(fieldName)) { + sharktype = SharkKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + GoblinShark deserializedGoblinShark = new GoblinShark(age); + deserializedGoblinShark.sharktype = sharktype; + + return deserializedGoblinShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/Salmon.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/Salmon.java new file mode 100644 index 000000000..aacf0fa51 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/Salmon.java @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumnesteddiscriminator.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The second level model in polymorphic multiple levels inheritance which contains references to other polymorphic + * instances. + */ +@Fluent +public final class Salmon extends Fish { + /* + * The friends property. + */ + @Generated + private List friends; + + /* + * The hate property. + */ + @Generated + private Map hate; + + /* + * The partner property. + */ + @Generated + private Fish partner; + + /** + * Creates an instance of Salmon class. + * + * @param age the age value to set. + */ + @Generated + public Salmon(int age) { + super(age); + this.kind = FishKind.SALMON; + } + + /** + * Get the friends property: The friends property. + * + * @return the friends value. + */ + @Generated + public List getFriends() { + return this.friends; + } + + /** + * Set the friends property: The friends property. + * + * @param friends the friends value to set. + * @return the Salmon object itself. + */ + @Generated + public Salmon setFriends(List friends) { + this.friends = friends; + return this; + } + + /** + * Get the hate property: The hate property. + * + * @return the hate value. + */ + @Generated + public Map getHate() { + return this.hate; + } + + /** + * Set the hate property: The hate property. + * + * @param hate the hate value to set. + * @return the Salmon object itself. + */ + @Generated + public Salmon setHate(Map hate) { + this.hate = hate; + return this; + } + + /** + * Get the partner property: The partner property. + * + * @return the partner value. + */ + @Generated + public Fish getPartner() { + return this.partner; + } + + /** + * Set the partner property: The partner property. + * + * @param partner the partner value to set. + * @return the Salmon object itself. + */ + @Generated + public Salmon setPartner(Fish partner) { + this.partner = partner; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + jsonWriter.writeArrayField("friends", this.friends, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeMapField("hate", this.hate, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("partner", this.partner); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Salmon from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Salmon 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 Salmon. + */ + @Generated + public static Salmon fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + FishKind kind = FishKind.SALMON; + List friends = null; + Map hate = null; + Fish partner = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = FishKind.fromString(reader.getString()); + } else if ("friends".equals(fieldName)) { + friends = reader.readArray(reader1 -> Fish.fromJson(reader1)); + } else if ("hate".equals(fieldName)) { + hate = reader.readMap(reader1 -> Fish.fromJson(reader1)); + } else if ("partner".equals(fieldName)) { + partner = Fish.fromJson(reader); + } else { + reader.skipChildren(); + } + } + Salmon deserializedSalmon = new Salmon(age); + deserializedSalmon.kind = kind; + deserializedSalmon.friends = friends; + deserializedSalmon.hate = hate; + deserializedSalmon.partner = partner; + + return deserializedSalmon; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/SawShark.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/SawShark.java new file mode 100644 index 000000000..7986fca5a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/SawShark.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumnesteddiscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The third level model SawShark in polymorphic multiple levels inheritance. + */ +@Immutable +public final class SawShark extends Shark { + /** + * Creates an instance of SawShark class. + * + * @param age the age value to set. + */ + @Generated + public SawShark(int age) { + super(age); + this.kind = FishKind.SHARK; + this.sharktype = SharkKind.SAW; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SawShark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SawShark 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 SawShark. + */ + @Generated + public static SawShark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + SharkKind sharktype = SharkKind.SAW; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("sharktype".equals(fieldName)) { + sharktype = SharkKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + SawShark deserializedSawShark = new SawShark(age); + deserializedSawShark.sharktype = sharktype; + + return deserializedSawShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/Shark.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/Shark.java new file mode 100644 index 000000000..88f6d8d49 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/Shark.java @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumnesteddiscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The second level model in polymorphic multiple levels inheritance and it defines a new discriminator. + */ +@Immutable +public class Shark extends Fish { + /* + * The sharktype property. + */ + @Generated + SharkKind sharktype; + + /** + * Creates an instance of Shark class. + * + * @param age the age value to set. + */ + @Generated + public Shark(int age) { + super(age); + this.kind = FishKind.SHARK; + this.sharktype = SharkKind.fromString("shark"); + } + + /** + * Get the sharktype property: The sharktype property. + * + * @return the sharktype value. + */ + @Generated + public SharkKind getSharktype() { + return this.sharktype; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + void toJsonShared(JsonWriter jsonWriter) throws IOException { + super.toJsonShared(jsonWriter); + jsonWriter.writeStringField("sharktype", this.sharktype == null ? null : this.sharktype.toString()); + } + + /** + * Reads an instance of Shark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Shark 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 Shark. + */ + @Generated + public static Shark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("sharktype".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("saw".equals(discriminatorValue)) { + return SawShark.fromJson(readerToUse.reset()); + } else if ("goblin".equals(discriminatorValue)) { + return GoblinShark.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Shark fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + SharkKind sharktype = SharkKind.fromString("shark"); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("sharktype".equals(fieldName)) { + sharktype = SharkKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + Shark deserializedShark = new Shark(age); + deserializedShark.sharktype = sharktype; + + return deserializedShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/SharkKind.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/SharkKind.java new file mode 100644 index 000000000..d1cab0d0d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/SharkKind.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumnesteddiscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * extensible enum type for discriminator. + */ +public final class SharkKind extends ExpandableStringEnum { + /** + * The kind of shark is saw. + */ + @Generated + public static final SharkKind SAW = fromString("saw"); + + /** + * The kind of shark is goblin. + */ + @Generated + public static final SharkKind GOBLIN = fromString("goblin"); + + /** + * Creates a new instance of SharkKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public SharkKind() { + } + + /** + * Creates or finds a SharkKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding SharkKind. + */ + @Generated + public static SharkKind fromString(String name) { + return fromString(name, SharkKind.class); + } + + /** + * Gets known SharkKind values. + * + * @return known SharkKind values. + */ + @Generated + public static Collection values() { + return values(SharkKind.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/models/package-info.java new file mode 100644 index 000000000..025870e6a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/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 EnumNestedDiscriminator. + * Illustrates multiple level inheritance with multiple enum discriminators. + * + */ +package com.type.model.inheritance.enumnesteddiscriminator.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/package-info.java new file mode 100644 index 000000000..7352cd617 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/enumnesteddiscriminator/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 EnumNestedDiscriminator. + * Illustrates multiple level inheritance with multiple enum discriminators. + * + */ +package com.type.model.inheritance.enumnesteddiscriminator; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorAsyncClient.java new file mode 100644 index 000000000..36ff20643 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorAsyncClient.java @@ -0,0 +1,310 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.nesteddiscriminator; + +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 com.type.model.inheritance.nesteddiscriminator.implementation.NestedDiscriminatorClientImpl; +import com.type.model.inheritance.nesteddiscriminator.models.Fish; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NestedDiscriminatorClient type. + */ +@ServiceClient(builder = NestedDiscriminatorClientBuilder.class, isAsync = true) +public final class NestedDiscriminatorAsyncClient { + @Generated + private final NestedDiscriminatorClientImpl serviceClient; + + /** + * Initializes an instance of NestedDiscriminatorAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NestedDiscriminatorAsyncClient(NestedDiscriminatorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponseAsync(requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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> putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putModelWithResponseAsync(input, requestOptions); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRecursiveModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRecursiveModelWithResponseAsync(requestOptions); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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> putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putRecursiveModelWithResponseAsync(input, requestOptions); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getMissingDiscriminatorWithResponseAsync(requestOptions); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWrongDiscriminatorWithResponseAsync(requestOptions); + } + + /** + * The getModel 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 this is base model for polymorphic multiple levels inheritance with a discriminator on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getModel() { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Fish.class)); + } + + /** + * The putModel 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 putModel(Fish input) { + // Generated convenience method for putModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getRecursiveModel 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 this is base model for polymorphic multiple levels inheritance with a discriminator on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getRecursiveModel() { + // Generated convenience method for getRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRecursiveModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Fish.class)); + } + + /** + * The putRecursiveModel 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 putRecursiveModel(Fish input) { + // Generated convenience method for putRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putRecursiveModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getMissingDiscriminator 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 this is base model for polymorphic multiple levels inheritance with a discriminator on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getMissingDiscriminator() { + // Generated convenience method for getMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMissingDiscriminatorWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Fish.class)); + } + + /** + * The getWrongDiscriminator 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 this is base model for polymorphic multiple levels inheritance with a discriminator on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getWrongDiscriminator() { + // Generated convenience method for getWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWrongDiscriminatorWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Fish.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClient.java new file mode 100644 index 000000000..6692bab26 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClient.java @@ -0,0 +1,298 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.nesteddiscriminator; + +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.type.model.inheritance.nesteddiscriminator.implementation.NestedDiscriminatorClientImpl; +import com.type.model.inheritance.nesteddiscriminator.models.Fish; + +/** + * Initializes a new instance of the synchronous NestedDiscriminatorClient type. + */ +@ServiceClient(builder = NestedDiscriminatorClientBuilder.class) +public final class NestedDiscriminatorClient { + @Generated + private final NestedDiscriminatorClientImpl serviceClient; + + /** + * Initializes an instance of NestedDiscriminatorClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NestedDiscriminatorClient(NestedDiscriminatorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponse(requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putModelWithResponse(input, requestOptions); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRecursiveModelWithResponse(requestOptions); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putRecursiveModelWithResponse(input, requestOptions); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getMissingDiscriminatorWithResponse(requestOptions); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWrongDiscriminatorWithResponse(requestOptions); + } + + /** + * The getModel 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 this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish getModel() { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(requestOptions).getValue().toObject(Fish.class); + } + + /** + * The putModel 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 putModel(Fish input) { + // Generated convenience method for putModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getRecursiveModel 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 this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish getRecursiveModel() { + // Generated convenience method for getRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRecursiveModelWithResponse(requestOptions).getValue().toObject(Fish.class); + } + + /** + * The putRecursiveModel 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 putRecursiveModel(Fish input) { + // Generated convenience method for putRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putRecursiveModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getMissingDiscriminator 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 this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish getMissingDiscriminator() { + // Generated convenience method for getMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMissingDiscriminatorWithResponse(requestOptions).getValue().toObject(Fish.class); + } + + /** + * The getWrongDiscriminator 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 this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Fish getWrongDiscriminator() { + // Generated convenience method for getWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWrongDiscriminatorWithResponse(requestOptions).getValue().toObject(Fish.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClientBuilder.java new file mode 100644 index 000000000..90d61f9bf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.nesteddiscriminator; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.model.inheritance.nesteddiscriminator.implementation.NestedDiscriminatorClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the NestedDiscriminatorClient type. + */ +@ServiceClientBuilder(serviceClients = { NestedDiscriminatorClient.class, NestedDiscriminatorAsyncClient.class }) +public final class NestedDiscriminatorClientBuilder 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("type-model-inheritance-nesteddiscriminator.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the NestedDiscriminatorClientBuilder. + */ + @Generated + public NestedDiscriminatorClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NestedDiscriminatorClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NestedDiscriminatorClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NestedDiscriminatorClientBuilder 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 NestedDiscriminatorClientBuilder 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 NestedDiscriminatorClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NestedDiscriminatorClientBuilder 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 NestedDiscriminatorClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NestedDiscriminatorClientBuilder 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 NestedDiscriminatorClientBuilder. + */ + @Generated + public NestedDiscriminatorClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of NestedDiscriminatorClientImpl with the provided parameters. + * + * @return an instance of NestedDiscriminatorClientImpl. + */ + @Generated + private NestedDiscriminatorClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + NestedDiscriminatorClientImpl client = new NestedDiscriminatorClientImpl(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 NestedDiscriminatorAsyncClient class. + * + * @return an instance of NestedDiscriminatorAsyncClient. + */ + @Generated + public NestedDiscriminatorAsyncClient buildAsyncClient() { + return new NestedDiscriminatorAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of NestedDiscriminatorClient class. + * + * @return an instance of NestedDiscriminatorClient. + */ + @Generated + public NestedDiscriminatorClient buildClient() { + return new NestedDiscriminatorClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NestedDiscriminatorClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/implementation/NestedDiscriminatorClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/implementation/NestedDiscriminatorClientImpl.java new file mode 100644 index 000000000..7b9917ffe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/implementation/NestedDiscriminatorClientImpl.java @@ -0,0 +1,547 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.nesteddiscriminator.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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 NestedDiscriminatorClient type. + */ +public final class NestedDiscriminatorClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NestedDiscriminatorClientService 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 NestedDiscriminatorClient client. + * + * @param endpoint Service host. + */ + public NestedDiscriminatorClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NestedDiscriminatorClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public NestedDiscriminatorClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NestedDiscriminatorClient 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 NestedDiscriminatorClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service + = RestProxy.create(NestedDiscriminatorClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for NestedDiscriminatorClient to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NestedDiscriminatorC") + public interface NestedDiscriminatorClientService { + @Get("/type/model/inheritance/nested-discriminator/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> getModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/nested-discriminator/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 getModelSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/nested-discriminator/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> putModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/nested-discriminator/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 putModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/nested-discriminator/recursivemodel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getRecursiveModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/nested-discriminator/recursivemodel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/nested-discriminator/recursivemodel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putRecursiveModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/nested-discriminator/recursivemodel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/nested-discriminator/missingdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getMissingDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/nested-discriminator/missingdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getMissingDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/nested-discriminator/wrongdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getWrongDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/nested-discriminator/wrongdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getModelWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getModel(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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> putModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.putModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRecursiveModelWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getRecursiveModel(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getRecursiveModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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> putRecursiveModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putRecursiveModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putRecursiveModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getMissingDiscriminatorWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getMissingDiscriminator(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWrongDiscriminatorWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getWrongDiscriminator(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     age: 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 this is base model for polymorphic multiple levels inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/implementation/package-info.java new file mode 100644 index 000000000..02b9b22e4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/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 NestedDiscriminator. + * Illustrates multiple level inheritance with multiple discriminators. + * + */ +package com.type.model.inheritance.nesteddiscriminator.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/Fish.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/Fish.java new file mode 100644 index 000000000..a1c40de55 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/Fish.java @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.nesteddiscriminator.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; + +/** + * This is base model for polymorphic multiple levels inheritance with a discriminator. + */ +@Immutable +public class Fish implements JsonSerializable { + /* + * Discriminator property for Fish. + */ + @Generated + String kind; + + /* + * The age property. + */ + @Generated + private final int age; + + /** + * Creates an instance of Fish class. + * + * @param age the age value to set. + */ + @Generated + public Fish(int age) { + this.age = age; + this.kind = "Fish"; + } + + /** + * Get the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + @Generated + public String getKind() { + return this.kind; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Generated + public int getAge() { + return this.age; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + void toJsonShared(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeIntField("age", this.age); + jsonWriter.writeStringField("kind", this.kind); + } + + /** + * 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 -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("shark".equals(discriminatorValue)) { + return Shark.fromJson(readerToUse.reset()); + } else if ("salmon".equals(discriminatorValue)) { + return Salmon.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Fish fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + String kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Fish deserializedFish = new Fish(age); + deserializedFish.kind = kind; + + return deserializedFish; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/GoblinShark.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/GoblinShark.java new file mode 100644 index 000000000..d73674547 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/GoblinShark.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.nesteddiscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The third level model GoblinShark in polymorphic multiple levels inheritance. + */ +@Immutable +public final class GoblinShark extends Shark { + /** + * Creates an instance of GoblinShark class. + * + * @param age the age value to set. + */ + @Generated + public GoblinShark(int age) { + super(age); + this.kind = "shark"; + this.sharktype = "goblin"; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GoblinShark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GoblinShark 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 GoblinShark. + */ + @Generated + public static GoblinShark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + String sharktype = "goblin"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("sharktype".equals(fieldName)) { + sharktype = reader.getString(); + } else { + reader.skipChildren(); + } + } + GoblinShark deserializedGoblinShark = new GoblinShark(age); + deserializedGoblinShark.sharktype = sharktype; + + return deserializedGoblinShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/Salmon.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/Salmon.java new file mode 100644 index 000000000..0e2eb07bc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/Salmon.java @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.nesteddiscriminator.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The second level model in polymorphic multiple levels inheritance which contains references to other polymorphic + * instances. + */ +@Fluent +public final class Salmon extends Fish { + /* + * The friends property. + */ + @Generated + private List friends; + + /* + * The hate property. + */ + @Generated + private Map hate; + + /* + * The partner property. + */ + @Generated + private Fish partner; + + /** + * Creates an instance of Salmon class. + * + * @param age the age value to set. + */ + @Generated + public Salmon(int age) { + super(age); + this.kind = "salmon"; + } + + /** + * Get the friends property: The friends property. + * + * @return the friends value. + */ + @Generated + public List getFriends() { + return this.friends; + } + + /** + * Set the friends property: The friends property. + * + * @param friends the friends value to set. + * @return the Salmon object itself. + */ + @Generated + public Salmon setFriends(List friends) { + this.friends = friends; + return this; + } + + /** + * Get the hate property: The hate property. + * + * @return the hate value. + */ + @Generated + public Map getHate() { + return this.hate; + } + + /** + * Set the hate property: The hate property. + * + * @param hate the hate value to set. + * @return the Salmon object itself. + */ + @Generated + public Salmon setHate(Map hate) { + this.hate = hate; + return this; + } + + /** + * Get the partner property: The partner property. + * + * @return the partner value. + */ + @Generated + public Fish getPartner() { + return this.partner; + } + + /** + * Set the partner property: The partner property. + * + * @param partner the partner value to set. + * @return the Salmon object itself. + */ + @Generated + public Salmon setPartner(Fish partner) { + this.partner = partner; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + jsonWriter.writeArrayField("friends", this.friends, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeMapField("hate", this.hate, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("partner", this.partner); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Salmon from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Salmon 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 Salmon. + */ + @Generated + public static Salmon fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + String kind = "salmon"; + List friends = null; + Map hate = null; + Fish partner = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else if ("friends".equals(fieldName)) { + friends = reader.readArray(reader1 -> Fish.fromJson(reader1)); + } else if ("hate".equals(fieldName)) { + hate = reader.readMap(reader1 -> Fish.fromJson(reader1)); + } else if ("partner".equals(fieldName)) { + partner = Fish.fromJson(reader); + } else { + reader.skipChildren(); + } + } + Salmon deserializedSalmon = new Salmon(age); + deserializedSalmon.kind = kind; + deserializedSalmon.friends = friends; + deserializedSalmon.hate = hate; + deserializedSalmon.partner = partner; + + return deserializedSalmon; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/SawShark.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/SawShark.java new file mode 100644 index 000000000..9078c1e9d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/SawShark.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.nesteddiscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The third level model SawShark in polymorphic multiple levels inheritance. + */ +@Immutable +public final class SawShark extends Shark { + /** + * Creates an instance of SawShark class. + * + * @param age the age value to set. + */ + @Generated + public SawShark(int age) { + super(age); + this.kind = "shark"; + this.sharktype = "saw"; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SawShark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SawShark 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 SawShark. + */ + @Generated + public static SawShark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + String sharktype = "saw"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("sharktype".equals(fieldName)) { + sharktype = reader.getString(); + } else { + reader.skipChildren(); + } + } + SawShark deserializedSawShark = new SawShark(age); + deserializedSawShark.sharktype = sharktype; + + return deserializedSawShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/Shark.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/Shark.java new file mode 100644 index 000000000..fd2e4f822 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/Shark.java @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.nesteddiscriminator.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The second level model in polymorphic multiple levels inheritance and it defines a new discriminator. + */ +@Immutable +public class Shark extends Fish { + /* + * The sharktype property. + */ + @Generated + String sharktype; + + /** + * Creates an instance of Shark class. + * + * @param age the age value to set. + */ + @Generated + public Shark(int age) { + super(age); + this.kind = "shark"; + this.sharktype = "shark"; + } + + /** + * Get the sharktype property: The sharktype property. + * + * @return the sharktype value. + */ + @Generated + public String getSharktype() { + return this.sharktype; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + void toJsonShared(JsonWriter jsonWriter) throws IOException { + super.toJsonShared(jsonWriter); + jsonWriter.writeStringField("sharktype", this.sharktype); + } + + /** + * Reads an instance of Shark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Shark 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 Shark. + */ + @Generated + public static Shark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("sharktype".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("saw".equals(discriminatorValue)) { + return SawShark.fromJson(readerToUse.reset()); + } else if ("goblin".equals(discriminatorValue)) { + return GoblinShark.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Shark fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + String sharktype = "shark"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("sharktype".equals(fieldName)) { + sharktype = reader.getString(); + } else { + reader.skipChildren(); + } + } + Shark deserializedShark = new Shark(age); + deserializedShark.sharktype = sharktype; + + return deserializedShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/models/package-info.java new file mode 100644 index 000000000..16cc0b50a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/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 NestedDiscriminator. + * Illustrates multiple level inheritance with multiple discriminators. + * + */ +package com.type.model.inheritance.nesteddiscriminator.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/package-info.java new file mode 100644 index 000000000..ac89064fb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/nesteddiscriminator/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 NestedDiscriminator. + * Illustrates multiple level inheritance with multiple discriminators. + * + */ +package com.type.model.inheritance.nesteddiscriminator; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedAsyncClient.java new file mode 100644 index 000000000..bd3b2a358 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedAsyncClient.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 com.type.model.inheritance.notdiscriminated; + +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 com.type.model.inheritance.notdiscriminated.implementation.NotDiscriminatedClientImpl; +import com.type.model.inheritance.notdiscriminated.models.Siamese; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NotDiscriminatedClient type. + */ +@ServiceClient(builder = NotDiscriminatedClientBuilder.class, isAsync = true) +public final class NotDiscriminatedAsyncClient { + @Generated + private final NotDiscriminatedClientImpl serviceClient; + + /** + * Initializes an instance of NotDiscriminatedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NotDiscriminatedAsyncClient(NotDiscriminatedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The postValid operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (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> postValidWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.postValidWithResponseAsync(input, requestOptions); + } + + /** + * The getValid operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (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 the third level model in the normal multiple levels inheritance along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getValidWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getValidWithResponseAsync(requestOptions); + } + + /** + * The putValid operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (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 third level model in the normal multiple levels inheritance along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putValidWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putValidWithResponseAsync(input, requestOptions); + } + + /** + * The postValid 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 postValid(Siamese input) { + // Generated convenience method for postValidWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postValidWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getValid 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 the third level model in the normal multiple levels inheritance on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getValid() { + // Generated convenience method for getValidWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getValidWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Siamese.class)); + } + + /** + * The putValid 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 the third level model in the normal multiple levels inheritance on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putValid(Siamese input) { + // Generated convenience method for putValidWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putValidWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Siamese.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedClient.java new file mode 100644 index 000000000..a0bde5926 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedClient.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.notdiscriminated; + +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.type.model.inheritance.notdiscriminated.implementation.NotDiscriminatedClientImpl; +import com.type.model.inheritance.notdiscriminated.models.Siamese; + +/** + * Initializes a new instance of the synchronous NotDiscriminatedClient type. + */ +@ServiceClient(builder = NotDiscriminatedClientBuilder.class) +public final class NotDiscriminatedClient { + @Generated + private final NotDiscriminatedClientImpl serviceClient; + + /** + * Initializes an instance of NotDiscriminatedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NotDiscriminatedClient(NotDiscriminatedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The postValid operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (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 postValidWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.postValidWithResponse(input, requestOptions); + } + + /** + * The getValid operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (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 the third level model in the normal multiple levels inheritance along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getValidWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getValidWithResponse(requestOptions); + } + + /** + * The putValid operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (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 third level model in the normal multiple levels inheritance along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putValidWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putValidWithResponse(input, requestOptions); + } + + /** + * The postValid 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 postValid(Siamese input) { + // Generated convenience method for postValidWithResponse + RequestOptions requestOptions = new RequestOptions(); + postValidWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getValid 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 the third level model in the normal multiple levels inheritance. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Siamese getValid() { + // Generated convenience method for getValidWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getValidWithResponse(requestOptions).getValue().toObject(Siamese.class); + } + + /** + * The putValid 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 the third level model in the normal multiple levels inheritance. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Siamese putValid(Siamese input) { + // Generated convenience method for putValidWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putValidWithResponse(BinaryData.fromObject(input), requestOptions).getValue().toObject(Siamese.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedClientBuilder.java new file mode 100644 index 000000000..65589f6b8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/NotDiscriminatedClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.notdiscriminated; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.model.inheritance.notdiscriminated.implementation.NotDiscriminatedClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the NotDiscriminatedClient type. + */ +@ServiceClientBuilder(serviceClients = { NotDiscriminatedClient.class, NotDiscriminatedAsyncClient.class }) +public final class NotDiscriminatedClientBuilder 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("type-model-inheritance-notdiscriminated.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the NotDiscriminatedClientBuilder. + */ + @Generated + public NotDiscriminatedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotDiscriminatedClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotDiscriminatedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotDiscriminatedClientBuilder 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 NotDiscriminatedClientBuilder 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 NotDiscriminatedClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotDiscriminatedClientBuilder 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 NotDiscriminatedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NotDiscriminatedClientBuilder 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 NotDiscriminatedClientBuilder. + */ + @Generated + public NotDiscriminatedClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of NotDiscriminatedClientImpl with the provided parameters. + * + * @return an instance of NotDiscriminatedClientImpl. + */ + @Generated + private NotDiscriminatedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + NotDiscriminatedClientImpl client = new NotDiscriminatedClientImpl(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 NotDiscriminatedAsyncClient class. + * + * @return an instance of NotDiscriminatedAsyncClient. + */ + @Generated + public NotDiscriminatedAsyncClient buildAsyncClient() { + return new NotDiscriminatedAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of NotDiscriminatedClient class. + * + * @return an instance of NotDiscriminatedClient. + */ + @Generated + public NotDiscriminatedClient buildClient() { + return new NotDiscriminatedClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NotDiscriminatedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/implementation/NotDiscriminatedClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/implementation/NotDiscriminatedClientImpl.java new file mode 100644 index 000000000..8bbbad56a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/implementation/NotDiscriminatedClientImpl.java @@ -0,0 +1,368 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.notdiscriminated.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.Put; +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 NotDiscriminatedClient type. + */ +public final class NotDiscriminatedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NotDiscriminatedClientService 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 NotDiscriminatedClient client. + * + * @param endpoint Service host. + */ + public NotDiscriminatedClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NotDiscriminatedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public NotDiscriminatedClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NotDiscriminatedClient 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 NotDiscriminatedClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service + = RestProxy.create(NotDiscriminatedClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for NotDiscriminatedClient to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NotDiscriminatedClie") + public interface NotDiscriminatedClientService { + @Post("/type/model/inheritance/not-discriminated/valid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> postValid(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Post("/type/model/inheritance/not-discriminated/valid") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response postValidSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/not-discriminated/valid") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getValid(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/not-discriminated/valid") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getValidSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/not-discriminated/valid") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putValid(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/not-discriminated/valid") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putValidSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + } + + /** + * The postValid operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (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> postValidWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.postValid(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The postValid operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (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 postValidWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.postValidSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The getValid operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (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 the third level model in the normal multiple levels inheritance along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getValidWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getValid(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getValid operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (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 the third level model in the normal multiple levels inheritance along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getValidWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getValidSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The putValid operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (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 third level model in the normal multiple levels inheritance along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putValidWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.putValid(this.getEndpoint(), contentType, accept, input, requestOptions, context)); + } + + /** + * The putValid operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (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 third level model in the normal multiple levels inheritance along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putValidWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.putValidSync(this.getEndpoint(), contentType, accept, input, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/implementation/package-info.java new file mode 100644 index 000000000..3ccb18dc3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/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 NotDiscriminated. + * Illustrates not-discriminated inheritance model. + * + */ +package com.type.model.inheritance.notdiscriminated.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/models/Cat.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/models/Cat.java new file mode 100644 index 000000000..5182b2905 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/models/Cat.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 com.type.model.inheritance.notdiscriminated.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The second level model in the normal multiple levels inheritance. + */ +@Immutable +public class Cat extends Pet { + /* + * The age property. + */ + @Generated + private final int age; + + /** + * Creates an instance of Cat class. + * + * @param name the name value to set. + * @param age the age value to set. + */ + @Generated + public Cat(String name, int age) { + super(name); + this.age = age; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Generated + public int getAge() { + return this.age; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeIntField("age", this.age); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Cat from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Cat 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 Cat. + */ + @Generated + public static Cat fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int age = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("age".equals(fieldName)) { + age = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new Cat(name, age); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/models/Pet.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/models/Pet.java new file mode 100644 index 000000000..6005597a7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/models/Pet.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.notdiscriminated.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; + +/** + * This is base model for not-discriminated normal multiple levels inheritance. + */ +@Immutable +public class Pet implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Pet class. + * + * @param name the name value to set. + */ + @Generated + public Pet(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Pet from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Pet 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 Pet. + */ + @Generated + public static Pet fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Pet(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/models/Siamese.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/models/Siamese.java new file mode 100644 index 000000000..6438aa502 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/models/Siamese.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.notdiscriminated.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The third level model in the normal multiple levels inheritance. + */ +@Immutable +public final class Siamese extends Cat { + /* + * The smart property. + */ + @Generated + private final boolean smart; + + /** + * Creates an instance of Siamese class. + * + * @param name the name value to set. + * @param age the age value to set. + * @param smart the smart value to set. + */ + @Generated + public Siamese(String name, int age, boolean smart) { + super(name, age); + this.smart = smart; + } + + /** + * Get the smart property: The smart property. + * + * @return the smart value. + */ + @Generated + public boolean isSmart() { + return this.smart; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeIntField("age", getAge()); + jsonWriter.writeBooleanField("smart", this.smart); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Siamese from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Siamese 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 Siamese. + */ + @Generated + public static Siamese fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int age = 0; + boolean smart = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("smart".equals(fieldName)) { + smart = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new Siamese(name, age, smart); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/models/package-info.java new file mode 100644 index 000000000..b979b23dd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/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 NotDiscriminated. + * Illustrates not-discriminated inheritance model. + * + */ +package com.type.model.inheritance.notdiscriminated.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/package-info.java new file mode 100644 index 000000000..4519ecd1d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/notdiscriminated/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 NotDiscriminated. + * Illustrates not-discriminated inheritance model. + * + */ +package com.type.model.inheritance.notdiscriminated; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/RecursiveAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/RecursiveAsyncClient.java new file mode 100644 index 000000000..b9a4e5aa6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/RecursiveAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.recursive; + +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 com.type.model.inheritance.recursive.implementation.RecursiveClientImpl; +import com.type.model.inheritance.recursive.models.Extension; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous RecursiveClient type. + */ +@ServiceClient(builder = RecursiveClientBuilder.class, isAsync = true) +public final class RecursiveAsyncClient { + @Generated + private final RecursiveClientImpl serviceClient; + + /** + * Initializes an instance of RecursiveAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RecursiveAsyncClient(RecursiveClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     extension (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     level: 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> putWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(input, requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     extension (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     level: 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 extension along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The put 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 put(Extension input) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The get 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 extension on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Extension.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/RecursiveClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/RecursiveClient.java new file mode 100644 index 000000000..77b681267 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/RecursiveClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.recursive; + +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.type.model.inheritance.recursive.implementation.RecursiveClientImpl; +import com.type.model.inheritance.recursive.models.Extension; + +/** + * Initializes a new instance of the synchronous RecursiveClient type. + */ +@ServiceClient(builder = RecursiveClientBuilder.class) +public final class RecursiveClient { + @Generated + private final RecursiveClientImpl serviceClient; + + /** + * Initializes an instance of RecursiveClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RecursiveClient(RecursiveClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     extension (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     level: 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 putWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(input, requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     extension (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     level: 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 extension along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put 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 put(Extension input) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The get 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 extension. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Extension get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(Extension.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/RecursiveClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/RecursiveClientBuilder.java new file mode 100644 index 000000000..757f02ca3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/RecursiveClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.recursive; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.model.inheritance.recursive.implementation.RecursiveClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the RecursiveClient type. + */ +@ServiceClientBuilder(serviceClients = { RecursiveClient.class, RecursiveAsyncClient.class }) +public final class RecursiveClientBuilder 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("type-model-inheritance-recursive.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the RecursiveClientBuilder. + */ + @Generated + public RecursiveClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RecursiveClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RecursiveClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RecursiveClientBuilder 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 RecursiveClientBuilder 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 RecursiveClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RecursiveClientBuilder 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 RecursiveClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RecursiveClientBuilder 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 RecursiveClientBuilder. + */ + @Generated + public RecursiveClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of RecursiveClientImpl with the provided parameters. + * + * @return an instance of RecursiveClientImpl. + */ + @Generated + private RecursiveClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + RecursiveClientImpl client + = new RecursiveClientImpl(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 RecursiveAsyncClient class. + * + * @return an instance of RecursiveAsyncClient. + */ + @Generated + public RecursiveAsyncClient buildAsyncClient() { + return new RecursiveAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of RecursiveClient class. + * + * @return an instance of RecursiveClient. + */ + @Generated + public RecursiveClient buildClient() { + return new RecursiveClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(RecursiveClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/implementation/RecursiveClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/implementation/RecursiveClientImpl.java new file mode 100644 index 000000000..97f4a6714 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/implementation/RecursiveClientImpl.java @@ -0,0 +1,272 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.recursive.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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 RecursiveClient type. + */ +public final class RecursiveClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RecursiveClientService 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 RecursiveClient client. + * + * @param endpoint Service host. + */ + public RecursiveClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of RecursiveClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public RecursiveClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of RecursiveClient 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 RecursiveClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(RecursiveClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for RecursiveClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "RecursiveClient") + public interface RecursiveClientService { + @Put("/type/model/inheritance/recursive") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/recursive") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/recursive") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/recursive") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     extension (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     level: 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> putWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     extension (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     level: 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 putWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     extension (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     level: 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 extension along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     extension (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     level: 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 extension along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/implementation/package-info.java new file mode 100644 index 000000000..ddc936e1e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/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 Recursive. + * Illustrates inheritance recursion. + * + */ +package com.type.model.inheritance.recursive.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/models/Element.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/models/Element.java new file mode 100644 index 000000000..c1c15571e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/models/Element.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.recursive.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; +import java.util.List; + +/** + * element. + */ +@Fluent +public class Element implements JsonSerializable { + /* + * The extension property. + */ + @Generated + private List extension; + + /** + * Creates an instance of Element class. + */ + @Generated + public Element() { + } + + /** + * Get the extension property: The extension property. + * + * @return the extension value. + */ + @Generated + public List getExtension() { + return this.extension; + } + + /** + * Set the extension property: The extension property. + * + * @param extension the extension value to set. + * @return the Element object itself. + */ + @Generated + public Element setExtension(List extension) { + this.extension = extension; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("extension", this.extension, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Element from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Element 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 Element. + */ + @Generated + public static Element fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Element deserializedElement = new Element(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("extension".equals(fieldName)) { + List extension = reader.readArray(reader1 -> Extension.fromJson(reader1)); + deserializedElement.extension = extension; + } else { + reader.skipChildren(); + } + } + + return deserializedElement; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/models/Extension.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/models/Extension.java new file mode 100644 index 000000000..822497fc0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/models/Extension.java @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.recursive.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * extension. + */ +@Fluent +public final class Extension extends Element { + /* + * The level property. + */ + @Generated + private final int level; + + /** + * Creates an instance of Extension class. + * + * @param level the level value to set. + */ + @Generated + public Extension(int level) { + this.level = level; + } + + /** + * Get the level property: The level property. + * + * @return the level value. + */ + @Generated + public int getLevel() { + return this.level; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public Extension setExtension(List extension) { + super.setExtension(extension); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("extension", getExtension(), (writer, element) -> writer.writeJson(element)); + jsonWriter.writeIntField("level", this.level); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Extension from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Extension 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 Extension. + */ + @Generated + public static Extension fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List extension = null; + int level = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("extension".equals(fieldName)) { + extension = reader.readArray(reader1 -> Extension.fromJson(reader1)); + } else if ("level".equals(fieldName)) { + level = reader.getInt(); + } else { + reader.skipChildren(); + } + } + Extension deserializedExtension = new Extension(level); + deserializedExtension.setExtension(extension); + + return deserializedExtension; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/models/package-info.java new file mode 100644 index 000000000..ed3743007 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/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 Recursive. + * Illustrates inheritance recursion. + * + */ +package com.type.model.inheritance.recursive.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/package-info.java new file mode 100644 index 000000000..527a83eba --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/recursive/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 Recursive. + * Illustrates inheritance recursion. + * + */ +package com.type.model.inheritance.recursive; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java new file mode 100644 index 000000000..824d3f77b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorAsyncClient.java @@ -0,0 +1,355 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.singlediscriminator; + +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 com.type.model.inheritance.singlediscriminator.implementation.SingleDiscriminatorClientImpl; +import com.type.model.inheritance.singlediscriminator.models.Bird; +import com.type.model.inheritance.singlediscriminator.models.Dinosaur; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous SingleDiscriminatorClient type. + */ +@ServiceClient(builder = SingleDiscriminatorClientBuilder.class, isAsync = true) +public final class SingleDiscriminatorAsyncClient { + @Generated + private final SingleDiscriminatorClientImpl serviceClient; + + /** + * Initializes an instance of SingleDiscriminatorAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SingleDiscriminatorAsyncClient(SingleDiscriminatorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponseAsync(requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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> putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putModelWithResponseAsync(input, requestOptions); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRecursiveModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRecursiveModelWithResponseAsync(requestOptions); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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> putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putRecursiveModelWithResponseAsync(input, requestOptions); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getMissingDiscriminatorWithResponseAsync(requestOptions); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWrongDiscriminatorWithResponseAsync(requestOptions); + } + + /** + * The getLegacyModel 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 define a base class in the legacy way along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getLegacyModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getLegacyModelWithResponseAsync(requestOptions); + } + + /** + * The getModel 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 this is base model for polymorphic single level inheritance with a discriminator on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getModel() { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Bird.class)); + } + + /** + * The putModel 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 putModel(Bird input) { + // Generated convenience method for putModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getRecursiveModel 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 this is base model for polymorphic single level inheritance with a discriminator on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getRecursiveModel() { + // Generated convenience method for getRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRecursiveModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Bird.class)); + } + + /** + * The putRecursiveModel 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 putRecursiveModel(Bird input) { + // Generated convenience method for putRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putRecursiveModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getMissingDiscriminator 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 this is base model for polymorphic single level inheritance with a discriminator on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getMissingDiscriminator() { + // Generated convenience method for getMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMissingDiscriminatorWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Bird.class)); + } + + /** + * The getWrongDiscriminator 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 this is base model for polymorphic single level inheritance with a discriminator on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getWrongDiscriminator() { + // Generated convenience method for getWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWrongDiscriminatorWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Bird.class)); + } + + /** + * The getLegacyModel 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 define a base class in the legacy way on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getLegacyModel() { + // Generated convenience method for getLegacyModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getLegacyModelWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Dinosaur.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java new file mode 100644 index 000000000..14e77c77e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java @@ -0,0 +1,341 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.singlediscriminator; + +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.type.model.inheritance.singlediscriminator.implementation.SingleDiscriminatorClientImpl; +import com.type.model.inheritance.singlediscriminator.models.Bird; +import com.type.model.inheritance.singlediscriminator.models.Dinosaur; + +/** + * Initializes a new instance of the synchronous SingleDiscriminatorClient type. + */ +@ServiceClient(builder = SingleDiscriminatorClientBuilder.class) +public final class SingleDiscriminatorClient { + @Generated + private final SingleDiscriminatorClientImpl serviceClient; + + /** + * Initializes an instance of SingleDiscriminatorClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SingleDiscriminatorClient(SingleDiscriminatorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponse(requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putModelWithResponse(input, requestOptions); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRecursiveModelWithResponse(requestOptions); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putRecursiveModelWithResponse(input, requestOptions); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getMissingDiscriminatorWithResponse(requestOptions); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWrongDiscriminatorWithResponse(requestOptions); + } + + /** + * The getLegacyModel 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 define a base class in the legacy way along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getLegacyModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getLegacyModelWithResponse(requestOptions); + } + + /** + * The getModel 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 this is base model for polymorphic single level inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Bird getModel() { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(requestOptions).getValue().toObject(Bird.class); + } + + /** + * The putModel 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 putModel(Bird input) { + // Generated convenience method for putModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getRecursiveModel 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 this is base model for polymorphic single level inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Bird getRecursiveModel() { + // Generated convenience method for getRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRecursiveModelWithResponse(requestOptions).getValue().toObject(Bird.class); + } + + /** + * The putRecursiveModel 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 putRecursiveModel(Bird input) { + // Generated convenience method for putRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putRecursiveModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getMissingDiscriminator 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 this is base model for polymorphic single level inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Bird getMissingDiscriminator() { + // Generated convenience method for getMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMissingDiscriminatorWithResponse(requestOptions).getValue().toObject(Bird.class); + } + + /** + * The getWrongDiscriminator 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 this is base model for polymorphic single level inheritance with a discriminator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Bird getWrongDiscriminator() { + // Generated convenience method for getWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWrongDiscriminatorWithResponse(requestOptions).getValue().toObject(Bird.class); + } + + /** + * The getLegacyModel 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 define a base class in the legacy way. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Dinosaur getLegacyModel() { + // Generated convenience method for getLegacyModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getLegacyModelWithResponse(requestOptions).getValue().toObject(Dinosaur.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java new file mode 100644 index 000000000..ccebf1a8b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.singlediscriminator; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.model.inheritance.singlediscriminator.implementation.SingleDiscriminatorClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the SingleDiscriminatorClient type. + */ +@ServiceClientBuilder(serviceClients = { SingleDiscriminatorClient.class, SingleDiscriminatorAsyncClient.class }) +public final class SingleDiscriminatorClientBuilder 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("type-model-inheritance-singlediscriminator.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the SingleDiscriminatorClientBuilder. + */ + @Generated + public SingleDiscriminatorClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SingleDiscriminatorClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SingleDiscriminatorClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SingleDiscriminatorClientBuilder 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 SingleDiscriminatorClientBuilder 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 SingleDiscriminatorClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SingleDiscriminatorClientBuilder 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 SingleDiscriminatorClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SingleDiscriminatorClientBuilder 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 SingleDiscriminatorClientBuilder. + */ + @Generated + public SingleDiscriminatorClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of SingleDiscriminatorClientImpl with the provided parameters. + * + * @return an instance of SingleDiscriminatorClientImpl. + */ + @Generated + private SingleDiscriminatorClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + SingleDiscriminatorClientImpl client = new SingleDiscriminatorClientImpl(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 SingleDiscriminatorAsyncClient class. + * + * @return an instance of SingleDiscriminatorAsyncClient. + */ + @Generated + public SingleDiscriminatorAsyncClient buildAsyncClient() { + return new SingleDiscriminatorAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of SingleDiscriminatorClient class. + * + * @return an instance of SingleDiscriminatorClient. + */ + @Generated + public SingleDiscriminatorClient buildClient() { + return new SingleDiscriminatorClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SingleDiscriminatorClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java new file mode 100644 index 000000000..555282626 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java @@ -0,0 +1,615 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.singlediscriminator.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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 SingleDiscriminatorClient type. + */ +public final class SingleDiscriminatorClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SingleDiscriminatorClientService 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 SingleDiscriminatorClient client. + * + * @param endpoint Service host. + */ + public SingleDiscriminatorClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of SingleDiscriminatorClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public SingleDiscriminatorClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of SingleDiscriminatorClient 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 SingleDiscriminatorClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service + = RestProxy.create(SingleDiscriminatorClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for SingleDiscriminatorClient to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SingleDiscriminatorC") + public interface SingleDiscriminatorClientService { + @Get("/type/model/inheritance/single-discriminator/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> getModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/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 getModelSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/single-discriminator/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> putModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/single-discriminator/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 putModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/recursivemodel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getRecursiveModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/recursivemodel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/single-discriminator/recursivemodel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putRecursiveModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/inheritance/single-discriminator/recursivemodel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/missingdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getMissingDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/missingdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getMissingDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/wrongdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getWrongDiscriminator(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/wrongdiscriminator") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/legacy-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> getLegacyModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/model/inheritance/single-discriminator/legacy-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 getLegacyModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getModelWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getModel(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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> putModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.putModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRecursiveModelWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getRecursiveModel(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getRecursiveModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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> putRecursiveModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putRecursiveModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putRecursiveModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getMissingDiscriminatorWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getMissingDiscriminator(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWrongDiscriminatorWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getWrongDiscriminator(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: 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 this is base model for polymorphic single level inheritance with a discriminator along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The getLegacyModel 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 define a base class in the legacy way along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getLegacyModelWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getLegacyModel(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getLegacyModel 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 define a base class in the legacy way along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getLegacyModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getLegacyModelSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/implementation/package-info.java new file mode 100644 index 000000000..f5f600fa3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/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 SingleDiscriminator. + * Illustrates inheritance with single discriminator. + * + */ +package com.type.model.inheritance.singlediscriminator.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Bird.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Bird.java new file mode 100644 index 000000000..29caef9d2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Bird.java @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.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; + +/** + * This is base model for polymorphic single level inheritance with a discriminator. + */ +@Immutable +public class Bird implements JsonSerializable { + /* + * The kind property. + */ + @Generated + String kind; + + /* + * The wingspan property. + */ + @Generated + private final int wingspan; + + /** + * Creates an instance of Bird class. + * + * @param wingspan the wingspan value to set. + */ + @Generated + public Bird(int wingspan) { + this.wingspan = wingspan; + this.kind = "Bird"; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Generated + public String getKind() { + return this.kind; + } + + /** + * Get the wingspan property: The wingspan property. + * + * @return the wingspan value. + */ + @Generated + public int getWingspan() { + return this.wingspan; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + void toJsonShared(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeIntField("wingspan", this.wingspan); + jsonWriter.writeStringField("kind", this.kind); + } + + /** + * Reads an instance of Bird from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Bird 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 Bird. + */ + @Generated + public static Bird fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("seagull".equals(discriminatorValue)) { + return SeaGull.fromJson(readerToUse.reset()); + } else if ("sparrow".equals(discriminatorValue)) { + return Sparrow.fromJson(readerToUse.reset()); + } else if ("goose".equals(discriminatorValue)) { + return Goose.fromJson(readerToUse.reset()); + } else if ("eagle".equals(discriminatorValue)) { + return Eagle.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Bird fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int wingspan = 0; + String kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wingspan".equals(fieldName)) { + wingspan = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Bird deserializedBird = new Bird(wingspan); + deserializedBird.kind = kind; + + return deserializedBird; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Dinosaur.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Dinosaur.java new file mode 100644 index 000000000..7067fd9f9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Dinosaur.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.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; + +/** + * Define a base class in the legacy way. Discriminator property is not explicitly defined in the model. + */ +@Immutable +public class Dinosaur implements JsonSerializable { + /* + * Discriminator property for Dinosaur. + */ + @Generated + String kind; + + /* + * The size property. + */ + @Generated + private final int size; + + /** + * Creates an instance of Dinosaur class. + * + * @param size the size value to set. + */ + @Generated + protected Dinosaur(int size) { + this.size = size; + this.kind = "Dinosaur"; + } + + /** + * Get the kind property: Discriminator property for Dinosaur. + * + * @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(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + void toJsonShared(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeIntField("size", this.size); + jsonWriter.writeStringField("kind", this.kind); + } + + /** + * Reads an instance of Dinosaur from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Dinosaur 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 Dinosaur. + */ + @Generated + public static Dinosaur fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("t-rex".equals(discriminatorValue)) { + return TRex.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static Dinosaur fromJsonKnownDiscriminator(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(); + } + } + Dinosaur deserializedDinosaur = new Dinosaur(size); + deserializedDinosaur.kind = kind; + + return deserializedDinosaur; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Eagle.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Eagle.java new file mode 100644 index 000000000..6b68a67b2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Eagle.java @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.singlediscriminator.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The second level model in polymorphic single levels inheritance which contains references to other polymorphic + * instances. + */ +@Fluent +public final class Eagle extends Bird { + /* + * The friends property. + */ + @Generated + private List friends; + + /* + * The hate property. + */ + @Generated + private Map hate; + + /* + * The partner property. + */ + @Generated + private Bird partner; + + /** + * Creates an instance of Eagle class. + * + * @param wingspan the wingspan value to set. + */ + @Generated + public Eagle(int wingspan) { + super(wingspan); + this.kind = "eagle"; + } + + /** + * Get the friends property: The friends property. + * + * @return the friends value. + */ + @Generated + public List getFriends() { + return this.friends; + } + + /** + * Set the friends property: The friends property. + * + * @param friends the friends value to set. + * @return the Eagle object itself. + */ + @Generated + public Eagle setFriends(List friends) { + this.friends = friends; + return this; + } + + /** + * Get the hate property: The hate property. + * + * @return the hate value. + */ + @Generated + public Map getHate() { + return this.hate; + } + + /** + * Set the hate property: The hate property. + * + * @param hate the hate value to set. + * @return the Eagle object itself. + */ + @Generated + public Eagle setHate(Map hate) { + this.hate = hate; + return this; + } + + /** + * Get the partner property: The partner property. + * + * @return the partner value. + */ + @Generated + public Bird getPartner() { + return this.partner; + } + + /** + * Set the partner property: The partner property. + * + * @param partner the partner value to set. + * @return the Eagle object itself. + */ + @Generated + public Eagle setPartner(Bird partner) { + this.partner = partner; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + jsonWriter.writeArrayField("friends", this.friends, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeMapField("hate", this.hate, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("partner", this.partner); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Eagle from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Eagle 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 Eagle. + */ + @Generated + public static Eagle fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int wingspan = 0; + String kind = "eagle"; + List friends = null; + Map hate = null; + Bird partner = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wingspan".equals(fieldName)) { + wingspan = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else if ("friends".equals(fieldName)) { + friends = reader.readArray(reader1 -> Bird.fromJson(reader1)); + } else if ("hate".equals(fieldName)) { + hate = reader.readMap(reader1 -> Bird.fromJson(reader1)); + } else if ("partner".equals(fieldName)) { + partner = Bird.fromJson(reader); + } else { + reader.skipChildren(); + } + } + Eagle deserializedEagle = new Eagle(wingspan); + deserializedEagle.kind = kind; + deserializedEagle.friends = friends; + deserializedEagle.hate = hate; + deserializedEagle.partner = partner; + + return deserializedEagle; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Goose.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Goose.java new file mode 100644 index 000000000..0ac82567b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Goose.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.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.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The second level model in polymorphic single level inheritance. + */ +@Immutable +public final class Goose extends Bird { + /** + * Creates an instance of Goose class. + * + * @param wingspan the wingspan value to set. + */ + @Generated + public Goose(int wingspan) { + super(wingspan); + this.kind = "goose"; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Goose from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Goose 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 Goose. + */ + @Generated + public static Goose fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int wingspan = 0; + String kind = "goose"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wingspan".equals(fieldName)) { + wingspan = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Goose deserializedGoose = new Goose(wingspan); + deserializedGoose.kind = kind; + + return deserializedGoose; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/SeaGull.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/SeaGull.java new file mode 100644 index 000000000..8f7f1db55 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/SeaGull.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.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.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The second level model in polymorphic single level inheritance. + */ +@Immutable +public final class SeaGull extends Bird { + /** + * Creates an instance of SeaGull class. + * + * @param wingspan the wingspan value to set. + */ + @Generated + public SeaGull(int wingspan) { + super(wingspan); + this.kind = "seagull"; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SeaGull from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SeaGull 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 SeaGull. + */ + @Generated + public static SeaGull fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int wingspan = 0; + String kind = "seagull"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wingspan".equals(fieldName)) { + wingspan = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + SeaGull deserializedSeaGull = new SeaGull(wingspan); + deserializedSeaGull.kind = kind; + + return deserializedSeaGull; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Sparrow.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Sparrow.java new file mode 100644 index 000000000..b9a00e0c1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/Sparrow.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.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.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The second level model in polymorphic single level inheritance. + */ +@Immutable +public final class Sparrow extends Bird { + /** + * Creates an instance of Sparrow class. + * + * @param wingspan the wingspan value to set. + */ + @Generated + public Sparrow(int wingspan) { + super(wingspan); + this.kind = "sparrow"; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Sparrow from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Sparrow 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 Sparrow. + */ + @Generated + public static Sparrow fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int wingspan = 0; + String kind = "sparrow"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wingspan".equals(fieldName)) { + wingspan = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Sparrow deserializedSparrow = new Sparrow(wingspan); + deserializedSparrow.kind = kind; + + return deserializedSparrow; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/TRex.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/TRex.java new file mode 100644 index 000000000..d0ccee9b8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/TRex.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.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.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The second level legacy model in polymorphic single level inheritance. + */ +@Immutable +public final class TRex extends Dinosaur { + /** + * Creates an instance of TRex class. + * + * @param size the size value to set. + */ + @Generated + private TRex(int size) { + super(size); + this.kind = "t-rex"; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TRex from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TRex 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 TRex. + */ + @Generated + public static TRex fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int size = 0; + String kind = "t-rex"; + 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(); + } + } + TRex deserializedTRex = new TRex(size); + deserializedTRex.kind = kind; + + return deserializedTRex; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/models/package-info.java new file mode 100644 index 000000000..1941c48ef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/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 SingleDiscriminator. + * Illustrates inheritance with single discriminator. + * + */ +package com.type.model.inheritance.singlediscriminator.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/package-info.java new file mode 100644 index 000000000..24c9746fc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/inheritance/singlediscriminator/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 SingleDiscriminator. + * Illustrates inheritance with single discriminator. + * + */ +package com.type.model.inheritance.singlediscriminator; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/UsageAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/UsageAsyncClient.java new file mode 100644 index 000000000..52b4e988f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/UsageAsyncClient.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 com.type.model.usage; + +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 com.type.model.usage.implementation.UsageClientImpl; +import com.type.model.usage.models.InputOutputRecord; +import com.type.model.usage.models.InputRecord; +import com.type.model.usage.models.OutputRecord; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UsageClient type. + */ +@ServiceClient(builder = UsageClientBuilder.class, isAsync = true) +public final class UsageAsyncClient { + @Generated + private final UsageClientImpl serviceClient; + + /** + * Initializes an instance of UsageAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UsageAsyncClient(UsageClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The input operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (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> inputWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.inputWithResponseAsync(input, requestOptions); + } + + /** + * The output operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (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 record used in operation return type along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> outputWithResponse(RequestOptions requestOptions) { + return this.serviceClient.outputWithResponseAsync(requestOptions); + } + + /** + * The inputAndOutput operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 record used both as operation parameter and return type along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> inputAndOutputWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.inputAndOutputWithResponseAsync(body, requestOptions); + } + + /** + * The input 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 input(InputRecord input) { + // Generated convenience method for inputWithResponse + RequestOptions requestOptions = new RequestOptions(); + return inputWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The output 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 record used in operation return type on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono output() { + // Generated convenience method for outputWithResponse + RequestOptions requestOptions = new RequestOptions(); + return outputWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(OutputRecord.class)); + } + + /** + * The inputAndOutput operation. + * + * @param body The body 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 record used both as operation parameter and return type on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono inputAndOutput(InputOutputRecord body) { + // Generated convenience method for inputAndOutputWithResponse + RequestOptions requestOptions = new RequestOptions(); + return inputAndOutputWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(InputOutputRecord.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/UsageClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/UsageClient.java new file mode 100644 index 000000000..84f101e5e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/UsageClient.java @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.usage; + +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.type.model.usage.implementation.UsageClientImpl; +import com.type.model.usage.models.InputOutputRecord; +import com.type.model.usage.models.InputRecord; +import com.type.model.usage.models.OutputRecord; + +/** + * Initializes a new instance of the synchronous UsageClient type. + */ +@ServiceClient(builder = UsageClientBuilder.class) +public final class UsageClient { + @Generated + private final UsageClientImpl serviceClient; + + /** + * Initializes an instance of UsageClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UsageClient(UsageClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The input operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (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 inputWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.inputWithResponse(input, requestOptions); + } + + /** + * The output operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (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 record used in operation return type along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response outputWithResponse(RequestOptions requestOptions) { + return this.serviceClient.outputWithResponse(requestOptions); + } + + /** + * The inputAndOutput operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 record used both as operation parameter and return type along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response inputAndOutputWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.inputAndOutputWithResponse(body, requestOptions); + } + + /** + * The input 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 input(InputRecord input) { + // Generated convenience method for inputWithResponse + RequestOptions requestOptions = new RequestOptions(); + inputWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The output 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 record used in operation return type. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public OutputRecord output() { + // Generated convenience method for outputWithResponse + RequestOptions requestOptions = new RequestOptions(); + return outputWithResponse(requestOptions).getValue().toObject(OutputRecord.class); + } + + /** + * The inputAndOutput operation. + * + * @param body The body 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 record used both as operation parameter and return type. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public InputOutputRecord inputAndOutput(InputOutputRecord body) { + // Generated convenience method for inputAndOutputWithResponse + RequestOptions requestOptions = new RequestOptions(); + return inputAndOutputWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(InputOutputRecord.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/UsageClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/UsageClientBuilder.java new file mode 100644 index 000000000..82dfb76e7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/UsageClientBuilder.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 com.type.model.usage; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.model.usage.implementation.UsageClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the UsageClient type. + */ +@ServiceClientBuilder(serviceClients = { UsageClient.class, UsageAsyncClient.class }) +public final class UsageClientBuilder 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("type-model-usage.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the UsageClientBuilder. + */ + @Generated + public UsageClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UsageClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UsageClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UsageClientBuilder 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 UsageClientBuilder 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 UsageClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UsageClientBuilder 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 UsageClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UsageClientBuilder 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 UsageClientBuilder. + */ + @Generated + public UsageClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of UsageClientImpl with the provided parameters. + * + * @return an instance of UsageClientImpl. + */ + @Generated + private UsageClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + UsageClientImpl client + = new UsageClientImpl(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 UsageAsyncClient class. + * + * @return an instance of UsageAsyncClient. + */ + @Generated + public UsageAsyncClient buildAsyncClient() { + return new UsageAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of UsageClient class. + * + * @return an instance of UsageClient. + */ + @Generated + public UsageClient buildClient() { + return new UsageClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(UsageClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/implementation/UsageClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/implementation/UsageClientImpl.java new file mode 100644 index 000000000..c39f723ea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/implementation/UsageClientImpl.java @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.usage.implementation; + +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.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 UsageClient type. + */ +public final class UsageClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UsageClientService 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 UsageClient client. + * + * @param endpoint Service host. + */ + public UsageClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of UsageClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public UsageClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of UsageClient 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 UsageClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(UsageClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for UsageClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UsageClient") + public interface UsageClientService { + @Post("/type/model/usage/input") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> input(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Post("/type/model/usage/input") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response inputSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Get("/type/model/usage/output") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> output(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/model/usage/output") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response outputSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/type/model/usage/input-output") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> inputAndOutput(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/type/model/usage/input-output") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response inputAndOutputSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The input operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (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> inputWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.input(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The input operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (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 inputWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.inputSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The output operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (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 record used in operation return type along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> outputWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.output(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The output operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (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 record used in operation return type along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response outputWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.outputSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The inputAndOutput operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 record used both as operation parameter and return type along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> inputAndOutputWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.inputAndOutput(this.getEndpoint(), contentType, accept, body, requestOptions, context)); + } + + /** + * The inputAndOutput operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+ * + * @param body The body 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 record used both as operation parameter and return type along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response inputAndOutputWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.inputAndOutputSync(this.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/implementation/package-info.java new file mode 100644 index 000000000..0c0af9d6e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/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 Usage. + * Illustrates usage of Record in different places(Operation parameters, return type or both). + * + */ +package com.type.model.usage.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/models/InputOutputRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/models/InputOutputRecord.java new file mode 100644 index 000000000..efee5367f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/models/InputOutputRecord.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.usage.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; + +/** + * Record used both as operation parameter and return type. + */ +@Immutable +public final class InputOutputRecord implements JsonSerializable { + /* + * The requiredProp property. + */ + @Generated + private final String requiredProp; + + /** + * Creates an instance of InputOutputRecord class. + * + * @param requiredProp the requiredProp value to set. + */ + @Generated + public InputOutputRecord(String requiredProp) { + this.requiredProp = requiredProp; + } + + /** + * Get the requiredProp property: The requiredProp property. + * + * @return the requiredProp value. + */ + @Generated + public String getRequiredProp() { + return this.requiredProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProp", this.requiredProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InputOutputRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InputOutputRecord 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 InputOutputRecord. + */ + @Generated + public static InputOutputRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String requiredProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProp".equals(fieldName)) { + requiredProp = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new InputOutputRecord(requiredProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/models/InputRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/models/InputRecord.java new file mode 100644 index 000000000..f006ebbdb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/models/InputRecord.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.usage.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; + +/** + * Record used in operation parameters. + */ +@Immutable +public final class InputRecord implements JsonSerializable { + /* + * The requiredProp property. + */ + @Generated + private final String requiredProp; + + /** + * Creates an instance of InputRecord class. + * + * @param requiredProp the requiredProp value to set. + */ + @Generated + public InputRecord(String requiredProp) { + this.requiredProp = requiredProp; + } + + /** + * Get the requiredProp property: The requiredProp property. + * + * @return the requiredProp value. + */ + @Generated + public String getRequiredProp() { + return this.requiredProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProp", this.requiredProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InputRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InputRecord 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 InputRecord. + */ + @Generated + public static InputRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String requiredProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProp".equals(fieldName)) { + requiredProp = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new InputRecord(requiredProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/models/OutputRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/models/OutputRecord.java new file mode 100644 index 000000000..64d342037 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/models/OutputRecord.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.usage.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; + +/** + * Record used in operation return type. + */ +@Immutable +public final class OutputRecord implements JsonSerializable { + /* + * The requiredProp property. + */ + @Generated + private final String requiredProp; + + /** + * Creates an instance of OutputRecord class. + * + * @param requiredProp the requiredProp value to set. + */ + @Generated + private OutputRecord(String requiredProp) { + this.requiredProp = requiredProp; + } + + /** + * Get the requiredProp property: The requiredProp property. + * + * @return the requiredProp value. + */ + @Generated + public String getRequiredProp() { + return this.requiredProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProp", this.requiredProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OutputRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OutputRecord 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 OutputRecord. + */ + @Generated + public static OutputRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String requiredProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProp".equals(fieldName)) { + requiredProp = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new OutputRecord(requiredProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/models/package-info.java new file mode 100644 index 000000000..d33e0620a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/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 Usage. + * Illustrates usage of Record in different places(Operation parameters, return type or both). + * + */ +package com.type.model.usage.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/package-info.java new file mode 100644 index 000000000..371c2d73a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/usage/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 Usage. + * Illustrates usage of Record in different places(Operation parameters, return type or both). + * + */ +package com.type.model.usage; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/VisibilityAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/VisibilityAsyncClient.java new file mode 100644 index 000000000..f2ad58052 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/VisibilityAsyncClient.java @@ -0,0 +1,435 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.visibility; + +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 com.type.model.visibility.implementation.VisibilityClientImpl; +import com.type.model.visibility.models.ReadOnlyModel; +import com.type.model.visibility.models.VisibilityModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous VisibilityClient type. + */ +@ServiceClient(builder = VisibilityClientBuilder.class, isAsync = true) +public final class VisibilityAsyncClient { + @Generated + private final VisibilityClientImpl serviceClient; + + /** + * Initializes an instance of VisibilityAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VisibilityAsyncClient(VisibilityClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 output model with visibility properties along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponseAsync(input, requestOptions); + } + + /** + * The headModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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> headModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.headModelWithResponseAsync(input, requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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> putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putModelWithResponseAsync(input, requestOptions); + } + + /** + * The patchModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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> patchModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.patchModelWithResponseAsync(input, requestOptions); + } + + /** + * The postModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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> postModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.postModelWithResponseAsync(input, requestOptions); + } + + /** + * The deleteModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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> deleteModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.deleteModelWithResponseAsync(input, requestOptions); + } + + /** + * The putReadOnlyModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     optionalNullableIntList (Optional): [
+     *         int (Optional)
+     *     ]
+     *     optionalStringRecord (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     optionalNullableIntList (Optional): [
+     *         int (Optional)
+     *     ]
+     *     optionalStringRecord (Optional): {
+     *         String: String (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 roundTrip model with readonly optional properties along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putReadOnlyModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putReadOnlyModelWithResponseAsync(input, requestOptions); + } + + /** + * The getModel 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 output model with visibility properties on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getModel(VisibilityModel input) { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VisibilityModel.class)); + } + + /** + * The headModel 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 headModel(VisibilityModel input) { + // Generated convenience method for headModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return headModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The putModel 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 putModel(VisibilityModel input) { + // Generated convenience method for putModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The patchModel 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 patchModel(VisibilityModel input) { + // Generated convenience method for patchModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return patchModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The postModel 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 postModel(VisibilityModel input) { + // Generated convenience method for postModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The deleteModel 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 deleteModel(VisibilityModel input) { + // Generated convenience method for deleteModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The putReadOnlyModel 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 roundTrip model with readonly optional properties on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono putReadOnlyModel(ReadOnlyModel input) { + // Generated convenience method for putReadOnlyModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putReadOnlyModelWithResponse(BinaryData.fromObject(input), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ReadOnlyModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/VisibilityClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/VisibilityClient.java new file mode 100644 index 000000000..758acf365 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/VisibilityClient.java @@ -0,0 +1,426 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.visibility; + +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.type.model.visibility.implementation.VisibilityClientImpl; +import com.type.model.visibility.models.ReadOnlyModel; +import com.type.model.visibility.models.VisibilityModel; + +/** + * Initializes a new instance of the synchronous VisibilityClient type. + */ +@ServiceClient(builder = VisibilityClientBuilder.class) +public final class VisibilityClient { + @Generated + private final VisibilityClientImpl serviceClient; + + /** + * Initializes an instance of VisibilityClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VisibilityClient(VisibilityClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 output model with visibility properties along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponse(input, requestOptions); + } + + /** + * The headModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 headModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.headModelWithResponse(input, requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putModelWithResponse(input, requestOptions); + } + + /** + * The patchModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 patchModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.patchModelWithResponse(input, requestOptions); + } + + /** + * The postModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 postModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.postModelWithResponse(input, requestOptions); + } + + /** + * The deleteModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 deleteModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.deleteModelWithResponse(input, requestOptions); + } + + /** + * The putReadOnlyModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     optionalNullableIntList (Optional): [
+     *         int (Optional)
+     *     ]
+     *     optionalStringRecord (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     optionalNullableIntList (Optional): [
+     *         int (Optional)
+     *     ]
+     *     optionalStringRecord (Optional): {
+     *         String: String (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 roundTrip model with readonly optional properties along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putReadOnlyModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putReadOnlyModelWithResponse(input, requestOptions); + } + + /** + * The getModel 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 output model with visibility properties. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VisibilityModel getModel(VisibilityModel input) { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue() + .toObject(VisibilityModel.class); + } + + /** + * The headModel 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 headModel(VisibilityModel input) { + // Generated convenience method for headModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + headModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The putModel 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 putModel(VisibilityModel input) { + // Generated convenience method for putModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The patchModel 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 patchModel(VisibilityModel input) { + // Generated convenience method for patchModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + patchModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The postModel 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 postModel(VisibilityModel input) { + // Generated convenience method for postModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + postModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The deleteModel 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 deleteModel(VisibilityModel input) { + // Generated convenience method for deleteModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The putReadOnlyModel 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 roundTrip model with readonly optional properties. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ReadOnlyModel putReadOnlyModel(ReadOnlyModel input) { + // Generated convenience method for putReadOnlyModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putReadOnlyModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue() + .toObject(ReadOnlyModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/VisibilityClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/VisibilityClientBuilder.java new file mode 100644 index 000000000..70668f3bb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/VisibilityClientBuilder.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 com.type.model.visibility; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.model.visibility.implementation.VisibilityClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the VisibilityClient type. + */ +@ServiceClientBuilder(serviceClients = { VisibilityClient.class, VisibilityAsyncClient.class }) +public final class VisibilityClientBuilder 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("type-model-visibility.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the VisibilityClientBuilder. + */ + @Generated + public VisibilityClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VisibilityClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VisibilityClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VisibilityClientBuilder 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 VisibilityClientBuilder 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 VisibilityClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VisibilityClientBuilder 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 VisibilityClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public VisibilityClientBuilder 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 VisibilityClientBuilder. + */ + @Generated + public VisibilityClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of VisibilityClientImpl with the provided parameters. + * + * @return an instance of VisibilityClientImpl. + */ + @Generated + private VisibilityClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + VisibilityClientImpl client + = new VisibilityClientImpl(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 VisibilityAsyncClient class. + * + * @return an instance of VisibilityAsyncClient. + */ + @Generated + public VisibilityAsyncClient buildAsyncClient() { + return new VisibilityAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of VisibilityClient class. + * + * @return an instance of VisibilityClient. + */ + @Generated + public VisibilityClient buildClient() { + return new VisibilityClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(VisibilityClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/implementation/VisibilityClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/implementation/VisibilityClientImpl.java new file mode 100644 index 000000000..323e87eed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/implementation/VisibilityClientImpl.java @@ -0,0 +1,787 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.visibility.implementation; + +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.Head; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.Put; +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 VisibilityClient type. + */ +public final class VisibilityClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final VisibilityClientService 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 VisibilityClient client. + * + * @param endpoint Service host. + */ + public VisibilityClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of VisibilityClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public VisibilityClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of VisibilityClient 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 VisibilityClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(VisibilityClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for VisibilityClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "VisibilityClient") + public interface VisibilityClientService { + @Get("/type/model/visibility") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + + @Get("/type/model/visibility") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + + @Head("/type/model/visibility") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> headModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Head("/type/model/visibility") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response headModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/visibility") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/visibility") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Patch("/type/model/visibility") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Patch("/type/model/visibility") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Post("/type/model/visibility") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> postModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Post("/type/model/visibility") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response postModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Delete("/type/model/visibility") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Delete("/type/model/visibility") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions, Context context); + + @Put("/type/model/visibility/readonlyroundtrip") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putReadOnlyModel(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + + @Put("/type/model/visibility/readonlyroundtrip") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putReadOnlyModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions, Context context); + } + + /** + * The getModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 output model with visibility properties along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getModel(this.getEndpoint(), contentType, accept, input, requestOptions, context)); + } + + /** + * The getModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 output model with visibility properties along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.getModelSync(this.getEndpoint(), contentType, accept, input, requestOptions, Context.NONE); + } + + /** + * The headModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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> headModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.headModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The headModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 headModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.headModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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> putModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.putModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The patchModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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> patchModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.patchModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The patchModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 patchModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.patchModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The postModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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> postModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.postModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The postModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 postModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.postModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The deleteModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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> deleteModelWithResponseAsync(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.deleteModel(this.getEndpoint(), contentType, input, requestOptions, context)); + } + + /** + * The deleteModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (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 deleteModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.deleteModelSync(this.getEndpoint(), contentType, input, requestOptions, Context.NONE); + } + + /** + * The putReadOnlyModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     optionalNullableIntList (Optional): [
+     *         int (Optional)
+     *     ]
+     *     optionalStringRecord (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     optionalNullableIntList (Optional): [
+     *         int (Optional)
+     *     ]
+     *     optionalStringRecord (Optional): {
+     *         String: String (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 roundTrip model with readonly optional properties along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> putReadOnlyModelWithResponseAsync(BinaryData input, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.putReadOnlyModel(this.getEndpoint(), contentType, accept, input, + requestOptions, context)); + } + + /** + * The putReadOnlyModel operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     optionalNullableIntList (Optional): [
+     *         int (Optional)
+     *     ]
+     *     optionalStringRecord (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     optionalNullableIntList (Optional): [
+     *         int (Optional)
+     *     ]
+     *     optionalStringRecord (Optional): {
+     *         String: String (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 roundTrip model with readonly optional properties along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response putReadOnlyModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.putReadOnlyModelSync(this.getEndpoint(), contentType, accept, input, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/implementation/package-info.java new file mode 100644 index 000000000..d2bfae536 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/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 Visibility. + * Illustrates models with visibility properties. + * + */ +package com.type.model.visibility.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/models/ReadOnlyModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/models/ReadOnlyModel.java new file mode 100644 index 000000000..fbe3b91d6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/models/ReadOnlyModel.java @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.visibility.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; +import java.util.List; +import java.util.Map; + +/** + * RoundTrip model with readonly optional properties. + */ +@Immutable +public final class ReadOnlyModel implements JsonSerializable { + /* + * Optional readonly nullable int list. + */ + @Generated + private List optionalNullableIntList; + + /* + * Optional readonly string dictionary. + */ + @Generated + private Map optionalStringRecord; + + /** + * Creates an instance of ReadOnlyModel class. + */ + @Generated + public ReadOnlyModel() { + } + + /** + * Get the optionalNullableIntList property: Optional readonly nullable int list. + * + * @return the optionalNullableIntList value. + */ + @Generated + public List getOptionalNullableIntList() { + return this.optionalNullableIntList; + } + + /** + * Get the optionalStringRecord property: Optional readonly string dictionary. + * + * @return the optionalStringRecord value. + */ + @Generated + public Map getOptionalStringRecord() { + return this.optionalStringRecord; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ReadOnlyModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ReadOnlyModel 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 ReadOnlyModel. + */ + @Generated + public static ReadOnlyModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ReadOnlyModel deserializedReadOnlyModel = new ReadOnlyModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("optionalNullableIntList".equals(fieldName)) { + List optionalNullableIntList = reader.readArray(reader1 -> reader1.getInt()); + deserializedReadOnlyModel.optionalNullableIntList = optionalNullableIntList; + } else if ("optionalStringRecord".equals(fieldName)) { + Map optionalStringRecord = reader.readMap(reader1 -> reader1.getString()); + deserializedReadOnlyModel.optionalStringRecord = optionalStringRecord; + } else { + reader.skipChildren(); + } + } + + return deserializedReadOnlyModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/models/VisibilityModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/models/VisibilityModel.java new file mode 100644 index 000000000..3ab604613 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/models/VisibilityModel.java @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.visibility.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; +import java.util.List; + +/** + * Output model with visibility properties. + */ +@Immutable +public final class VisibilityModel implements JsonSerializable { + /* + * Required string, illustrating a readonly property. + */ + @Generated + private String readProp; + + /* + * Required int32, illustrating a query property. + */ + @Generated + private final Integer queryProp; + + /* + * Required string[], illustrating a create property. + */ + @Generated + private final List createProp; + + /* + * Required int32[], illustrating a update property. + */ + @Generated + private final List updateProp; + + /* + * Required bool, illustrating a delete property. + */ + @Generated + private final Boolean deleteProp; + + /** + * Creates an instance of VisibilityModel class. + * + * @param queryProp the queryProp value to set. + * @param createProp the createProp value to set. + * @param updateProp the updateProp value to set. + * @param deleteProp the deleteProp value to set. + */ + @Generated + public VisibilityModel(Integer queryProp, List createProp, List updateProp, Boolean deleteProp) { + this.queryProp = queryProp; + this.createProp = createProp; + this.updateProp = updateProp; + this.deleteProp = deleteProp; + } + + /** + * Get the readProp property: Required string, illustrating a readonly property. + * + * @return the readProp value. + */ + @Generated + public String getReadProp() { + return this.readProp; + } + + /** + * Get the queryProp property: Required int32, illustrating a query property. + * + * @return the queryProp value. + */ + @Generated + public Integer getQueryProp() { + return this.queryProp; + } + + /** + * Get the createProp property: Required string[], illustrating a create property. + * + * @return the createProp value. + */ + @Generated + public List getCreateProp() { + return this.createProp; + } + + /** + * Get the updateProp property: Required int32[], illustrating a update property. + * + * @return the updateProp value. + */ + @Generated + public List getUpdateProp() { + return this.updateProp; + } + + /** + * Get the deleteProp property: Required bool, illustrating a delete property. + * + * @return the deleteProp value. + */ + @Generated + public Boolean isDeleteProp() { + return this.deleteProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("queryProp", this.queryProp); + jsonWriter.writeArrayField("createProp", this.createProp, (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("updateProp", this.updateProp, (writer, element) -> writer.writeInt(element)); + jsonWriter.writeBooleanField("deleteProp", this.deleteProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VisibilityModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VisibilityModel 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 VisibilityModel. + */ + @Generated + public static VisibilityModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String readProp = null; + Integer queryProp = null; + List createProp = null; + List updateProp = null; + Boolean deleteProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("readProp".equals(fieldName)) { + readProp = reader.getString(); + } else if ("queryProp".equals(fieldName)) { + queryProp = reader.getNullable(JsonReader::getInt); + } else if ("createProp".equals(fieldName)) { + createProp = reader.readArray(reader1 -> reader1.getString()); + } else if ("updateProp".equals(fieldName)) { + updateProp = reader.readArray(reader1 -> reader1.getInt()); + } else if ("deleteProp".equals(fieldName)) { + deleteProp = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + VisibilityModel deserializedVisibilityModel + = new VisibilityModel(queryProp, createProp, updateProp, deleteProp); + deserializedVisibilityModel.readProp = readProp; + + return deserializedVisibilityModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/models/package-info.java new file mode 100644 index 000000000..812e9dac9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/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 Visibility. + * Illustrates models with visibility properties. + * + */ +package com.type.model.visibility.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/package-info.java new file mode 100644 index 000000000..238b05674 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/model/visibility/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 Visibility. + * Illustrates models with visibility properties. + * + */ +package com.type.model.visibility; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/AdditionalPropertiesClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/AdditionalPropertiesClientBuilder.java new file mode 100644 index 000000000..6e1941fd4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/AdditionalPropertiesClientBuilder.java @@ -0,0 +1,979 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.property.additionalproperties.implementation.AdditionalPropertiesClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the AdditionalPropertiesClient type. + */ +@ServiceClientBuilder( + serviceClients = { + ExtendsUnknownClient.class, + ExtendsUnknownDerivedClient.class, + ExtendsUnknownDiscriminatedClient.class, + IsUnknownClient.class, + IsUnknownDerivedClient.class, + IsUnknownDiscriminatedClient.class, + ExtendsStringClient.class, + IsStringClient.class, + SpreadStringClient.class, + ExtendsFloatClient.class, + IsFloatClient.class, + SpreadFloatClient.class, + ExtendsModelClient.class, + IsModelClient.class, + SpreadModelClient.class, + ExtendsModelArrayClient.class, + IsModelArrayClient.class, + SpreadModelArrayClient.class, + SpreadDifferentStringClient.class, + SpreadDifferentFloatClient.class, + SpreadDifferentModelClient.class, + SpreadDifferentModelArrayClient.class, + ExtendsDifferentSpreadStringClient.class, + ExtendsDifferentSpreadFloatClient.class, + ExtendsDifferentSpreadModelClient.class, + ExtendsDifferentSpreadModelArrayClient.class, + MultipleSpreadClient.class, + SpreadRecordUnionClient.class, + SpreadRecordDiscriminatedUnionClient.class, + SpreadRecordNonDiscriminatedUnionClient.class, + SpreadRecordNonDiscriminatedUnion2Client.class, + SpreadRecordNonDiscriminatedUnion3Client.class, + ExtendsUnknownAsyncClient.class, + ExtendsUnknownDerivedAsyncClient.class, + ExtendsUnknownDiscriminatedAsyncClient.class, + IsUnknownAsyncClient.class, + IsUnknownDerivedAsyncClient.class, + IsUnknownDiscriminatedAsyncClient.class, + ExtendsStringAsyncClient.class, + IsStringAsyncClient.class, + SpreadStringAsyncClient.class, + ExtendsFloatAsyncClient.class, + IsFloatAsyncClient.class, + SpreadFloatAsyncClient.class, + ExtendsModelAsyncClient.class, + IsModelAsyncClient.class, + SpreadModelAsyncClient.class, + ExtendsModelArrayAsyncClient.class, + IsModelArrayAsyncClient.class, + SpreadModelArrayAsyncClient.class, + SpreadDifferentStringAsyncClient.class, + SpreadDifferentFloatAsyncClient.class, + SpreadDifferentModelAsyncClient.class, + SpreadDifferentModelArrayAsyncClient.class, + ExtendsDifferentSpreadStringAsyncClient.class, + ExtendsDifferentSpreadFloatAsyncClient.class, + ExtendsDifferentSpreadModelAsyncClient.class, + ExtendsDifferentSpreadModelArrayAsyncClient.class, + MultipleSpreadAsyncClient.class, + SpreadRecordUnionAsyncClient.class, + SpreadRecordDiscriminatedUnionAsyncClient.class, + SpreadRecordNonDiscriminatedUnionAsyncClient.class, + SpreadRecordNonDiscriminatedUnion2AsyncClient.class, + SpreadRecordNonDiscriminatedUnion3AsyncClient.class }) +public final class AdditionalPropertiesClientBuilder 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("type-property-additionalproperties.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the AdditionalPropertiesClientBuilder. + */ + @Generated + public AdditionalPropertiesClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AdditionalPropertiesClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AdditionalPropertiesClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AdditionalPropertiesClientBuilder 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 AdditionalPropertiesClientBuilder 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 AdditionalPropertiesClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AdditionalPropertiesClientBuilder 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 AdditionalPropertiesClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AdditionalPropertiesClientBuilder 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 AdditionalPropertiesClientBuilder. + */ + @Generated + public AdditionalPropertiesClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of AdditionalPropertiesClientImpl with the provided parameters. + * + * @return an instance of AdditionalPropertiesClientImpl. + */ + @Generated + private AdditionalPropertiesClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + AdditionalPropertiesClientImpl client = new AdditionalPropertiesClientImpl(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 ExtendsUnknownAsyncClient class. + * + * @return an instance of ExtendsUnknownAsyncClient. + */ + @Generated + public ExtendsUnknownAsyncClient buildExtendsUnknownAsyncClient() { + return new ExtendsUnknownAsyncClient(buildInnerClient().getExtendsUnknowns()); + } + + /** + * Builds an instance of ExtendsUnknownDerivedAsyncClient class. + * + * @return an instance of ExtendsUnknownDerivedAsyncClient. + */ + @Generated + public ExtendsUnknownDerivedAsyncClient buildExtendsUnknownDerivedAsyncClient() { + return new ExtendsUnknownDerivedAsyncClient(buildInnerClient().getExtendsUnknownDeriveds()); + } + + /** + * Builds an instance of ExtendsUnknownDiscriminatedAsyncClient class. + * + * @return an instance of ExtendsUnknownDiscriminatedAsyncClient. + */ + @Generated + public ExtendsUnknownDiscriminatedAsyncClient buildExtendsUnknownDiscriminatedAsyncClient() { + return new ExtendsUnknownDiscriminatedAsyncClient(buildInnerClient().getExtendsUnknownDiscriminateds()); + } + + /** + * Builds an instance of IsUnknownAsyncClient class. + * + * @return an instance of IsUnknownAsyncClient. + */ + @Generated + public IsUnknownAsyncClient buildIsUnknownAsyncClient() { + return new IsUnknownAsyncClient(buildInnerClient().getIsUnknowns()); + } + + /** + * Builds an instance of IsUnknownDerivedAsyncClient class. + * + * @return an instance of IsUnknownDerivedAsyncClient. + */ + @Generated + public IsUnknownDerivedAsyncClient buildIsUnknownDerivedAsyncClient() { + return new IsUnknownDerivedAsyncClient(buildInnerClient().getIsUnknownDeriveds()); + } + + /** + * Builds an instance of IsUnknownDiscriminatedAsyncClient class. + * + * @return an instance of IsUnknownDiscriminatedAsyncClient. + */ + @Generated + public IsUnknownDiscriminatedAsyncClient buildIsUnknownDiscriminatedAsyncClient() { + return new IsUnknownDiscriminatedAsyncClient(buildInnerClient().getIsUnknownDiscriminateds()); + } + + /** + * Builds an instance of ExtendsStringAsyncClient class. + * + * @return an instance of ExtendsStringAsyncClient. + */ + @Generated + public ExtendsStringAsyncClient buildExtendsStringAsyncClient() { + return new ExtendsStringAsyncClient(buildInnerClient().getExtendsStrings()); + } + + /** + * Builds an instance of IsStringAsyncClient class. + * + * @return an instance of IsStringAsyncClient. + */ + @Generated + public IsStringAsyncClient buildIsStringAsyncClient() { + return new IsStringAsyncClient(buildInnerClient().getIsStrings()); + } + + /** + * Builds an instance of SpreadStringAsyncClient class. + * + * @return an instance of SpreadStringAsyncClient. + */ + @Generated + public SpreadStringAsyncClient buildSpreadStringAsyncClient() { + return new SpreadStringAsyncClient(buildInnerClient().getSpreadStrings()); + } + + /** + * Builds an instance of ExtendsFloatAsyncClient class. + * + * @return an instance of ExtendsFloatAsyncClient. + */ + @Generated + public ExtendsFloatAsyncClient buildExtendsFloatAsyncClient() { + return new ExtendsFloatAsyncClient(buildInnerClient().getExtendsFloats()); + } + + /** + * Builds an instance of IsFloatAsyncClient class. + * + * @return an instance of IsFloatAsyncClient. + */ + @Generated + public IsFloatAsyncClient buildIsFloatAsyncClient() { + return new IsFloatAsyncClient(buildInnerClient().getIsFloats()); + } + + /** + * Builds an instance of SpreadFloatAsyncClient class. + * + * @return an instance of SpreadFloatAsyncClient. + */ + @Generated + public SpreadFloatAsyncClient buildSpreadFloatAsyncClient() { + return new SpreadFloatAsyncClient(buildInnerClient().getSpreadFloats()); + } + + /** + * Builds an instance of ExtendsModelAsyncClient class. + * + * @return an instance of ExtendsModelAsyncClient. + */ + @Generated + public ExtendsModelAsyncClient buildExtendsModelAsyncClient() { + return new ExtendsModelAsyncClient(buildInnerClient().getExtendsModels()); + } + + /** + * Builds an instance of IsModelAsyncClient class. + * + * @return an instance of IsModelAsyncClient. + */ + @Generated + public IsModelAsyncClient buildIsModelAsyncClient() { + return new IsModelAsyncClient(buildInnerClient().getIsModels()); + } + + /** + * Builds an instance of SpreadModelAsyncClient class. + * + * @return an instance of SpreadModelAsyncClient. + */ + @Generated + public SpreadModelAsyncClient buildSpreadModelAsyncClient() { + return new SpreadModelAsyncClient(buildInnerClient().getSpreadModels()); + } + + /** + * Builds an instance of ExtendsModelArrayAsyncClient class. + * + * @return an instance of ExtendsModelArrayAsyncClient. + */ + @Generated + public ExtendsModelArrayAsyncClient buildExtendsModelArrayAsyncClient() { + return new ExtendsModelArrayAsyncClient(buildInnerClient().getExtendsModelArrays()); + } + + /** + * Builds an instance of IsModelArrayAsyncClient class. + * + * @return an instance of IsModelArrayAsyncClient. + */ + @Generated + public IsModelArrayAsyncClient buildIsModelArrayAsyncClient() { + return new IsModelArrayAsyncClient(buildInnerClient().getIsModelArrays()); + } + + /** + * Builds an instance of SpreadModelArrayAsyncClient class. + * + * @return an instance of SpreadModelArrayAsyncClient. + */ + @Generated + public SpreadModelArrayAsyncClient buildSpreadModelArrayAsyncClient() { + return new SpreadModelArrayAsyncClient(buildInnerClient().getSpreadModelArrays()); + } + + /** + * Builds an instance of SpreadDifferentStringAsyncClient class. + * + * @return an instance of SpreadDifferentStringAsyncClient. + */ + @Generated + public SpreadDifferentStringAsyncClient buildSpreadDifferentStringAsyncClient() { + return new SpreadDifferentStringAsyncClient(buildInnerClient().getSpreadDifferentStrings()); + } + + /** + * Builds an instance of SpreadDifferentFloatAsyncClient class. + * + * @return an instance of SpreadDifferentFloatAsyncClient. + */ + @Generated + public SpreadDifferentFloatAsyncClient buildSpreadDifferentFloatAsyncClient() { + return new SpreadDifferentFloatAsyncClient(buildInnerClient().getSpreadDifferentFloats()); + } + + /** + * Builds an instance of SpreadDifferentModelAsyncClient class. + * + * @return an instance of SpreadDifferentModelAsyncClient. + */ + @Generated + public SpreadDifferentModelAsyncClient buildSpreadDifferentModelAsyncClient() { + return new SpreadDifferentModelAsyncClient(buildInnerClient().getSpreadDifferentModels()); + } + + /** + * Builds an instance of SpreadDifferentModelArrayAsyncClient class. + * + * @return an instance of SpreadDifferentModelArrayAsyncClient. + */ + @Generated + public SpreadDifferentModelArrayAsyncClient buildSpreadDifferentModelArrayAsyncClient() { + return new SpreadDifferentModelArrayAsyncClient(buildInnerClient().getSpreadDifferentModelArrays()); + } + + /** + * Builds an instance of ExtendsDifferentSpreadStringAsyncClient class. + * + * @return an instance of ExtendsDifferentSpreadStringAsyncClient. + */ + @Generated + public ExtendsDifferentSpreadStringAsyncClient buildExtendsDifferentSpreadStringAsyncClient() { + return new ExtendsDifferentSpreadStringAsyncClient(buildInnerClient().getExtendsDifferentSpreadStrings()); + } + + /** + * Builds an instance of ExtendsDifferentSpreadFloatAsyncClient class. + * + * @return an instance of ExtendsDifferentSpreadFloatAsyncClient. + */ + @Generated + public ExtendsDifferentSpreadFloatAsyncClient buildExtendsDifferentSpreadFloatAsyncClient() { + return new ExtendsDifferentSpreadFloatAsyncClient(buildInnerClient().getExtendsDifferentSpreadFloats()); + } + + /** + * Builds an instance of ExtendsDifferentSpreadModelAsyncClient class. + * + * @return an instance of ExtendsDifferentSpreadModelAsyncClient. + */ + @Generated + public ExtendsDifferentSpreadModelAsyncClient buildExtendsDifferentSpreadModelAsyncClient() { + return new ExtendsDifferentSpreadModelAsyncClient(buildInnerClient().getExtendsDifferentSpreadModels()); + } + + /** + * Builds an instance of ExtendsDifferentSpreadModelArrayAsyncClient class. + * + * @return an instance of ExtendsDifferentSpreadModelArrayAsyncClient. + */ + @Generated + public ExtendsDifferentSpreadModelArrayAsyncClient buildExtendsDifferentSpreadModelArrayAsyncClient() { + return new ExtendsDifferentSpreadModelArrayAsyncClient( + buildInnerClient().getExtendsDifferentSpreadModelArrays()); + } + + /** + * Builds an instance of MultipleSpreadAsyncClient class. + * + * @return an instance of MultipleSpreadAsyncClient. + */ + @Generated + public MultipleSpreadAsyncClient buildMultipleSpreadAsyncClient() { + return new MultipleSpreadAsyncClient(buildInnerClient().getMultipleSpreads()); + } + + /** + * Builds an instance of SpreadRecordUnionAsyncClient class. + * + * @return an instance of SpreadRecordUnionAsyncClient. + */ + @Generated + public SpreadRecordUnionAsyncClient buildSpreadRecordUnionAsyncClient() { + return new SpreadRecordUnionAsyncClient(buildInnerClient().getSpreadRecordUnions()); + } + + /** + * Builds an instance of SpreadRecordDiscriminatedUnionAsyncClient class. + * + * @return an instance of SpreadRecordDiscriminatedUnionAsyncClient. + */ + @Generated + public SpreadRecordDiscriminatedUnionAsyncClient buildSpreadRecordDiscriminatedUnionAsyncClient() { + return new SpreadRecordDiscriminatedUnionAsyncClient(buildInnerClient().getSpreadRecordDiscriminatedUnions()); + } + + /** + * Builds an instance of SpreadRecordNonDiscriminatedUnionAsyncClient class. + * + * @return an instance of SpreadRecordNonDiscriminatedUnionAsyncClient. + */ + @Generated + public SpreadRecordNonDiscriminatedUnionAsyncClient buildSpreadRecordNonDiscriminatedUnionAsyncClient() { + return new SpreadRecordNonDiscriminatedUnionAsyncClient( + buildInnerClient().getSpreadRecordNonDiscriminatedUnions()); + } + + /** + * Builds an instance of SpreadRecordNonDiscriminatedUnion2AsyncClient class. + * + * @return an instance of SpreadRecordNonDiscriminatedUnion2AsyncClient. + */ + @Generated + public SpreadRecordNonDiscriminatedUnion2AsyncClient buildSpreadRecordNonDiscriminatedUnion2AsyncClient() { + return new SpreadRecordNonDiscriminatedUnion2AsyncClient( + buildInnerClient().getSpreadRecordNonDiscriminatedUnion2s()); + } + + /** + * Builds an instance of SpreadRecordNonDiscriminatedUnion3AsyncClient class. + * + * @return an instance of SpreadRecordNonDiscriminatedUnion3AsyncClient. + */ + @Generated + public SpreadRecordNonDiscriminatedUnion3AsyncClient buildSpreadRecordNonDiscriminatedUnion3AsyncClient() { + return new SpreadRecordNonDiscriminatedUnion3AsyncClient( + buildInnerClient().getSpreadRecordNonDiscriminatedUnion3s()); + } + + /** + * Builds an instance of ExtendsUnknownClient class. + * + * @return an instance of ExtendsUnknownClient. + */ + @Generated + public ExtendsUnknownClient buildExtendsUnknownClient() { + return new ExtendsUnknownClient(buildInnerClient().getExtendsUnknowns()); + } + + /** + * Builds an instance of ExtendsUnknownDerivedClient class. + * + * @return an instance of ExtendsUnknownDerivedClient. + */ + @Generated + public ExtendsUnknownDerivedClient buildExtendsUnknownDerivedClient() { + return new ExtendsUnknownDerivedClient(buildInnerClient().getExtendsUnknownDeriveds()); + } + + /** + * Builds an instance of ExtendsUnknownDiscriminatedClient class. + * + * @return an instance of ExtendsUnknownDiscriminatedClient. + */ + @Generated + public ExtendsUnknownDiscriminatedClient buildExtendsUnknownDiscriminatedClient() { + return new ExtendsUnknownDiscriminatedClient(buildInnerClient().getExtendsUnknownDiscriminateds()); + } + + /** + * Builds an instance of IsUnknownClient class. + * + * @return an instance of IsUnknownClient. + */ + @Generated + public IsUnknownClient buildIsUnknownClient() { + return new IsUnknownClient(buildInnerClient().getIsUnknowns()); + } + + /** + * Builds an instance of IsUnknownDerivedClient class. + * + * @return an instance of IsUnknownDerivedClient. + */ + @Generated + public IsUnknownDerivedClient buildIsUnknownDerivedClient() { + return new IsUnknownDerivedClient(buildInnerClient().getIsUnknownDeriveds()); + } + + /** + * Builds an instance of IsUnknownDiscriminatedClient class. + * + * @return an instance of IsUnknownDiscriminatedClient. + */ + @Generated + public IsUnknownDiscriminatedClient buildIsUnknownDiscriminatedClient() { + return new IsUnknownDiscriminatedClient(buildInnerClient().getIsUnknownDiscriminateds()); + } + + /** + * Builds an instance of ExtendsStringClient class. + * + * @return an instance of ExtendsStringClient. + */ + @Generated + public ExtendsStringClient buildExtendsStringClient() { + return new ExtendsStringClient(buildInnerClient().getExtendsStrings()); + } + + /** + * Builds an instance of IsStringClient class. + * + * @return an instance of IsStringClient. + */ + @Generated + public IsStringClient buildIsStringClient() { + return new IsStringClient(buildInnerClient().getIsStrings()); + } + + /** + * Builds an instance of SpreadStringClient class. + * + * @return an instance of SpreadStringClient. + */ + @Generated + public SpreadStringClient buildSpreadStringClient() { + return new SpreadStringClient(buildInnerClient().getSpreadStrings()); + } + + /** + * Builds an instance of ExtendsFloatClient class. + * + * @return an instance of ExtendsFloatClient. + */ + @Generated + public ExtendsFloatClient buildExtendsFloatClient() { + return new ExtendsFloatClient(buildInnerClient().getExtendsFloats()); + } + + /** + * Builds an instance of IsFloatClient class. + * + * @return an instance of IsFloatClient. + */ + @Generated + public IsFloatClient buildIsFloatClient() { + return new IsFloatClient(buildInnerClient().getIsFloats()); + } + + /** + * Builds an instance of SpreadFloatClient class. + * + * @return an instance of SpreadFloatClient. + */ + @Generated + public SpreadFloatClient buildSpreadFloatClient() { + return new SpreadFloatClient(buildInnerClient().getSpreadFloats()); + } + + /** + * Builds an instance of ExtendsModelClient class. + * + * @return an instance of ExtendsModelClient. + */ + @Generated + public ExtendsModelClient buildExtendsModelClient() { + return new ExtendsModelClient(buildInnerClient().getExtendsModels()); + } + + /** + * Builds an instance of IsModelClient class. + * + * @return an instance of IsModelClient. + */ + @Generated + public IsModelClient buildIsModelClient() { + return new IsModelClient(buildInnerClient().getIsModels()); + } + + /** + * Builds an instance of SpreadModelClient class. + * + * @return an instance of SpreadModelClient. + */ + @Generated + public SpreadModelClient buildSpreadModelClient() { + return new SpreadModelClient(buildInnerClient().getSpreadModels()); + } + + /** + * Builds an instance of ExtendsModelArrayClient class. + * + * @return an instance of ExtendsModelArrayClient. + */ + @Generated + public ExtendsModelArrayClient buildExtendsModelArrayClient() { + return new ExtendsModelArrayClient(buildInnerClient().getExtendsModelArrays()); + } + + /** + * Builds an instance of IsModelArrayClient class. + * + * @return an instance of IsModelArrayClient. + */ + @Generated + public IsModelArrayClient buildIsModelArrayClient() { + return new IsModelArrayClient(buildInnerClient().getIsModelArrays()); + } + + /** + * Builds an instance of SpreadModelArrayClient class. + * + * @return an instance of SpreadModelArrayClient. + */ + @Generated + public SpreadModelArrayClient buildSpreadModelArrayClient() { + return new SpreadModelArrayClient(buildInnerClient().getSpreadModelArrays()); + } + + /** + * Builds an instance of SpreadDifferentStringClient class. + * + * @return an instance of SpreadDifferentStringClient. + */ + @Generated + public SpreadDifferentStringClient buildSpreadDifferentStringClient() { + return new SpreadDifferentStringClient(buildInnerClient().getSpreadDifferentStrings()); + } + + /** + * Builds an instance of SpreadDifferentFloatClient class. + * + * @return an instance of SpreadDifferentFloatClient. + */ + @Generated + public SpreadDifferentFloatClient buildSpreadDifferentFloatClient() { + return new SpreadDifferentFloatClient(buildInnerClient().getSpreadDifferentFloats()); + } + + /** + * Builds an instance of SpreadDifferentModelClient class. + * + * @return an instance of SpreadDifferentModelClient. + */ + @Generated + public SpreadDifferentModelClient buildSpreadDifferentModelClient() { + return new SpreadDifferentModelClient(buildInnerClient().getSpreadDifferentModels()); + } + + /** + * Builds an instance of SpreadDifferentModelArrayClient class. + * + * @return an instance of SpreadDifferentModelArrayClient. + */ + @Generated + public SpreadDifferentModelArrayClient buildSpreadDifferentModelArrayClient() { + return new SpreadDifferentModelArrayClient(buildInnerClient().getSpreadDifferentModelArrays()); + } + + /** + * Builds an instance of ExtendsDifferentSpreadStringClient class. + * + * @return an instance of ExtendsDifferentSpreadStringClient. + */ + @Generated + public ExtendsDifferentSpreadStringClient buildExtendsDifferentSpreadStringClient() { + return new ExtendsDifferentSpreadStringClient(buildInnerClient().getExtendsDifferentSpreadStrings()); + } + + /** + * Builds an instance of ExtendsDifferentSpreadFloatClient class. + * + * @return an instance of ExtendsDifferentSpreadFloatClient. + */ + @Generated + public ExtendsDifferentSpreadFloatClient buildExtendsDifferentSpreadFloatClient() { + return new ExtendsDifferentSpreadFloatClient(buildInnerClient().getExtendsDifferentSpreadFloats()); + } + + /** + * Builds an instance of ExtendsDifferentSpreadModelClient class. + * + * @return an instance of ExtendsDifferentSpreadModelClient. + */ + @Generated + public ExtendsDifferentSpreadModelClient buildExtendsDifferentSpreadModelClient() { + return new ExtendsDifferentSpreadModelClient(buildInnerClient().getExtendsDifferentSpreadModels()); + } + + /** + * Builds an instance of ExtendsDifferentSpreadModelArrayClient class. + * + * @return an instance of ExtendsDifferentSpreadModelArrayClient. + */ + @Generated + public ExtendsDifferentSpreadModelArrayClient buildExtendsDifferentSpreadModelArrayClient() { + return new ExtendsDifferentSpreadModelArrayClient(buildInnerClient().getExtendsDifferentSpreadModelArrays()); + } + + /** + * Builds an instance of MultipleSpreadClient class. + * + * @return an instance of MultipleSpreadClient. + */ + @Generated + public MultipleSpreadClient buildMultipleSpreadClient() { + return new MultipleSpreadClient(buildInnerClient().getMultipleSpreads()); + } + + /** + * Builds an instance of SpreadRecordUnionClient class. + * + * @return an instance of SpreadRecordUnionClient. + */ + @Generated + public SpreadRecordUnionClient buildSpreadRecordUnionClient() { + return new SpreadRecordUnionClient(buildInnerClient().getSpreadRecordUnions()); + } + + /** + * Builds an instance of SpreadRecordDiscriminatedUnionClient class. + * + * @return an instance of SpreadRecordDiscriminatedUnionClient. + */ + @Generated + public SpreadRecordDiscriminatedUnionClient buildSpreadRecordDiscriminatedUnionClient() { + return new SpreadRecordDiscriminatedUnionClient(buildInnerClient().getSpreadRecordDiscriminatedUnions()); + } + + /** + * Builds an instance of SpreadRecordNonDiscriminatedUnionClient class. + * + * @return an instance of SpreadRecordNonDiscriminatedUnionClient. + */ + @Generated + public SpreadRecordNonDiscriminatedUnionClient buildSpreadRecordNonDiscriminatedUnionClient() { + return new SpreadRecordNonDiscriminatedUnionClient(buildInnerClient().getSpreadRecordNonDiscriminatedUnions()); + } + + /** + * Builds an instance of SpreadRecordNonDiscriminatedUnion2Client class. + * + * @return an instance of SpreadRecordNonDiscriminatedUnion2Client. + */ + @Generated + public SpreadRecordNonDiscriminatedUnion2Client buildSpreadRecordNonDiscriminatedUnion2Client() { + return new SpreadRecordNonDiscriminatedUnion2Client( + buildInnerClient().getSpreadRecordNonDiscriminatedUnion2s()); + } + + /** + * Builds an instance of SpreadRecordNonDiscriminatedUnion3Client class. + * + * @return an instance of SpreadRecordNonDiscriminatedUnion3Client. + */ + @Generated + public SpreadRecordNonDiscriminatedUnion3Client buildSpreadRecordNonDiscriminatedUnion3Client() { + return new SpreadRecordNonDiscriminatedUnion3Client( + buildInnerClient().getSpreadRecordNonDiscriminatedUnion3s()); + } + + private static final ClientLogger LOGGER = new ClientLogger(AdditionalPropertiesClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadFloatAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadFloatAsyncClient.java new file mode 100644 index 000000000..0a77172f1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadFloatAsyncClient.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.ExtendsDifferentSpreadFloatsImpl; +import com.type.property.additionalproperties.models.DifferentSpreadFloatDerived; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class ExtendsDifferentSpreadFloatAsyncClient { + @Generated + private final ExtendsDifferentSpreadFloatsImpl serviceClient; + + /** + * Initializes an instance of ExtendsDifferentSpreadFloatAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsDifferentSpreadFloatAsyncClient(ExtendsDifferentSpreadFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     *     derivedProp: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     *     derivedProp: double (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DifferentSpreadFloatDerived.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadFloatDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadFloatClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadFloatClient.java new file mode 100644 index 000000000..a18b3d3fc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadFloatClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.ExtendsDifferentSpreadFloatsImpl; +import com.type.property.additionalproperties.models.DifferentSpreadFloatDerived; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsDifferentSpreadFloatClient { + @Generated + private final ExtendsDifferentSpreadFloatsImpl serviceClient; + + /** + * Initializes an instance of ExtendsDifferentSpreadFloatClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsDifferentSpreadFloatClient(ExtendsDifferentSpreadFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     *     derivedProp: double (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     *     derivedProp: double (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DifferentSpreadFloatDerived get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(DifferentSpreadFloatDerived.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadFloatDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadModelArrayAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadModelArrayAsyncClient.java new file mode 100644 index 000000000..8e539dc46 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadModelArrayAsyncClient.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 com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.ExtendsDifferentSpreadModelArraysImpl; +import com.type.property.additionalproperties.models.DifferentSpreadModelArrayDerived; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class ExtendsDifferentSpreadModelArrayAsyncClient { + @Generated + private final ExtendsDifferentSpreadModelArraysImpl serviceClient; + + /** + * Initializes an instance of ExtendsDifferentSpreadModelArrayAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsDifferentSpreadModelArrayAsyncClient(ExtendsDifferentSpreadModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     *     derivedProp (Required): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     *     derivedProp (Required): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DifferentSpreadModelArrayDerived.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadModelArrayDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadModelArrayClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadModelArrayClient.java new file mode 100644 index 000000000..c9341fbd7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadModelArrayClient.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.ExtendsDifferentSpreadModelArraysImpl; +import com.type.property.additionalproperties.models.DifferentSpreadModelArrayDerived; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsDifferentSpreadModelArrayClient { + @Generated + private final ExtendsDifferentSpreadModelArraysImpl serviceClient; + + /** + * Initializes an instance of ExtendsDifferentSpreadModelArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsDifferentSpreadModelArrayClient(ExtendsDifferentSpreadModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     *     derivedProp (Required): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     *     derivedProp (Required): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DifferentSpreadModelArrayDerived get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(DifferentSpreadModelArrayDerived.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadModelArrayDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadModelAsyncClient.java new file mode 100644 index 000000000..edeaef6e6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadModelAsyncClient.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.ExtendsDifferentSpreadModelsImpl; +import com.type.property.additionalproperties.models.DifferentSpreadModelDerived; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class ExtendsDifferentSpreadModelAsyncClient { + @Generated + private final ExtendsDifferentSpreadModelsImpl serviceClient; + + /** + * Initializes an instance of ExtendsDifferentSpreadModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsDifferentSpreadModelAsyncClient(ExtendsDifferentSpreadModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     *     derivedProp (Required): (recursive schema, see derivedProp above)
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     *     derivedProp (Required): (recursive schema, see derivedProp above)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DifferentSpreadModelDerived.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadModelDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadModelClient.java new file mode 100644 index 000000000..3ef771373 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadModelClient.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.ExtendsDifferentSpreadModelsImpl; +import com.type.property.additionalproperties.models.DifferentSpreadModelDerived; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsDifferentSpreadModelClient { + @Generated + private final ExtendsDifferentSpreadModelsImpl serviceClient; + + /** + * Initializes an instance of ExtendsDifferentSpreadModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsDifferentSpreadModelClient(ExtendsDifferentSpreadModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     *     derivedProp (Required): (recursive schema, see derivedProp above)
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     *     derivedProp (Required): (recursive schema, see derivedProp above)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DifferentSpreadModelDerived get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(DifferentSpreadModelDerived.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadModelDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadStringAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadStringAsyncClient.java new file mode 100644 index 000000000..79c7ee9f4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadStringAsyncClient.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.ExtendsDifferentSpreadStringsImpl; +import com.type.property.additionalproperties.models.DifferentSpreadStringDerived; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class ExtendsDifferentSpreadStringAsyncClient { + @Generated + private final ExtendsDifferentSpreadStringsImpl serviceClient; + + /** + * Initializes an instance of ExtendsDifferentSpreadStringAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsDifferentSpreadStringAsyncClient(ExtendsDifferentSpreadStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     *     derivedProp: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     *     derivedProp: String (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DifferentSpreadStringDerived.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadStringDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadStringClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadStringClient.java new file mode 100644 index 000000000..c110a4e66 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsDifferentSpreadStringClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.ExtendsDifferentSpreadStringsImpl; +import com.type.property.additionalproperties.models.DifferentSpreadStringDerived; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsDifferentSpreadStringClient { + @Generated + private final ExtendsDifferentSpreadStringsImpl serviceClient; + + /** + * Initializes an instance of ExtendsDifferentSpreadStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsDifferentSpreadStringClient(ExtendsDifferentSpreadStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     *     derivedProp: String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     *     derivedProp: String (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DifferentSpreadStringDerived get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(DifferentSpreadStringDerived.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadStringDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsFloatAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsFloatAsyncClient.java new file mode 100644 index 000000000..165efe096 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsFloatAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.ExtendsFloatsImpl; +import com.type.property.additionalproperties.models.ExtendsFloatAdditionalProperties; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class ExtendsFloatAsyncClient { + @Generated + private final ExtendsFloatsImpl serviceClient; + + /** + * Initializes an instance of ExtendsFloatAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsFloatAsyncClient(ExtendsFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ExtendsFloatAdditionalProperties.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsFloatAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsFloatClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsFloatClient.java new file mode 100644 index 000000000..2344a7bcc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsFloatClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.ExtendsFloatsImpl; +import com.type.property.additionalproperties.models.ExtendsFloatAdditionalProperties; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsFloatClient { + @Generated + private final ExtendsFloatsImpl serviceClient; + + /** + * Initializes an instance of ExtendsFloatClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsFloatClient(ExtendsFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExtendsFloatAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(ExtendsFloatAdditionalProperties.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsFloatAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsModelArrayAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsModelArrayAsyncClient.java new file mode 100644 index 000000000..aee6c3bdf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsModelArrayAsyncClient.java @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.ExtendsModelArraysImpl; +import com.type.property.additionalproperties.models.ExtendsModelArrayAdditionalProperties; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class ExtendsModelArrayAsyncClient { + @Generated + private final ExtendsModelArraysImpl serviceClient; + + /** + * Initializes an instance of ExtendsModelArrayAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsModelArrayAsyncClient(ExtendsModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ExtendsModelArrayAdditionalProperties.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsModelArrayAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsModelArrayClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsModelArrayClient.java new file mode 100644 index 000000000..112640784 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsModelArrayClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.ExtendsModelArraysImpl; +import com.type.property.additionalproperties.models.ExtendsModelArrayAdditionalProperties; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsModelArrayClient { + @Generated + private final ExtendsModelArraysImpl serviceClient; + + /** + * Initializes an instance of ExtendsModelArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsModelArrayClient(ExtendsModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExtendsModelArrayAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(ExtendsModelArrayAdditionalProperties.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsModelArrayAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsModelAsyncClient.java new file mode 100644 index 000000000..3e2c8a262 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsModelAsyncClient.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.ExtendsModelsImpl; +import com.type.property.additionalproperties.models.ExtendsModelAdditionalProperties; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class ExtendsModelAsyncClient { + @Generated + private final ExtendsModelsImpl serviceClient; + + /** + * Initializes an instance of ExtendsModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsModelAsyncClient(ExtendsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ExtendsModelAdditionalProperties.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsModelAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsModelClient.java new file mode 100644 index 000000000..350b125c5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsModelClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.ExtendsModelsImpl; +import com.type.property.additionalproperties.models.ExtendsModelAdditionalProperties; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsModelClient { + @Generated + private final ExtendsModelsImpl serviceClient; + + /** + * Initializes an instance of ExtendsModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsModelClient(ExtendsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExtendsModelAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(ExtendsModelAdditionalProperties.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsModelAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsStringAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsStringAsyncClient.java new file mode 100644 index 000000000..631556ec3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsStringAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.ExtendsStringsImpl; +import com.type.property.additionalproperties.models.ExtendsStringAdditionalProperties; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class ExtendsStringAsyncClient { + @Generated + private final ExtendsStringsImpl serviceClient; + + /** + * Initializes an instance of ExtendsStringAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsStringAsyncClient(ExtendsStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ExtendsStringAdditionalProperties.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsStringAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsStringClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsStringClient.java new file mode 100644 index 000000000..18ef0b0b9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsStringClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.ExtendsStringsImpl; +import com.type.property.additionalproperties.models.ExtendsStringAdditionalProperties; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsStringClient { + @Generated + private final ExtendsStringsImpl serviceClient; + + /** + * Initializes an instance of ExtendsStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsStringClient(ExtendsStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExtendsStringAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(ExtendsStringAdditionalProperties.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsStringAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownAsyncClient.java new file mode 100644 index 000000000..a3971293d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.ExtendsUnknownsImpl; +import com.type.property.additionalproperties.models.ExtendsUnknownAdditionalProperties; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class ExtendsUnknownAsyncClient { + @Generated + private final ExtendsUnknownsImpl serviceClient; + + /** + * Initializes an instance of ExtendsUnknownAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsUnknownAsyncClient(ExtendsUnknownsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ExtendsUnknownAdditionalProperties.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsUnknownAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownClient.java new file mode 100644 index 000000000..d1223a971 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.ExtendsUnknownsImpl; +import com.type.property.additionalproperties.models.ExtendsUnknownAdditionalProperties; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsUnknownClient { + @Generated + private final ExtendsUnknownsImpl serviceClient; + + /** + * Initializes an instance of ExtendsUnknownClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsUnknownClient(ExtendsUnknownsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExtendsUnknownAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(ExtendsUnknownAdditionalProperties.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsUnknownAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownDerivedAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownDerivedAsyncClient.java new file mode 100644 index 000000000..47555089a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownDerivedAsyncClient.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.ExtendsUnknownDerivedsImpl; +import com.type.property.additionalproperties.models.ExtendsUnknownAdditionalPropertiesDerived; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class ExtendsUnknownDerivedAsyncClient { + @Generated + private final ExtendsUnknownDerivedsImpl serviceClient; + + /** + * Initializes an instance of ExtendsUnknownDerivedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsUnknownDerivedAsyncClient(ExtendsUnknownDerivedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ExtendsUnknownAdditionalPropertiesDerived.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsUnknownAdditionalPropertiesDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownDerivedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownDerivedClient.java new file mode 100644 index 000000000..a711f89a9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownDerivedClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.ExtendsUnknownDerivedsImpl; +import com.type.property.additionalproperties.models.ExtendsUnknownAdditionalPropertiesDerived; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsUnknownDerivedClient { + @Generated + private final ExtendsUnknownDerivedsImpl serviceClient; + + /** + * Initializes an instance of ExtendsUnknownDerivedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsUnknownDerivedClient(ExtendsUnknownDerivedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExtendsUnknownAdditionalPropertiesDerived get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(ExtendsUnknownAdditionalPropertiesDerived.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsUnknownAdditionalPropertiesDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownDiscriminatedAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownDiscriminatedAsyncClient.java new file mode 100644 index 000000000..2996ebdb5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownDiscriminatedAsyncClient.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.ExtendsUnknownDiscriminatedsImpl; +import com.type.property.additionalproperties.models.ExtendsUnknownAdditionalPropertiesDiscriminated; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class ExtendsUnknownDiscriminatedAsyncClient { + @Generated + private final ExtendsUnknownDiscriminatedsImpl serviceClient; + + /** + * Initializes an instance of ExtendsUnknownDiscriminatedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsUnknownDiscriminatedAsyncClient(ExtendsUnknownDiscriminatedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData + .toObject(ExtendsUnknownAdditionalPropertiesDiscriminated.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsUnknownAdditionalPropertiesDiscriminated body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownDiscriminatedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownDiscriminatedClient.java new file mode 100644 index 000000000..8c6553325 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/ExtendsUnknownDiscriminatedClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.ExtendsUnknownDiscriminatedsImpl; +import com.type.property.additionalproperties.models.ExtendsUnknownAdditionalPropertiesDiscriminated; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsUnknownDiscriminatedClient { + @Generated + private final ExtendsUnknownDiscriminatedsImpl serviceClient; + + /** + * Initializes an instance of ExtendsUnknownDiscriminatedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtendsUnknownDiscriminatedClient(ExtendsUnknownDiscriminatedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExtendsUnknownAdditionalPropertiesDiscriminated get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue() + .toObject(ExtendsUnknownAdditionalPropertiesDiscriminated.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtendsUnknownAdditionalPropertiesDiscriminated body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsFloatAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsFloatAsyncClient.java new file mode 100644 index 000000000..f0b5bec86 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsFloatAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.IsFloatsImpl; +import com.type.property.additionalproperties.models.IsFloatAdditionalProperties; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class IsFloatAsyncClient { + @Generated + private final IsFloatsImpl serviceClient; + + /** + * Initializes an instance of IsFloatAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsFloatAsyncClient(IsFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(IsFloatAdditionalProperties.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsFloatAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsFloatClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsFloatClient.java new file mode 100644 index 000000000..59f59264a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsFloatClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.IsFloatsImpl; +import com.type.property.additionalproperties.models.IsFloatAdditionalProperties; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsFloatClient { + @Generated + private final IsFloatsImpl serviceClient; + + /** + * Initializes an instance of IsFloatClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsFloatClient(IsFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public IsFloatAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(IsFloatAdditionalProperties.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsFloatAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsModelArrayAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsModelArrayAsyncClient.java new file mode 100644 index 000000000..dc5b7a138 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsModelArrayAsyncClient.java @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.IsModelArraysImpl; +import com.type.property.additionalproperties.models.IsModelArrayAdditionalProperties; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class IsModelArrayAsyncClient { + @Generated + private final IsModelArraysImpl serviceClient; + + /** + * Initializes an instance of IsModelArrayAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsModelArrayAsyncClient(IsModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(IsModelArrayAdditionalProperties.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsModelArrayAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsModelArrayClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsModelArrayClient.java new file mode 100644 index 000000000..ed99323be --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsModelArrayClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.IsModelArraysImpl; +import com.type.property.additionalproperties.models.IsModelArrayAdditionalProperties; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsModelArrayClient { + @Generated + private final IsModelArraysImpl serviceClient; + + /** + * Initializes an instance of IsModelArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsModelArrayClient(IsModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public IsModelArrayAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(IsModelArrayAdditionalProperties.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsModelArrayAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsModelAsyncClient.java new file mode 100644 index 000000000..245ff4088 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsModelAsyncClient.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.IsModelsImpl; +import com.type.property.additionalproperties.models.IsModelAdditionalProperties; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class IsModelAsyncClient { + @Generated + private final IsModelsImpl serviceClient; + + /** + * Initializes an instance of IsModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsModelAsyncClient(IsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(IsModelAdditionalProperties.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsModelAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsModelClient.java new file mode 100644 index 000000000..cb9bb36ef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsModelClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.IsModelsImpl; +import com.type.property.additionalproperties.models.IsModelAdditionalProperties; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsModelClient { + @Generated + private final IsModelsImpl serviceClient; + + /** + * Initializes an instance of IsModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsModelClient(IsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public IsModelAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(IsModelAdditionalProperties.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsModelAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsStringAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsStringAsyncClient.java new file mode 100644 index 000000000..4388e9f9a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsStringAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.IsStringsImpl; +import com.type.property.additionalproperties.models.IsStringAdditionalProperties; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class IsStringAsyncClient { + @Generated + private final IsStringsImpl serviceClient; + + /** + * Initializes an instance of IsStringAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsStringAsyncClient(IsStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(IsStringAdditionalProperties.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsStringAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsStringClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsStringClient.java new file mode 100644 index 000000000..54f77899d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsStringClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.IsStringsImpl; +import com.type.property.additionalproperties.models.IsStringAdditionalProperties; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsStringClient { + @Generated + private final IsStringsImpl serviceClient; + + /** + * Initializes an instance of IsStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsStringClient(IsStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public IsStringAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(IsStringAdditionalProperties.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsStringAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownAsyncClient.java new file mode 100644 index 000000000..56fb6113f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.IsUnknownsImpl; +import com.type.property.additionalproperties.models.IsUnknownAdditionalProperties; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class IsUnknownAsyncClient { + @Generated + private final IsUnknownsImpl serviceClient; + + /** + * Initializes an instance of IsUnknownAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsUnknownAsyncClient(IsUnknownsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(IsUnknownAdditionalProperties.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsUnknownAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownClient.java new file mode 100644 index 000000000..e5fde6da3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.IsUnknownsImpl; +import com.type.property.additionalproperties.models.IsUnknownAdditionalProperties; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsUnknownClient { + @Generated + private final IsUnknownsImpl serviceClient; + + /** + * Initializes an instance of IsUnknownClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsUnknownClient(IsUnknownsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public IsUnknownAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(IsUnknownAdditionalProperties.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsUnknownAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownDerivedAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownDerivedAsyncClient.java new file mode 100644 index 000000000..6527d2fd2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownDerivedAsyncClient.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.IsUnknownDerivedsImpl; +import com.type.property.additionalproperties.models.IsUnknownAdditionalPropertiesDerived; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class IsUnknownDerivedAsyncClient { + @Generated + private final IsUnknownDerivedsImpl serviceClient; + + /** + * Initializes an instance of IsUnknownDerivedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsUnknownDerivedAsyncClient(IsUnknownDerivedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(IsUnknownAdditionalPropertiesDerived.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsUnknownAdditionalPropertiesDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownDerivedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownDerivedClient.java new file mode 100644 index 000000000..ff945769c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownDerivedClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.IsUnknownDerivedsImpl; +import com.type.property.additionalproperties.models.IsUnknownAdditionalPropertiesDerived; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsUnknownDerivedClient { + @Generated + private final IsUnknownDerivedsImpl serviceClient; + + /** + * Initializes an instance of IsUnknownDerivedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsUnknownDerivedClient(IsUnknownDerivedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public IsUnknownAdditionalPropertiesDerived get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(IsUnknownAdditionalPropertiesDerived.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsUnknownAdditionalPropertiesDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownDiscriminatedAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownDiscriminatedAsyncClient.java new file mode 100644 index 000000000..33cd143e8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownDiscriminatedAsyncClient.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.IsUnknownDiscriminatedsImpl; +import com.type.property.additionalproperties.models.IsUnknownAdditionalPropertiesDiscriminated; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class IsUnknownDiscriminatedAsyncClient { + @Generated + private final IsUnknownDiscriminatedsImpl serviceClient; + + /** + * Initializes an instance of IsUnknownDiscriminatedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsUnknownDiscriminatedAsyncClient(IsUnknownDiscriminatedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(IsUnknownAdditionalPropertiesDiscriminated.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsUnknownAdditionalPropertiesDiscriminated body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownDiscriminatedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownDiscriminatedClient.java new file mode 100644 index 000000000..8d336689c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/IsUnknownDiscriminatedClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.IsUnknownDiscriminatedsImpl; +import com.type.property.additionalproperties.models.IsUnknownAdditionalPropertiesDiscriminated; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsUnknownDiscriminatedClient { + @Generated + private final IsUnknownDiscriminatedsImpl serviceClient; + + /** + * Initializes an instance of IsUnknownDiscriminatedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IsUnknownDiscriminatedClient(IsUnknownDiscriminatedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public IsUnknownAdditionalPropertiesDiscriminated get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(IsUnknownAdditionalPropertiesDiscriminated.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IsUnknownAdditionalPropertiesDiscriminated body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/MultipleSpreadAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/MultipleSpreadAsyncClient.java new file mode 100644 index 000000000..4a7f13d10 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/MultipleSpreadAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.MultipleSpreadsImpl; +import com.type.property.additionalproperties.models.MultipleSpreadRecord; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class MultipleSpreadAsyncClient { + @Generated + private final MultipleSpreadsImpl serviceClient; + + /** + * Initializes an instance of MultipleSpreadAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MultipleSpreadAsyncClient(MultipleSpreadsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(MultipleSpreadRecord.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(MultipleSpreadRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/MultipleSpreadClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/MultipleSpreadClient.java new file mode 100644 index 000000000..695adb7ab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/MultipleSpreadClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.MultipleSpreadsImpl; +import com.type.property.additionalproperties.models.MultipleSpreadRecord; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class MultipleSpreadClient { + @Generated + private final MultipleSpreadsImpl serviceClient; + + /** + * Initializes an instance of MultipleSpreadClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MultipleSpreadClient(MultipleSpreadsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public MultipleSpreadRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(MultipleSpreadRecord.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(MultipleSpreadRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentFloatAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentFloatAsyncClient.java new file mode 100644 index 000000000..52c264e60 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentFloatAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadDifferentFloatsImpl; +import com.type.property.additionalproperties.models.DifferentSpreadFloatRecord; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadDifferentFloatAsyncClient { + @Generated + private final SpreadDifferentFloatsImpl serviceClient; + + /** + * Initializes an instance of SpreadDifferentFloatAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadDifferentFloatAsyncClient(SpreadDifferentFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DifferentSpreadFloatRecord.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadFloatRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentFloatClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentFloatClient.java new file mode 100644 index 000000000..cf800c43f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentFloatClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadDifferentFloatsImpl; +import com.type.property.additionalproperties.models.DifferentSpreadFloatRecord; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadDifferentFloatClient { + @Generated + private final SpreadDifferentFloatsImpl serviceClient; + + /** + * Initializes an instance of SpreadDifferentFloatClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadDifferentFloatClient(SpreadDifferentFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DifferentSpreadFloatRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(DifferentSpreadFloatRecord.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadFloatRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentModelArrayAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentModelArrayAsyncClient.java new file mode 100644 index 000000000..90fbf5a45 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentModelArrayAsyncClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadDifferentModelArraysImpl; +import com.type.property.additionalproperties.models.DifferentSpreadModelArrayRecord; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadDifferentModelArrayAsyncClient { + @Generated + private final SpreadDifferentModelArraysImpl serviceClient; + + /** + * Initializes an instance of SpreadDifferentModelArrayAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadDifferentModelArrayAsyncClient(SpreadDifferentModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DifferentSpreadModelArrayRecord.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadModelArrayRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentModelArrayClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentModelArrayClient.java new file mode 100644 index 000000000..75c931ef4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentModelArrayClient.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadDifferentModelArraysImpl; +import com.type.property.additionalproperties.models.DifferentSpreadModelArrayRecord; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadDifferentModelArrayClient { + @Generated + private final SpreadDifferentModelArraysImpl serviceClient; + + /** + * Initializes an instance of SpreadDifferentModelArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadDifferentModelArrayClient(SpreadDifferentModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DifferentSpreadModelArrayRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(DifferentSpreadModelArrayRecord.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadModelArrayRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentModelAsyncClient.java new file mode 100644 index 000000000..dd78d0eaf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentModelAsyncClient.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadDifferentModelsImpl; +import com.type.property.additionalproperties.models.DifferentSpreadModelRecord; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadDifferentModelAsyncClient { + @Generated + private final SpreadDifferentModelsImpl serviceClient; + + /** + * Initializes an instance of SpreadDifferentModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadDifferentModelAsyncClient(SpreadDifferentModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DifferentSpreadModelRecord.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadModelRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentModelClient.java new file mode 100644 index 000000000..2de9b57e6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentModelClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadDifferentModelsImpl; +import com.type.property.additionalproperties.models.DifferentSpreadModelRecord; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadDifferentModelClient { + @Generated + private final SpreadDifferentModelsImpl serviceClient; + + /** + * Initializes an instance of SpreadDifferentModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadDifferentModelClient(SpreadDifferentModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DifferentSpreadModelRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(DifferentSpreadModelRecord.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadModelRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentStringAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentStringAsyncClient.java new file mode 100644 index 000000000..9a5b40423 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentStringAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadDifferentStringsImpl; +import com.type.property.additionalproperties.models.DifferentSpreadStringRecord; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadDifferentStringAsyncClient { + @Generated + private final SpreadDifferentStringsImpl serviceClient; + + /** + * Initializes an instance of SpreadDifferentStringAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadDifferentStringAsyncClient(SpreadDifferentStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DifferentSpreadStringRecord.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadStringRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentStringClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentStringClient.java new file mode 100644 index 000000000..c052f4d6b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadDifferentStringClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadDifferentStringsImpl; +import com.type.property.additionalproperties.models.DifferentSpreadStringRecord; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadDifferentStringClient { + @Generated + private final SpreadDifferentStringsImpl serviceClient; + + /** + * Initializes an instance of SpreadDifferentStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadDifferentStringClient(SpreadDifferentStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DifferentSpreadStringRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(DifferentSpreadStringRecord.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DifferentSpreadStringRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadFloatAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadFloatAsyncClient.java new file mode 100644 index 000000000..4491b1cea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadFloatAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadFloatsImpl; +import com.type.property.additionalproperties.models.SpreadFloatRecord; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadFloatAsyncClient { + @Generated + private final SpreadFloatsImpl serviceClient; + + /** + * Initializes an instance of SpreadFloatAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadFloatAsyncClient(SpreadFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SpreadFloatRecord.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadFloatRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadFloatClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadFloatClient.java new file mode 100644 index 000000000..844165116 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadFloatClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadFloatsImpl; +import com.type.property.additionalproperties.models.SpreadFloatRecord; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadFloatClient { + @Generated + private final SpreadFloatsImpl serviceClient; + + /** + * Initializes an instance of SpreadFloatClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadFloatClient(SpreadFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SpreadFloatRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(SpreadFloatRecord.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadFloatRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadModelArrayAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadModelArrayAsyncClient.java new file mode 100644 index 000000000..bfb87faa8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadModelArrayAsyncClient.java @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadModelArraysImpl; +import com.type.property.additionalproperties.models.SpreadModelArrayRecord; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadModelArrayAsyncClient { + @Generated + private final SpreadModelArraysImpl serviceClient; + + /** + * Initializes an instance of SpreadModelArrayAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadModelArrayAsyncClient(SpreadModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SpreadModelArrayRecord.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadModelArrayRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadModelArrayClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadModelArrayClient.java new file mode 100644 index 000000000..d869e8b9d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadModelArrayClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadModelArraysImpl; +import com.type.property.additionalproperties.models.SpreadModelArrayRecord; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadModelArrayClient { + @Generated + private final SpreadModelArraysImpl serviceClient; + + /** + * Initializes an instance of SpreadModelArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadModelArrayClient(SpreadModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SpreadModelArrayRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(SpreadModelArrayRecord.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadModelArrayRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadModelAsyncClient.java new file mode 100644 index 000000000..c1250d5ee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadModelAsyncClient.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadModelsImpl; +import com.type.property.additionalproperties.models.SpreadModelRecord; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadModelAsyncClient { + @Generated + private final SpreadModelsImpl serviceClient; + + /** + * Initializes an instance of SpreadModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadModelAsyncClient(SpreadModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SpreadModelRecord.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadModelRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadModelClient.java new file mode 100644 index 000000000..ed489d434 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadModelClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadModelsImpl; +import com.type.property.additionalproperties.models.SpreadModelRecord; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadModelClient { + @Generated + private final SpreadModelsImpl serviceClient; + + /** + * Initializes an instance of SpreadModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadModelClient(SpreadModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SpreadModelRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(SpreadModelRecord.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadModelRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordDiscriminatedUnionAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordDiscriminatedUnionAsyncClient.java new file mode 100644 index 000000000..7baae2dcb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordDiscriminatedUnionAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadRecordDiscriminatedUnionsImpl; +import com.type.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadRecordDiscriminatedUnionAsyncClient { + @Generated + private final SpreadRecordDiscriminatedUnionsImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordDiscriminatedUnionAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadRecordDiscriminatedUnionAsyncClient(SpreadRecordDiscriminatedUnionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SpreadRecordForDiscriminatedUnion.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadRecordForDiscriminatedUnion body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordDiscriminatedUnionClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordDiscriminatedUnionClient.java new file mode 100644 index 000000000..641f7c849 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordDiscriminatedUnionClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadRecordDiscriminatedUnionsImpl; +import com.type.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadRecordDiscriminatedUnionClient { + @Generated + private final SpreadRecordDiscriminatedUnionsImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordDiscriminatedUnionClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadRecordDiscriminatedUnionClient(SpreadRecordDiscriminatedUnionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SpreadRecordForDiscriminatedUnion get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(SpreadRecordForDiscriminatedUnion.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadRecordForDiscriminatedUnion body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion2AsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion2AsyncClient.java new file mode 100644 index 000000000..25d072990 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion2AsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadRecordNonDiscriminatedUnion2sImpl; +import com.type.property.additionalproperties.models.SpreadRecordForNonDiscriminatedUnion2; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadRecordNonDiscriminatedUnion2AsyncClient { + @Generated + private final SpreadRecordNonDiscriminatedUnion2sImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnion2AsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadRecordNonDiscriminatedUnion2AsyncClient(SpreadRecordNonDiscriminatedUnion2sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SpreadRecordForNonDiscriminatedUnion2.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadRecordForNonDiscriminatedUnion2 body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion2Client.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion2Client.java new file mode 100644 index 000000000..25af9e446 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion2Client.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadRecordNonDiscriminatedUnion2sImpl; +import com.type.property.additionalproperties.models.SpreadRecordForNonDiscriminatedUnion2; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadRecordNonDiscriminatedUnion2Client { + @Generated + private final SpreadRecordNonDiscriminatedUnion2sImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnion2Client class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadRecordNonDiscriminatedUnion2Client(SpreadRecordNonDiscriminatedUnion2sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SpreadRecordForNonDiscriminatedUnion2 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(SpreadRecordForNonDiscriminatedUnion2.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadRecordForNonDiscriminatedUnion2 body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion3AsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion3AsyncClient.java new file mode 100644 index 000000000..067ee6ee4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion3AsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadRecordNonDiscriminatedUnion3sImpl; +import com.type.property.additionalproperties.models.SpreadRecordForNonDiscriminatedUnion3; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadRecordNonDiscriminatedUnion3AsyncClient { + @Generated + private final SpreadRecordNonDiscriminatedUnion3sImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnion3AsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadRecordNonDiscriminatedUnion3AsyncClient(SpreadRecordNonDiscriminatedUnion3sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SpreadRecordForNonDiscriminatedUnion3.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadRecordForNonDiscriminatedUnion3 body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion3Client.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion3Client.java new file mode 100644 index 000000000..d14844fa2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion3Client.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadRecordNonDiscriminatedUnion3sImpl; +import com.type.property.additionalproperties.models.SpreadRecordForNonDiscriminatedUnion3; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadRecordNonDiscriminatedUnion3Client { + @Generated + private final SpreadRecordNonDiscriminatedUnion3sImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnion3Client class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadRecordNonDiscriminatedUnion3Client(SpreadRecordNonDiscriminatedUnion3sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SpreadRecordForNonDiscriminatedUnion3 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(SpreadRecordForNonDiscriminatedUnion3.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadRecordForNonDiscriminatedUnion3 body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnionAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnionAsyncClient.java new file mode 100644 index 000000000..637b3d680 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnionAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadRecordNonDiscriminatedUnionsImpl; +import com.type.property.additionalproperties.models.SpreadRecordForNonDiscriminatedUnion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadRecordNonDiscriminatedUnionAsyncClient { + @Generated + private final SpreadRecordNonDiscriminatedUnionsImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnionAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadRecordNonDiscriminatedUnionAsyncClient(SpreadRecordNonDiscriminatedUnionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SpreadRecordForNonDiscriminatedUnion.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadRecordForNonDiscriminatedUnion body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnionClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnionClient.java new file mode 100644 index 000000000..96fda8ee0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnionClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadRecordNonDiscriminatedUnionsImpl; +import com.type.property.additionalproperties.models.SpreadRecordForNonDiscriminatedUnion; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadRecordNonDiscriminatedUnionClient { + @Generated + private final SpreadRecordNonDiscriminatedUnionsImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnionClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadRecordNonDiscriminatedUnionClient(SpreadRecordNonDiscriminatedUnionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SpreadRecordForNonDiscriminatedUnion get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(SpreadRecordForNonDiscriminatedUnion.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadRecordForNonDiscriminatedUnion body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordUnionAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordUnionAsyncClient.java new file mode 100644 index 000000000..f59998aac --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordUnionAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadRecordUnionsImpl; +import com.type.property.additionalproperties.models.SpreadRecordForUnion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadRecordUnionAsyncClient { + @Generated + private final SpreadRecordUnionsImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordUnionAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadRecordUnionAsyncClient(SpreadRecordUnionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SpreadRecordForUnion.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadRecordForUnion body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordUnionClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordUnionClient.java new file mode 100644 index 000000000..c8eaa17b0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadRecordUnionClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadRecordUnionsImpl; +import com.type.property.additionalproperties.models.SpreadRecordForUnion; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadRecordUnionClient { + @Generated + private final SpreadRecordUnionsImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordUnionClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadRecordUnionClient(SpreadRecordUnionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SpreadRecordForUnion get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(SpreadRecordForUnion.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadRecordForUnion body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadStringAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadStringAsyncClient.java new file mode 100644 index 000000000..51c27dd0e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadStringAsyncClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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 com.type.property.additionalproperties.implementation.SpreadStringsImpl; +import com.type.property.additionalproperties.models.SpreadStringRecord; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class, isAsync = true) +public final class SpreadStringAsyncClient { + @Generated + private final SpreadStringsImpl serviceClient; + + /** + * Initializes an instance of SpreadStringAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadStringAsyncClient(SpreadStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SpreadStringRecord.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadStringRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadStringClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadStringClient.java new file mode 100644 index 000000000..ccd177461 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/SpreadStringClient.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties; + +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.type.property.additionalproperties.implementation.SpreadStringsImpl; +import com.type.property.additionalproperties.models.SpreadStringRecord; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadStringClient { + @Generated + private final SpreadStringsImpl serviceClient; + + /** + * Initializes an instance of SpreadStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SpreadStringClient(SpreadStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SpreadStringRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(SpreadStringRecord.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(SpreadStringRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/AdditionalPropertiesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/AdditionalPropertiesClientImpl.java new file mode 100644 index 000000000..bc91cfeee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/AdditionalPropertiesClientImpl.java @@ -0,0 +1,573 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the AdditionalPropertiesClient type. + */ +public final class AdditionalPropertiesClientImpl { + /** + * 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; + } + + /** + * The ExtendsUnknownsImpl object to access its operations. + */ + private final ExtendsUnknownsImpl extendsUnknowns; + + /** + * Gets the ExtendsUnknownsImpl object to access its operations. + * + * @return the ExtendsUnknownsImpl object. + */ + public ExtendsUnknownsImpl getExtendsUnknowns() { + return this.extendsUnknowns; + } + + /** + * The ExtendsUnknownDerivedsImpl object to access its operations. + */ + private final ExtendsUnknownDerivedsImpl extendsUnknownDeriveds; + + /** + * Gets the ExtendsUnknownDerivedsImpl object to access its operations. + * + * @return the ExtendsUnknownDerivedsImpl object. + */ + public ExtendsUnknownDerivedsImpl getExtendsUnknownDeriveds() { + return this.extendsUnknownDeriveds; + } + + /** + * The ExtendsUnknownDiscriminatedsImpl object to access its operations. + */ + private final ExtendsUnknownDiscriminatedsImpl extendsUnknownDiscriminateds; + + /** + * Gets the ExtendsUnknownDiscriminatedsImpl object to access its operations. + * + * @return the ExtendsUnknownDiscriminatedsImpl object. + */ + public ExtendsUnknownDiscriminatedsImpl getExtendsUnknownDiscriminateds() { + return this.extendsUnknownDiscriminateds; + } + + /** + * The IsUnknownsImpl object to access its operations. + */ + private final IsUnknownsImpl isUnknowns; + + /** + * Gets the IsUnknownsImpl object to access its operations. + * + * @return the IsUnknownsImpl object. + */ + public IsUnknownsImpl getIsUnknowns() { + return this.isUnknowns; + } + + /** + * The IsUnknownDerivedsImpl object to access its operations. + */ + private final IsUnknownDerivedsImpl isUnknownDeriveds; + + /** + * Gets the IsUnknownDerivedsImpl object to access its operations. + * + * @return the IsUnknownDerivedsImpl object. + */ + public IsUnknownDerivedsImpl getIsUnknownDeriveds() { + return this.isUnknownDeriveds; + } + + /** + * The IsUnknownDiscriminatedsImpl object to access its operations. + */ + private final IsUnknownDiscriminatedsImpl isUnknownDiscriminateds; + + /** + * Gets the IsUnknownDiscriminatedsImpl object to access its operations. + * + * @return the IsUnknownDiscriminatedsImpl object. + */ + public IsUnknownDiscriminatedsImpl getIsUnknownDiscriminateds() { + return this.isUnknownDiscriminateds; + } + + /** + * The ExtendsStringsImpl object to access its operations. + */ + private final ExtendsStringsImpl extendsStrings; + + /** + * Gets the ExtendsStringsImpl object to access its operations. + * + * @return the ExtendsStringsImpl object. + */ + public ExtendsStringsImpl getExtendsStrings() { + return this.extendsStrings; + } + + /** + * The IsStringsImpl object to access its operations. + */ + private final IsStringsImpl isStrings; + + /** + * Gets the IsStringsImpl object to access its operations. + * + * @return the IsStringsImpl object. + */ + public IsStringsImpl getIsStrings() { + return this.isStrings; + } + + /** + * The SpreadStringsImpl object to access its operations. + */ + private final SpreadStringsImpl spreadStrings; + + /** + * Gets the SpreadStringsImpl object to access its operations. + * + * @return the SpreadStringsImpl object. + */ + public SpreadStringsImpl getSpreadStrings() { + return this.spreadStrings; + } + + /** + * The ExtendsFloatsImpl object to access its operations. + */ + private final ExtendsFloatsImpl extendsFloats; + + /** + * Gets the ExtendsFloatsImpl object to access its operations. + * + * @return the ExtendsFloatsImpl object. + */ + public ExtendsFloatsImpl getExtendsFloats() { + return this.extendsFloats; + } + + /** + * The IsFloatsImpl object to access its operations. + */ + private final IsFloatsImpl isFloats; + + /** + * Gets the IsFloatsImpl object to access its operations. + * + * @return the IsFloatsImpl object. + */ + public IsFloatsImpl getIsFloats() { + return this.isFloats; + } + + /** + * The SpreadFloatsImpl object to access its operations. + */ + private final SpreadFloatsImpl spreadFloats; + + /** + * Gets the SpreadFloatsImpl object to access its operations. + * + * @return the SpreadFloatsImpl object. + */ + public SpreadFloatsImpl getSpreadFloats() { + return this.spreadFloats; + } + + /** + * The ExtendsModelsImpl object to access its operations. + */ + private final ExtendsModelsImpl extendsModels; + + /** + * Gets the ExtendsModelsImpl object to access its operations. + * + * @return the ExtendsModelsImpl object. + */ + public ExtendsModelsImpl getExtendsModels() { + return this.extendsModels; + } + + /** + * The IsModelsImpl object to access its operations. + */ + private final IsModelsImpl isModels; + + /** + * Gets the IsModelsImpl object to access its operations. + * + * @return the IsModelsImpl object. + */ + public IsModelsImpl getIsModels() { + return this.isModels; + } + + /** + * The SpreadModelsImpl object to access its operations. + */ + private final SpreadModelsImpl spreadModels; + + /** + * Gets the SpreadModelsImpl object to access its operations. + * + * @return the SpreadModelsImpl object. + */ + public SpreadModelsImpl getSpreadModels() { + return this.spreadModels; + } + + /** + * The ExtendsModelArraysImpl object to access its operations. + */ + private final ExtendsModelArraysImpl extendsModelArrays; + + /** + * Gets the ExtendsModelArraysImpl object to access its operations. + * + * @return the ExtendsModelArraysImpl object. + */ + public ExtendsModelArraysImpl getExtendsModelArrays() { + return this.extendsModelArrays; + } + + /** + * The IsModelArraysImpl object to access its operations. + */ + private final IsModelArraysImpl isModelArrays; + + /** + * Gets the IsModelArraysImpl object to access its operations. + * + * @return the IsModelArraysImpl object. + */ + public IsModelArraysImpl getIsModelArrays() { + return this.isModelArrays; + } + + /** + * The SpreadModelArraysImpl object to access its operations. + */ + private final SpreadModelArraysImpl spreadModelArrays; + + /** + * Gets the SpreadModelArraysImpl object to access its operations. + * + * @return the SpreadModelArraysImpl object. + */ + public SpreadModelArraysImpl getSpreadModelArrays() { + return this.spreadModelArrays; + } + + /** + * The SpreadDifferentStringsImpl object to access its operations. + */ + private final SpreadDifferentStringsImpl spreadDifferentStrings; + + /** + * Gets the SpreadDifferentStringsImpl object to access its operations. + * + * @return the SpreadDifferentStringsImpl object. + */ + public SpreadDifferentStringsImpl getSpreadDifferentStrings() { + return this.spreadDifferentStrings; + } + + /** + * The SpreadDifferentFloatsImpl object to access its operations. + */ + private final SpreadDifferentFloatsImpl spreadDifferentFloats; + + /** + * Gets the SpreadDifferentFloatsImpl object to access its operations. + * + * @return the SpreadDifferentFloatsImpl object. + */ + public SpreadDifferentFloatsImpl getSpreadDifferentFloats() { + return this.spreadDifferentFloats; + } + + /** + * The SpreadDifferentModelsImpl object to access its operations. + */ + private final SpreadDifferentModelsImpl spreadDifferentModels; + + /** + * Gets the SpreadDifferentModelsImpl object to access its operations. + * + * @return the SpreadDifferentModelsImpl object. + */ + public SpreadDifferentModelsImpl getSpreadDifferentModels() { + return this.spreadDifferentModels; + } + + /** + * The SpreadDifferentModelArraysImpl object to access its operations. + */ + private final SpreadDifferentModelArraysImpl spreadDifferentModelArrays; + + /** + * Gets the SpreadDifferentModelArraysImpl object to access its operations. + * + * @return the SpreadDifferentModelArraysImpl object. + */ + public SpreadDifferentModelArraysImpl getSpreadDifferentModelArrays() { + return this.spreadDifferentModelArrays; + } + + /** + * The ExtendsDifferentSpreadStringsImpl object to access its operations. + */ + private final ExtendsDifferentSpreadStringsImpl extendsDifferentSpreadStrings; + + /** + * Gets the ExtendsDifferentSpreadStringsImpl object to access its operations. + * + * @return the ExtendsDifferentSpreadStringsImpl object. + */ + public ExtendsDifferentSpreadStringsImpl getExtendsDifferentSpreadStrings() { + return this.extendsDifferentSpreadStrings; + } + + /** + * The ExtendsDifferentSpreadFloatsImpl object to access its operations. + */ + private final ExtendsDifferentSpreadFloatsImpl extendsDifferentSpreadFloats; + + /** + * Gets the ExtendsDifferentSpreadFloatsImpl object to access its operations. + * + * @return the ExtendsDifferentSpreadFloatsImpl object. + */ + public ExtendsDifferentSpreadFloatsImpl getExtendsDifferentSpreadFloats() { + return this.extendsDifferentSpreadFloats; + } + + /** + * The ExtendsDifferentSpreadModelsImpl object to access its operations. + */ + private final ExtendsDifferentSpreadModelsImpl extendsDifferentSpreadModels; + + /** + * Gets the ExtendsDifferentSpreadModelsImpl object to access its operations. + * + * @return the ExtendsDifferentSpreadModelsImpl object. + */ + public ExtendsDifferentSpreadModelsImpl getExtendsDifferentSpreadModels() { + return this.extendsDifferentSpreadModels; + } + + /** + * The ExtendsDifferentSpreadModelArraysImpl object to access its operations. + */ + private final ExtendsDifferentSpreadModelArraysImpl extendsDifferentSpreadModelArrays; + + /** + * Gets the ExtendsDifferentSpreadModelArraysImpl object to access its operations. + * + * @return the ExtendsDifferentSpreadModelArraysImpl object. + */ + public ExtendsDifferentSpreadModelArraysImpl getExtendsDifferentSpreadModelArrays() { + return this.extendsDifferentSpreadModelArrays; + } + + /** + * The MultipleSpreadsImpl object to access its operations. + */ + private final MultipleSpreadsImpl multipleSpreads; + + /** + * Gets the MultipleSpreadsImpl object to access its operations. + * + * @return the MultipleSpreadsImpl object. + */ + public MultipleSpreadsImpl getMultipleSpreads() { + return this.multipleSpreads; + } + + /** + * The SpreadRecordUnionsImpl object to access its operations. + */ + private final SpreadRecordUnionsImpl spreadRecordUnions; + + /** + * Gets the SpreadRecordUnionsImpl object to access its operations. + * + * @return the SpreadRecordUnionsImpl object. + */ + public SpreadRecordUnionsImpl getSpreadRecordUnions() { + return this.spreadRecordUnions; + } + + /** + * The SpreadRecordDiscriminatedUnionsImpl object to access its operations. + */ + private final SpreadRecordDiscriminatedUnionsImpl spreadRecordDiscriminatedUnions; + + /** + * Gets the SpreadRecordDiscriminatedUnionsImpl object to access its operations. + * + * @return the SpreadRecordDiscriminatedUnionsImpl object. + */ + public SpreadRecordDiscriminatedUnionsImpl getSpreadRecordDiscriminatedUnions() { + return this.spreadRecordDiscriminatedUnions; + } + + /** + * The SpreadRecordNonDiscriminatedUnionsImpl object to access its operations. + */ + private final SpreadRecordNonDiscriminatedUnionsImpl spreadRecordNonDiscriminatedUnions; + + /** + * Gets the SpreadRecordNonDiscriminatedUnionsImpl object to access its operations. + * + * @return the SpreadRecordNonDiscriminatedUnionsImpl object. + */ + public SpreadRecordNonDiscriminatedUnionsImpl getSpreadRecordNonDiscriminatedUnions() { + return this.spreadRecordNonDiscriminatedUnions; + } + + /** + * The SpreadRecordNonDiscriminatedUnion2sImpl object to access its operations. + */ + private final SpreadRecordNonDiscriminatedUnion2sImpl spreadRecordNonDiscriminatedUnion2s; + + /** + * Gets the SpreadRecordNonDiscriminatedUnion2sImpl object to access its operations. + * + * @return the SpreadRecordNonDiscriminatedUnion2sImpl object. + */ + public SpreadRecordNonDiscriminatedUnion2sImpl getSpreadRecordNonDiscriminatedUnion2s() { + return this.spreadRecordNonDiscriminatedUnion2s; + } + + /** + * The SpreadRecordNonDiscriminatedUnion3sImpl object to access its operations. + */ + private final SpreadRecordNonDiscriminatedUnion3sImpl spreadRecordNonDiscriminatedUnion3s; + + /** + * Gets the SpreadRecordNonDiscriminatedUnion3sImpl object to access its operations. + * + * @return the SpreadRecordNonDiscriminatedUnion3sImpl object. + */ + public SpreadRecordNonDiscriminatedUnion3sImpl getSpreadRecordNonDiscriminatedUnion3s() { + return this.spreadRecordNonDiscriminatedUnion3s; + } + + /** + * Initializes an instance of AdditionalPropertiesClient client. + * + * @param endpoint Service host. + */ + public AdditionalPropertiesClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of AdditionalPropertiesClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public AdditionalPropertiesClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of AdditionalPropertiesClient 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 AdditionalPropertiesClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.extendsUnknowns = new ExtendsUnknownsImpl(this); + this.extendsUnknownDeriveds = new ExtendsUnknownDerivedsImpl(this); + this.extendsUnknownDiscriminateds = new ExtendsUnknownDiscriminatedsImpl(this); + this.isUnknowns = new IsUnknownsImpl(this); + this.isUnknownDeriveds = new IsUnknownDerivedsImpl(this); + this.isUnknownDiscriminateds = new IsUnknownDiscriminatedsImpl(this); + this.extendsStrings = new ExtendsStringsImpl(this); + this.isStrings = new IsStringsImpl(this); + this.spreadStrings = new SpreadStringsImpl(this); + this.extendsFloats = new ExtendsFloatsImpl(this); + this.isFloats = new IsFloatsImpl(this); + this.spreadFloats = new SpreadFloatsImpl(this); + this.extendsModels = new ExtendsModelsImpl(this); + this.isModels = new IsModelsImpl(this); + this.spreadModels = new SpreadModelsImpl(this); + this.extendsModelArrays = new ExtendsModelArraysImpl(this); + this.isModelArrays = new IsModelArraysImpl(this); + this.spreadModelArrays = new SpreadModelArraysImpl(this); + this.spreadDifferentStrings = new SpreadDifferentStringsImpl(this); + this.spreadDifferentFloats = new SpreadDifferentFloatsImpl(this); + this.spreadDifferentModels = new SpreadDifferentModelsImpl(this); + this.spreadDifferentModelArrays = new SpreadDifferentModelArraysImpl(this); + this.extendsDifferentSpreadStrings = new ExtendsDifferentSpreadStringsImpl(this); + this.extendsDifferentSpreadFloats = new ExtendsDifferentSpreadFloatsImpl(this); + this.extendsDifferentSpreadModels = new ExtendsDifferentSpreadModelsImpl(this); + this.extendsDifferentSpreadModelArrays = new ExtendsDifferentSpreadModelArraysImpl(this); + this.multipleSpreads = new MultipleSpreadsImpl(this); + this.spreadRecordUnions = new SpreadRecordUnionsImpl(this); + this.spreadRecordDiscriminatedUnions = new SpreadRecordDiscriminatedUnionsImpl(this); + this.spreadRecordNonDiscriminatedUnions = new SpreadRecordNonDiscriminatedUnionsImpl(this); + this.spreadRecordNonDiscriminatedUnion2s = new SpreadRecordNonDiscriminatedUnion2sImpl(this); + this.spreadRecordNonDiscriminatedUnion3s = new SpreadRecordNonDiscriminatedUnion3sImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadFloatsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadFloatsImpl.java new file mode 100644 index 000000000..d62be5217 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadFloatsImpl.java @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ExtendsDifferentSpreadFloats. + */ +public final class ExtendsDifferentSpreadFloatsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsDifferentSpreadFloatsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsDifferentSpreadFloatsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsDifferentSpreadFloatsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsDifferentSpreadFloatsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsDifferentSpreadFloats to be used by + * the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface ExtendsDifferentSpreadFloatsService { + @Get("/type/property/additionalProperties/extendsDifferentSpreadFloat") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/extendsDifferentSpreadFloat") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsDifferentSpreadFloat") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsDifferentSpreadFloat") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     *     derivedProp: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     *     derivedProp: double (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     *     derivedProp: double (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     *     derivedProp: double (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelArraysImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelArraysImpl.java new file mode 100644 index 000000000..8c75fb14c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelArraysImpl.java @@ -0,0 +1,234 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ExtendsDifferentSpreadModelArrays. + */ +public final class ExtendsDifferentSpreadModelArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsDifferentSpreadModelArraysService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsDifferentSpreadModelArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsDifferentSpreadModelArraysImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsDifferentSpreadModelArraysService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsDifferentSpreadModelArrays to be + * used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface ExtendsDifferentSpreadModelArraysService { + @Get("/type/property/additionalProperties/extendsDifferentSpreadModelArray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/extendsDifferentSpreadModelArray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsDifferentSpreadModelArray") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsDifferentSpreadModelArray") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     *     derivedProp (Required): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     *     derivedProp (Required): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     *     derivedProp (Required): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     *     derivedProp (Required): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelsImpl.java new file mode 100644 index 000000000..8e55e04e6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelsImpl.java @@ -0,0 +1,218 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ExtendsDifferentSpreadModels. + */ +public final class ExtendsDifferentSpreadModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsDifferentSpreadModelsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsDifferentSpreadModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsDifferentSpreadModelsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsDifferentSpreadModelsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsDifferentSpreadModels to be used by + * the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface ExtendsDifferentSpreadModelsService { + @Get("/type/property/additionalProperties/extendsDifferentSpreadModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/extendsDifferentSpreadModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsDifferentSpreadModel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsDifferentSpreadModel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     *     derivedProp (Required): (recursive schema, see derivedProp above)
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     *     derivedProp (Required): (recursive schema, see derivedProp above)
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     *     derivedProp (Required): (recursive schema, see derivedProp above)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     *     derivedProp (Required): (recursive schema, see derivedProp above)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadStringsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadStringsImpl.java new file mode 100644 index 000000000..bfd2dd11f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsDifferentSpreadStringsImpl.java @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ExtendsDifferentSpreadStrings. + */ +public final class ExtendsDifferentSpreadStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsDifferentSpreadStringsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsDifferentSpreadStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsDifferentSpreadStringsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsDifferentSpreadStringsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsDifferentSpreadStrings to be used by + * the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface ExtendsDifferentSpreadStringsService { + @Get("/type/property/additionalProperties/extendsDifferentSpreadString") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/extendsDifferentSpreadString") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsDifferentSpreadString") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsDifferentSpreadString") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     *     derivedProp: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     *     derivedProp: String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     *     derivedProp: String (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     *     derivedProp: String (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsFloatsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsFloatsImpl.java new file mode 100644 index 000000000..11ac9cc0b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsFloatsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ExtendsFloats. + */ +public final class ExtendsFloatsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsFloatsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsFloatsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsFloatsImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(ExtendsFloatsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsFloats to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface ExtendsFloatsService { + @Get("/type/property/additionalProperties/extendsRecordFloat") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/extendsRecordFloat") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsRecordFloat") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsRecordFloat") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelArraysImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelArraysImpl.java new file mode 100644 index 000000000..e48e96e72 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelArraysImpl.java @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ExtendsModelArrays. + */ +public final class ExtendsModelArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsModelArraysService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsModelArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsModelArraysImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsModelArraysService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsModelArrays to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface ExtendsModelArraysService { + @Get("/type/property/additionalProperties/extendsRecordModelArray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/extendsRecordModelArray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsRecordModelArray") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsRecordModelArray") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelsImpl.java new file mode 100644 index 000000000..37d6a056c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsModelsImpl.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ExtendsModels. + */ +public final class ExtendsModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsModelsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsModelsImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(ExtendsModelsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsModels to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface ExtendsModelsService { + @Get("/type/property/additionalProperties/extendsRecordModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/extendsRecordModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsRecordModel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsRecordModel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsStringsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsStringsImpl.java new file mode 100644 index 000000000..2ee447666 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsStringsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ExtendsStrings. + */ +public final class ExtendsStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsStringsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsStringsImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(ExtendsStringsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsStrings to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface ExtendsStringsService { + @Get("/type/property/additionalProperties/extendsRecordString") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/extendsRecordString") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsRecordString") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsRecordString") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDerivedsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDerivedsImpl.java new file mode 100644 index 000000000..2aaf5b14d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDerivedsImpl.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ExtendsUnknownDeriveds. + */ +public final class ExtendsUnknownDerivedsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsUnknownDerivedsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsUnknownDerivedsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsUnknownDerivedsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsUnknownDerivedsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsUnknownDeriveds to be used by the + * proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface ExtendsUnknownDerivedsService { + @Get("/type/property/additionalProperties/extendsRecordUnknownDerived") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/extendsRecordUnknownDerived") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsRecordUnknownDerived") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsRecordUnknownDerived") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDiscriminatedsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDiscriminatedsImpl.java new file mode 100644 index 000000000..5e67fb8e7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownDiscriminatedsImpl.java @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ExtendsUnknownDiscriminateds. + */ +public final class ExtendsUnknownDiscriminatedsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsUnknownDiscriminatedsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsUnknownDiscriminatedsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsUnknownDiscriminatedsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsUnknownDiscriminatedsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsUnknownDiscriminateds to be used by + * the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface ExtendsUnknownDiscriminatedsService { + @Get("/type/property/additionalProperties/extendsUnknownDiscriminated") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/extendsUnknownDiscriminated") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsUnknownDiscriminated") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsUnknownDiscriminated") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownsImpl.java new file mode 100644 index 000000000..28f682fb1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/ExtendsUnknownsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ExtendsUnknowns. + */ +public final class ExtendsUnknownsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsUnknownsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsUnknownsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsUnknownsImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(ExtendsUnknownsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsUnknowns to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface ExtendsUnknownsService { + @Get("/type/property/additionalProperties/extendsRecordUnknown") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/extendsRecordUnknown") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsRecordUnknown") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/extendsRecordUnknown") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsFloatsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsFloatsImpl.java new file mode 100644 index 000000000..c65261625 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsFloatsImpl.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 com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 IsFloats. + */ +public final class IsFloatsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsFloatsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsFloatsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsFloatsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(IsFloatsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsFloats to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface IsFloatsService { + @Get("/type/property/additionalProperties/isRecordFloat") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/isRecordFloat") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isRecordFloat") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isRecordFloat") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsModelArraysImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsModelArraysImpl.java new file mode 100644 index 000000000..8d95467fb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsModelArraysImpl.java @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 IsModelArrays. + */ +public final class IsModelArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsModelArraysService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsModelArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsModelArraysImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(IsModelArraysService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsModelArrays to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface IsModelArraysService { + @Get("/type/property/additionalProperties/isRecordModelArray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/isRecordModelArray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isRecordModelArray") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isRecordModelArray") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsModelsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsModelsImpl.java new file mode 100644 index 000000000..44b0c52fb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsModelsImpl.java @@ -0,0 +1,213 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 IsModels. + */ +public final class IsModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsModelsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsModelsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(IsModelsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsModels to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface IsModelsService { + @Get("/type/property/additionalProperties/isRecordModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/isRecordModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isRecordModel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isRecordModel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsStringsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsStringsImpl.java new file mode 100644 index 000000000..35198e065 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsStringsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 IsStrings. + */ +public final class IsStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsStringsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsStringsImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(IsStringsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsStrings to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface IsStringsService { + @Get("/type/property/additionalProperties/isRecordstring") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/isRecordstring") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isRecordstring") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isRecordstring") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDerivedsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDerivedsImpl.java new file mode 100644 index 000000000..05a68b6bb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDerivedsImpl.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 IsUnknownDeriveds. + */ +public final class IsUnknownDerivedsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsUnknownDerivedsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsUnknownDerivedsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsUnknownDerivedsImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(IsUnknownDerivedsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsUnknownDeriveds to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface IsUnknownDerivedsService { + @Get("/type/property/additionalProperties/isRecordUnknownDerived") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/isRecordUnknownDerived") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isRecordUnknownDerived") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isRecordUnknownDerived") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDiscriminatedsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDiscriminatedsImpl.java new file mode 100644 index 000000000..11d80df74 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownDiscriminatedsImpl.java @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 IsUnknownDiscriminateds. + */ +public final class IsUnknownDiscriminatedsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsUnknownDiscriminatedsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsUnknownDiscriminatedsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsUnknownDiscriminatedsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(IsUnknownDiscriminatedsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsUnknownDiscriminateds to be used by the + * proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface IsUnknownDiscriminatedsService { + @Get("/type/property/additionalProperties/isUnknownDiscriminated") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/isUnknownDiscriminated") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isUnknownDiscriminated") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isUnknownDiscriminated") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownsImpl.java new file mode 100644 index 000000000..14af79a15 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/IsUnknownsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 IsUnknowns. + */ +public final class IsUnknownsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsUnknownsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsUnknownsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsUnknownsImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(IsUnknownsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsUnknowns to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface IsUnknownsService { + @Get("/type/property/additionalProperties/isRecordUnknown") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/isRecordUnknown") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isRecordUnknown") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/isRecordUnknown") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: Object (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/MultipleSpreadsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/MultipleSpreadsImpl.java new file mode 100644 index 000000000..77c14978b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/MultipleSpreadsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 MultipleSpreads. + */ +public final class MultipleSpreadsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MultipleSpreadsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of MultipleSpreadsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + MultipleSpreadsImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(MultipleSpreadsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientMultipleSpreads to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface MultipleSpreadsService { + @Get("/type/property/additionalProperties/multipleSpreadRecord") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/multipleSpreadRecord") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/multipleSpreadRecord") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/multipleSpreadRecord") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentFloatsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentFloatsImpl.java new file mode 100644 index 000000000..0141e36ac --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentFloatsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadDifferentFloats. + */ +public final class SpreadDifferentFloatsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadDifferentFloatsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadDifferentFloatsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadDifferentFloatsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadDifferentFloatsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadDifferentFloats to be used by the + * proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadDifferentFloatsService { + @Get("/type/property/additionalProperties/spreadDifferentRecordFloat") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadDifferentRecordFloat") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadDifferentRecordFloat") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadDifferentRecordFloat") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelArraysImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelArraysImpl.java new file mode 100644 index 000000000..c1e3aa384 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelArraysImpl.java @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadDifferentModelArrays. + */ +public final class SpreadDifferentModelArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadDifferentModelArraysService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadDifferentModelArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadDifferentModelArraysImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadDifferentModelArraysService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadDifferentModelArrays to be used by + * the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadDifferentModelArraysService { + @Get("/type/property/additionalProperties/spreadDifferentRecordModelArray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadDifferentRecordModelArray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadDifferentRecordModelArray") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadDifferentRecordModelArray") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelsImpl.java new file mode 100644 index 000000000..fed8bd79d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentModelsImpl.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadDifferentModels. + */ +public final class SpreadDifferentModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadDifferentModelsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadDifferentModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadDifferentModelsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadDifferentModelsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadDifferentModels to be used by the + * proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadDifferentModelsService { + @Get("/type/property/additionalProperties/spreadDifferentRecordModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadDifferentRecordModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadDifferentRecordModel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadDifferentRecordModel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentStringsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentStringsImpl.java new file mode 100644 index 000000000..a8056c035 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadDifferentStringsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadDifferentStrings. + */ +public final class SpreadDifferentStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadDifferentStringsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadDifferentStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadDifferentStringsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadDifferentStringsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadDifferentStrings to be used by the + * proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadDifferentStringsService { + @Get("/type/property/additionalProperties/spreadDifferentRecordString") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadDifferentRecordString") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadDifferentRecordString") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadDifferentRecordString") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadFloatsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadFloatsImpl.java new file mode 100644 index 000000000..a6e5600d3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadFloatsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadFloats. + */ +public final class SpreadFloatsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadFloatsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadFloatsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadFloatsImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(SpreadFloatsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadFloats to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadFloatsService { + @Get("/type/property/additionalProperties/spreadRecordFloat") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadRecordFloat") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordFloat") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordFloat") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelArraysImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelArraysImpl.java new file mode 100644 index 000000000..25eb98c76 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelArraysImpl.java @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadModelArrays. + */ +public final class SpreadModelArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadModelArraysService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadModelArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadModelArraysImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(SpreadModelArraysService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadModelArrays to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadModelArraysService { + @Get("/type/property/additionalProperties/spreadRecordModelArray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadRecordModelArray") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordModelArray") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordModelArray") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelsImpl.java new file mode 100644 index 000000000..fdd2a2fd9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadModelsImpl.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadModels. + */ +public final class SpreadModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadModelsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadModelsImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(SpreadModelsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadModels to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadModelsService { + @Get("/type/property/additionalProperties/spreadRecordModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadRecordModel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordModel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordModel") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordDiscriminatedUnionsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordDiscriminatedUnionsImpl.java new file mode 100644 index 000000000..08605622c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordDiscriminatedUnionsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadRecordDiscriminatedUnions. + */ +public final class SpreadRecordDiscriminatedUnionsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadRecordDiscriminatedUnionsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadRecordDiscriminatedUnionsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadRecordDiscriminatedUnionsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadRecordDiscriminatedUnionsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadRecordDiscriminatedUnions to be used + * by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadRecordDiscriminatedUnionsService { + @Get("/type/property/additionalProperties/spreadRecordDiscriminatedUnion") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadRecordDiscriminatedUnion") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordDiscriminatedUnion") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordDiscriminatedUnion") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion2sImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion2sImpl.java new file mode 100644 index 000000000..774b0db13 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion2sImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadRecordNonDiscriminatedUnion2s. + */ +public final class SpreadRecordNonDiscriminatedUnion2sImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadRecordNonDiscriminatedUnion2sService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnion2sImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadRecordNonDiscriminatedUnion2sImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadRecordNonDiscriminatedUnion2sService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadRecordNonDiscriminatedUnion2s to be + * used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadRecordNonDiscriminatedUnion2sService { + @Get("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion2") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion2") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion2") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion2") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion3sImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion3sImpl.java new file mode 100644 index 000000000..29f7579eb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion3sImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadRecordNonDiscriminatedUnion3s. + */ +public final class SpreadRecordNonDiscriminatedUnion3sImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadRecordNonDiscriminatedUnion3sService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnion3sImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadRecordNonDiscriminatedUnion3sImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadRecordNonDiscriminatedUnion3sService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadRecordNonDiscriminatedUnion3s to be + * used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadRecordNonDiscriminatedUnion3sService { + @Get("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion3") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion3") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion3") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion3") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnionsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnionsImpl.java new file mode 100644 index 000000000..f438e1fa7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnionsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadRecordNonDiscriminatedUnions. + */ +public final class SpreadRecordNonDiscriminatedUnionsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadRecordNonDiscriminatedUnionsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnionsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadRecordNonDiscriminatedUnionsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadRecordNonDiscriminatedUnionsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadRecordNonDiscriminatedUnions to be + * used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadRecordNonDiscriminatedUnionsService { + @Get("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordUnionsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordUnionsImpl.java new file mode 100644 index 000000000..381cf3286 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadRecordUnionsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadRecordUnions. + */ +public final class SpreadRecordUnionsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadRecordUnionsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadRecordUnionsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadRecordUnionsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadRecordUnionsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadRecordUnions to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadRecordUnionsService { + @Get("/type/property/additionalProperties/spreadRecordUnion") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadRecordUnion") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordUnion") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordUnion") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadStringsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadStringsImpl.java new file mode 100644 index 000000000..8c744222c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/SpreadStringsImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 SpreadStrings. + */ +public final class SpreadStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadStringsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadStringsImpl(AdditionalPropertiesClientImpl client) { + this.service + = RestProxy.create(SpreadStringsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadStrings to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AdditionalProperties") + public interface SpreadStringsService { + @Get("/type/property/additionalProperties/spreadRecordString") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/additionalProperties/spreadRecordString") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordString") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/additionalProperties/spreadRecordString") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/implementation/package-info.java new file mode 100644 index 000000000..5d4c70b29 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/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 AdditionalProperties. + * Tests for additional properties of models. + * + */ +package com.type.property.additionalproperties.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadFloatDerived.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadFloatDerived.java new file mode 100644 index 000000000..ed2606bf8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadFloatDerived.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 com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from a model that spread Record<float32> with the different known property type. + */ +@Immutable +public final class DifferentSpreadFloatDerived extends DifferentSpreadFloatRecord { + /* + * The index property + */ + @Generated + private final double derivedProp; + + /** + * Creates an instance of DifferentSpreadFloatDerived class. + * + * @param name the name value to set. + * @param derivedProp the derivedProp value to set. + */ + @Generated + public DifferentSpreadFloatDerived(String name, double derivedProp) { + super(name); + this.derivedProp = derivedProp; + } + + /** + * Get the derivedProp property: The index property. + * + * @return the derivedProp value. + */ + @Generated + public double getDerivedProp() { + return this.derivedProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeDoubleField("derivedProp", this.derivedProp); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadFloatDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadFloatDerived 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 DifferentSpreadFloatDerived. + */ + @Generated + public static DifferentSpreadFloatDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + double derivedProp = 0.0; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("derivedProp".equals(fieldName)) { + derivedProp = reader.getDouble(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getDouble()); + } + } + DifferentSpreadFloatDerived deserializedDifferentSpreadFloatDerived + = new DifferentSpreadFloatDerived(name, derivedProp); + deserializedDifferentSpreadFloatDerived.setAdditionalProperties(additionalProperties); + + return deserializedDifferentSpreadFloatDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadFloatRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadFloatRecord.java new file mode 100644 index 000000000..9380e6298 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadFloatRecord.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<float32> with the different known property type. + */ +@Fluent +public class DifferentSpreadFloatRecord implements JsonSerializable { + /* + * The id property + */ + @Generated + private final String name; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of DifferentSpreadFloatRecord class. + * + * @param name the name value to set. + */ + @Generated + public DifferentSpreadFloatRecord(String name) { + this.name = name; + } + + /** + * Get the name property: The id property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the DifferentSpreadFloatRecord object itself. + */ + @Generated + public DifferentSpreadFloatRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadFloatRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadFloatRecord 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 DifferentSpreadFloatRecord. + */ + @Generated + public static DifferentSpreadFloatRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getDouble()); + } + } + DifferentSpreadFloatRecord deserializedDifferentSpreadFloatRecord = new DifferentSpreadFloatRecord(name); + deserializedDifferentSpreadFloatRecord.additionalProperties = additionalProperties; + + return deserializedDifferentSpreadFloatRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadModelArrayDerived.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadModelArrayDerived.java new file mode 100644 index 000000000..8cc458bf8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadModelArrayDerived.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * The model extends from a model that spread Record<ModelForRecord[]> with the different known property type. + */ +@Immutable +public final class DifferentSpreadModelArrayDerived extends DifferentSpreadModelArrayRecord { + /* + * The index property + */ + @Generated + private final List derivedProp; + + /** + * Creates an instance of DifferentSpreadModelArrayDerived class. + * + * @param knownProp the knownProp value to set. + * @param derivedProp the derivedProp value to set. + */ + @Generated + public DifferentSpreadModelArrayDerived(String knownProp, List derivedProp) { + super(knownProp); + this.derivedProp = derivedProp; + } + + /** + * Get the derivedProp property: The index property. + * + * @return the derivedProp value. + */ + @Generated + public List getDerivedProp() { + return this.derivedProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("knownProp", getKnownProp()); + jsonWriter.writeArrayField("derivedProp", this.derivedProp, (writer, element) -> writer.writeJson(element)); + if (getAdditionalProperties() != null) { + for (Map.Entry> additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadModelArrayDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadModelArrayDerived 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 DifferentSpreadModelArrayDerived. + */ + @Generated + public static DifferentSpreadModelArrayDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String knownProp = null; + List derivedProp = null; + Map> additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.getString(); + } else if ("derivedProp".equals(fieldName)) { + derivedProp = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + List additionalPropertiesArrayItem + = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + additionalProperties.put(fieldName, additionalPropertiesArrayItem); + } + } + DifferentSpreadModelArrayDerived deserializedDifferentSpreadModelArrayDerived + = new DifferentSpreadModelArrayDerived(knownProp, derivedProp); + deserializedDifferentSpreadModelArrayDerived.setAdditionalProperties(additionalProperties); + + return deserializedDifferentSpreadModelArrayDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadModelArrayRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadModelArrayRecord.java new file mode 100644 index 000000000..0fd24f55f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadModelArrayRecord.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * The model spread Record<ModelForRecord[]> with the different known property type. + */ +@Fluent +public class DifferentSpreadModelArrayRecord implements JsonSerializable { + /* + * The knownProp property. + */ + @Generated + private final String knownProp; + + /* + * Additional properties + */ + @Generated + private Map> additionalProperties; + + /** + * Creates an instance of DifferentSpreadModelArrayRecord class. + * + * @param knownProp the knownProp value to set. + */ + @Generated + public DifferentSpreadModelArrayRecord(String knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Generated + public String getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map> getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the DifferentSpreadModelArrayRecord object itself. + */ + @Generated + public DifferentSpreadModelArrayRecord + setAdditionalProperties(Map> additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("knownProp", this.knownProp); + if (additionalProperties != null) { + for (Map.Entry> additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadModelArrayRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadModelArrayRecord 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 DifferentSpreadModelArrayRecord. + */ + @Generated + public static DifferentSpreadModelArrayRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String knownProp = null; + Map> additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + List additionalPropertiesArrayItem + = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + additionalProperties.put(fieldName, additionalPropertiesArrayItem); + } + } + DifferentSpreadModelArrayRecord deserializedDifferentSpreadModelArrayRecord + = new DifferentSpreadModelArrayRecord(knownProp); + deserializedDifferentSpreadModelArrayRecord.additionalProperties = additionalProperties; + + return deserializedDifferentSpreadModelArrayRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadModelDerived.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadModelDerived.java new file mode 100644 index 000000000..ee4654da7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadModelDerived.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 com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from a model that spread Record<ModelForRecord> with the different known property type. + */ +@Immutable +public final class DifferentSpreadModelDerived extends DifferentSpreadModelRecord { + /* + * The index property + */ + @Generated + private final ModelForRecord derivedProp; + + /** + * Creates an instance of DifferentSpreadModelDerived class. + * + * @param knownProp the knownProp value to set. + * @param derivedProp the derivedProp value to set. + */ + @Generated + public DifferentSpreadModelDerived(String knownProp, ModelForRecord derivedProp) { + super(knownProp); + this.derivedProp = derivedProp; + } + + /** + * Get the derivedProp property: The index property. + * + * @return the derivedProp value. + */ + @Generated + public ModelForRecord getDerivedProp() { + return this.derivedProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("knownProp", getKnownProp()); + jsonWriter.writeJsonField("derivedProp", this.derivedProp); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadModelDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadModelDerived 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 DifferentSpreadModelDerived. + */ + @Generated + public static DifferentSpreadModelDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String knownProp = null; + ModelForRecord derivedProp = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.getString(); + } else if ("derivedProp".equals(fieldName)) { + derivedProp = ModelForRecord.fromJson(reader); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, ModelForRecord.fromJson(reader)); + } + } + DifferentSpreadModelDerived deserializedDifferentSpreadModelDerived + = new DifferentSpreadModelDerived(knownProp, derivedProp); + deserializedDifferentSpreadModelDerived.setAdditionalProperties(additionalProperties); + + return deserializedDifferentSpreadModelDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadModelRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadModelRecord.java new file mode 100644 index 000000000..d59f31441 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadModelRecord.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<ModelForRecord> with the different known property type. + */ +@Fluent +public class DifferentSpreadModelRecord implements JsonSerializable { + /* + * The knownProp property. + */ + @Generated + private final String knownProp; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of DifferentSpreadModelRecord class. + * + * @param knownProp the knownProp value to set. + */ + @Generated + public DifferentSpreadModelRecord(String knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Generated + public String getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the DifferentSpreadModelRecord object itself. + */ + @Generated + public DifferentSpreadModelRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("knownProp", this.knownProp); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadModelRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadModelRecord 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 DifferentSpreadModelRecord. + */ + @Generated + public static DifferentSpreadModelRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String knownProp = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, ModelForRecord.fromJson(reader)); + } + } + DifferentSpreadModelRecord deserializedDifferentSpreadModelRecord + = new DifferentSpreadModelRecord(knownProp); + deserializedDifferentSpreadModelRecord.additionalProperties = additionalProperties; + + return deserializedDifferentSpreadModelRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadStringDerived.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadStringDerived.java new file mode 100644 index 000000000..af5a0eb27 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadStringDerived.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 com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from a model that spread Record<string> with the different known property type. + */ +@Immutable +public final class DifferentSpreadStringDerived extends DifferentSpreadStringRecord { + /* + * The index property + */ + @Generated + private final String derivedProp; + + /** + * Creates an instance of DifferentSpreadStringDerived class. + * + * @param id the id value to set. + * @param derivedProp the derivedProp value to set. + */ + @Generated + public DifferentSpreadStringDerived(double id, String derivedProp) { + super(id); + this.derivedProp = derivedProp; + } + + /** + * Get the derivedProp property: The index property. + * + * @return the derivedProp value. + */ + @Generated + public String getDerivedProp() { + return this.derivedProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("id", getId()); + jsonWriter.writeStringField("derivedProp", this.derivedProp); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadStringDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadStringDerived 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 DifferentSpreadStringDerived. + */ + @Generated + public static DifferentSpreadStringDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double id = 0.0; + String derivedProp = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getDouble(); + } else if ("derivedProp".equals(fieldName)) { + derivedProp = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getString()); + } + } + DifferentSpreadStringDerived deserializedDifferentSpreadStringDerived + = new DifferentSpreadStringDerived(id, derivedProp); + deserializedDifferentSpreadStringDerived.setAdditionalProperties(additionalProperties); + + return deserializedDifferentSpreadStringDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadStringRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadStringRecord.java new file mode 100644 index 000000000..1b80d7a08 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/DifferentSpreadStringRecord.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<string> with the different known property type. + */ +@Fluent +public class DifferentSpreadStringRecord implements JsonSerializable { + /* + * The name property + */ + @Generated + private final double id; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of DifferentSpreadStringRecord class. + * + * @param id the id value to set. + */ + @Generated + public DifferentSpreadStringRecord(double id) { + this.id = id; + } + + /** + * Get the id property: The name property. + * + * @return the id value. + */ + @Generated + public double getId() { + return this.id; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the DifferentSpreadStringRecord object itself. + */ + @Generated + public DifferentSpreadStringRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("id", this.id); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadStringRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadStringRecord 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 DifferentSpreadStringRecord. + */ + @Generated + public static DifferentSpreadStringRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double id = 0.0; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getDouble(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getString()); + } + } + DifferentSpreadStringRecord deserializedDifferentSpreadStringRecord = new DifferentSpreadStringRecord(id); + deserializedDifferentSpreadStringRecord.additionalProperties = additionalProperties; + + return deserializedDifferentSpreadStringRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsFloatAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsFloatAdditionalProperties.java new file mode 100644 index 000000000..114b1a0db --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsFloatAdditionalProperties.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from Record<float32> type. + */ +@Fluent +public final class ExtendsFloatAdditionalProperties implements JsonSerializable { + /* + * The id property + */ + @Generated + private final double id; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of ExtendsFloatAdditionalProperties class. + * + * @param id the id value to set. + */ + @Generated + public ExtendsFloatAdditionalProperties(double id) { + this.id = id; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public double getId() { + return this.id; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ExtendsFloatAdditionalProperties object itself. + */ + @Generated + public ExtendsFloatAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("id", this.id); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsFloatAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsFloatAdditionalProperties 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 ExtendsFloatAdditionalProperties. + */ + @Generated + public static ExtendsFloatAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double id = 0.0; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getDouble(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getDouble()); + } + } + ExtendsFloatAdditionalProperties deserializedExtendsFloatAdditionalProperties + = new ExtendsFloatAdditionalProperties(id); + deserializedExtendsFloatAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedExtendsFloatAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsModelAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsModelAdditionalProperties.java new file mode 100644 index 000000000..dda534372 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsModelAdditionalProperties.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from Record<ModelForRecord> type. + */ +@Fluent +public final class ExtendsModelAdditionalProperties implements JsonSerializable { + /* + * The knownProp property. + */ + @Generated + private final ModelForRecord knownProp; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of ExtendsModelAdditionalProperties class. + * + * @param knownProp the knownProp value to set. + */ + @Generated + public ExtendsModelAdditionalProperties(ModelForRecord knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Generated + public ModelForRecord getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ExtendsModelAdditionalProperties object itself. + */ + @Generated + public ExtendsModelAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("knownProp", this.knownProp); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsModelAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsModelAdditionalProperties 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 ExtendsModelAdditionalProperties. + */ + @Generated + public static ExtendsModelAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ModelForRecord knownProp = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = ModelForRecord.fromJson(reader); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, ModelForRecord.fromJson(reader)); + } + } + ExtendsModelAdditionalProperties deserializedExtendsModelAdditionalProperties + = new ExtendsModelAdditionalProperties(knownProp); + deserializedExtendsModelAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedExtendsModelAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsModelArrayAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsModelArrayAdditionalProperties.java new file mode 100644 index 000000000..6ef199078 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsModelArrayAdditionalProperties.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * The model extends from Record<ModelForRecord[]> type. + */ +@Fluent +public final class ExtendsModelArrayAdditionalProperties + implements JsonSerializable { + /* + * The knownProp property. + */ + @Generated + private final List knownProp; + + /* + * Additional properties + */ + @Generated + private Map> additionalProperties; + + /** + * Creates an instance of ExtendsModelArrayAdditionalProperties class. + * + * @param knownProp the knownProp value to set. + */ + @Generated + public ExtendsModelArrayAdditionalProperties(List knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Generated + public List getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map> getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ExtendsModelArrayAdditionalProperties object itself. + */ + @Generated + public ExtendsModelArrayAdditionalProperties + setAdditionalProperties(Map> additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("knownProp", this.knownProp, (writer, element) -> writer.writeJson(element)); + if (additionalProperties != null) { + for (Map.Entry> additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsModelArrayAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsModelArrayAdditionalProperties 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 ExtendsModelArrayAdditionalProperties. + */ + @Generated + public static ExtendsModelArrayAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List knownProp = null; + Map> additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + List additionalPropertiesArrayItem + = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + additionalProperties.put(fieldName, additionalPropertiesArrayItem); + } + } + ExtendsModelArrayAdditionalProperties deserializedExtendsModelArrayAdditionalProperties + = new ExtendsModelArrayAdditionalProperties(knownProp); + deserializedExtendsModelArrayAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedExtendsModelArrayAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsStringAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsStringAdditionalProperties.java new file mode 100644 index 000000000..80005f7ed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsStringAdditionalProperties.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from Record<string> type. + */ +@Fluent +public final class ExtendsStringAdditionalProperties implements JsonSerializable { + /* + * The name property + */ + @Generated + private final String name; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of ExtendsStringAdditionalProperties class. + * + * @param name the name value to set. + */ + @Generated + public ExtendsStringAdditionalProperties(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ExtendsStringAdditionalProperties object itself. + */ + @Generated + public ExtendsStringAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsStringAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsStringAdditionalProperties 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 ExtendsStringAdditionalProperties. + */ + @Generated + public static ExtendsStringAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getString()); + } + } + ExtendsStringAdditionalProperties deserializedExtendsStringAdditionalProperties + = new ExtendsStringAdditionalProperties(name); + deserializedExtendsStringAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedExtendsStringAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsUnknownAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsUnknownAdditionalProperties.java new file mode 100644 index 000000000..4fefffab1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsUnknownAdditionalProperties.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from Record<unknown> type. + */ +@Fluent +public class ExtendsUnknownAdditionalProperties implements JsonSerializable { + /* + * The name property + */ + @Generated + private final String name; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of ExtendsUnknownAdditionalProperties class. + * + * @param name the name value to set. + */ + @Generated + public ExtendsUnknownAdditionalProperties(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ExtendsUnknownAdditionalProperties object itself. + */ + @Generated + public ExtendsUnknownAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsUnknownAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsUnknownAdditionalProperties 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 ExtendsUnknownAdditionalProperties. + */ + @Generated + public static ExtendsUnknownAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.readUntyped()); + } + } + ExtendsUnknownAdditionalProperties deserializedExtendsUnknownAdditionalProperties + = new ExtendsUnknownAdditionalProperties(name); + deserializedExtendsUnknownAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedExtendsUnknownAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsUnknownAdditionalPropertiesDerived.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsUnknownAdditionalPropertiesDerived.java new file mode 100644 index 000000000..76ecf7f70 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsUnknownAdditionalPropertiesDerived.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from a type that extends from Record<unknown>. + */ +@Fluent +public final class ExtendsUnknownAdditionalPropertiesDerived extends ExtendsUnknownAdditionalProperties { + /* + * The index property + */ + @Generated + private final int index; + + /* + * The age property + */ + @Generated + private Double age; + + /** + * Creates an instance of ExtendsUnknownAdditionalPropertiesDerived class. + * + * @param name the name value to set. + * @param index the index value to set. + */ + @Generated + public ExtendsUnknownAdditionalPropertiesDerived(String name, int index) { + super(name); + this.index = index; + } + + /** + * Get the index property: The index property. + * + * @return the index value. + */ + @Generated + public int getIndex() { + return this.index; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Generated + public Double getAge() { + return this.age; + } + + /** + * Set the age property: The age property. + * + * @param age the age value to set. + * @return the ExtendsUnknownAdditionalPropertiesDerived object itself. + */ + @Generated + public ExtendsUnknownAdditionalPropertiesDerived setAge(Double age) { + this.age = age; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeIntField("index", this.index); + jsonWriter.writeNumberField("age", this.age); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsUnknownAdditionalPropertiesDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsUnknownAdditionalPropertiesDerived 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 ExtendsUnknownAdditionalPropertiesDerived. + */ + @Generated + public static ExtendsUnknownAdditionalPropertiesDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int index = 0; + Double age = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("age".equals(fieldName)) { + age = reader.getNullable(JsonReader::getDouble); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.readUntyped()); + } + } + ExtendsUnknownAdditionalPropertiesDerived deserializedExtendsUnknownAdditionalPropertiesDerived + = new ExtendsUnknownAdditionalPropertiesDerived(name, index); + deserializedExtendsUnknownAdditionalPropertiesDerived.age = age; + deserializedExtendsUnknownAdditionalPropertiesDerived.setAdditionalProperties(additionalProperties); + + return deserializedExtendsUnknownAdditionalPropertiesDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsUnknownAdditionalPropertiesDiscriminated.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsUnknownAdditionalPropertiesDiscriminated.java new file mode 100644 index 000000000..59b128de4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsUnknownAdditionalPropertiesDiscriminated.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from Record<unknown> with a discriminator. + */ +@Fluent +public class ExtendsUnknownAdditionalPropertiesDiscriminated + implements JsonSerializable { + /* + * The discriminator + */ + @Generated + String kind; + + /* + * The name property + */ + @Generated + private final String name; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of ExtendsUnknownAdditionalPropertiesDiscriminated class. + * + * @param name the name value to set. + */ + @Generated + public ExtendsUnknownAdditionalPropertiesDiscriminated(String name) { + this.name = name; + this.kind = "ExtendsUnknownAdditionalPropertiesDiscriminated"; + } + + /** + * Get the kind property: The discriminator. + * + * @return the kind value. + */ + @Generated + public String getKind() { + return this.kind; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ExtendsUnknownAdditionalPropertiesDiscriminated object itself. + */ + @Generated + public ExtendsUnknownAdditionalPropertiesDiscriminated + setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + void toJsonShared(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("kind", this.kind); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + } + + /** + * Reads an instance of ExtendsUnknownAdditionalPropertiesDiscriminated from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsUnknownAdditionalPropertiesDiscriminated 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 ExtendsUnknownAdditionalPropertiesDiscriminated. + */ + @Generated + public static ExtendsUnknownAdditionalPropertiesDiscriminated fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("derived".equals(discriminatorValue)) { + return ExtendsUnknownAdditionalPropertiesDiscriminatedDerived.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static ExtendsUnknownAdditionalPropertiesDiscriminated fromJsonKnownDiscriminator(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String kind = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.readUntyped()); + } + } + ExtendsUnknownAdditionalPropertiesDiscriminated deserializedExtendsUnknownAdditionalPropertiesDiscriminated + = new ExtendsUnknownAdditionalPropertiesDiscriminated(name); + deserializedExtendsUnknownAdditionalPropertiesDiscriminated.kind = kind; + deserializedExtendsUnknownAdditionalPropertiesDiscriminated.additionalProperties = additionalProperties; + + return deserializedExtendsUnknownAdditionalPropertiesDiscriminated; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsUnknownAdditionalPropertiesDiscriminatedDerived.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsUnknownAdditionalPropertiesDiscriminatedDerived.java new file mode 100644 index 000000000..029927ebd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ExtendsUnknownAdditionalPropertiesDiscriminatedDerived.java @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The derived discriminated type. + */ +@Fluent +public final class ExtendsUnknownAdditionalPropertiesDiscriminatedDerived + extends ExtendsUnknownAdditionalPropertiesDiscriminated { + /* + * The index property + */ + @Generated + private final int index; + + /* + * The age property + */ + @Generated + private Double age; + + /** + * Creates an instance of ExtendsUnknownAdditionalPropertiesDiscriminatedDerived class. + * + * @param name the name value to set. + * @param index the index value to set. + */ + @Generated + public ExtendsUnknownAdditionalPropertiesDiscriminatedDerived(String name, int index) { + super(name); + this.index = index; + this.kind = "derived"; + } + + /** + * Get the index property: The index property. + * + * @return the index value. + */ + @Generated + public int getIndex() { + return this.index; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Generated + public Double getAge() { + return this.age; + } + + /** + * Set the age property: The age property. + * + * @param age the age value to set. + * @return the ExtendsUnknownAdditionalPropertiesDiscriminatedDerived object itself. + */ + @Generated + public ExtendsUnknownAdditionalPropertiesDiscriminatedDerived setAge(Double age) { + this.age = age; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + jsonWriter.writeIntField("index", this.index); + jsonWriter.writeNumberField("age", this.age); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsUnknownAdditionalPropertiesDiscriminatedDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsUnknownAdditionalPropertiesDiscriminatedDerived 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 ExtendsUnknownAdditionalPropertiesDiscriminatedDerived. + */ + @Generated + public static ExtendsUnknownAdditionalPropertiesDiscriminatedDerived fromJson(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int index = 0; + String kind = "derived"; + Double age = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else if ("age".equals(fieldName)) { + age = reader.getNullable(JsonReader::getDouble); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.readUntyped()); + } + } + ExtendsUnknownAdditionalPropertiesDiscriminatedDerived deserializedExtendsUnknownAdditionalPropertiesDiscriminatedDerived + = new ExtendsUnknownAdditionalPropertiesDiscriminatedDerived(name, index); + deserializedExtendsUnknownAdditionalPropertiesDiscriminatedDerived.kind = kind; + deserializedExtendsUnknownAdditionalPropertiesDiscriminatedDerived.age = age; + deserializedExtendsUnknownAdditionalPropertiesDiscriminatedDerived + .setAdditionalProperties(additionalProperties); + + return deserializedExtendsUnknownAdditionalPropertiesDiscriminatedDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsFloatAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsFloatAdditionalProperties.java new file mode 100644 index 000000000..ea6cdacab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsFloatAdditionalProperties.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model is from Record<float32> type. + */ +@Fluent +public final class IsFloatAdditionalProperties implements JsonSerializable { + /* + * The id property + */ + @Generated + private final double id; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of IsFloatAdditionalProperties class. + * + * @param id the id value to set. + */ + @Generated + public IsFloatAdditionalProperties(double id) { + this.id = id; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public double getId() { + return this.id; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the IsFloatAdditionalProperties object itself. + */ + @Generated + public IsFloatAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("id", this.id); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsFloatAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsFloatAdditionalProperties 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 IsFloatAdditionalProperties. + */ + @Generated + public static IsFloatAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double id = 0.0; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getDouble(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getDouble()); + } + } + IsFloatAdditionalProperties deserializedIsFloatAdditionalProperties = new IsFloatAdditionalProperties(id); + deserializedIsFloatAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedIsFloatAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsModelAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsModelAdditionalProperties.java new file mode 100644 index 000000000..92e2e844f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsModelAdditionalProperties.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model is from Record<ModelForRecord> type. + */ +@Fluent +public final class IsModelAdditionalProperties implements JsonSerializable { + /* + * The knownProp property. + */ + @Generated + private final ModelForRecord knownProp; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of IsModelAdditionalProperties class. + * + * @param knownProp the knownProp value to set. + */ + @Generated + public IsModelAdditionalProperties(ModelForRecord knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Generated + public ModelForRecord getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the IsModelAdditionalProperties object itself. + */ + @Generated + public IsModelAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("knownProp", this.knownProp); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsModelAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsModelAdditionalProperties 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 IsModelAdditionalProperties. + */ + @Generated + public static IsModelAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ModelForRecord knownProp = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = ModelForRecord.fromJson(reader); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, ModelForRecord.fromJson(reader)); + } + } + IsModelAdditionalProperties deserializedIsModelAdditionalProperties + = new IsModelAdditionalProperties(knownProp); + deserializedIsModelAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedIsModelAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsModelArrayAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsModelArrayAdditionalProperties.java new file mode 100644 index 000000000..3f8caf737 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsModelArrayAdditionalProperties.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * The model is from Record<ModelForRecord[]> type. + */ +@Fluent +public final class IsModelArrayAdditionalProperties implements JsonSerializable { + /* + * The knownProp property. + */ + @Generated + private final List knownProp; + + /* + * Additional properties + */ + @Generated + private Map> additionalProperties; + + /** + * Creates an instance of IsModelArrayAdditionalProperties class. + * + * @param knownProp the knownProp value to set. + */ + @Generated + public IsModelArrayAdditionalProperties(List knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Generated + public List getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map> getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the IsModelArrayAdditionalProperties object itself. + */ + @Generated + public IsModelArrayAdditionalProperties + setAdditionalProperties(Map> additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("knownProp", this.knownProp, (writer, element) -> writer.writeJson(element)); + if (additionalProperties != null) { + for (Map.Entry> additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsModelArrayAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsModelArrayAdditionalProperties 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 IsModelArrayAdditionalProperties. + */ + @Generated + public static IsModelArrayAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List knownProp = null; + Map> additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + List additionalPropertiesArrayItem + = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + additionalProperties.put(fieldName, additionalPropertiesArrayItem); + } + } + IsModelArrayAdditionalProperties deserializedIsModelArrayAdditionalProperties + = new IsModelArrayAdditionalProperties(knownProp); + deserializedIsModelArrayAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedIsModelArrayAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsStringAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsStringAdditionalProperties.java new file mode 100644 index 000000000..f7abf2864 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsStringAdditionalProperties.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model is from Record<string> type. + */ +@Fluent +public final class IsStringAdditionalProperties implements JsonSerializable { + /* + * The name property + */ + @Generated + private final String name; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of IsStringAdditionalProperties class. + * + * @param name the name value to set. + */ + @Generated + public IsStringAdditionalProperties(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the IsStringAdditionalProperties object itself. + */ + @Generated + public IsStringAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsStringAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsStringAdditionalProperties 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 IsStringAdditionalProperties. + */ + @Generated + public static IsStringAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getString()); + } + } + IsStringAdditionalProperties deserializedIsStringAdditionalProperties + = new IsStringAdditionalProperties(name); + deserializedIsStringAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedIsStringAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsUnknownAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsUnknownAdditionalProperties.java new file mode 100644 index 000000000..77f4d0d13 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsUnknownAdditionalProperties.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model is from Record<unknown> type. + */ +@Fluent +public class IsUnknownAdditionalProperties implements JsonSerializable { + /* + * The name property + */ + @Generated + private final String name; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of IsUnknownAdditionalProperties class. + * + * @param name the name value to set. + */ + @Generated + public IsUnknownAdditionalProperties(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the IsUnknownAdditionalProperties object itself. + */ + @Generated + public IsUnknownAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsUnknownAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsUnknownAdditionalProperties 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 IsUnknownAdditionalProperties. + */ + @Generated + public static IsUnknownAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.readUntyped()); + } + } + IsUnknownAdditionalProperties deserializedIsUnknownAdditionalProperties + = new IsUnknownAdditionalProperties(name); + deserializedIsUnknownAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedIsUnknownAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsUnknownAdditionalPropertiesDerived.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsUnknownAdditionalPropertiesDerived.java new file mode 100644 index 000000000..e2ef4a71a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsUnknownAdditionalPropertiesDerived.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from a type that is Record<unknown> type. + */ +@Fluent +public final class IsUnknownAdditionalPropertiesDerived extends IsUnknownAdditionalProperties { + /* + * The index property + */ + @Generated + private final int index; + + /* + * The age property + */ + @Generated + private Double age; + + /** + * Creates an instance of IsUnknownAdditionalPropertiesDerived class. + * + * @param name the name value to set. + * @param index the index value to set. + */ + @Generated + public IsUnknownAdditionalPropertiesDerived(String name, int index) { + super(name); + this.index = index; + } + + /** + * Get the index property: The index property. + * + * @return the index value. + */ + @Generated + public int getIndex() { + return this.index; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Generated + public Double getAge() { + return this.age; + } + + /** + * Set the age property: The age property. + * + * @param age the age value to set. + * @return the IsUnknownAdditionalPropertiesDerived object itself. + */ + @Generated + public IsUnknownAdditionalPropertiesDerived setAge(Double age) { + this.age = age; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeIntField("index", this.index); + jsonWriter.writeNumberField("age", this.age); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsUnknownAdditionalPropertiesDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsUnknownAdditionalPropertiesDerived 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 IsUnknownAdditionalPropertiesDerived. + */ + @Generated + public static IsUnknownAdditionalPropertiesDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int index = 0; + Double age = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("age".equals(fieldName)) { + age = reader.getNullable(JsonReader::getDouble); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.readUntyped()); + } + } + IsUnknownAdditionalPropertiesDerived deserializedIsUnknownAdditionalPropertiesDerived + = new IsUnknownAdditionalPropertiesDerived(name, index); + deserializedIsUnknownAdditionalPropertiesDerived.age = age; + deserializedIsUnknownAdditionalPropertiesDerived.setAdditionalProperties(additionalProperties); + + return deserializedIsUnknownAdditionalPropertiesDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsUnknownAdditionalPropertiesDiscriminated.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsUnknownAdditionalPropertiesDiscriminated.java new file mode 100644 index 000000000..b0192eb43 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsUnknownAdditionalPropertiesDiscriminated.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model is Record<unknown> with a discriminator. + */ +@Fluent +public class IsUnknownAdditionalPropertiesDiscriminated + implements JsonSerializable { + /* + * The discriminator + */ + @Generated + String kind; + + /* + * The name property + */ + @Generated + private final String name; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of IsUnknownAdditionalPropertiesDiscriminated class. + * + * @param name the name value to set. + */ + @Generated + public IsUnknownAdditionalPropertiesDiscriminated(String name) { + this.name = name; + this.kind = "IsUnknownAdditionalPropertiesDiscriminated"; + } + + /** + * Get the kind property: The discriminator. + * + * @return the kind value. + */ + @Generated + public String getKind() { + return this.kind; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the IsUnknownAdditionalPropertiesDiscriminated object itself. + */ + @Generated + public IsUnknownAdditionalPropertiesDiscriminated + setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + return jsonWriter.writeEndObject(); + } + + void toJsonShared(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("kind", this.kind); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + } + + /** + * Reads an instance of IsUnknownAdditionalPropertiesDiscriminated from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsUnknownAdditionalPropertiesDiscriminated 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 IsUnknownAdditionalPropertiesDiscriminated. + */ + @Generated + public static IsUnknownAdditionalPropertiesDiscriminated fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("derived".equals(discriminatorValue)) { + return IsUnknownAdditionalPropertiesDiscriminatedDerived.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static IsUnknownAdditionalPropertiesDiscriminated fromJsonKnownDiscriminator(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String kind = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.readUntyped()); + } + } + IsUnknownAdditionalPropertiesDiscriminated deserializedIsUnknownAdditionalPropertiesDiscriminated + = new IsUnknownAdditionalPropertiesDiscriminated(name); + deserializedIsUnknownAdditionalPropertiesDiscriminated.kind = kind; + deserializedIsUnknownAdditionalPropertiesDiscriminated.additionalProperties = additionalProperties; + + return deserializedIsUnknownAdditionalPropertiesDiscriminated; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsUnknownAdditionalPropertiesDiscriminatedDerived.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsUnknownAdditionalPropertiesDiscriminatedDerived.java new file mode 100644 index 000000000..692ee746d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/IsUnknownAdditionalPropertiesDiscriminatedDerived.java @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The derived discriminated type. + */ +@Fluent +public final class IsUnknownAdditionalPropertiesDiscriminatedDerived + extends IsUnknownAdditionalPropertiesDiscriminated { + /* + * The index property + */ + @Generated + private final int index; + + /* + * The age property + */ + @Generated + private Double age; + + /** + * Creates an instance of IsUnknownAdditionalPropertiesDiscriminatedDerived class. + * + * @param name the name value to set. + * @param index the index value to set. + */ + @Generated + public IsUnknownAdditionalPropertiesDiscriminatedDerived(String name, int index) { + super(name); + this.index = index; + this.kind = "derived"; + } + + /** + * Get the index property: The index property. + * + * @return the index value. + */ + @Generated + public int getIndex() { + return this.index; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Generated + public Double getAge() { + return this.age; + } + + /** + * Set the age property: The age property. + * + * @param age the age value to set. + * @return the IsUnknownAdditionalPropertiesDiscriminatedDerived object itself. + */ + @Generated + public IsUnknownAdditionalPropertiesDiscriminatedDerived setAge(Double age) { + this.age = age; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + toJsonShared(jsonWriter); + jsonWriter.writeIntField("index", this.index); + jsonWriter.writeNumberField("age", this.age); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsUnknownAdditionalPropertiesDiscriminatedDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsUnknownAdditionalPropertiesDiscriminatedDerived 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 IsUnknownAdditionalPropertiesDiscriminatedDerived. + */ + @Generated + public static IsUnknownAdditionalPropertiesDiscriminatedDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int index = 0; + String kind = "derived"; + Double age = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else if ("age".equals(fieldName)) { + age = reader.getNullable(JsonReader::getDouble); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.readUntyped()); + } + } + IsUnknownAdditionalPropertiesDiscriminatedDerived deserializedIsUnknownAdditionalPropertiesDiscriminatedDerived + = new IsUnknownAdditionalPropertiesDiscriminatedDerived(name, index); + deserializedIsUnknownAdditionalPropertiesDiscriminatedDerived.kind = kind; + deserializedIsUnknownAdditionalPropertiesDiscriminatedDerived.age = age; + deserializedIsUnknownAdditionalPropertiesDiscriminatedDerived.setAdditionalProperties(additionalProperties); + + return deserializedIsUnknownAdditionalPropertiesDiscriminatedDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ModelForRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ModelForRecord.java new file mode 100644 index 000000000..e941af282 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/ModelForRecord.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; + +/** + * model for record. + */ +@Immutable +public final class ModelForRecord implements JsonSerializable { + /* + * The state property + */ + @Generated + private final String state; + + /** + * Creates an instance of ModelForRecord class. + * + * @param state the state value to set. + */ + @Generated + public ModelForRecord(String state) { + this.state = state; + } + + /** + * Get the state property: The state property. + * + * @return the state value. + */ + @Generated + public String getState() { + return this.state; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("state", this.state); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelForRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelForRecord 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 ModelForRecord. + */ + @Generated + public static ModelForRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String state = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("state".equals(fieldName)) { + state = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ModelForRecord(state); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/MultipleSpreadRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/MultipleSpreadRecord.java new file mode 100644 index 000000000..17eb39295 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/MultipleSpreadRecord.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +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.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<string> and Record<float32>. + */ +@Fluent +public final class MultipleSpreadRecord implements JsonSerializable { + /* + * The name property + */ + @Generated + private final boolean flag; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of MultipleSpreadRecord class. + * + * @param flag the flag value to set. + */ + @Generated + public MultipleSpreadRecord(boolean flag) { + this.flag = flag; + } + + /** + * Get the flag property: The name property. + * + * @return the flag value. + */ + @Generated + public boolean isFlag() { + return this.flag; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the MultipleSpreadRecord object itself. + */ + @Generated + public MultipleSpreadRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("flag", this.flag); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), + additionalProperty.getValue() == null + ? null + : additionalProperty.getValue().toObject(Object.class)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MultipleSpreadRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MultipleSpreadRecord 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 MultipleSpreadRecord. + */ + @Generated + public static MultipleSpreadRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean flag = false; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("flag".equals(fieldName)) { + flag = reader.getBoolean(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + MultipleSpreadRecord deserializedMultipleSpreadRecord = new MultipleSpreadRecord(flag); + deserializedMultipleSpreadRecord.additionalProperties = additionalProperties; + + return deserializedMultipleSpreadRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadFloatRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadFloatRecord.java new file mode 100644 index 000000000..151205d30 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadFloatRecord.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<float32> with the same known property type. + */ +@Fluent +public final class SpreadFloatRecord implements JsonSerializable { + /* + * The id property + */ + @Generated + private final double id; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of SpreadFloatRecord class. + * + * @param id the id value to set. + */ + @Generated + public SpreadFloatRecord(double id) { + this.id = id; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Generated + public double getId() { + return this.id; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadFloatRecord object itself. + */ + @Generated + public SpreadFloatRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("id", this.id); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadFloatRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadFloatRecord 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 SpreadFloatRecord. + */ + @Generated + public static SpreadFloatRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double id = 0.0; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getDouble(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getDouble()); + } + } + SpreadFloatRecord deserializedSpreadFloatRecord = new SpreadFloatRecord(id); + deserializedSpreadFloatRecord.additionalProperties = additionalProperties; + + return deserializedSpreadFloatRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadModelArrayRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadModelArrayRecord.java new file mode 100644 index 000000000..bb0ec31ae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadModelArrayRecord.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * The SpreadModelArrayRecord model. + */ +@Fluent +public final class SpreadModelArrayRecord implements JsonSerializable { + /* + * The knownProp property. + */ + @Generated + private final List knownProp; + + /* + * Additional properties + */ + @Generated + private Map> additionalProperties; + + /** + * Creates an instance of SpreadModelArrayRecord class. + * + * @param knownProp the knownProp value to set. + */ + @Generated + public SpreadModelArrayRecord(List knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Generated + public List getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map> getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadModelArrayRecord object itself. + */ + @Generated + public SpreadModelArrayRecord setAdditionalProperties(Map> additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("knownProp", this.knownProp, (writer, element) -> writer.writeJson(element)); + if (additionalProperties != null) { + for (Map.Entry> additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadModelArrayRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadModelArrayRecord 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 SpreadModelArrayRecord. + */ + @Generated + public static SpreadModelArrayRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List knownProp = null; + Map> additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + List additionalPropertiesArrayItem + = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + additionalProperties.put(fieldName, additionalPropertiesArrayItem); + } + } + SpreadModelArrayRecord deserializedSpreadModelArrayRecord = new SpreadModelArrayRecord(knownProp); + deserializedSpreadModelArrayRecord.additionalProperties = additionalProperties; + + return deserializedSpreadModelArrayRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadModelRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadModelRecord.java new file mode 100644 index 000000000..263ecfd52 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadModelRecord.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<ModelForRecord> with the same known property type. + */ +@Fluent +public final class SpreadModelRecord implements JsonSerializable { + /* + * The knownProp property. + */ + @Generated + private final ModelForRecord knownProp; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of SpreadModelRecord class. + * + * @param knownProp the knownProp value to set. + */ + @Generated + public SpreadModelRecord(ModelForRecord knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Generated + public ModelForRecord getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadModelRecord object itself. + */ + @Generated + public SpreadModelRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("knownProp", this.knownProp); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadModelRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadModelRecord 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 SpreadModelRecord. + */ + @Generated + public static SpreadModelRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ModelForRecord knownProp = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = ModelForRecord.fromJson(reader); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, ModelForRecord.fromJson(reader)); + } + } + SpreadModelRecord deserializedSpreadModelRecord = new SpreadModelRecord(knownProp); + deserializedSpreadModelRecord.additionalProperties = additionalProperties; + + return deserializedSpreadModelRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForDiscriminatedUnion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForDiscriminatedUnion.java new file mode 100644 index 000000000..b30378ea4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForDiscriminatedUnion.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +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.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<WidgetData>. + */ +@Fluent +public final class SpreadRecordForDiscriminatedUnion implements JsonSerializable { + /* + * The name property + */ + @Generated + private final String name; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of SpreadRecordForDiscriminatedUnion class. + * + * @param name the name value to set. + */ + @Generated + public SpreadRecordForDiscriminatedUnion(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadRecordForDiscriminatedUnion object itself. + */ + @Generated + public SpreadRecordForDiscriminatedUnion setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), + additionalProperty.getValue() == null + ? null + : additionalProperty.getValue().toObject(Object.class)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadRecordForDiscriminatedUnion from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadRecordForDiscriminatedUnion 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 SpreadRecordForDiscriminatedUnion. + */ + @Generated + public static SpreadRecordForDiscriminatedUnion fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + SpreadRecordForDiscriminatedUnion deserializedSpreadRecordForDiscriminatedUnion + = new SpreadRecordForDiscriminatedUnion(name); + deserializedSpreadRecordForDiscriminatedUnion.additionalProperties = additionalProperties; + + return deserializedSpreadRecordForDiscriminatedUnion; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForNonDiscriminatedUnion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForNonDiscriminatedUnion.java new file mode 100644 index 000000000..0a16a95d0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForNonDiscriminatedUnion.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +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.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<WidgetData0 | WidgetData1>. + */ +@Fluent +public final class SpreadRecordForNonDiscriminatedUnion + implements JsonSerializable { + /* + * The name property + */ + @Generated + private final String name; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of SpreadRecordForNonDiscriminatedUnion class. + * + * @param name the name value to set. + */ + @Generated + public SpreadRecordForNonDiscriminatedUnion(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadRecordForNonDiscriminatedUnion object itself. + */ + @Generated + public SpreadRecordForNonDiscriminatedUnion setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), + additionalProperty.getValue() == null + ? null + : additionalProperty.getValue().toObject(Object.class)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadRecordForNonDiscriminatedUnion from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadRecordForNonDiscriminatedUnion 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 SpreadRecordForNonDiscriminatedUnion. + */ + @Generated + public static SpreadRecordForNonDiscriminatedUnion fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + SpreadRecordForNonDiscriminatedUnion deserializedSpreadRecordForNonDiscriminatedUnion + = new SpreadRecordForNonDiscriminatedUnion(name); + deserializedSpreadRecordForNonDiscriminatedUnion.additionalProperties = additionalProperties; + + return deserializedSpreadRecordForNonDiscriminatedUnion; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForNonDiscriminatedUnion2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForNonDiscriminatedUnion2.java new file mode 100644 index 000000000..0f6160220 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForNonDiscriminatedUnion2.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +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.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<WidgetData2 | WidgetData1>. + */ +@Fluent +public final class SpreadRecordForNonDiscriminatedUnion2 + implements JsonSerializable { + /* + * The name property + */ + @Generated + private final String name; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of SpreadRecordForNonDiscriminatedUnion2 class. + * + * @param name the name value to set. + */ + @Generated + public SpreadRecordForNonDiscriminatedUnion2(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadRecordForNonDiscriminatedUnion2 object itself. + */ + @Generated + public SpreadRecordForNonDiscriminatedUnion2 setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), + additionalProperty.getValue() == null + ? null + : additionalProperty.getValue().toObject(Object.class)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadRecordForNonDiscriminatedUnion2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadRecordForNonDiscriminatedUnion2 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 SpreadRecordForNonDiscriminatedUnion2. + */ + @Generated + public static SpreadRecordForNonDiscriminatedUnion2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + SpreadRecordForNonDiscriminatedUnion2 deserializedSpreadRecordForNonDiscriminatedUnion2 + = new SpreadRecordForNonDiscriminatedUnion2(name); + deserializedSpreadRecordForNonDiscriminatedUnion2.additionalProperties = additionalProperties; + + return deserializedSpreadRecordForNonDiscriminatedUnion2; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForNonDiscriminatedUnion3.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForNonDiscriminatedUnion3.java new file mode 100644 index 000000000..63be6ef06 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForNonDiscriminatedUnion3.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +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.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<WidgetData2[] | WidgetData1>. + */ +@Fluent +public final class SpreadRecordForNonDiscriminatedUnion3 + implements JsonSerializable { + /* + * The name property + */ + @Generated + private final String name; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of SpreadRecordForNonDiscriminatedUnion3 class. + * + * @param name the name value to set. + */ + @Generated + public SpreadRecordForNonDiscriminatedUnion3(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadRecordForNonDiscriminatedUnion3 object itself. + */ + @Generated + public SpreadRecordForNonDiscriminatedUnion3 setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), + additionalProperty.getValue() == null + ? null + : additionalProperty.getValue().toObject(Object.class)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadRecordForNonDiscriminatedUnion3 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadRecordForNonDiscriminatedUnion3 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 SpreadRecordForNonDiscriminatedUnion3. + */ + @Generated + public static SpreadRecordForNonDiscriminatedUnion3 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + SpreadRecordForNonDiscriminatedUnion3 deserializedSpreadRecordForNonDiscriminatedUnion3 + = new SpreadRecordForNonDiscriminatedUnion3(name); + deserializedSpreadRecordForNonDiscriminatedUnion3.additionalProperties = additionalProperties; + + return deserializedSpreadRecordForNonDiscriminatedUnion3; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForUnion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForUnion.java new file mode 100644 index 000000000..a8689acb2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadRecordForUnion.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +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.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<string | float32>. + */ +@Fluent +public final class SpreadRecordForUnion implements JsonSerializable { + /* + * The name property + */ + @Generated + private final boolean flag; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of SpreadRecordForUnion class. + * + * @param flag the flag value to set. + */ + @Generated + public SpreadRecordForUnion(boolean flag) { + this.flag = flag; + } + + /** + * Get the flag property: The name property. + * + * @return the flag value. + */ + @Generated + public boolean isFlag() { + return this.flag; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadRecordForUnion object itself. + */ + @Generated + public SpreadRecordForUnion setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("flag", this.flag); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), + additionalProperty.getValue() == null + ? null + : additionalProperty.getValue().toObject(Object.class)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadRecordForUnion from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadRecordForUnion 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 SpreadRecordForUnion. + */ + @Generated + public static SpreadRecordForUnion fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean flag = false; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("flag".equals(fieldName)) { + flag = reader.getBoolean(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + SpreadRecordForUnion deserializedSpreadRecordForUnion = new SpreadRecordForUnion(flag); + deserializedSpreadRecordForUnion.additionalProperties = additionalProperties; + + return deserializedSpreadRecordForUnion; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadStringRecord.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadStringRecord.java new file mode 100644 index 000000000..85a22abd7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/SpreadStringRecord.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<string> with the same known property type. + */ +@Fluent +public final class SpreadStringRecord implements JsonSerializable { + /* + * The name property + */ + @Generated + private final String name; + + /* + * Additional properties + */ + @Generated + private Map additionalProperties; + + /** + * Creates an instance of SpreadStringRecord class. + * + * @param name the name value to set. + */ + @Generated + public SpreadStringRecord(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Generated + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadStringRecord object itself. + */ + @Generated + public SpreadStringRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadStringRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadStringRecord 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 SpreadStringRecord. + */ + @Generated + public static SpreadStringRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getString()); + } + } + SpreadStringRecord deserializedSpreadStringRecord = new SpreadStringRecord(name); + deserializedSpreadStringRecord.additionalProperties = additionalProperties; + + return deserializedSpreadStringRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/WidgetData0.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/WidgetData0.java new file mode 100644 index 000000000..1150e828b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/WidgetData0.java @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; + +/** + * The WidgetData0 model. + */ +@Immutable +public final class WidgetData0 implements JsonSerializable { + /* + * The kind property. + */ + @Generated + private final String kind = "kind0"; + + /* + * The fooProp property. + */ + @Generated + private final String fooProp; + + /** + * Creates an instance of WidgetData0 class. + * + * @param fooProp the fooProp value to set. + */ + @Generated + public WidgetData0(String fooProp) { + this.fooProp = fooProp; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Generated + public String getKind() { + return this.kind; + } + + /** + * Get the fooProp property: The fooProp property. + * + * @return the fooProp value. + */ + @Generated + public String getFooProp() { + return this.fooProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeStringField("fooProp", this.fooProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of WidgetData0 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WidgetData0 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 WidgetData0. + */ + @Generated + public static WidgetData0 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String fooProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("fooProp".equals(fieldName)) { + fooProp = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new WidgetData0(fooProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/WidgetData1.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/WidgetData1.java new file mode 100644 index 000000000..48dab187d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/WidgetData1.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +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.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * The WidgetData1 model. + */ +@Fluent +public final class WidgetData1 implements JsonSerializable { + /* + * The kind property. + */ + @Generated + private final String kind = "kind1"; + + /* + * The start property. + */ + @Generated + private final OffsetDateTime start; + + /* + * The end property. + */ + @Generated + private OffsetDateTime end; + + /** + * Creates an instance of WidgetData1 class. + * + * @param start the start value to set. + */ + @Generated + public WidgetData1(OffsetDateTime start) { + this.start = start; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Generated + public String getKind() { + return this.kind; + } + + /** + * Get the start property: The start property. + * + * @return the start value. + */ + @Generated + public OffsetDateTime getStart() { + return this.start; + } + + /** + * Get the end property: The end property. + * + * @return the end value. + */ + @Generated + public OffsetDateTime getEnd() { + return this.end; + } + + /** + * Set the end property: The end property. + * + * @param end the end value to set. + * @return the WidgetData1 object itself. + */ + @Generated + public WidgetData1 setEnd(OffsetDateTime end) { + this.end = end; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeStringField("start", + this.start == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.start)); + jsonWriter.writeStringField("end", + this.end == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.end)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of WidgetData1 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WidgetData1 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 WidgetData1. + */ + @Generated + public static WidgetData1 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime start = null; + OffsetDateTime end = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("start".equals(fieldName)) { + start = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("end".equals(fieldName)) { + end = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + WidgetData1 deserializedWidgetData1 = new WidgetData1(start); + deserializedWidgetData1.end = end; + + return deserializedWidgetData1; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/WidgetData2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/WidgetData2.java new file mode 100644 index 000000000..ede0038f4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/WidgetData2.java @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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; + +/** + * The WidgetData2 model. + */ +@Immutable +public final class WidgetData2 implements JsonSerializable { + /* + * The kind property. + */ + @Generated + private final String kind = "kind1"; + + /* + * The start property. + */ + @Generated + private final String start; + + /** + * Creates an instance of WidgetData2 class. + * + * @param start the start value to set. + */ + @Generated + public WidgetData2(String start) { + this.start = start; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Generated + public String getKind() { + return this.kind; + } + + /** + * Get the start property: The start property. + * + * @return the start value. + */ + @Generated + public String getStart() { + return this.start; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeStringField("start", this.start); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of WidgetData2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WidgetData2 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 WidgetData2. + */ + @Generated + public static WidgetData2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String start = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("start".equals(fieldName)) { + start = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new WidgetData2(start); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/models/package-info.java new file mode 100644 index 000000000..300d2ca2f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/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 AdditionalProperties. + * Tests for additional properties of models. + * + */ +package com.type.property.additionalproperties.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/package-info.java new file mode 100644 index 000000000..4dd402de1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/additionalproperties/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 AdditionalProperties. + * Tests for additional properties of models. + * + */ +package com.type.property.additionalproperties; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/BytesAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/BytesAsyncClient.java new file mode 100644 index 000000000..dc15c34de --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/BytesAsyncClient.java @@ -0,0 +1,229 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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 com.type.property.nullable.implementation.BytesImpl; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.models.BytesProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class, isAsync = true) +public final class BytesAsyncClient { + @Generated + private final BytesImpl serviceClient; + + /** + * Initializes an instance of BytesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BytesAsyncClient(BytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BytesProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BytesProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(BytesProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getBytesPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getBytesPropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNonNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(BytesProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getBytesPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getBytesPropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/BytesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/BytesClient.java new file mode 100644 index 000000000..d8ae75cd3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/BytesClient.java @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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.type.property.nullable.implementation.BytesImpl; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.models.BytesProperty; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class BytesClient { + @Generated + private final BytesImpl serviceClient; + + /** + * Initializes an instance of BytesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BytesClient(BytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BytesProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue().toObject(BytesProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BytesProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue().toObject(BytesProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(BytesProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getBytesPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getBytesPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(BytesProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getBytesPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getBytesPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsByteAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsByteAsyncClient.java new file mode 100644 index 000000000..85e397e71 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsByteAsyncClient.java @@ -0,0 +1,237 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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 com.type.property.nullable.implementation.CollectionsBytesImpl; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.models.CollectionsByteProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class, isAsync = true) +public final class CollectionsByteAsyncClient { + @Generated + private final CollectionsBytesImpl serviceClient; + + /** + * Initializes an instance of CollectionsByteAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsByteAsyncClient(CollectionsBytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsByteProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsByteProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(CollectionsByteProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsBytePropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsBytePropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNonNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(CollectionsByteProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsBytePropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsBytePropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsByteClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsByteClient.java new file mode 100644 index 000000000..058ede5f1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsByteClient.java @@ -0,0 +1,229 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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.type.property.nullable.implementation.CollectionsBytesImpl; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.models.CollectionsByteProperty; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class CollectionsByteClient { + @Generated + private final CollectionsBytesImpl serviceClient; + + /** + * Initializes an instance of CollectionsByteClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsByteClient(CollectionsBytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsByteProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue().toObject(CollectionsByteProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsByteProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue().toObject(CollectionsByteProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(CollectionsByteProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsBytePropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsBytePropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(CollectionsByteProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsBytePropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsBytePropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsModelAsyncClient.java new file mode 100644 index 000000000..a0aca8862 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsModelAsyncClient.java @@ -0,0 +1,245 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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 com.type.property.nullable.implementation.CollectionsModelsImpl; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.models.CollectionsModelProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class, isAsync = true) +public final class CollectionsModelAsyncClient { + @Generated + private final CollectionsModelsImpl serviceClient; + + /** + * Initializes an instance of CollectionsModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsModelAsyncClient(CollectionsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsModelProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsModelProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(CollectionsModelProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsModelPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsModelPropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNonNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(CollectionsModelProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsModelPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsModelPropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsModelClient.java new file mode 100644 index 000000000..ce1d4f5cc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsModelClient.java @@ -0,0 +1,237 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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.type.property.nullable.implementation.CollectionsModelsImpl; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.models.CollectionsModelProperty; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class CollectionsModelClient { + @Generated + private final CollectionsModelsImpl serviceClient; + + /** + * Initializes an instance of CollectionsModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsModelClient(CollectionsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsModelProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue().toObject(CollectionsModelProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsModelProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue().toObject(CollectionsModelProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(CollectionsModelProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsModelPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsModelPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(CollectionsModelProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsModelPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsModelPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsStringAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsStringAsyncClient.java new file mode 100644 index 000000000..a7a9cfdb5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsStringAsyncClient.java @@ -0,0 +1,237 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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 com.type.property.nullable.implementation.CollectionsStringsImpl; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.models.CollectionsStringProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class, isAsync = true) +public final class CollectionsStringAsyncClient { + @Generated + private final CollectionsStringsImpl serviceClient; + + /** + * Initializes an instance of CollectionsStringAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsStringAsyncClient(CollectionsStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsStringProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsStringProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(CollectionsStringProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsStringPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsStringPropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNonNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(CollectionsStringProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsStringPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsStringPropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsStringClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsStringClient.java new file mode 100644 index 000000000..3329a9e43 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/CollectionsStringClient.java @@ -0,0 +1,229 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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.type.property.nullable.implementation.CollectionsStringsImpl; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.models.CollectionsStringProperty; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class CollectionsStringClient { + @Generated + private final CollectionsStringsImpl serviceClient; + + /** + * Initializes an instance of CollectionsStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsStringClient(CollectionsStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsStringProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue().toObject(CollectionsStringProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsStringProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue().toObject(CollectionsStringProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(CollectionsStringProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsStringPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsStringPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(CollectionsStringProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsStringPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsStringPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/DatetimeOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/DatetimeOperationAsyncClient.java new file mode 100644 index 000000000..ef61ca233 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/DatetimeOperationAsyncClient.java @@ -0,0 +1,229 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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 com.type.property.nullable.implementation.DatetimeOperationsImpl; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.models.DatetimeProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class, isAsync = true) +public final class DatetimeOperationAsyncClient { + @Generated + private final DatetimeOperationsImpl serviceClient; + + /** + * Initializes an instance of DatetimeOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DatetimeOperationAsyncClient(DatetimeOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DatetimeProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DatetimeProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(DatetimeProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDatetimePropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDatetimePropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNonNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(DatetimeProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDatetimePropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDatetimePropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/DatetimeOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/DatetimeOperationClient.java new file mode 100644 index 000000000..dfeb42ff6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/DatetimeOperationClient.java @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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.type.property.nullable.implementation.DatetimeOperationsImpl; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.models.DatetimeProperty; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class DatetimeOperationClient { + @Generated + private final DatetimeOperationsImpl serviceClient; + + /** + * Initializes an instance of DatetimeOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DatetimeOperationClient(DatetimeOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DatetimeProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue().toObject(DatetimeProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DatetimeProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue().toObject(DatetimeProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(DatetimeProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDatetimePropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDatetimePropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(DatetimeProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDatetimePropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDatetimePropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/DurationOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/DurationOperationAsyncClient.java new file mode 100644 index 000000000..376670438 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/DurationOperationAsyncClient.java @@ -0,0 +1,229 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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 com.type.property.nullable.implementation.DurationOperationsImpl; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.models.DurationProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class, isAsync = true) +public final class DurationOperationAsyncClient { + @Generated + private final DurationOperationsImpl serviceClient; + + /** + * Initializes an instance of DurationOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DurationOperationAsyncClient(DurationOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DurationProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DurationProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(DurationProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDurationPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDurationPropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNonNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(DurationProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDurationPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDurationPropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/DurationOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/DurationOperationClient.java new file mode 100644 index 000000000..e3a7cd47f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/DurationOperationClient.java @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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.type.property.nullable.implementation.DurationOperationsImpl; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.models.DurationProperty; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class DurationOperationClient { + @Generated + private final DurationOperationsImpl serviceClient; + + /** + * Initializes an instance of DurationOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DurationOperationClient(DurationOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DurationProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue().toObject(DurationProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DurationProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue().toObject(DurationProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(DurationProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDurationPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDurationPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(DurationProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDurationPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDurationPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/NullableClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/NullableClientBuilder.java new file mode 100644 index 000000000..2fd868406 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/NullableClientBuilder.java @@ -0,0 +1,422 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.property.nullable.implementation.NullableClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the NullableClient type. + */ +@ServiceClientBuilder( + serviceClients = { + StringOperationClient.class, + BytesClient.class, + DatetimeOperationClient.class, + DurationOperationClient.class, + CollectionsByteClient.class, + CollectionsModelClient.class, + CollectionsStringClient.class, + StringOperationAsyncClient.class, + BytesAsyncClient.class, + DatetimeOperationAsyncClient.class, + DurationOperationAsyncClient.class, + CollectionsByteAsyncClient.class, + CollectionsModelAsyncClient.class, + CollectionsStringAsyncClient.class }) +public final class NullableClientBuilder 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("type-property-nullable.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the NullableClientBuilder. + */ + @Generated + public NullableClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NullableClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NullableClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NullableClientBuilder 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 NullableClientBuilder 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 NullableClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NullableClientBuilder 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 NullableClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public NullableClientBuilder 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 NullableClientBuilder. + */ + @Generated + public NullableClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of NullableClientImpl with the provided parameters. + * + * @return an instance of NullableClientImpl. + */ + @Generated + private NullableClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + NullableClientImpl client + = new NullableClientImpl(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 StringOperationAsyncClient class. + * + * @return an instance of StringOperationAsyncClient. + */ + @Generated + public StringOperationAsyncClient buildStringOperationAsyncClient() { + return new StringOperationAsyncClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of BytesAsyncClient class. + * + * @return an instance of BytesAsyncClient. + */ + @Generated + public BytesAsyncClient buildBytesAsyncClient() { + return new BytesAsyncClient(buildInnerClient().getBytes()); + } + + /** + * Builds an instance of DatetimeOperationAsyncClient class. + * + * @return an instance of DatetimeOperationAsyncClient. + */ + @Generated + public DatetimeOperationAsyncClient buildDatetimeOperationAsyncClient() { + return new DatetimeOperationAsyncClient(buildInnerClient().getDatetimeOperations()); + } + + /** + * Builds an instance of DurationOperationAsyncClient class. + * + * @return an instance of DurationOperationAsyncClient. + */ + @Generated + public DurationOperationAsyncClient buildDurationOperationAsyncClient() { + return new DurationOperationAsyncClient(buildInnerClient().getDurationOperations()); + } + + /** + * Builds an instance of CollectionsByteAsyncClient class. + * + * @return an instance of CollectionsByteAsyncClient. + */ + @Generated + public CollectionsByteAsyncClient buildCollectionsByteAsyncClient() { + return new CollectionsByteAsyncClient(buildInnerClient().getCollectionsBytes()); + } + + /** + * Builds an instance of CollectionsModelAsyncClient class. + * + * @return an instance of CollectionsModelAsyncClient. + */ + @Generated + public CollectionsModelAsyncClient buildCollectionsModelAsyncClient() { + return new CollectionsModelAsyncClient(buildInnerClient().getCollectionsModels()); + } + + /** + * Builds an instance of CollectionsStringAsyncClient class. + * + * @return an instance of CollectionsStringAsyncClient. + */ + @Generated + public CollectionsStringAsyncClient buildCollectionsStringAsyncClient() { + return new CollectionsStringAsyncClient(buildInnerClient().getCollectionsStrings()); + } + + /** + * Builds an instance of StringOperationClient class. + * + * @return an instance of StringOperationClient. + */ + @Generated + public StringOperationClient buildStringOperationClient() { + return new StringOperationClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of BytesClient class. + * + * @return an instance of BytesClient. + */ + @Generated + public BytesClient buildBytesClient() { + return new BytesClient(buildInnerClient().getBytes()); + } + + /** + * Builds an instance of DatetimeOperationClient class. + * + * @return an instance of DatetimeOperationClient. + */ + @Generated + public DatetimeOperationClient buildDatetimeOperationClient() { + return new DatetimeOperationClient(buildInnerClient().getDatetimeOperations()); + } + + /** + * Builds an instance of DurationOperationClient class. + * + * @return an instance of DurationOperationClient. + */ + @Generated + public DurationOperationClient buildDurationOperationClient() { + return new DurationOperationClient(buildInnerClient().getDurationOperations()); + } + + /** + * Builds an instance of CollectionsByteClient class. + * + * @return an instance of CollectionsByteClient. + */ + @Generated + public CollectionsByteClient buildCollectionsByteClient() { + return new CollectionsByteClient(buildInnerClient().getCollectionsBytes()); + } + + /** + * Builds an instance of CollectionsModelClient class. + * + * @return an instance of CollectionsModelClient. + */ + @Generated + public CollectionsModelClient buildCollectionsModelClient() { + return new CollectionsModelClient(buildInnerClient().getCollectionsModels()); + } + + /** + * Builds an instance of CollectionsStringClient class. + * + * @return an instance of CollectionsStringClient. + */ + @Generated + public CollectionsStringClient buildCollectionsStringClient() { + return new CollectionsStringClient(buildInnerClient().getCollectionsStrings()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NullableClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/StringOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/StringOperationAsyncClient.java new file mode 100644 index 000000000..64cc982cf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/StringOperationAsyncClient.java @@ -0,0 +1,229 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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 com.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.implementation.StringOperationsImpl; +import com.type.property.nullable.models.StringProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class, isAsync = true) +public final class StringOperationAsyncClient { + @Generated + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of StringOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringOperationAsyncClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(StringProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(StringProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(StringProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getStringPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getStringPropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNonNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(StringProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getStringPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getStringPropertyAccessor().prepareModelForJsonMergePatch(body, false); + return patchNullWithResponse(bodyInBinaryData, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/StringOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/StringOperationClient.java new file mode 100644 index 000000000..3ec28d6f8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/StringOperationClient.java @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable; + +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.type.property.nullable.implementation.JsonMergePatchHelper; +import com.type.property.nullable.implementation.StringOperationsImpl; +import com.type.property.nullable.models.StringProperty; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class StringOperationClient { + @Generated + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of StringOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringOperationClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public StringProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue().toObject(StringProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public StringProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue().toObject(StringProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 patchNonNull(StringProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getStringPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getStringPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 patchNull(StringProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getStringPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getStringPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/BytesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/BytesImpl.java new file mode 100644 index 000000000..a84d26ea0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/BytesImpl.java @@ -0,0 +1,339 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +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.BinaryData; +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 Bytes. + */ +public final class BytesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BytesService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of BytesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BytesImpl(NullableClientImpl client) { + this.service = RestProxy.create(BytesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientBytes to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NullableClientBytes") + public interface BytesService { + @Get("/type/property/nullable/bytes/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/bytes/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/bytes/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/bytes/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/bytes/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/bytes/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/bytes/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/bytes/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/CollectionsBytesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/CollectionsBytesImpl.java new file mode 100644 index 000000000..6d1cccfcb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/CollectionsBytesImpl.java @@ -0,0 +1,356 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +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.BinaryData; +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 CollectionsBytes. + */ +public final class CollectionsBytesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsBytesService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of CollectionsBytesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsBytesImpl(NullableClientImpl client) { + this.service + = RestProxy.create(CollectionsBytesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientCollectionsBytes to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NullableClientCollec") + public interface CollectionsBytesService { + @Get("/type/property/nullable/collections/bytes/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/collections/bytes/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/collections/bytes/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/collections/bytes/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/collections/bytes/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/collections/bytes/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/collections/bytes/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/collections/bytes/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/CollectionsModelsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/CollectionsModelsImpl.java new file mode 100644 index 000000000..c1d453e10 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/CollectionsModelsImpl.java @@ -0,0 +1,372 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +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.BinaryData; +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 CollectionsModels. + */ +public final class CollectionsModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsModelsService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of CollectionsModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsModelsImpl(NullableClientImpl client) { + this.service + = RestProxy.create(CollectionsModelsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientCollectionsModels to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NullableClientCollec") + public interface CollectionsModelsService { + @Get("/type/property/nullable/collections/model/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/collections/model/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/collections/model/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/collections/model/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/collections/model/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/collections/model/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/collections/model/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/collections/model/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/CollectionsStringsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/CollectionsStringsImpl.java new file mode 100644 index 000000000..d6cd65ef0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/CollectionsStringsImpl.java @@ -0,0 +1,356 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +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.BinaryData; +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 CollectionsStrings. + */ +public final class CollectionsStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsStringsService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of CollectionsStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsStringsImpl(NullableClientImpl client) { + this.service = RestProxy.create(CollectionsStringsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientCollectionsStrings to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NullableClientCollec") + public interface CollectionsStringsService { + @Get("/type/property/nullable/collections/string/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/collections/string/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/collections/string/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/collections/string/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/collections/string/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/collections/string/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/collections/string/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/collections/string/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/DatetimeOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/DatetimeOperationsImpl.java new file mode 100644 index 000000000..d4356df4d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/DatetimeOperationsImpl.java @@ -0,0 +1,340 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +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.BinaryData; +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 DatetimeOperations. + */ +public final class DatetimeOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DatetimeOperationsService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of DatetimeOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DatetimeOperationsImpl(NullableClientImpl client) { + this.service = RestProxy.create(DatetimeOperationsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientDatetimeOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NullableClientDateti") + public interface DatetimeOperationsService { + @Get("/type/property/nullable/datetime/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/datetime/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/datetime/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/datetime/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/datetime/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/datetime/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/datetime/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/datetime/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/DurationOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/DurationOperationsImpl.java new file mode 100644 index 000000000..c4f14abab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/DurationOperationsImpl.java @@ -0,0 +1,340 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +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.BinaryData; +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 DurationOperations. + */ +public final class DurationOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DurationOperationsService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of DurationOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DurationOperationsImpl(NullableClientImpl client) { + this.service = RestProxy.create(DurationOperationsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientDurationOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NullableClientDurati") + public interface DurationOperationsService { + @Get("/type/property/nullable/duration/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/duration/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/duration/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/duration/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/duration/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/duration/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/duration/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/duration/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/JsonMergePatchHelper.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/JsonMergePatchHelper.java new file mode 100644 index 000000000..2aab9a3cd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/JsonMergePatchHelper.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.implementation; + +import com.type.property.nullable.models.BytesProperty; +import com.type.property.nullable.models.CollectionsByteProperty; +import com.type.property.nullable.models.CollectionsModelProperty; +import com.type.property.nullable.models.CollectionsStringProperty; +import com.type.property.nullable.models.DatetimeProperty; +import com.type.property.nullable.models.DurationProperty; +import com.type.property.nullable.models.InnerModel; +import com.type.property.nullable.models.StringProperty; + +/** + * This is the Helper class to enable json merge patch serialization for a model. + */ +public class JsonMergePatchHelper { + private static StringPropertyAccessor stringPropertyAccessor; + + public interface StringPropertyAccessor { + StringProperty prepareModelForJsonMergePatch(StringProperty stringProperty, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(StringProperty stringProperty); + } + + public static void setStringPropertyAccessor(StringPropertyAccessor accessor) { + stringPropertyAccessor = accessor; + } + + public static StringPropertyAccessor getStringPropertyAccessor() { + return stringPropertyAccessor; + } + + private static BytesPropertyAccessor bytesPropertyAccessor; + + public interface BytesPropertyAccessor { + BytesProperty prepareModelForJsonMergePatch(BytesProperty bytesProperty, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(BytesProperty bytesProperty); + } + + public static void setBytesPropertyAccessor(BytesPropertyAccessor accessor) { + bytesPropertyAccessor = accessor; + } + + public static BytesPropertyAccessor getBytesPropertyAccessor() { + return bytesPropertyAccessor; + } + + private static DatetimePropertyAccessor datetimePropertyAccessor; + + public interface DatetimePropertyAccessor { + DatetimeProperty prepareModelForJsonMergePatch(DatetimeProperty datetimeProperty, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(DatetimeProperty datetimeProperty); + } + + public static void setDatetimePropertyAccessor(DatetimePropertyAccessor accessor) { + datetimePropertyAccessor = accessor; + } + + public static DatetimePropertyAccessor getDatetimePropertyAccessor() { + return datetimePropertyAccessor; + } + + private static DurationPropertyAccessor durationPropertyAccessor; + + public interface DurationPropertyAccessor { + DurationProperty prepareModelForJsonMergePatch(DurationProperty durationProperty, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(DurationProperty durationProperty); + } + + public static void setDurationPropertyAccessor(DurationPropertyAccessor accessor) { + durationPropertyAccessor = accessor; + } + + public static DurationPropertyAccessor getDurationPropertyAccessor() { + return durationPropertyAccessor; + } + + private static CollectionsBytePropertyAccessor collectionsBytePropertyAccessor; + + public interface CollectionsBytePropertyAccessor { + CollectionsByteProperty prepareModelForJsonMergePatch(CollectionsByteProperty collectionsByteProperty, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(CollectionsByteProperty collectionsByteProperty); + } + + public static void setCollectionsBytePropertyAccessor(CollectionsBytePropertyAccessor accessor) { + collectionsBytePropertyAccessor = accessor; + } + + public static CollectionsBytePropertyAccessor getCollectionsBytePropertyAccessor() { + return collectionsBytePropertyAccessor; + } + + private static CollectionsModelPropertyAccessor collectionsModelPropertyAccessor; + + public interface CollectionsModelPropertyAccessor { + CollectionsModelProperty prepareModelForJsonMergePatch(CollectionsModelProperty collectionsModelProperty, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(CollectionsModelProperty collectionsModelProperty); + } + + public static void setCollectionsModelPropertyAccessor(CollectionsModelPropertyAccessor accessor) { + collectionsModelPropertyAccessor = accessor; + } + + public static CollectionsModelPropertyAccessor getCollectionsModelPropertyAccessor() { + return collectionsModelPropertyAccessor; + } + + private static InnerModelAccessor innerModelAccessor; + + public interface InnerModelAccessor { + InnerModel prepareModelForJsonMergePatch(InnerModel innerModel, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(InnerModel innerModel); + } + + public static void setInnerModelAccessor(InnerModelAccessor accessor) { + innerModelAccessor = accessor; + } + + public static InnerModelAccessor getInnerModelAccessor() { + return innerModelAccessor; + } + + private static CollectionsStringPropertyAccessor collectionsStringPropertyAccessor; + + public interface CollectionsStringPropertyAccessor { + CollectionsStringProperty prepareModelForJsonMergePatch(CollectionsStringProperty collectionsStringProperty, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(CollectionsStringProperty collectionsStringProperty); + } + + public static void setCollectionsStringPropertyAccessor(CollectionsStringPropertyAccessor accessor) { + collectionsStringPropertyAccessor = accessor; + } + + public static CollectionsStringPropertyAccessor getCollectionsStringPropertyAccessor() { + return collectionsStringPropertyAccessor; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/NullableClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/NullableClientImpl.java new file mode 100644 index 000000000..25e685719 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/NullableClientImpl.java @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the NullableClient type. + */ +public final class NullableClientImpl { + /** + * 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; + } + + /** + * The StringOperationsImpl object to access its operations. + */ + private final StringOperationsImpl stringOperations; + + /** + * Gets the StringOperationsImpl object to access its operations. + * + * @return the StringOperationsImpl object. + */ + public StringOperationsImpl getStringOperations() { + return this.stringOperations; + } + + /** + * The BytesImpl object to access its operations. + */ + private final BytesImpl bytes; + + /** + * Gets the BytesImpl object to access its operations. + * + * @return the BytesImpl object. + */ + public BytesImpl getBytes() { + return this.bytes; + } + + /** + * The DatetimeOperationsImpl object to access its operations. + */ + private final DatetimeOperationsImpl datetimeOperations; + + /** + * Gets the DatetimeOperationsImpl object to access its operations. + * + * @return the DatetimeOperationsImpl object. + */ + public DatetimeOperationsImpl getDatetimeOperations() { + return this.datetimeOperations; + } + + /** + * The DurationOperationsImpl object to access its operations. + */ + private final DurationOperationsImpl durationOperations; + + /** + * Gets the DurationOperationsImpl object to access its operations. + * + * @return the DurationOperationsImpl object. + */ + public DurationOperationsImpl getDurationOperations() { + return this.durationOperations; + } + + /** + * The CollectionsBytesImpl object to access its operations. + */ + private final CollectionsBytesImpl collectionsBytes; + + /** + * Gets the CollectionsBytesImpl object to access its operations. + * + * @return the CollectionsBytesImpl object. + */ + public CollectionsBytesImpl getCollectionsBytes() { + return this.collectionsBytes; + } + + /** + * The CollectionsModelsImpl object to access its operations. + */ + private final CollectionsModelsImpl collectionsModels; + + /** + * Gets the CollectionsModelsImpl object to access its operations. + * + * @return the CollectionsModelsImpl object. + */ + public CollectionsModelsImpl getCollectionsModels() { + return this.collectionsModels; + } + + /** + * The CollectionsStringsImpl object to access its operations. + */ + private final CollectionsStringsImpl collectionsStrings; + + /** + * Gets the CollectionsStringsImpl object to access its operations. + * + * @return the CollectionsStringsImpl object. + */ + public CollectionsStringsImpl getCollectionsStrings() { + return this.collectionsStrings; + } + + /** + * Initializes an instance of NullableClient client. + * + * @param endpoint Service host. + */ + public NullableClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NullableClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public NullableClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of NullableClient 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 NullableClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.stringOperations = new StringOperationsImpl(this); + this.bytes = new BytesImpl(this); + this.datetimeOperations = new DatetimeOperationsImpl(this); + this.durationOperations = new DurationOperationsImpl(this); + this.collectionsBytes = new CollectionsBytesImpl(this); + this.collectionsModels = new CollectionsModelsImpl(this); + this.collectionsStrings = new CollectionsStringsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/StringOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/StringOperationsImpl.java new file mode 100644 index 000000000..c4b61dcb8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/StringOperationsImpl.java @@ -0,0 +1,340 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +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.BinaryData; +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 StringOperations. + */ +public final class StringOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringOperationsService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of StringOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringOperationsImpl(NullableClientImpl client) { + this.service + = RestProxy.create(StringOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientStringOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "NullableClientString") + public interface StringOperationsService { + @Get("/type/property/nullable/string/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/string/non-null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/string/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNull(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/nullable/string/null") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNullSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/string/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNonNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/string/non-null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/string/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> patchNull(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Patch("/type/property/nullable/string/null") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNonNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNonNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNullWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNull(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNonNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNonNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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> patchNullWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return FluxUtil.withContext( + context -> service.patchNull(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+ * + * @param body The body 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 patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/implementation/package-info.java new file mode 100644 index 000000000..e40199df9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/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 Nullable. + * Illustrates models with nullable properties. + * + */ +package com.type.property.nullable.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/BytesProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/BytesProperty.java new file mode 100644 index 000000000..efcb62904 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/BytesProperty.java @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * Template type for testing models with nullable property. Pass in the type of the property you are looking for. + */ +@Fluent +public final class BytesProperty implements JsonSerializable { + /* + * Required property + */ + @Generated + private String requiredProperty; + + /* + * Property + */ + @Generated + private byte[] nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setBytesPropertyAccessor(new JsonMergePatchHelper.BytesPropertyAccessor() { + @Override + public BytesProperty prepareModelForJsonMergePatch(BytesProperty model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(BytesProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of BytesProperty class. + */ + @Generated + public BytesProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Generated + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the BytesProperty object itself. + */ + @Generated + public BytesProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Generated + public byte[] getNullableProperty() { + return CoreUtils.clone(this.nullableProperty); + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the BytesProperty object itself. + */ + @Generated + public BytesProperty setNullableProperty(byte[] nullableProperty) { + this.nullableProperty = CoreUtils.clone(nullableProperty); + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeBinaryField("nullableProperty", this.nullableProperty); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeBinaryField("nullableProperty", this.nullableProperty); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BytesProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BytesProperty 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 BytesProperty. + */ + @Generated + public static BytesProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BytesProperty deserializedBytesProperty = new BytesProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedBytesProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + deserializedBytesProperty.nullableProperty = reader.getBinary(); + } else { + reader.skipChildren(); + } + } + + return deserializedBytesProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/CollectionsByteProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/CollectionsByteProperty.java new file mode 100644 index 000000000..50f91335d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/CollectionsByteProperty.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 com.type.property.nullable.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 com.type.property.nullable.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Model with collection bytes properties. + */ +@Fluent +public final class CollectionsByteProperty implements JsonSerializable { + /* + * Required property + */ + @Generated + private String requiredProperty; + + /* + * Property + */ + @Generated + private List nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper + .setCollectionsBytePropertyAccessor(new JsonMergePatchHelper.CollectionsBytePropertyAccessor() { + @Override + public CollectionsByteProperty prepareModelForJsonMergePatch(CollectionsByteProperty model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(CollectionsByteProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of CollectionsByteProperty class. + */ + @Generated + public CollectionsByteProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Generated + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the CollectionsByteProperty object itself. + */ + @Generated + public CollectionsByteProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Generated + public List getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the CollectionsByteProperty object itself. + */ + @Generated + public CollectionsByteProperty setNullableProperty(List nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeArrayField("nullableProperty", this.nullableProperty, + (writer, element) -> writer.writeBinary(element)); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeArrayField("nullableProperty", this.nullableProperty, + (writer, element) -> writer.writeBinary(element)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsByteProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsByteProperty 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 CollectionsByteProperty. + */ + @Generated + public static CollectionsByteProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CollectionsByteProperty deserializedCollectionsByteProperty = new CollectionsByteProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedCollectionsByteProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + List nullableProperty = reader.readArray(reader1 -> reader1.getBinary()); + deserializedCollectionsByteProperty.nullableProperty = nullableProperty; + } else { + reader.skipChildren(); + } + } + + return deserializedCollectionsByteProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/CollectionsModelProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/CollectionsModelProperty.java new file mode 100644 index 000000000..11e195750 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/CollectionsModelProperty.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 com.type.property.nullable.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 com.type.property.nullable.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Model with collection models properties. + */ +@Fluent +public final class CollectionsModelProperty implements JsonSerializable { + /* + * Required property + */ + @Generated + private String requiredProperty; + + /* + * Property + */ + @Generated + private List nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper + .setCollectionsModelPropertyAccessor(new JsonMergePatchHelper.CollectionsModelPropertyAccessor() { + @Override + public CollectionsModelProperty prepareModelForJsonMergePatch(CollectionsModelProperty model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(CollectionsModelProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of CollectionsModelProperty class. + */ + @Generated + public CollectionsModelProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Generated + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the CollectionsModelProperty object itself. + */ + @Generated + public CollectionsModelProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Generated + public List getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the CollectionsModelProperty object itself. + */ + @Generated + public CollectionsModelProperty setNullableProperty(List nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeArrayField("nullableProperty", this.nullableProperty, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeArrayField("nullableProperty", this.nullableProperty, + (writer, element) -> writer.writeJson(element)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsModelProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsModelProperty 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 CollectionsModelProperty. + */ + @Generated + public static CollectionsModelProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CollectionsModelProperty deserializedCollectionsModelProperty = new CollectionsModelProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedCollectionsModelProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + List nullableProperty = reader.readArray(reader1 -> InnerModel.fromJson(reader1)); + deserializedCollectionsModelProperty.nullableProperty = nullableProperty; + } else { + reader.skipChildren(); + } + } + + return deserializedCollectionsModelProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/CollectionsStringProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/CollectionsStringProperty.java new file mode 100644 index 000000000..ca19fad5e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/CollectionsStringProperty.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 com.type.property.nullable.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 com.type.property.nullable.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Model with collection string properties. + */ +@Fluent +public final class CollectionsStringProperty implements JsonSerializable { + /* + * Required property + */ + @Generated + private String requiredProperty; + + /* + * Property + */ + @Generated + private List nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper + .setCollectionsStringPropertyAccessor(new JsonMergePatchHelper.CollectionsStringPropertyAccessor() { + @Override + public CollectionsStringProperty prepareModelForJsonMergePatch(CollectionsStringProperty model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(CollectionsStringProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of CollectionsStringProperty class. + */ + @Generated + public CollectionsStringProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Generated + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the CollectionsStringProperty object itself. + */ + @Generated + public CollectionsStringProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Generated + public List getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the CollectionsStringProperty object itself. + */ + @Generated + public CollectionsStringProperty setNullableProperty(List nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeArrayField("nullableProperty", this.nullableProperty, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeArrayField("nullableProperty", this.nullableProperty, + (writer, element) -> writer.writeString(element)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsStringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsStringProperty 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 CollectionsStringProperty. + */ + @Generated + public static CollectionsStringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CollectionsStringProperty deserializedCollectionsStringProperty = new CollectionsStringProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedCollectionsStringProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + List nullableProperty = reader.readArray(reader1 -> reader1.getString()); + deserializedCollectionsStringProperty.nullableProperty = nullableProperty; + } else { + reader.skipChildren(); + } + } + + return deserializedCollectionsStringProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/DatetimeProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/DatetimeProperty.java new file mode 100644 index 000000000..ae257111d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/DatetimeProperty.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashSet; +import java.util.Set; + +/** + * Model with a datetime property. + */ +@Fluent +public final class DatetimeProperty implements JsonSerializable { + /* + * Required property + */ + @Generated + private String requiredProperty; + + /* + * Property + */ + @Generated + private OffsetDateTime nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setDatetimePropertyAccessor(new JsonMergePatchHelper.DatetimePropertyAccessor() { + @Override + public DatetimeProperty prepareModelForJsonMergePatch(DatetimeProperty model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(DatetimeProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of DatetimeProperty class. + */ + @Generated + public DatetimeProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Generated + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the DatetimeProperty object itself. + */ + @Generated + public DatetimeProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Generated + public OffsetDateTime getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the DatetimeProperty object itself. + */ + @Generated + public DatetimeProperty setNullableProperty(OffsetDateTime nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeStringField("nullableProperty", + this.nullableProperty == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.nullableProperty)); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeStringField("nullableProperty", + this.nullableProperty == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.nullableProperty)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DatetimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DatetimeProperty 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 DatetimeProperty. + */ + @Generated + public static DatetimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DatetimeProperty deserializedDatetimeProperty = new DatetimeProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedDatetimeProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + deserializedDatetimeProperty.nullableProperty = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedDatetimeProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/DurationProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/DurationProperty.java new file mode 100644 index 000000000..b9750709d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/DurationProperty.java @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.type.property.nullable.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.time.Duration; +import java.util.HashSet; +import java.util.Set; + +/** + * Model with a duration property. + */ +@Fluent +public final class DurationProperty implements JsonSerializable { + /* + * Required property + */ + @Generated + private String requiredProperty; + + /* + * Property + */ + @Generated + private Duration nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setDurationPropertyAccessor(new JsonMergePatchHelper.DurationPropertyAccessor() { + @Override + public DurationProperty prepareModelForJsonMergePatch(DurationProperty model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(DurationProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of DurationProperty class. + */ + @Generated + public DurationProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Generated + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the DurationProperty object itself. + */ + @Generated + public DurationProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Generated + public Duration getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the DurationProperty object itself. + */ + @Generated + public DurationProperty setNullableProperty(Duration nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeStringField("nullableProperty", CoreUtils.durationToStringWithDays(this.nullableProperty)); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeStringField("nullableProperty", + CoreUtils.durationToStringWithDays(this.nullableProperty)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DurationProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DurationProperty 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 DurationProperty. + */ + @Generated + public static DurationProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DurationProperty deserializedDurationProperty = new DurationProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedDurationProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + deserializedDurationProperty.nullableProperty + = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedDurationProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/InnerModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/InnerModel.java new file mode 100644 index 000000000..18c53df60 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/InnerModel.java @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.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 com.type.property.nullable.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * Inner model used in collections model property. + */ +@Fluent +public final class InnerModel implements JsonSerializable { + /* + * Inner model property + */ + @Generated + private String property; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setInnerModelAccessor(new JsonMergePatchHelper.InnerModelAccessor() { + @Override + public InnerModel prepareModelForJsonMergePatch(InnerModel model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(InnerModel model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of InnerModel class. + */ + @Generated + public InnerModel() { + } + + /** + * Get the property property: Inner model property. + * + * @return the property value. + */ + @Generated + public String getProperty() { + return this.property; + } + + /** + * Set the property property: Inner model property. + *

Required when create the resource.

+ * + * @param property the property value to set. + * @return the InnerModel object itself. + */ + @Generated + public InnerModel setProperty(String property) { + this.property = property; + this.updatedProperties.add("property"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("property")) { + if (this.property == null) { + jsonWriter.writeNullField("property"); + } else { + jsonWriter.writeStringField("property", this.property); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerModel 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 InnerModel. + */ + @Generated + public static InnerModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + InnerModel deserializedInnerModel = new InnerModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedInnerModel.property = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedInnerModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/StringProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/StringProperty.java new file mode 100644 index 000000000..861c05f65 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/StringProperty.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 com.type.property.nullable.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 com.type.property.nullable.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * Template type for testing models with nullable property. Pass in the type of the property you are looking for. + */ +@Fluent +public final class StringProperty implements JsonSerializable { + /* + * Required property + */ + @Generated + private String requiredProperty; + + /* + * Property + */ + @Generated + private String nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setStringPropertyAccessor(new JsonMergePatchHelper.StringPropertyAccessor() { + @Override + public StringProperty prepareModelForJsonMergePatch(StringProperty model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(StringProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of StringProperty class. + */ + @Generated + public StringProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Generated + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the StringProperty object itself. + */ + @Generated + public StringProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Generated + public String getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the StringProperty object itself. + */ + @Generated + public StringProperty setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeStringField("nullableProperty", this.nullableProperty); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeStringField("nullableProperty", this.nullableProperty); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StringProperty 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 StringProperty. + */ + @Generated + public static StringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringProperty deserializedStringProperty = new StringProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedStringProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + deserializedStringProperty.nullableProperty = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedStringProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/models/package-info.java new file mode 100644 index 000000000..7987d0063 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/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 Nullable. + * Illustrates models with nullable properties. + * + */ +package com.type.property.nullable.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/package-info.java new file mode 100644 index 000000000..c217b6d67 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/nullable/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 Nullable. + * Illustrates models with nullable properties. + * + */ +package com.type.property.nullable; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/BooleanLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/BooleanLiteralAsyncClient.java new file mode 100644 index 000000000..1b744de17 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/BooleanLiteralAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.BooleanLiteralsImpl; +import com.type.property.optional.models.BooleanLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class BooleanLiteralAsyncClient { + @Generated + private final BooleanLiteralsImpl serviceClient; + + /** + * Initializes an instance of BooleanLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BooleanLiteralAsyncClient(BooleanLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BooleanLiteralProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BooleanLiteralProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(BooleanLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(BooleanLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/BooleanLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/BooleanLiteralClient.java new file mode 100644 index 000000000..aedbc41fb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/BooleanLiteralClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.BooleanLiteralsImpl; +import com.type.property.optional.models.BooleanLiteralProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class BooleanLiteralClient { + @Generated + private final BooleanLiteralsImpl serviceClient; + + /** + * Initializes an instance of BooleanLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BooleanLiteralClient(BooleanLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BooleanLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(BooleanLiteralProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BooleanLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(BooleanLiteralProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(BooleanLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(BooleanLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/BytesAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/BytesAsyncClient.java new file mode 100644 index 000000000..ff4076bdd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/BytesAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.BytesImpl; +import com.type.property.optional.models.BytesProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class BytesAsyncClient { + @Generated + private final BytesImpl serviceClient; + + /** + * Initializes an instance of BytesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BytesAsyncClient(BytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BytesProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BytesProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(BytesProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(BytesProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/BytesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/BytesClient.java new file mode 100644 index 000000000..e9a0400de --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/BytesClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.BytesImpl; +import com.type.property.optional.models.BytesProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class BytesClient { + @Generated + private final BytesImpl serviceClient; + + /** + * Initializes an instance of BytesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BytesClient(BytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BytesProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(BytesProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BytesProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(BytesProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(BytesProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(BytesProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/CollectionsByteAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/CollectionsByteAsyncClient.java new file mode 100644 index 000000000..82c01f6a2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/CollectionsByteAsyncClient.java @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.CollectionsBytesImpl; +import com.type.property.optional.models.CollectionsByteProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class CollectionsByteAsyncClient { + @Generated + private final CollectionsBytesImpl serviceClient; + + /** + * Initializes an instance of CollectionsByteAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsByteAsyncClient(CollectionsBytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsByteProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsByteProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(CollectionsByteProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(CollectionsByteProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/CollectionsByteClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/CollectionsByteClient.java new file mode 100644 index 000000000..082eef861 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/CollectionsByteClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.CollectionsBytesImpl; +import com.type.property.optional.models.CollectionsByteProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class CollectionsByteClient { + @Generated + private final CollectionsBytesImpl serviceClient; + + /** + * Initializes an instance of CollectionsByteClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsByteClient(CollectionsBytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsByteProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(CollectionsByteProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsByteProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(CollectionsByteProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(CollectionsByteProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(CollectionsByteProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/CollectionsModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/CollectionsModelAsyncClient.java new file mode 100644 index 000000000..baf2f7a09 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/CollectionsModelAsyncClient.java @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.CollectionsModelsImpl; +import com.type.property.optional.models.CollectionsModelProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class CollectionsModelAsyncClient { + @Generated + private final CollectionsModelsImpl serviceClient; + + /** + * Initializes an instance of CollectionsModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsModelAsyncClient(CollectionsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsModelProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsModelProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(CollectionsModelProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(CollectionsModelProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/CollectionsModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/CollectionsModelClient.java new file mode 100644 index 000000000..4a2f83821 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/CollectionsModelClient.java @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.CollectionsModelsImpl; +import com.type.property.optional.models.CollectionsModelProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class CollectionsModelClient { + @Generated + private final CollectionsModelsImpl serviceClient; + + /** + * Initializes an instance of CollectionsModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsModelClient(CollectionsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsModelProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(CollectionsModelProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsModelProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(CollectionsModelProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(CollectionsModelProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(CollectionsModelProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/DatetimeOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/DatetimeOperationAsyncClient.java new file mode 100644 index 000000000..76b091646 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/DatetimeOperationAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.DatetimeOperationsImpl; +import com.type.property.optional.models.DatetimeProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class DatetimeOperationAsyncClient { + @Generated + private final DatetimeOperationsImpl serviceClient; + + /** + * Initializes an instance of DatetimeOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DatetimeOperationAsyncClient(DatetimeOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DatetimeProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DatetimeProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(DatetimeProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(DatetimeProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/DatetimeOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/DatetimeOperationClient.java new file mode 100644 index 000000000..7707ac2dd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/DatetimeOperationClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.DatetimeOperationsImpl; +import com.type.property.optional.models.DatetimeProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class DatetimeOperationClient { + @Generated + private final DatetimeOperationsImpl serviceClient; + + /** + * Initializes an instance of DatetimeOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DatetimeOperationClient(DatetimeOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DatetimeProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(DatetimeProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DatetimeProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(DatetimeProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(DatetimeProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(DatetimeProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/DurationOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/DurationOperationAsyncClient.java new file mode 100644 index 000000000..2e0543ca4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/DurationOperationAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.DurationOperationsImpl; +import com.type.property.optional.models.DurationProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class DurationOperationAsyncClient { + @Generated + private final DurationOperationsImpl serviceClient; + + /** + * Initializes an instance of DurationOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DurationOperationAsyncClient(DurationOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DurationProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DurationProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(DurationProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(DurationProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/DurationOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/DurationOperationClient.java new file mode 100644 index 000000000..276c91e42 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/DurationOperationClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.DurationOperationsImpl; +import com.type.property.optional.models.DurationProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class DurationOperationClient { + @Generated + private final DurationOperationsImpl serviceClient; + + /** + * Initializes an instance of DurationOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DurationOperationClient(DurationOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DurationProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(DurationProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DurationProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(DurationProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(DurationProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(DurationProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/FloatLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/FloatLiteralAsyncClient.java new file mode 100644 index 000000000..a2a5e7e83 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/FloatLiteralAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.FloatLiteralsImpl; +import com.type.property.optional.models.FloatLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class FloatLiteralAsyncClient { + @Generated + private final FloatLiteralsImpl serviceClient; + + /** + * Initializes an instance of FloatLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FloatLiteralAsyncClient(FloatLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FloatLiteralProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FloatLiteralProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(FloatLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(FloatLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/FloatLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/FloatLiteralClient.java new file mode 100644 index 000000000..55497ed2c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/FloatLiteralClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.FloatLiteralsImpl; +import com.type.property.optional.models.FloatLiteralProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class FloatLiteralClient { + @Generated + private final FloatLiteralsImpl serviceClient; + + /** + * Initializes an instance of FloatLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FloatLiteralClient(FloatLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FloatLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(FloatLiteralProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FloatLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(FloatLiteralProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(FloatLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(FloatLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/IntLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/IntLiteralAsyncClient.java new file mode 100644 index 000000000..9054c2ff2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/IntLiteralAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.IntLiteralsImpl; +import com.type.property.optional.models.IntLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class IntLiteralAsyncClient { + @Generated + private final IntLiteralsImpl serviceClient; + + /** + * Initializes an instance of IntLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IntLiteralAsyncClient(IntLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(IntLiteralProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(IntLiteralProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(IntLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(IntLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/IntLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/IntLiteralClient.java new file mode 100644 index 000000000..9df5a7c45 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/IntLiteralClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.IntLiteralsImpl; +import com.type.property.optional.models.IntLiteralProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class IntLiteralClient { + @Generated + private final IntLiteralsImpl serviceClient; + + /** + * Initializes an instance of IntLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IntLiteralClient(IntLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public IntLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(IntLiteralProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public IntLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(IntLiteralProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(IntLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(IntLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/OptionalClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/OptionalClientBuilder.java new file mode 100644 index 000000000..10051d33c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/OptionalClientBuilder.java @@ -0,0 +1,620 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.property.optional.implementation.OptionalClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the OptionalClient type. + */ +@ServiceClientBuilder( + serviceClients = { + StringOperationClient.class, + BytesClient.class, + DatetimeOperationClient.class, + DurationOperationClient.class, + PlainDateClient.class, + PlainTimeClient.class, + CollectionsByteClient.class, + CollectionsModelClient.class, + StringLiteralClient.class, + IntLiteralClient.class, + FloatLiteralClient.class, + BooleanLiteralClient.class, + UnionStringLiteralClient.class, + UnionIntLiteralClient.class, + UnionFloatLiteralClient.class, + RequiredAndOptionalClient.class, + StringOperationAsyncClient.class, + BytesAsyncClient.class, + DatetimeOperationAsyncClient.class, + DurationOperationAsyncClient.class, + PlainDateAsyncClient.class, + PlainTimeAsyncClient.class, + CollectionsByteAsyncClient.class, + CollectionsModelAsyncClient.class, + StringLiteralAsyncClient.class, + IntLiteralAsyncClient.class, + FloatLiteralAsyncClient.class, + BooleanLiteralAsyncClient.class, + UnionStringLiteralAsyncClient.class, + UnionIntLiteralAsyncClient.class, + UnionFloatLiteralAsyncClient.class, + RequiredAndOptionalAsyncClient.class }) +public final class OptionalClientBuilder 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("type-property-optional.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the OptionalClientBuilder. + */ + @Generated + public OptionalClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OptionalClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OptionalClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OptionalClientBuilder 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 OptionalClientBuilder 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 OptionalClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OptionalClientBuilder 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 OptionalClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public OptionalClientBuilder 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 OptionalClientBuilder. + */ + @Generated + public OptionalClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of OptionalClientImpl with the provided parameters. + * + * @return an instance of OptionalClientImpl. + */ + @Generated + private OptionalClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + OptionalClientImpl client + = new OptionalClientImpl(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 StringOperationAsyncClient class. + * + * @return an instance of StringOperationAsyncClient. + */ + @Generated + public StringOperationAsyncClient buildStringOperationAsyncClient() { + return new StringOperationAsyncClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of BytesAsyncClient class. + * + * @return an instance of BytesAsyncClient. + */ + @Generated + public BytesAsyncClient buildBytesAsyncClient() { + return new BytesAsyncClient(buildInnerClient().getBytes()); + } + + /** + * Builds an instance of DatetimeOperationAsyncClient class. + * + * @return an instance of DatetimeOperationAsyncClient. + */ + @Generated + public DatetimeOperationAsyncClient buildDatetimeOperationAsyncClient() { + return new DatetimeOperationAsyncClient(buildInnerClient().getDatetimeOperations()); + } + + /** + * Builds an instance of DurationOperationAsyncClient class. + * + * @return an instance of DurationOperationAsyncClient. + */ + @Generated + public DurationOperationAsyncClient buildDurationOperationAsyncClient() { + return new DurationOperationAsyncClient(buildInnerClient().getDurationOperations()); + } + + /** + * Builds an instance of PlainDateAsyncClient class. + * + * @return an instance of PlainDateAsyncClient. + */ + @Generated + public PlainDateAsyncClient buildPlainDateAsyncClient() { + return new PlainDateAsyncClient(buildInnerClient().getPlainDates()); + } + + /** + * Builds an instance of PlainTimeAsyncClient class. + * + * @return an instance of PlainTimeAsyncClient. + */ + @Generated + public PlainTimeAsyncClient buildPlainTimeAsyncClient() { + return new PlainTimeAsyncClient(buildInnerClient().getPlainTimes()); + } + + /** + * Builds an instance of CollectionsByteAsyncClient class. + * + * @return an instance of CollectionsByteAsyncClient. + */ + @Generated + public CollectionsByteAsyncClient buildCollectionsByteAsyncClient() { + return new CollectionsByteAsyncClient(buildInnerClient().getCollectionsBytes()); + } + + /** + * Builds an instance of CollectionsModelAsyncClient class. + * + * @return an instance of CollectionsModelAsyncClient. + */ + @Generated + public CollectionsModelAsyncClient buildCollectionsModelAsyncClient() { + return new CollectionsModelAsyncClient(buildInnerClient().getCollectionsModels()); + } + + /** + * Builds an instance of StringLiteralAsyncClient class. + * + * @return an instance of StringLiteralAsyncClient. + */ + @Generated + public StringLiteralAsyncClient buildStringLiteralAsyncClient() { + return new StringLiteralAsyncClient(buildInnerClient().getStringLiterals()); + } + + /** + * Builds an instance of IntLiteralAsyncClient class. + * + * @return an instance of IntLiteralAsyncClient. + */ + @Generated + public IntLiteralAsyncClient buildIntLiteralAsyncClient() { + return new IntLiteralAsyncClient(buildInnerClient().getIntLiterals()); + } + + /** + * Builds an instance of FloatLiteralAsyncClient class. + * + * @return an instance of FloatLiteralAsyncClient. + */ + @Generated + public FloatLiteralAsyncClient buildFloatLiteralAsyncClient() { + return new FloatLiteralAsyncClient(buildInnerClient().getFloatLiterals()); + } + + /** + * Builds an instance of BooleanLiteralAsyncClient class. + * + * @return an instance of BooleanLiteralAsyncClient. + */ + @Generated + public BooleanLiteralAsyncClient buildBooleanLiteralAsyncClient() { + return new BooleanLiteralAsyncClient(buildInnerClient().getBooleanLiterals()); + } + + /** + * Builds an instance of UnionStringLiteralAsyncClient class. + * + * @return an instance of UnionStringLiteralAsyncClient. + */ + @Generated + public UnionStringLiteralAsyncClient buildUnionStringLiteralAsyncClient() { + return new UnionStringLiteralAsyncClient(buildInnerClient().getUnionStringLiterals()); + } + + /** + * Builds an instance of UnionIntLiteralAsyncClient class. + * + * @return an instance of UnionIntLiteralAsyncClient. + */ + @Generated + public UnionIntLiteralAsyncClient buildUnionIntLiteralAsyncClient() { + return new UnionIntLiteralAsyncClient(buildInnerClient().getUnionIntLiterals()); + } + + /** + * Builds an instance of UnionFloatLiteralAsyncClient class. + * + * @return an instance of UnionFloatLiteralAsyncClient. + */ + @Generated + public UnionFloatLiteralAsyncClient buildUnionFloatLiteralAsyncClient() { + return new UnionFloatLiteralAsyncClient(buildInnerClient().getUnionFloatLiterals()); + } + + /** + * Builds an instance of RequiredAndOptionalAsyncClient class. + * + * @return an instance of RequiredAndOptionalAsyncClient. + */ + @Generated + public RequiredAndOptionalAsyncClient buildRequiredAndOptionalAsyncClient() { + return new RequiredAndOptionalAsyncClient(buildInnerClient().getRequiredAndOptionals()); + } + + /** + * Builds an instance of StringOperationClient class. + * + * @return an instance of StringOperationClient. + */ + @Generated + public StringOperationClient buildStringOperationClient() { + return new StringOperationClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of BytesClient class. + * + * @return an instance of BytesClient. + */ + @Generated + public BytesClient buildBytesClient() { + return new BytesClient(buildInnerClient().getBytes()); + } + + /** + * Builds an instance of DatetimeOperationClient class. + * + * @return an instance of DatetimeOperationClient. + */ + @Generated + public DatetimeOperationClient buildDatetimeOperationClient() { + return new DatetimeOperationClient(buildInnerClient().getDatetimeOperations()); + } + + /** + * Builds an instance of DurationOperationClient class. + * + * @return an instance of DurationOperationClient. + */ + @Generated + public DurationOperationClient buildDurationOperationClient() { + return new DurationOperationClient(buildInnerClient().getDurationOperations()); + } + + /** + * Builds an instance of PlainDateClient class. + * + * @return an instance of PlainDateClient. + */ + @Generated + public PlainDateClient buildPlainDateClient() { + return new PlainDateClient(buildInnerClient().getPlainDates()); + } + + /** + * Builds an instance of PlainTimeClient class. + * + * @return an instance of PlainTimeClient. + */ + @Generated + public PlainTimeClient buildPlainTimeClient() { + return new PlainTimeClient(buildInnerClient().getPlainTimes()); + } + + /** + * Builds an instance of CollectionsByteClient class. + * + * @return an instance of CollectionsByteClient. + */ + @Generated + public CollectionsByteClient buildCollectionsByteClient() { + return new CollectionsByteClient(buildInnerClient().getCollectionsBytes()); + } + + /** + * Builds an instance of CollectionsModelClient class. + * + * @return an instance of CollectionsModelClient. + */ + @Generated + public CollectionsModelClient buildCollectionsModelClient() { + return new CollectionsModelClient(buildInnerClient().getCollectionsModels()); + } + + /** + * Builds an instance of StringLiteralClient class. + * + * @return an instance of StringLiteralClient. + */ + @Generated + public StringLiteralClient buildStringLiteralClient() { + return new StringLiteralClient(buildInnerClient().getStringLiterals()); + } + + /** + * Builds an instance of IntLiteralClient class. + * + * @return an instance of IntLiteralClient. + */ + @Generated + public IntLiteralClient buildIntLiteralClient() { + return new IntLiteralClient(buildInnerClient().getIntLiterals()); + } + + /** + * Builds an instance of FloatLiteralClient class. + * + * @return an instance of FloatLiteralClient. + */ + @Generated + public FloatLiteralClient buildFloatLiteralClient() { + return new FloatLiteralClient(buildInnerClient().getFloatLiterals()); + } + + /** + * Builds an instance of BooleanLiteralClient class. + * + * @return an instance of BooleanLiteralClient. + */ + @Generated + public BooleanLiteralClient buildBooleanLiteralClient() { + return new BooleanLiteralClient(buildInnerClient().getBooleanLiterals()); + } + + /** + * Builds an instance of UnionStringLiteralClient class. + * + * @return an instance of UnionStringLiteralClient. + */ + @Generated + public UnionStringLiteralClient buildUnionStringLiteralClient() { + return new UnionStringLiteralClient(buildInnerClient().getUnionStringLiterals()); + } + + /** + * Builds an instance of UnionIntLiteralClient class. + * + * @return an instance of UnionIntLiteralClient. + */ + @Generated + public UnionIntLiteralClient buildUnionIntLiteralClient() { + return new UnionIntLiteralClient(buildInnerClient().getUnionIntLiterals()); + } + + /** + * Builds an instance of UnionFloatLiteralClient class. + * + * @return an instance of UnionFloatLiteralClient. + */ + @Generated + public UnionFloatLiteralClient buildUnionFloatLiteralClient() { + return new UnionFloatLiteralClient(buildInnerClient().getUnionFloatLiterals()); + } + + /** + * Builds an instance of RequiredAndOptionalClient class. + * + * @return an instance of RequiredAndOptionalClient. + */ + @Generated + public RequiredAndOptionalClient buildRequiredAndOptionalClient() { + return new RequiredAndOptionalClient(buildInnerClient().getRequiredAndOptionals()); + } + + private static final ClientLogger LOGGER = new ClientLogger(OptionalClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/PlainDateAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/PlainDateAsyncClient.java new file mode 100644 index 000000000..69a3a90fd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/PlainDateAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.PlainDatesImpl; +import com.type.property.optional.models.PlainDateProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class PlainDateAsyncClient { + @Generated + private final PlainDatesImpl serviceClient; + + /** + * Initializes an instance of PlainDateAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PlainDateAsyncClient(PlainDatesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PlainDateProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PlainDateProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(PlainDateProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(PlainDateProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/PlainDateClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/PlainDateClient.java new file mode 100644 index 000000000..50abcca5e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/PlainDateClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.PlainDatesImpl; +import com.type.property.optional.models.PlainDateProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class PlainDateClient { + @Generated + private final PlainDatesImpl serviceClient; + + /** + * Initializes an instance of PlainDateClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PlainDateClient(PlainDatesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PlainDateProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(PlainDateProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PlainDateProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(PlainDateProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(PlainDateProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(PlainDateProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/PlainTimeAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/PlainTimeAsyncClient.java new file mode 100644 index 000000000..25736b8d8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/PlainTimeAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.PlainTimesImpl; +import com.type.property.optional.models.PlainTimeProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class PlainTimeAsyncClient { + @Generated + private final PlainTimesImpl serviceClient; + + /** + * Initializes an instance of PlainTimeAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PlainTimeAsyncClient(PlainTimesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PlainTimeProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PlainTimeProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(PlainTimeProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(PlainTimeProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/PlainTimeClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/PlainTimeClient.java new file mode 100644 index 000000000..1b8d867dc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/PlainTimeClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.PlainTimesImpl; +import com.type.property.optional.models.PlainTimeProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class PlainTimeClient { + @Generated + private final PlainTimesImpl serviceClient; + + /** + * Initializes an instance of PlainTimeClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PlainTimeClient(PlainTimesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PlainTimeProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(PlainTimeProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PlainTimeProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(PlainTimeProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(PlainTimeProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(PlainTimeProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/RequiredAndOptionalAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/RequiredAndOptionalAsyncClient.java new file mode 100644 index 000000000..9f9d8c40f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/RequiredAndOptionalAsyncClient.java @@ -0,0 +1,218 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.RequiredAndOptionalsImpl; +import com.type.property.optional.models.RequiredAndOptionalProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class RequiredAndOptionalAsyncClient { + @Generated + private final RequiredAndOptionalsImpl serviceClient; + + /** + * Initializes an instance of RequiredAndOptionalAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RequiredAndOptionalAsyncClient(RequiredAndOptionalsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: 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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return only the required properties. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: 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 models that will return only the required properties along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRequiredOnlyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRequiredOnlyWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with only required properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+ * + * @param body The body 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> putRequiredOnlyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putRequiredOnlyWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(RequiredAndOptionalProperty.class)); + } + + /** + * Get models that will return only the required properties. + * + * @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 models that will return only the required properties on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getRequiredOnly() { + // Generated convenience method for getRequiredOnlyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRequiredOnlyWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(RequiredAndOptionalProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(RequiredAndOptionalProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with only required properties. + * + * @param body The body 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 putRequiredOnly(RequiredAndOptionalProperty body) { + // Generated convenience method for putRequiredOnlyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putRequiredOnlyWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/RequiredAndOptionalClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/RequiredAndOptionalClient.java new file mode 100644 index 000000000..f617bed9c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/RequiredAndOptionalClient.java @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.RequiredAndOptionalsImpl; +import com.type.property.optional.models.RequiredAndOptionalProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class RequiredAndOptionalClient { + @Generated + private final RequiredAndOptionalsImpl serviceClient; + + /** + * Initializes an instance of RequiredAndOptionalClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RequiredAndOptionalClient(RequiredAndOptionalsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: 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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return only the required properties. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: 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 models that will return only the required properties along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRequiredOnlyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRequiredOnlyWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with only required properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+ * + * @param body The body 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 putRequiredOnlyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putRequiredOnlyWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public RequiredAndOptionalProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(RequiredAndOptionalProperty.class); + } + + /** + * Get models that will return only the required properties. + * + * @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 models that will return only the required properties. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public RequiredAndOptionalProperty getRequiredOnly() { + // Generated convenience method for getRequiredOnlyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRequiredOnlyWithResponse(requestOptions).getValue().toObject(RequiredAndOptionalProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(RequiredAndOptionalProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with only required properties. + * + * @param body The body 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 putRequiredOnly(RequiredAndOptionalProperty body) { + // Generated convenience method for putRequiredOnlyWithResponse + RequestOptions requestOptions = new RequestOptions(); + putRequiredOnlyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/StringLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/StringLiteralAsyncClient.java new file mode 100644 index 000000000..8738ca211 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/StringLiteralAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.StringLiteralsImpl; +import com.type.property.optional.models.StringLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class StringLiteralAsyncClient { + @Generated + private final StringLiteralsImpl serviceClient; + + /** + * Initializes an instance of StringLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringLiteralAsyncClient(StringLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(StringLiteralProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(StringLiteralProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(StringLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(StringLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/StringLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/StringLiteralClient.java new file mode 100644 index 000000000..9d9edb2a0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/StringLiteralClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.StringLiteralsImpl; +import com.type.property.optional.models.StringLiteralProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class StringLiteralClient { + @Generated + private final StringLiteralsImpl serviceClient; + + /** + * Initializes an instance of StringLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringLiteralClient(StringLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public StringLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(StringLiteralProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public StringLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(StringLiteralProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(StringLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(StringLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/StringOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/StringOperationAsyncClient.java new file mode 100644 index 000000000..ccb6ab14d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/StringOperationAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.StringOperationsImpl; +import com.type.property.optional.models.StringProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class StringOperationAsyncClient { + @Generated + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of StringOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringOperationAsyncClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(StringProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(StringProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(StringProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(StringProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/StringOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/StringOperationClient.java new file mode 100644 index 000000000..f5a89b6b7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/StringOperationClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.StringOperationsImpl; +import com.type.property.optional.models.StringProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class StringOperationClient { + @Generated + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of StringOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringOperationClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public StringProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(StringProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public StringProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(StringProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(StringProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(StringProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionFloatLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionFloatLiteralAsyncClient.java new file mode 100644 index 000000000..c1a677f4f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionFloatLiteralAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.UnionFloatLiteralsImpl; +import com.type.property.optional.models.UnionFloatLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class UnionFloatLiteralAsyncClient { + @Generated + private final UnionFloatLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionFloatLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionFloatLiteralAsyncClient(UnionFloatLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnionFloatLiteralProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnionFloatLiteralProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(UnionFloatLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(UnionFloatLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionFloatLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionFloatLiteralClient.java new file mode 100644 index 000000000..d73101ed7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionFloatLiteralClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.UnionFloatLiteralsImpl; +import com.type.property.optional.models.UnionFloatLiteralProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class UnionFloatLiteralClient { + @Generated + private final UnionFloatLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionFloatLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionFloatLiteralClient(UnionFloatLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnionFloatLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(UnionFloatLiteralProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnionFloatLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(UnionFloatLiteralProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(UnionFloatLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(UnionFloatLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionIntLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionIntLiteralAsyncClient.java new file mode 100644 index 000000000..0d026ff1c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionIntLiteralAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.UnionIntLiteralsImpl; +import com.type.property.optional.models.UnionIntLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class UnionIntLiteralAsyncClient { + @Generated + private final UnionIntLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionIntLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionIntLiteralAsyncClient(UnionIntLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnionIntLiteralProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnionIntLiteralProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(UnionIntLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(UnionIntLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionIntLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionIntLiteralClient.java new file mode 100644 index 000000000..0e32a129a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionIntLiteralClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.UnionIntLiteralsImpl; +import com.type.property.optional.models.UnionIntLiteralProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class UnionIntLiteralClient { + @Generated + private final UnionIntLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionIntLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionIntLiteralClient(UnionIntLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnionIntLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(UnionIntLiteralProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnionIntLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(UnionIntLiteralProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(UnionIntLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(UnionIntLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionStringLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionStringLiteralAsyncClient.java new file mode 100644 index 000000000..34e9fd00f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionStringLiteralAsyncClient.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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 com.type.property.optional.implementation.UnionStringLiteralsImpl; +import com.type.property.optional.models.UnionStringLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class, isAsync = true) +public final class UnionStringLiteralAsyncClient { + @Generated + private final UnionStringLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionStringLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionStringLiteralAsyncClient(UnionStringLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponseAsync(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponseAsync(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponseAsync(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponseAsync(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnionStringLiteralProperty.class)); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnionStringLiteralProperty.class)); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(UnionStringLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putAllWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(UnionStringLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionStringLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionStringLiteralClient.java new file mode 100644 index 000000000..c2965da69 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/UnionStringLiteralClient.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional; + +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.type.property.optional.implementation.UnionStringLiteralsImpl; +import com.type.property.optional.models.UnionStringLiteralProperty; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class UnionStringLiteralClient { + @Generated + private final UnionStringLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionStringLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionStringLiteralClient(UnionStringLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @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 models that will return all properties in the model. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnionStringLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue().toObject(UnionStringLiteralProperty.class); + } + + /** + * Get models that will return the default object. + * + * @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 models that will return the default object. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnionStringLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue().toObject(UnionStringLiteralProperty.class); + } + + /** + * Put a body with all properties present. + * + * @param body The body 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 putAll(UnionStringLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body 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 putDefault(UnionStringLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/BooleanLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/BooleanLiteralsImpl.java new file mode 100644 index 000000000..e417d0f07 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/BooleanLiteralsImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 BooleanLiterals. + */ +public final class BooleanLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BooleanLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of BooleanLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BooleanLiteralsImpl(OptionalClientImpl client) { + this.service + = RestProxy.create(BooleanLiteralsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientBooleanLiterals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientBoolea") + public interface BooleanLiteralsService { + @Get("/type/property/optional/boolean/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/boolean/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/boolean/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/boolean/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/boolean/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/boolean/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/boolean/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/boolean/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/BytesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/BytesImpl.java new file mode 100644 index 000000000..4aa5b0e29 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/BytesImpl.java @@ -0,0 +1,331 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Bytes. + */ +public final class BytesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BytesService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of BytesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BytesImpl(OptionalClientImpl client) { + this.service = RestProxy.create(BytesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientBytes to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientBytes") + public interface BytesService { + @Get("/type/property/optional/bytes/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/bytes/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/bytes/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/bytes/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/bytes/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/bytes/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/bytes/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/bytes/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/CollectionsBytesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/CollectionsBytesImpl.java new file mode 100644 index 000000000..bc22af5f7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/CollectionsBytesImpl.java @@ -0,0 +1,348 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 CollectionsBytes. + */ +public final class CollectionsBytesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsBytesService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of CollectionsBytesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsBytesImpl(OptionalClientImpl client) { + this.service + = RestProxy.create(CollectionsBytesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientCollectionsBytes to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientCollec") + public interface CollectionsBytesService { + @Get("/type/property/optional/collections/bytes/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/collections/bytes/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/collections/bytes/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/collections/bytes/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/collections/bytes/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/collections/bytes/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/collections/bytes/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/collections/bytes/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/CollectionsModelsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/CollectionsModelsImpl.java new file mode 100644 index 000000000..f83f9c944 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/CollectionsModelsImpl.java @@ -0,0 +1,364 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 CollectionsModels. + */ +public final class CollectionsModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsModelsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of CollectionsModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsModelsImpl(OptionalClientImpl client) { + this.service + = RestProxy.create(CollectionsModelsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientCollectionsModels to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientCollec") + public interface CollectionsModelsService { + @Get("/type/property/optional/collections/model/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/collections/model/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/collections/model/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/collections/model/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/collections/model/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/collections/model/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/collections/model/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/collections/model/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/DatetimeOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/DatetimeOperationsImpl.java new file mode 100644 index 000000000..538f44b6f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/DatetimeOperationsImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 DatetimeOperations. + */ +public final class DatetimeOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DatetimeOperationsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of DatetimeOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DatetimeOperationsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(DatetimeOperationsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientDatetimeOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientDateti") + public interface DatetimeOperationsService { + @Get("/type/property/optional/datetime/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/datetime/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/datetime/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/datetime/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/datetime/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/datetime/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/datetime/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/datetime/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/DurationOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/DurationOperationsImpl.java new file mode 100644 index 000000000..3931d71c3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/DurationOperationsImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 DurationOperations. + */ +public final class DurationOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DurationOperationsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of DurationOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DurationOperationsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(DurationOperationsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientDurationOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientDurati") + public interface DurationOperationsService { + @Get("/type/property/optional/duration/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/duration/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/duration/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/duration/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/duration/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/duration/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/duration/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/duration/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/FloatLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/FloatLiteralsImpl.java new file mode 100644 index 000000000..3b6a47333 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/FloatLiteralsImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 FloatLiterals. + */ +public final class FloatLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FloatLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of FloatLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FloatLiteralsImpl(OptionalClientImpl client) { + this.service + = RestProxy.create(FloatLiteralsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientFloatLiterals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientFloatL") + public interface FloatLiteralsService { + @Get("/type/property/optional/float/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/float/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/float/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/float/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/float/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/float/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/float/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/float/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/IntLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/IntLiteralsImpl.java new file mode 100644 index 000000000..672e4db8c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/IntLiteralsImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 IntLiterals. + */ +public final class IntLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IntLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of IntLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IntLiteralsImpl(OptionalClientImpl client) { + this.service + = RestProxy.create(IntLiteralsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientIntLiterals to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientIntLit") + public interface IntLiteralsService { + @Get("/type/property/optional/int/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/int/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/int/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/int/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/int/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/int/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/int/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/int/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/OptionalClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/OptionalClientImpl.java new file mode 100644 index 000000000..3340a3128 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/OptionalClientImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the OptionalClient type. + */ +public final class OptionalClientImpl { + /** + * 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; + } + + /** + * The StringOperationsImpl object to access its operations. + */ + private final StringOperationsImpl stringOperations; + + /** + * Gets the StringOperationsImpl object to access its operations. + * + * @return the StringOperationsImpl object. + */ + public StringOperationsImpl getStringOperations() { + return this.stringOperations; + } + + /** + * The BytesImpl object to access its operations. + */ + private final BytesImpl bytes; + + /** + * Gets the BytesImpl object to access its operations. + * + * @return the BytesImpl object. + */ + public BytesImpl getBytes() { + return this.bytes; + } + + /** + * The DatetimeOperationsImpl object to access its operations. + */ + private final DatetimeOperationsImpl datetimeOperations; + + /** + * Gets the DatetimeOperationsImpl object to access its operations. + * + * @return the DatetimeOperationsImpl object. + */ + public DatetimeOperationsImpl getDatetimeOperations() { + return this.datetimeOperations; + } + + /** + * The DurationOperationsImpl object to access its operations. + */ + private final DurationOperationsImpl durationOperations; + + /** + * Gets the DurationOperationsImpl object to access its operations. + * + * @return the DurationOperationsImpl object. + */ + public DurationOperationsImpl getDurationOperations() { + return this.durationOperations; + } + + /** + * The PlainDatesImpl object to access its operations. + */ + private final PlainDatesImpl plainDates; + + /** + * Gets the PlainDatesImpl object to access its operations. + * + * @return the PlainDatesImpl object. + */ + public PlainDatesImpl getPlainDates() { + return this.plainDates; + } + + /** + * The PlainTimesImpl object to access its operations. + */ + private final PlainTimesImpl plainTimes; + + /** + * Gets the PlainTimesImpl object to access its operations. + * + * @return the PlainTimesImpl object. + */ + public PlainTimesImpl getPlainTimes() { + return this.plainTimes; + } + + /** + * The CollectionsBytesImpl object to access its operations. + */ + private final CollectionsBytesImpl collectionsBytes; + + /** + * Gets the CollectionsBytesImpl object to access its operations. + * + * @return the CollectionsBytesImpl object. + */ + public CollectionsBytesImpl getCollectionsBytes() { + return this.collectionsBytes; + } + + /** + * The CollectionsModelsImpl object to access its operations. + */ + private final CollectionsModelsImpl collectionsModels; + + /** + * Gets the CollectionsModelsImpl object to access its operations. + * + * @return the CollectionsModelsImpl object. + */ + public CollectionsModelsImpl getCollectionsModels() { + return this.collectionsModels; + } + + /** + * The StringLiteralsImpl object to access its operations. + */ + private final StringLiteralsImpl stringLiterals; + + /** + * Gets the StringLiteralsImpl object to access its operations. + * + * @return the StringLiteralsImpl object. + */ + public StringLiteralsImpl getStringLiterals() { + return this.stringLiterals; + } + + /** + * The IntLiteralsImpl object to access its operations. + */ + private final IntLiteralsImpl intLiterals; + + /** + * Gets the IntLiteralsImpl object to access its operations. + * + * @return the IntLiteralsImpl object. + */ + public IntLiteralsImpl getIntLiterals() { + return this.intLiterals; + } + + /** + * The FloatLiteralsImpl object to access its operations. + */ + private final FloatLiteralsImpl floatLiterals; + + /** + * Gets the FloatLiteralsImpl object to access its operations. + * + * @return the FloatLiteralsImpl object. + */ + public FloatLiteralsImpl getFloatLiterals() { + return this.floatLiterals; + } + + /** + * The BooleanLiteralsImpl object to access its operations. + */ + private final BooleanLiteralsImpl booleanLiterals; + + /** + * Gets the BooleanLiteralsImpl object to access its operations. + * + * @return the BooleanLiteralsImpl object. + */ + public BooleanLiteralsImpl getBooleanLiterals() { + return this.booleanLiterals; + } + + /** + * The UnionStringLiteralsImpl object to access its operations. + */ + private final UnionStringLiteralsImpl unionStringLiterals; + + /** + * Gets the UnionStringLiteralsImpl object to access its operations. + * + * @return the UnionStringLiteralsImpl object. + */ + public UnionStringLiteralsImpl getUnionStringLiterals() { + return this.unionStringLiterals; + } + + /** + * The UnionIntLiteralsImpl object to access its operations. + */ + private final UnionIntLiteralsImpl unionIntLiterals; + + /** + * Gets the UnionIntLiteralsImpl object to access its operations. + * + * @return the UnionIntLiteralsImpl object. + */ + public UnionIntLiteralsImpl getUnionIntLiterals() { + return this.unionIntLiterals; + } + + /** + * The UnionFloatLiteralsImpl object to access its operations. + */ + private final UnionFloatLiteralsImpl unionFloatLiterals; + + /** + * Gets the UnionFloatLiteralsImpl object to access its operations. + * + * @return the UnionFloatLiteralsImpl object. + */ + public UnionFloatLiteralsImpl getUnionFloatLiterals() { + return this.unionFloatLiterals; + } + + /** + * The RequiredAndOptionalsImpl object to access its operations. + */ + private final RequiredAndOptionalsImpl requiredAndOptionals; + + /** + * Gets the RequiredAndOptionalsImpl object to access its operations. + * + * @return the RequiredAndOptionalsImpl object. + */ + public RequiredAndOptionalsImpl getRequiredAndOptionals() { + return this.requiredAndOptionals; + } + + /** + * Initializes an instance of OptionalClient client. + * + * @param endpoint Service host. + */ + public OptionalClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of OptionalClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public OptionalClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of OptionalClient 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 OptionalClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.stringOperations = new StringOperationsImpl(this); + this.bytes = new BytesImpl(this); + this.datetimeOperations = new DatetimeOperationsImpl(this); + this.durationOperations = new DurationOperationsImpl(this); + this.plainDates = new PlainDatesImpl(this); + this.plainTimes = new PlainTimesImpl(this); + this.collectionsBytes = new CollectionsBytesImpl(this); + this.collectionsModels = new CollectionsModelsImpl(this); + this.stringLiterals = new StringLiteralsImpl(this); + this.intLiterals = new IntLiteralsImpl(this); + this.floatLiterals = new FloatLiteralsImpl(this); + this.booleanLiterals = new BooleanLiteralsImpl(this); + this.unionStringLiterals = new UnionStringLiteralsImpl(this); + this.unionIntLiterals = new UnionIntLiteralsImpl(this); + this.unionFloatLiterals = new UnionFloatLiteralsImpl(this); + this.requiredAndOptionals = new RequiredAndOptionalsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/PlainDatesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/PlainDatesImpl.java new file mode 100644 index 000000000..c97140957 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/PlainDatesImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 PlainDates. + */ +public final class PlainDatesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PlainDatesService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of PlainDatesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PlainDatesImpl(OptionalClientImpl client) { + this.service + = RestProxy.create(PlainDatesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientPlainDates to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientPlainD") + public interface PlainDatesService { + @Get("/type/property/optional/plainDate/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/plainDate/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/plainDate/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/plainDate/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/plainDate/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/plainDate/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/plainDate/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/plainDate/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/PlainTimesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/PlainTimesImpl.java new file mode 100644 index 000000000..12a0ebd72 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/PlainTimesImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 PlainTimes. + */ +public final class PlainTimesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PlainTimesService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of PlainTimesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PlainTimesImpl(OptionalClientImpl client) { + this.service + = RestProxy.create(PlainTimesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientPlainTimes to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientPlainT") + public interface PlainTimesService { + @Get("/type/property/optional/plainTime/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/plainTime/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/plainTime/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/plainTime/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/plainTime/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/plainTime/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/plainTime/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/plainTime/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/RequiredAndOptionalsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/RequiredAndOptionalsImpl.java new file mode 100644 index 000000000..4e6d033be --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/RequiredAndOptionalsImpl.java @@ -0,0 +1,340 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 RequiredAndOptionals. + */ +public final class RequiredAndOptionalsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RequiredAndOptionalsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of RequiredAndOptionalsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + RequiredAndOptionalsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(RequiredAndOptionalsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientRequiredAndOptionals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientRequir") + public interface RequiredAndOptionalsService { + @Get("/type/property/optional/requiredAndOptional/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/requiredAndOptional/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/requiredAndOptional/requiredOnly") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getRequiredOnly(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/requiredAndOptional/requiredOnly") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getRequiredOnlySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/requiredAndOptional/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/requiredAndOptional/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/requiredAndOptional/requiredOnly") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putRequiredOnly(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/requiredAndOptional/requiredOnly") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putRequiredOnlySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: 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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: 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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return only the required properties. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: 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 models that will return only the required properties along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRequiredOnlyWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getRequiredOnly(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return only the required properties. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: 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 models that will return only the required properties along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRequiredOnlyWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getRequiredOnlySync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with only required properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+ * + * @param body The body 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> putRequiredOnlyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putRequiredOnly(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with only required properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+ * + * @param body The body 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 putRequiredOnlyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putRequiredOnlySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/StringLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/StringLiteralsImpl.java new file mode 100644 index 000000000..7eb0af857 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/StringLiteralsImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 StringLiterals. + */ +public final class StringLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of StringLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringLiteralsImpl(OptionalClientImpl client) { + this.service + = RestProxy.create(StringLiteralsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientStringLiterals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientString") + public interface StringLiteralsService { + @Get("/type/property/optional/string/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/string/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/string/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/string/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/string/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/string/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/string/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/string/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/StringOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/StringOperationsImpl.java new file mode 100644 index 000000000..e75323f13 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/StringOperationsImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 StringOperations. + */ +public final class StringOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringOperationsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of StringOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringOperationsImpl(OptionalClientImpl client) { + this.service + = RestProxy.create(StringOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientStringOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientString") + public interface StringOperationsService { + @Get("/type/property/optional/string/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/string/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/string/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/string/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/string/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/string/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/string/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/string/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/UnionFloatLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/UnionFloatLiteralsImpl.java new file mode 100644 index 000000000..2d6f4c897 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/UnionFloatLiteralsImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnionFloatLiterals. + */ +public final class UnionFloatLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionFloatLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of UnionFloatLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionFloatLiteralsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(UnionFloatLiteralsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientUnionFloatLiterals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientUnionF") + public interface UnionFloatLiteralsService { + @Get("/type/property/optional/union/float/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/union/float/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/union/float/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/union/float/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/union/float/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/union/float/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/union/float/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/union/float/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/UnionIntLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/UnionIntLiteralsImpl.java new file mode 100644 index 000000000..1f032a817 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/UnionIntLiteralsImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnionIntLiterals. + */ +public final class UnionIntLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionIntLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of UnionIntLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionIntLiteralsImpl(OptionalClientImpl client) { + this.service + = RestProxy.create(UnionIntLiteralsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientUnionIntLiterals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientUnionI") + public interface UnionIntLiteralsService { + @Get("/type/property/optional/union/int/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/union/int/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/union/int/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/union/int/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/union/int/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/union/int/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/union/int/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/union/int/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/UnionStringLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/UnionStringLiteralsImpl.java new file mode 100644 index 000000000..f3269df46 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/UnionStringLiteralsImpl.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnionStringLiterals. + */ +public final class UnionStringLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionStringLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of UnionStringLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionStringLiteralsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(UnionStringLiteralsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientUnionStringLiterals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "OptionalClientUnionS") + public interface UnionStringLiteralsService { + @Get("/type/property/optional/union/string/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAll(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/union/string/literal/all") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/union/string/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/property/optional/union/string/literal/default") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/union/string/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putAll(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/union/string/literal/all") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/union/string/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> putDefault(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/optional/union/string/literal/default") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAllWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getAll(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @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 models that will return all properties in the model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDefaultWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getDefault(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @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 models that will return the default object along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putAllWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putAll(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @param body The body 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> putDefaultWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.putDefault(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+ * + * @param body The body 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 putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/implementation/package-info.java new file mode 100644 index 000000000..b38abd0ba --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/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 Optional. + * Illustrates models with optional properties. + * + */ +package com.type.property.optional.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BooleanLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BooleanLiteralProperty.java new file mode 100644 index 000000000..4d68c92ad --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BooleanLiteralProperty.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; + +/** + * Model with boolean literal property. + */ +@Fluent +public final class BooleanLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private BooleanLiteralPropertyProperty property; + + /** + * Creates an instance of BooleanLiteralProperty class. + */ + @Generated + public BooleanLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public BooleanLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the BooleanLiteralProperty object itself. + */ + @Generated + public BooleanLiteralProperty setProperty(BooleanLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("property", this.property == null ? null : this.property.toBoolean()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BooleanLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BooleanLiteralProperty 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 BooleanLiteralProperty. + */ + @Generated + public static BooleanLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BooleanLiteralProperty deserializedBooleanLiteralProperty = new BooleanLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedBooleanLiteralProperty.property + = BooleanLiteralPropertyProperty.fromBoolean(reader.getBoolean()); + } else { + reader.skipChildren(); + } + } + + return deserializedBooleanLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BooleanLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BooleanLiteralPropertyProperty.java new file mode 100644 index 000000000..9a51ba705 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BooleanLiteralPropertyProperty.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.models; + +/** + * Defines values for BooleanLiteralPropertyProperty. + */ +public enum BooleanLiteralPropertyProperty { + /** + * Enum value true. + */ + TRUE(true); + + /** + * The actual serialized value for a BooleanLiteralPropertyProperty instance. + */ + private final boolean value; + + BooleanLiteralPropertyProperty(boolean value) { + this.value = value; + } + + /** + * Parses a serialized value to a BooleanLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed BooleanLiteralPropertyProperty object, or null if unable to parse. + */ + public static BooleanLiteralPropertyProperty fromBoolean(boolean value) { + BooleanLiteralPropertyProperty[] items = BooleanLiteralPropertyProperty.values(); + for (BooleanLiteralPropertyProperty item : items) { + if (item.toBoolean() == value) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to boolean value. + * + * @return the boolean value. + */ + public boolean toBoolean() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BytesProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BytesProperty.java new file mode 100644 index 000000000..78a54d588 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/BytesProperty.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Template type for testing models with optional property. Pass in the type of the property you are looking for. + */ +@Fluent +public final class BytesProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private byte[] property; + + /** + * Creates an instance of BytesProperty class. + */ + @Generated + public BytesProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public byte[] getProperty() { + return CoreUtils.clone(this.property); + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the BytesProperty object itself. + */ + @Generated + public BytesProperty setProperty(byte[] property) { + this.property = CoreUtils.clone(property); + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBinaryField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BytesProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BytesProperty 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 BytesProperty. + */ + @Generated + public static BytesProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BytesProperty deserializedBytesProperty = new BytesProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedBytesProperty.property = reader.getBinary(); + } else { + reader.skipChildren(); + } + } + + return deserializedBytesProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/CollectionsByteProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/CollectionsByteProperty.java new file mode 100644 index 000000000..e2b0a94a7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/CollectionsByteProperty.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; +import java.util.List; + +/** + * Model with collection bytes properties. + */ +@Fluent +public final class CollectionsByteProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private List property; + + /** + * Creates an instance of CollectionsByteProperty class. + */ + @Generated + public CollectionsByteProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public List getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the CollectionsByteProperty object itself. + */ + @Generated + public CollectionsByteProperty setProperty(List property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("property", this.property, (writer, element) -> writer.writeBinary(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsByteProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsByteProperty 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 CollectionsByteProperty. + */ + @Generated + public static CollectionsByteProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CollectionsByteProperty deserializedCollectionsByteProperty = new CollectionsByteProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + List property = reader.readArray(reader1 -> reader1.getBinary()); + deserializedCollectionsByteProperty.property = property; + } else { + reader.skipChildren(); + } + } + + return deserializedCollectionsByteProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/CollectionsModelProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/CollectionsModelProperty.java new file mode 100644 index 000000000..ee0f6c81e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/CollectionsModelProperty.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; +import java.util.List; + +/** + * Model with collection models properties. + */ +@Fluent +public final class CollectionsModelProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private List property; + + /** + * Creates an instance of CollectionsModelProperty class. + */ + @Generated + public CollectionsModelProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public List getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the CollectionsModelProperty object itself. + */ + @Generated + public CollectionsModelProperty setProperty(List property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("property", this.property, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsModelProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsModelProperty 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 CollectionsModelProperty. + */ + @Generated + public static CollectionsModelProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CollectionsModelProperty deserializedCollectionsModelProperty = new CollectionsModelProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + List property = reader.readArray(reader1 -> StringProperty.fromJson(reader1)); + deserializedCollectionsModelProperty.property = property; + } else { + reader.skipChildren(); + } + } + + return deserializedCollectionsModelProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/DatetimeProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/DatetimeProperty.java new file mode 100644 index 000000000..8cd50ea09 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/DatetimeProperty.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +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.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Model with a datetime property. + */ +@Fluent +public final class DatetimeProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private OffsetDateTime property; + + /** + * Creates an instance of DatetimeProperty class. + */ + @Generated + public DatetimeProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public OffsetDateTime getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the DatetimeProperty object itself. + */ + @Generated + public DatetimeProperty setProperty(OffsetDateTime property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", + this.property == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.property)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DatetimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DatetimeProperty 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 DatetimeProperty. + */ + @Generated + public static DatetimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DatetimeProperty deserializedDatetimeProperty = new DatetimeProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedDatetimeProperty.property = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedDatetimeProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/DurationProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/DurationProperty.java new file mode 100644 index 000000000..5d04dbcf6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/DurationProperty.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +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.time.Duration; + +/** + * Model with a duration property. + */ +@Fluent +public final class DurationProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private Duration property; + + /** + * Creates an instance of DurationProperty class. + */ + @Generated + public DurationProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public Duration getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the DurationProperty object itself. + */ + @Generated + public DurationProperty setProperty(Duration property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", CoreUtils.durationToStringWithDays(this.property)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DurationProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DurationProperty 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 DurationProperty. + */ + @Generated + public static DurationProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DurationProperty deserializedDurationProperty = new DurationProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedDurationProperty.property + = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedDurationProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/FloatLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/FloatLiteralProperty.java new file mode 100644 index 000000000..a8fa21684 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/FloatLiteralProperty.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; + +/** + * Model with float literal property. + */ +@Fluent +public final class FloatLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private FloatLiteralPropertyProperty property; + + /** + * Creates an instance of FloatLiteralProperty class. + */ + @Generated + public FloatLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public FloatLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the FloatLiteralProperty object itself. + */ + @Generated + public FloatLiteralProperty setProperty(FloatLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property == null ? null : this.property.toDouble()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FloatLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FloatLiteralProperty 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 FloatLiteralProperty. + */ + @Generated + public static FloatLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FloatLiteralProperty deserializedFloatLiteralProperty = new FloatLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedFloatLiteralProperty.property + = FloatLiteralPropertyProperty.fromDouble(reader.getDouble()); + } else { + reader.skipChildren(); + } + } + + return deserializedFloatLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/FloatLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/FloatLiteralPropertyProperty.java new file mode 100644 index 000000000..8c313b5eb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/FloatLiteralPropertyProperty.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.models; + +/** + * Defines values for FloatLiteralPropertyProperty. + */ +public enum FloatLiteralPropertyProperty { + /** + * Enum value 1.25. + */ + ONE_TWO_FIVE(1.25); + + /** + * The actual serialized value for a FloatLiteralPropertyProperty instance. + */ + private final double value; + + FloatLiteralPropertyProperty(double value) { + this.value = value; + } + + /** + * Parses a serialized value to a FloatLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed FloatLiteralPropertyProperty object, or null if unable to parse. + */ + public static FloatLiteralPropertyProperty fromDouble(double value) { + FloatLiteralPropertyProperty[] items = FloatLiteralPropertyProperty.values(); + for (FloatLiteralPropertyProperty item : items) { + if (Double.doubleToLongBits(item.toDouble()) == Double.doubleToLongBits(value)) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to double value. + * + * @return the double value. + */ + public double toDouble() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/IntLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/IntLiteralProperty.java new file mode 100644 index 000000000..ea98bf571 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/IntLiteralProperty.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; + +/** + * Model with int literal property. + */ +@Fluent +public final class IntLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private IntLiteralPropertyProperty property; + + /** + * Creates an instance of IntLiteralProperty class. + */ + @Generated + public IntLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public IntLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the IntLiteralProperty object itself. + */ + @Generated + public IntLiteralProperty setProperty(IntLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property == null ? null : this.property.toInt()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IntLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IntLiteralProperty 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 IntLiteralProperty. + */ + @Generated + public static IntLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + IntLiteralProperty deserializedIntLiteralProperty = new IntLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedIntLiteralProperty.property = IntLiteralPropertyProperty.fromInt(reader.getInt()); + } else { + reader.skipChildren(); + } + } + + return deserializedIntLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/IntLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/IntLiteralPropertyProperty.java new file mode 100644 index 000000000..9aeb70262 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/IntLiteralPropertyProperty.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.models; + +/** + * Defines values for IntLiteralPropertyProperty. + */ +public enum IntLiteralPropertyProperty { + /** + * Enum value 1. + */ + ONE(1); + + /** + * The actual serialized value for a IntLiteralPropertyProperty instance. + */ + private final int value; + + IntLiteralPropertyProperty(int value) { + this.value = value; + } + + /** + * Parses a serialized value to a IntLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed IntLiteralPropertyProperty object, or null if unable to parse. + */ + public static IntLiteralPropertyProperty fromInt(int value) { + IntLiteralPropertyProperty[] items = IntLiteralPropertyProperty.values(); + for (IntLiteralPropertyProperty item : items) { + if (item.toInt() == value) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to int value. + * + * @return the int value. + */ + public int toInt() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/PlainDateProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/PlainDateProperty.java new file mode 100644 index 000000000..873c7c246 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/PlainDateProperty.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; +import java.time.LocalDate; +import java.util.Objects; + +/** + * Model with a plainDate property. + */ +@Fluent +public final class PlainDateProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private LocalDate property; + + /** + * Creates an instance of PlainDateProperty class. + */ + @Generated + public PlainDateProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public LocalDate getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the PlainDateProperty object itself. + */ + @Generated + public PlainDateProperty setProperty(LocalDate property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", Objects.toString(this.property, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PlainDateProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PlainDateProperty 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 PlainDateProperty. + */ + @Generated + public static PlainDateProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PlainDateProperty deserializedPlainDateProperty = new PlainDateProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedPlainDateProperty.property + = reader.getNullable(nonNullReader -> LocalDate.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedPlainDateProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/PlainTimeProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/PlainTimeProperty.java new file mode 100644 index 000000000..47bccd9ed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/PlainTimeProperty.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; + +/** + * Model with a plainTime property. + */ +@Fluent +public final class PlainTimeProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private String property; + + /** + * Creates an instance of PlainTimeProperty class. + */ + @Generated + public PlainTimeProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public String getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the PlainTimeProperty object itself. + */ + @Generated + public PlainTimeProperty setProperty(String property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PlainTimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PlainTimeProperty 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 PlainTimeProperty. + */ + @Generated + public static PlainTimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PlainTimeProperty deserializedPlainTimeProperty = new PlainTimeProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedPlainTimeProperty.property = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedPlainTimeProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/RequiredAndOptionalProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/RequiredAndOptionalProperty.java new file mode 100644 index 000000000..e98c83a5b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/RequiredAndOptionalProperty.java @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; + +/** + * Model with required and optional properties. + */ +@Fluent +public final class RequiredAndOptionalProperty implements JsonSerializable { + /* + * optional string property + */ + @Generated + private String optionalProperty; + + /* + * required int property + */ + @Generated + private final int requiredProperty; + + /** + * Creates an instance of RequiredAndOptionalProperty class. + * + * @param requiredProperty the requiredProperty value to set. + */ + @Generated + public RequiredAndOptionalProperty(int requiredProperty) { + this.requiredProperty = requiredProperty; + } + + /** + * Get the optionalProperty property: optional string property. + * + * @return the optionalProperty value. + */ + @Generated + public String getOptionalProperty() { + return this.optionalProperty; + } + + /** + * Set the optionalProperty property: optional string property. + * + * @param optionalProperty the optionalProperty value to set. + * @return the RequiredAndOptionalProperty object itself. + */ + @Generated + public RequiredAndOptionalProperty setOptionalProperty(String optionalProperty) { + this.optionalProperty = optionalProperty; + return this; + } + + /** + * Get the requiredProperty property: required int property. + * + * @return the requiredProperty value. + */ + @Generated + public int getRequiredProperty() { + return this.requiredProperty; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("requiredProperty", this.requiredProperty); + jsonWriter.writeStringField("optionalProperty", this.optionalProperty); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RequiredAndOptionalProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RequiredAndOptionalProperty 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 RequiredAndOptionalProperty. + */ + @Generated + public static RequiredAndOptionalProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int requiredProperty = 0; + String optionalProperty = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + requiredProperty = reader.getInt(); + } else if ("optionalProperty".equals(fieldName)) { + optionalProperty = reader.getString(); + } else { + reader.skipChildren(); + } + } + RequiredAndOptionalProperty deserializedRequiredAndOptionalProperty + = new RequiredAndOptionalProperty(requiredProperty); + deserializedRequiredAndOptionalProperty.optionalProperty = optionalProperty; + + return deserializedRequiredAndOptionalProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringLiteralProperty.java new file mode 100644 index 000000000..00f7cf498 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringLiteralProperty.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; + +/** + * Model with string literal property. + */ +@Fluent +public final class StringLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private StringLiteralPropertyProperty property; + + /** + * Creates an instance of StringLiteralProperty class. + */ + @Generated + public StringLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public StringLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the StringLiteralProperty object itself. + */ + @Generated + public StringLiteralProperty setProperty(StringLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property == null ? null : this.property.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StringLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StringLiteralProperty 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 StringLiteralProperty. + */ + @Generated + public static StringLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringLiteralProperty deserializedStringLiteralProperty = new StringLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedStringLiteralProperty.property + = StringLiteralPropertyProperty.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedStringLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringLiteralPropertyProperty.java new file mode 100644 index 000000000..e9e47354f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringLiteralPropertyProperty.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.models; + +/** + * Defines values for StringLiteralPropertyProperty. + */ +public enum StringLiteralPropertyProperty { + /** + * Enum value hello. + */ + HELLO("hello"); + + /** + * The actual serialized value for a StringLiteralPropertyProperty instance. + */ + private final String value; + + StringLiteralPropertyProperty(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a StringLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed StringLiteralPropertyProperty object, or null if unable to parse. + */ + public static StringLiteralPropertyProperty fromString(String value) { + if (value == null) { + return null; + } + StringLiteralPropertyProperty[] items = StringLiteralPropertyProperty.values(); + for (StringLiteralPropertyProperty item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringProperty.java new file mode 100644 index 000000000..feb394f99 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/StringProperty.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; + +/** + * Template type for testing models with optional property. Pass in the type of the property you are looking for. + */ +@Fluent +public final class StringProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private String property; + + /** + * Creates an instance of StringProperty class. + */ + @Generated + public StringProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public String getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the StringProperty object itself. + */ + @Generated + public StringProperty setProperty(String property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StringProperty 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 StringProperty. + */ + @Generated + public static StringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringProperty deserializedStringProperty = new StringProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedStringProperty.property = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedStringProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionFloatLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionFloatLiteralProperty.java new file mode 100644 index 000000000..b95b4caef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionFloatLiteralProperty.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; + +/** + * Model with union of float literal property. + */ +@Fluent +public final class UnionFloatLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private UnionFloatLiteralPropertyProperty property; + + /** + * Creates an instance of UnionFloatLiteralProperty class. + */ + @Generated + public UnionFloatLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public UnionFloatLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the UnionFloatLiteralProperty object itself. + */ + @Generated + public UnionFloatLiteralProperty setProperty(UnionFloatLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property == null ? null : this.property.toDouble()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionFloatLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionFloatLiteralProperty 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 UnionFloatLiteralProperty. + */ + @Generated + public static UnionFloatLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionFloatLiteralProperty deserializedUnionFloatLiteralProperty = new UnionFloatLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedUnionFloatLiteralProperty.property + = UnionFloatLiteralPropertyProperty.fromDouble(reader.getDouble()); + } else { + reader.skipChildren(); + } + } + + return deserializedUnionFloatLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionFloatLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionFloatLiteralPropertyProperty.java new file mode 100644 index 000000000..673f70089 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionFloatLiteralPropertyProperty.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.models; + +/** + * Defines values for UnionFloatLiteralPropertyProperty. + */ +public enum UnionFloatLiteralPropertyProperty { + /** + * Enum value 1.25. + */ + ONE_TWO_FIVE(1.25), + + /** + * Enum value 2.375. + */ + TWO_THREE_SEVEN_FIVE(2.375); + + /** + * The actual serialized value for a UnionFloatLiteralPropertyProperty instance. + */ + private final double value; + + UnionFloatLiteralPropertyProperty(double value) { + this.value = value; + } + + /** + * Parses a serialized value to a UnionFloatLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed UnionFloatLiteralPropertyProperty object, or null if unable to parse. + */ + public static UnionFloatLiteralPropertyProperty fromDouble(double value) { + UnionFloatLiteralPropertyProperty[] items = UnionFloatLiteralPropertyProperty.values(); + for (UnionFloatLiteralPropertyProperty item : items) { + if (Double.doubleToLongBits(item.toDouble()) == Double.doubleToLongBits(value)) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to double value. + * + * @return the double value. + */ + public double toDouble() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionIntLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionIntLiteralProperty.java new file mode 100644 index 000000000..af01ecfd0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionIntLiteralProperty.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; + +/** + * Model with union of int literal property. + */ +@Fluent +public final class UnionIntLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private UnionIntLiteralPropertyProperty property; + + /** + * Creates an instance of UnionIntLiteralProperty class. + */ + @Generated + public UnionIntLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public UnionIntLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the UnionIntLiteralProperty object itself. + */ + @Generated + public UnionIntLiteralProperty setProperty(UnionIntLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property == null ? null : this.property.toInt()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionIntLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionIntLiteralProperty 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 UnionIntLiteralProperty. + */ + @Generated + public static UnionIntLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionIntLiteralProperty deserializedUnionIntLiteralProperty = new UnionIntLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedUnionIntLiteralProperty.property + = UnionIntLiteralPropertyProperty.fromInt(reader.getInt()); + } else { + reader.skipChildren(); + } + } + + return deserializedUnionIntLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionIntLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionIntLiteralPropertyProperty.java new file mode 100644 index 000000000..180cb8903 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionIntLiteralPropertyProperty.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.models; + +/** + * Defines values for UnionIntLiteralPropertyProperty. + */ +public enum UnionIntLiteralPropertyProperty { + /** + * Enum value 1. + */ + ONE(1), + + /** + * Enum value 2. + */ + TWO(2); + + /** + * The actual serialized value for a UnionIntLiteralPropertyProperty instance. + */ + private final int value; + + UnionIntLiteralPropertyProperty(int value) { + this.value = value; + } + + /** + * Parses a serialized value to a UnionIntLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed UnionIntLiteralPropertyProperty object, or null if unable to parse. + */ + public static UnionIntLiteralPropertyProperty fromInt(int value) { + UnionIntLiteralPropertyProperty[] items = UnionIntLiteralPropertyProperty.values(); + for (UnionIntLiteralPropertyProperty item : items) { + if (item.toInt() == value) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to int value. + * + * @return the int value. + */ + public int toInt() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionStringLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionStringLiteralProperty.java new file mode 100644 index 000000000..993b32cf1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionStringLiteralProperty.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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; + +/** + * Model with union of string literal property. + */ +@Fluent +public final class UnionStringLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private UnionStringLiteralPropertyProperty property; + + /** + * Creates an instance of UnionStringLiteralProperty class. + */ + @Generated + public UnionStringLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public UnionStringLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the UnionStringLiteralProperty object itself. + */ + @Generated + public UnionStringLiteralProperty setProperty(UnionStringLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property == null ? null : this.property.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionStringLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionStringLiteralProperty 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 UnionStringLiteralProperty. + */ + @Generated + public static UnionStringLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionStringLiteralProperty deserializedUnionStringLiteralProperty = new UnionStringLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedUnionStringLiteralProperty.property + = UnionStringLiteralPropertyProperty.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedUnionStringLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionStringLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionStringLiteralPropertyProperty.java new file mode 100644 index 000000000..db22621f2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/UnionStringLiteralPropertyProperty.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 com.type.property.optional.models; + +/** + * Defines values for UnionStringLiteralPropertyProperty. + */ +public enum UnionStringLiteralPropertyProperty { + /** + * Enum value hello. + */ + HELLO("hello"), + + /** + * Enum value world. + */ + WORLD("world"); + + /** + * The actual serialized value for a UnionStringLiteralPropertyProperty instance. + */ + private final String value; + + UnionStringLiteralPropertyProperty(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a UnionStringLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed UnionStringLiteralPropertyProperty object, or null if unable to parse. + */ + public static UnionStringLiteralPropertyProperty fromString(String value) { + if (value == null) { + return null; + } + UnionStringLiteralPropertyProperty[] items = UnionStringLiteralPropertyProperty.values(); + for (UnionStringLiteralPropertyProperty item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/models/package-info.java new file mode 100644 index 000000000..8b279644e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/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 Optional. + * Illustrates models with optional properties. + * + */ +package com.type.property.optional.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/package-info.java new file mode 100644 index 000000000..363240a35 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/optional/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 Optional. + * Illustrates models with optional properties. + * + */ +package com.type.property.optional; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BooleanLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BooleanLiteralAsyncClient.java new file mode 100644 index 000000000..b6af04d1c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BooleanLiteralAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.BooleanLiteralsImpl; +import com.type.property.valuetypes.models.BooleanLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class BooleanLiteralAsyncClient { + @Generated + private final BooleanLiteralsImpl serviceClient; + + /** + * Initializes an instance of BooleanLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BooleanLiteralAsyncClient(BooleanLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BooleanLiteralProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(BooleanLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BooleanLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BooleanLiteralClient.java new file mode 100644 index 000000000..6b0a528a2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BooleanLiteralClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.BooleanLiteralsImpl; +import com.type.property.valuetypes.models.BooleanLiteralProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class BooleanLiteralClient { + @Generated + private final BooleanLiteralsImpl serviceClient; + + /** + * Initializes an instance of BooleanLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BooleanLiteralClient(BooleanLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BooleanLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(BooleanLiteralProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(BooleanLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BooleanOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BooleanOperationAsyncClient.java new file mode 100644 index 000000000..ab3775f86 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BooleanOperationAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.BooleanOperationsImpl; +import com.type.property.valuetypes.models.BooleanProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class BooleanOperationAsyncClient { + @Generated + private final BooleanOperationsImpl serviceClient; + + /** + * Initializes an instance of BooleanOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BooleanOperationAsyncClient(BooleanOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BooleanProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(BooleanProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BooleanOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BooleanOperationClient.java new file mode 100644 index 000000000..d4e7f5dd0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BooleanOperationClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.BooleanOperationsImpl; +import com.type.property.valuetypes.models.BooleanProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class BooleanOperationClient { + @Generated + private final BooleanOperationsImpl serviceClient; + + /** + * Initializes an instance of BooleanOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BooleanOperationClient(BooleanOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BooleanProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(BooleanProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(BooleanProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BytesAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BytesAsyncClient.java new file mode 100644 index 000000000..dd79a17a7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BytesAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.BytesImpl; +import com.type.property.valuetypes.models.BytesProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class BytesAsyncClient { + @Generated + private final BytesImpl serviceClient; + + /** + * Initializes an instance of BytesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BytesAsyncClient(BytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BytesProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(BytesProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BytesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BytesClient.java new file mode 100644 index 000000000..d3615f65a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/BytesClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.BytesImpl; +import com.type.property.valuetypes.models.BytesProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class BytesClient { + @Generated + private final BytesImpl serviceClient; + + /** + * Initializes an instance of BytesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BytesClient(BytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BytesProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(BytesProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(BytesProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsIntAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsIntAsyncClient.java new file mode 100644 index 000000000..2828e55a2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsIntAsyncClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.CollectionsIntsImpl; +import com.type.property.valuetypes.models.CollectionsIntProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class CollectionsIntAsyncClient { + @Generated + private final CollectionsIntsImpl serviceClient; + + /** + * Initializes an instance of CollectionsIntAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsIntAsyncClient(CollectionsIntsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsIntProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(CollectionsIntProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsIntClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsIntClient.java new file mode 100644 index 000000000..0d3b0442e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsIntClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.CollectionsIntsImpl; +import com.type.property.valuetypes.models.CollectionsIntProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class CollectionsIntClient { + @Generated + private final CollectionsIntsImpl serviceClient; + + /** + * Initializes an instance of CollectionsIntClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsIntClient(CollectionsIntsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsIntProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(CollectionsIntProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(CollectionsIntProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsModelAsyncClient.java new file mode 100644 index 000000000..b193658be --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsModelAsyncClient.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.CollectionsModelsImpl; +import com.type.property.valuetypes.models.CollectionsModelProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class CollectionsModelAsyncClient { + @Generated + private final CollectionsModelsImpl serviceClient; + + /** + * Initializes an instance of CollectionsModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsModelAsyncClient(CollectionsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *          (Required){
+     *             property: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *          (Required){
+     *             property: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsModelProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(CollectionsModelProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsModelClient.java new file mode 100644 index 000000000..5ba3a996d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsModelClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.CollectionsModelsImpl; +import com.type.property.valuetypes.models.CollectionsModelProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class CollectionsModelClient { + @Generated + private final CollectionsModelsImpl serviceClient; + + /** + * Initializes an instance of CollectionsModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsModelClient(CollectionsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *          (Required){
+     *             property: String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *          (Required){
+     *             property: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsModelProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(CollectionsModelProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(CollectionsModelProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsStringAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsStringAsyncClient.java new file mode 100644 index 000000000..c4d33d5d2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsStringAsyncClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.CollectionsStringsImpl; +import com.type.property.valuetypes.models.CollectionsStringProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class CollectionsStringAsyncClient { + @Generated + private final CollectionsStringsImpl serviceClient; + + /** + * Initializes an instance of CollectionsStringAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsStringAsyncClient(CollectionsStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         String (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CollectionsStringProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(CollectionsStringProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsStringClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsStringClient.java new file mode 100644 index 000000000..18405b33e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/CollectionsStringClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.CollectionsStringsImpl; +import com.type.property.valuetypes.models.CollectionsStringProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class CollectionsStringClient { + @Generated + private final CollectionsStringsImpl serviceClient; + + /** + * Initializes an instance of CollectionsStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + CollectionsStringClient(CollectionsStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         String (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CollectionsStringProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(CollectionsStringProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(CollectionsStringProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DatetimeOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DatetimeOperationAsyncClient.java new file mode 100644 index 000000000..421c87f11 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DatetimeOperationAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.DatetimeOperationsImpl; +import com.type.property.valuetypes.models.DatetimeProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class DatetimeOperationAsyncClient { + @Generated + private final DatetimeOperationsImpl serviceClient; + + /** + * Initializes an instance of DatetimeOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DatetimeOperationAsyncClient(DatetimeOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DatetimeProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DatetimeProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DatetimeOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DatetimeOperationClient.java new file mode 100644 index 000000000..4c2c29ea5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DatetimeOperationClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.DatetimeOperationsImpl; +import com.type.property.valuetypes.models.DatetimeProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class DatetimeOperationClient { + @Generated + private final DatetimeOperationsImpl serviceClient; + + /** + * Initializes an instance of DatetimeOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DatetimeOperationClient(DatetimeOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DatetimeProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(DatetimeProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DatetimeProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/Decimal128AsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/Decimal128AsyncClient.java new file mode 100644 index 000000000..bbb25640c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/Decimal128AsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.Decimal128sImpl; +import com.type.property.valuetypes.models.Decimal128Property; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class Decimal128AsyncClient { + @Generated + private final Decimal128sImpl serviceClient; + + /** + * Initializes an instance of Decimal128AsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Decimal128AsyncClient(Decimal128sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Decimal128Property.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(Decimal128Property body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/Decimal128Client.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/Decimal128Client.java new file mode 100644 index 000000000..6b2e7e0b7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/Decimal128Client.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.Decimal128sImpl; +import com.type.property.valuetypes.models.Decimal128Property; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class Decimal128Client { + @Generated + private final Decimal128sImpl serviceClient; + + /** + * Initializes an instance of Decimal128Client class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Decimal128Client(Decimal128sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Decimal128Property get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(Decimal128Property.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(Decimal128Property body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DecimalAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DecimalAsyncClient.java new file mode 100644 index 000000000..10495283a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DecimalAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.DecimalsImpl; +import com.type.property.valuetypes.models.DecimalProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class DecimalAsyncClient { + @Generated + private final DecimalsImpl serviceClient; + + /** + * Initializes an instance of DecimalAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DecimalAsyncClient(DecimalsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DecimalProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DecimalProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DecimalClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DecimalClient.java new file mode 100644 index 000000000..f3f222323 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DecimalClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.DecimalsImpl; +import com.type.property.valuetypes.models.DecimalProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class DecimalClient { + @Generated + private final DecimalsImpl serviceClient; + + /** + * Initializes an instance of DecimalClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DecimalClient(DecimalsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DecimalProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(DecimalProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DecimalProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DictionaryStringAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DictionaryStringAsyncClient.java new file mode 100644 index 000000000..b776f2e00 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DictionaryStringAsyncClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.DictionaryStringsImpl; +import com.type.property.valuetypes.models.DictionaryStringProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class DictionaryStringAsyncClient { + @Generated + private final DictionaryStringsImpl serviceClient; + + /** + * Initializes an instance of DictionaryStringAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DictionaryStringAsyncClient(DictionaryStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         String: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DictionaryStringProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DictionaryStringProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DictionaryStringClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DictionaryStringClient.java new file mode 100644 index 000000000..0b7e9ca73 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DictionaryStringClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.DictionaryStringsImpl; +import com.type.property.valuetypes.models.DictionaryStringProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class DictionaryStringClient { + @Generated + private final DictionaryStringsImpl serviceClient; + + /** + * Initializes an instance of DictionaryStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DictionaryStringClient(DictionaryStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         String: String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DictionaryStringProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(DictionaryStringProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DictionaryStringProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DurationOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DurationOperationAsyncClient.java new file mode 100644 index 000000000..bf2371059 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DurationOperationAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.DurationOperationsImpl; +import com.type.property.valuetypes.models.DurationProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class DurationOperationAsyncClient { + @Generated + private final DurationOperationsImpl serviceClient; + + /** + * Initializes an instance of DurationOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DurationOperationAsyncClient(DurationOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DurationProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DurationProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DurationOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DurationOperationClient.java new file mode 100644 index 000000000..f8452ab30 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/DurationOperationClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.DurationOperationsImpl; +import com.type.property.valuetypes.models.DurationProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class DurationOperationClient { + @Generated + private final DurationOperationsImpl serviceClient; + + /** + * Initializes an instance of DurationOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DurationOperationClient(DurationOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DurationProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(DurationProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(DurationProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/EnumAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/EnumAsyncClient.java new file mode 100644 index 000000000..6c8d1e4a5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/EnumAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.EnumsImpl; +import com.type.property.valuetypes.models.EnumProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class EnumAsyncClient { + @Generated + private final EnumsImpl serviceClient; + + /** + * Initializes an instance of EnumAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EnumAsyncClient(EnumsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(EnumProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(EnumProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/EnumClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/EnumClient.java new file mode 100644 index 000000000..a80ef76be --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/EnumClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.EnumsImpl; +import com.type.property.valuetypes.models.EnumProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class EnumClient { + @Generated + private final EnumsImpl serviceClient; + + /** + * Initializes an instance of EnumClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EnumClient(EnumsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public EnumProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(EnumProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(EnumProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ExtensibleEnumAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ExtensibleEnumAsyncClient.java new file mode 100644 index 000000000..f7dec5b95 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ExtensibleEnumAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.ExtensibleEnumsImpl; +import com.type.property.valuetypes.models.ExtensibleEnumProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class ExtensibleEnumAsyncClient { + @Generated + private final ExtensibleEnumsImpl serviceClient; + + /** + * Initializes an instance of ExtensibleEnumAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtensibleEnumAsyncClient(ExtensibleEnumsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ExtensibleEnumProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtensibleEnumProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ExtensibleEnumClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ExtensibleEnumClient.java new file mode 100644 index 000000000..d5085c204 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ExtensibleEnumClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.ExtensibleEnumsImpl; +import com.type.property.valuetypes.models.ExtensibleEnumProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class ExtensibleEnumClient { + @Generated + private final ExtensibleEnumsImpl serviceClient; + + /** + * Initializes an instance of ExtensibleEnumClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ExtensibleEnumClient(ExtensibleEnumsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ExtensibleEnumProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(ExtensibleEnumProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ExtensibleEnumProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/FloatLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/FloatLiteralAsyncClient.java new file mode 100644 index 000000000..8079183e5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/FloatLiteralAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.FloatLiteralsImpl; +import com.type.property.valuetypes.models.FloatLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class FloatLiteralAsyncClient { + @Generated + private final FloatLiteralsImpl serviceClient; + + /** + * Initializes an instance of FloatLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FloatLiteralAsyncClient(FloatLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FloatLiteralProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(FloatLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/FloatLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/FloatLiteralClient.java new file mode 100644 index 000000000..2ff74c584 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/FloatLiteralClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.FloatLiteralsImpl; +import com.type.property.valuetypes.models.FloatLiteralProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class FloatLiteralClient { + @Generated + private final FloatLiteralsImpl serviceClient; + + /** + * Initializes an instance of FloatLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FloatLiteralClient(FloatLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: double (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FloatLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(FloatLiteralProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(FloatLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/FloatOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/FloatOperationAsyncClient.java new file mode 100644 index 000000000..a2ce50e82 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/FloatOperationAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.FloatOperationsImpl; +import com.type.property.valuetypes.models.FloatProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class FloatOperationAsyncClient { + @Generated + private final FloatOperationsImpl serviceClient; + + /** + * Initializes an instance of FloatOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FloatOperationAsyncClient(FloatOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FloatProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(FloatProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/FloatOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/FloatOperationClient.java new file mode 100644 index 000000000..fb2acae46 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/FloatOperationClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.FloatOperationsImpl; +import com.type.property.valuetypes.models.FloatProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class FloatOperationClient { + @Generated + private final FloatOperationsImpl serviceClient; + + /** + * Initializes an instance of FloatOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FloatOperationClient(FloatOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: double (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FloatProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(FloatProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(FloatProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/IntAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/IntAsyncClient.java new file mode 100644 index 000000000..58bfa7d20 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/IntAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.IntsImpl; +import com.type.property.valuetypes.models.IntProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class IntAsyncClient { + @Generated + private final IntsImpl serviceClient; + + /** + * Initializes an instance of IntAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IntAsyncClient(IntsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: 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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(IntProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IntProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/IntClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/IntClient.java new file mode 100644 index 000000000..5af2cc2da --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/IntClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.IntsImpl; +import com.type.property.valuetypes.models.IntProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class IntClient { + @Generated + private final IntsImpl serviceClient; + + /** + * Initializes an instance of IntClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IntClient(IntsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: 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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public IntProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(IntProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IntProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/IntLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/IntLiteralAsyncClient.java new file mode 100644 index 000000000..5e47bc932 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/IntLiteralAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.IntLiteralsImpl; +import com.type.property.valuetypes.models.IntLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class IntLiteralAsyncClient { + @Generated + private final IntLiteralsImpl serviceClient; + + /** + * Initializes an instance of IntLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IntLiteralAsyncClient(IntLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: 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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(IntLiteralProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IntLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/IntLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/IntLiteralClient.java new file mode 100644 index 000000000..60d67a57b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/IntLiteralClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.IntLiteralsImpl; +import com.type.property.valuetypes.models.IntLiteralProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class IntLiteralClient { + @Generated + private final IntLiteralsImpl serviceClient; + + /** + * Initializes an instance of IntLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IntLiteralClient(IntLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: 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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public IntLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(IntLiteralProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(IntLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ModelAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ModelAsyncClient.java new file mode 100644 index 000000000..c75310c16 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ModelAsyncClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.ModelsImpl; +import com.type.property.valuetypes.models.ModelProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class ModelAsyncClient { + @Generated + private final ModelsImpl serviceClient; + + /** + * Initializes an instance of ModelAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelAsyncClient(ModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         property: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         property: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ModelProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ModelProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ModelClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ModelClient.java new file mode 100644 index 000000000..9e9cba458 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ModelClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.ModelsImpl; +import com.type.property.valuetypes.models.ModelProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class ModelClient { + @Generated + private final ModelsImpl serviceClient; + + /** + * Initializes an instance of ModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelClient(ModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         property: String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         property: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ModelProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(ModelProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(ModelProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/NeverAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/NeverAsyncClient.java new file mode 100644 index 000000000..a2dfced92 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/NeverAsyncClient.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 com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.NeversImpl; +import com.type.property.valuetypes.models.NeverProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class NeverAsyncClient { + @Generated + private final NeversImpl serviceClient; + + /** + * Initializes an instance of NeverAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NeverAsyncClient(NeversImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(NeverProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(NeverProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/NeverClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/NeverClient.java new file mode 100644 index 000000000..27bb34204 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/NeverClient.java @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.NeversImpl; +import com.type.property.valuetypes.models.NeverProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class NeverClient { + @Generated + private final NeversImpl serviceClient; + + /** + * Initializes an instance of NeverClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NeverClient(NeversImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public NeverProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(NeverProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(NeverProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/StringLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/StringLiteralAsyncClient.java new file mode 100644 index 000000000..89e6d85cc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/StringLiteralAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.StringLiteralsImpl; +import com.type.property.valuetypes.models.StringLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class StringLiteralAsyncClient { + @Generated + private final StringLiteralsImpl serviceClient; + + /** + * Initializes an instance of StringLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringLiteralAsyncClient(StringLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(StringLiteralProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(StringLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/StringLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/StringLiteralClient.java new file mode 100644 index 000000000..6e7d29ce6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/StringLiteralClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.StringLiteralsImpl; +import com.type.property.valuetypes.models.StringLiteralProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class StringLiteralClient { + @Generated + private final StringLiteralsImpl serviceClient; + + /** + * Initializes an instance of StringLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringLiteralClient(StringLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public StringLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(StringLiteralProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(StringLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/StringOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/StringOperationAsyncClient.java new file mode 100644 index 000000000..f1208deeb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/StringOperationAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.StringOperationsImpl; +import com.type.property.valuetypes.models.StringProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class StringOperationAsyncClient { + @Generated + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of StringOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringOperationAsyncClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(StringProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(StringProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/StringOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/StringOperationClient.java new file mode 100644 index 000000000..a11dfddc5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/StringOperationClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.StringOperationsImpl; +import com.type.property.valuetypes.models.StringProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class StringOperationClient { + @Generated + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of StringOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringOperationClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public StringProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(StringProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(StringProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionEnumValueAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionEnumValueAsyncClient.java new file mode 100644 index 000000000..52d190338 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionEnumValueAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.UnionEnumValuesImpl; +import com.type.property.valuetypes.models.UnionEnumValueProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class UnionEnumValueAsyncClient { + @Generated + private final UnionEnumValuesImpl serviceClient; + + /** + * Initializes an instance of UnionEnumValueAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionEnumValueAsyncClient(UnionEnumValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(value2) (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(value2) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnionEnumValueProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnionEnumValueProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionEnumValueClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionEnumValueClient.java new file mode 100644 index 000000000..a1503da5f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionEnumValueClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.UnionEnumValuesImpl; +import com.type.property.valuetypes.models.UnionEnumValueProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnionEnumValueClient { + @Generated + private final UnionEnumValuesImpl serviceClient; + + /** + * Initializes an instance of UnionEnumValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionEnumValueClient(UnionEnumValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(value2) (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(value2) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnionEnumValueProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(UnionEnumValueProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnionEnumValueProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionFloatLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionFloatLiteralAsyncClient.java new file mode 100644 index 000000000..160e23a08 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionFloatLiteralAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.UnionFloatLiteralsImpl; +import com.type.property.valuetypes.models.UnionFloatLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class UnionFloatLiteralAsyncClient { + @Generated + private final UnionFloatLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionFloatLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionFloatLiteralAsyncClient(UnionFloatLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(43.125/46.875) (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(43.125/46.875) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnionFloatLiteralProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnionFloatLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionFloatLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionFloatLiteralClient.java new file mode 100644 index 000000000..5ce4c1c40 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionFloatLiteralClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.UnionFloatLiteralsImpl; +import com.type.property.valuetypes.models.UnionFloatLiteralProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnionFloatLiteralClient { + @Generated + private final UnionFloatLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionFloatLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionFloatLiteralClient(UnionFloatLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(43.125/46.875) (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(43.125/46.875) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnionFloatLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(UnionFloatLiteralProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnionFloatLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionIntLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionIntLiteralAsyncClient.java new file mode 100644 index 000000000..4855784b5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionIntLiteralAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.UnionIntLiteralsImpl; +import com.type.property.valuetypes.models.UnionIntLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class UnionIntLiteralAsyncClient { + @Generated + private final UnionIntLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionIntLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionIntLiteralAsyncClient(UnionIntLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(42/43) (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(42/43) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnionIntLiteralProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnionIntLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionIntLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionIntLiteralClient.java new file mode 100644 index 000000000..d570a5aa5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionIntLiteralClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.UnionIntLiteralsImpl; +import com.type.property.valuetypes.models.UnionIntLiteralProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnionIntLiteralClient { + @Generated + private final UnionIntLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionIntLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionIntLiteralClient(UnionIntLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(42/43) (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(42/43) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnionIntLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(UnionIntLiteralProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnionIntLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionStringLiteralAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionStringLiteralAsyncClient.java new file mode 100644 index 000000000..e64dcb924 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionStringLiteralAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.UnionStringLiteralsImpl; +import com.type.property.valuetypes.models.UnionStringLiteralProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class UnionStringLiteralAsyncClient { + @Generated + private final UnionStringLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionStringLiteralAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionStringLiteralAsyncClient(UnionStringLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnionStringLiteralProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnionStringLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionStringLiteralClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionStringLiteralClient.java new file mode 100644 index 000000000..933d39b0b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnionStringLiteralClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.UnionStringLiteralsImpl; +import com.type.property.valuetypes.models.UnionStringLiteralProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnionStringLiteralClient { + @Generated + private final UnionStringLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionStringLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnionStringLiteralClient(UnionStringLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnionStringLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(UnionStringLiteralProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnionStringLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownArrayAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownArrayAsyncClient.java new file mode 100644 index 000000000..770b3d5ee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownArrayAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.UnknownArraysImpl; +import com.type.property.valuetypes.models.UnknownArrayProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class UnknownArrayAsyncClient { + @Generated + private final UnknownArraysImpl serviceClient; + + /** + * Initializes an instance of UnknownArrayAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownArrayAsyncClient(UnknownArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnknownArrayProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnknownArrayProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownArrayClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownArrayClient.java new file mode 100644 index 000000000..a08599812 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownArrayClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.UnknownArraysImpl; +import com.type.property.valuetypes.models.UnknownArrayProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnknownArrayClient { + @Generated + private final UnknownArraysImpl serviceClient; + + /** + * Initializes an instance of UnknownArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownArrayClient(UnknownArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnknownArrayProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(UnknownArrayProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnknownArrayProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownDictAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownDictAsyncClient.java new file mode 100644 index 000000000..9460b676d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownDictAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.UnknownDictsImpl; +import com.type.property.valuetypes.models.UnknownDictProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class UnknownDictAsyncClient { + @Generated + private final UnknownDictsImpl serviceClient; + + /** + * Initializes an instance of UnknownDictAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownDictAsyncClient(UnknownDictsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnknownDictProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnknownDictProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownDictClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownDictClient.java new file mode 100644 index 000000000..754d29a11 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownDictClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.UnknownDictsImpl; +import com.type.property.valuetypes.models.UnknownDictProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnknownDictClient { + @Generated + private final UnknownDictsImpl serviceClient; + + /** + * Initializes an instance of UnknownDictClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownDictClient(UnknownDictsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnknownDictProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(UnknownDictProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnknownDictProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownIntAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownIntAsyncClient.java new file mode 100644 index 000000000..6dab5dae3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownIntAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.UnknownIntsImpl; +import com.type.property.valuetypes.models.UnknownIntProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class UnknownIntAsyncClient { + @Generated + private final UnknownIntsImpl serviceClient; + + /** + * Initializes an instance of UnknownIntAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownIntAsyncClient(UnknownIntsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnknownIntProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnknownIntProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownIntClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownIntClient.java new file mode 100644 index 000000000..1e8e38cbd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownIntClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.UnknownIntsImpl; +import com.type.property.valuetypes.models.UnknownIntProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnknownIntClient { + @Generated + private final UnknownIntsImpl serviceClient; + + /** + * Initializes an instance of UnknownIntClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownIntClient(UnknownIntsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnknownIntProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(UnknownIntProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnknownIntProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownStringAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownStringAsyncClient.java new file mode 100644 index 000000000..e8a87af73 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownStringAsyncClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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 com.type.property.valuetypes.implementation.UnknownStringsImpl; +import com.type.property.valuetypes.models.UnknownStringProperty; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class, isAsync = true) +public final class UnknownStringAsyncClient { + @Generated + private final UnknownStringsImpl serviceClient; + + /** + * Initializes an instance of UnknownStringAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownStringAsyncClient(UnknownStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * Get call. + * + * @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 call on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(UnknownStringProperty.class)); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnknownStringProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownStringClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownStringClient.java new file mode 100644 index 000000000..f4f9faf52 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/UnknownStringClient.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 com.type.property.valuetypes; + +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.type.property.valuetypes.implementation.UnknownStringsImpl; +import com.type.property.valuetypes.models.UnknownStringProperty; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnknownStringClient { + @Generated + private final UnknownStringsImpl serviceClient; + + /** + * Initializes an instance of UnknownStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownStringClient(UnknownStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @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 call. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public UnknownStringProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(UnknownStringProperty.class); + } + + /** + * Put operation. + * + * @param body body. + * @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 put(UnknownStringProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ValueTypesClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ValueTypesClientBuilder.java new file mode 100644 index 000000000..c08bd9971 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/ValueTypesClientBuilder.java @@ -0,0 +1,907 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.property.valuetypes.implementation.ValueTypesClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ValueTypesClient type. + */ +@ServiceClientBuilder( + serviceClients = { + BooleanOperationClient.class, + StringOperationClient.class, + BytesClient.class, + IntClient.class, + FloatOperationClient.class, + DecimalClient.class, + Decimal128Client.class, + DatetimeOperationClient.class, + DurationOperationClient.class, + EnumClient.class, + ExtensibleEnumClient.class, + ModelClient.class, + CollectionsStringClient.class, + CollectionsIntClient.class, + CollectionsModelClient.class, + DictionaryStringClient.class, + NeverClient.class, + UnknownStringClient.class, + UnknownIntClient.class, + UnknownDictClient.class, + UnknownArrayClient.class, + StringLiteralClient.class, + IntLiteralClient.class, + FloatLiteralClient.class, + BooleanLiteralClient.class, + UnionStringLiteralClient.class, + UnionIntLiteralClient.class, + UnionFloatLiteralClient.class, + UnionEnumValueClient.class, + BooleanOperationAsyncClient.class, + StringOperationAsyncClient.class, + BytesAsyncClient.class, + IntAsyncClient.class, + FloatOperationAsyncClient.class, + DecimalAsyncClient.class, + Decimal128AsyncClient.class, + DatetimeOperationAsyncClient.class, + DurationOperationAsyncClient.class, + EnumAsyncClient.class, + ExtensibleEnumAsyncClient.class, + ModelAsyncClient.class, + CollectionsStringAsyncClient.class, + CollectionsIntAsyncClient.class, + CollectionsModelAsyncClient.class, + DictionaryStringAsyncClient.class, + NeverAsyncClient.class, + UnknownStringAsyncClient.class, + UnknownIntAsyncClient.class, + UnknownDictAsyncClient.class, + UnknownArrayAsyncClient.class, + StringLiteralAsyncClient.class, + IntLiteralAsyncClient.class, + FloatLiteralAsyncClient.class, + BooleanLiteralAsyncClient.class, + UnionStringLiteralAsyncClient.class, + UnionIntLiteralAsyncClient.class, + UnionFloatLiteralAsyncClient.class, + UnionEnumValueAsyncClient.class }) +public final class ValueTypesClientBuilder 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("type-property-valuetypes.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ValueTypesClientBuilder. + */ + @Generated + public ValueTypesClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ValueTypesClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ValueTypesClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ValueTypesClientBuilder 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 ValueTypesClientBuilder 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 ValueTypesClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ValueTypesClientBuilder 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 ValueTypesClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ValueTypesClientBuilder 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 ValueTypesClientBuilder. + */ + @Generated + public ValueTypesClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ValueTypesClientImpl with the provided parameters. + * + * @return an instance of ValueTypesClientImpl. + */ + @Generated + private ValueTypesClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ValueTypesClientImpl client + = new ValueTypesClientImpl(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 BooleanOperationAsyncClient class. + * + * @return an instance of BooleanOperationAsyncClient. + */ + @Generated + public BooleanOperationAsyncClient buildBooleanOperationAsyncClient() { + return new BooleanOperationAsyncClient(buildInnerClient().getBooleanOperations()); + } + + /** + * Builds an instance of StringOperationAsyncClient class. + * + * @return an instance of StringOperationAsyncClient. + */ + @Generated + public StringOperationAsyncClient buildStringOperationAsyncClient() { + return new StringOperationAsyncClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of BytesAsyncClient class. + * + * @return an instance of BytesAsyncClient. + */ + @Generated + public BytesAsyncClient buildBytesAsyncClient() { + return new BytesAsyncClient(buildInnerClient().getBytes()); + } + + /** + * Builds an instance of IntAsyncClient class. + * + * @return an instance of IntAsyncClient. + */ + @Generated + public IntAsyncClient buildIntAsyncClient() { + return new IntAsyncClient(buildInnerClient().getInts()); + } + + /** + * Builds an instance of FloatOperationAsyncClient class. + * + * @return an instance of FloatOperationAsyncClient. + */ + @Generated + public FloatOperationAsyncClient buildFloatOperationAsyncClient() { + return new FloatOperationAsyncClient(buildInnerClient().getFloatOperations()); + } + + /** + * Builds an instance of DecimalAsyncClient class. + * + * @return an instance of DecimalAsyncClient. + */ + @Generated + public DecimalAsyncClient buildDecimalAsyncClient() { + return new DecimalAsyncClient(buildInnerClient().getDecimals()); + } + + /** + * Builds an instance of Decimal128AsyncClient class. + * + * @return an instance of Decimal128AsyncClient. + */ + @Generated + public Decimal128AsyncClient buildDecimal128AsyncClient() { + return new Decimal128AsyncClient(buildInnerClient().getDecimal128s()); + } + + /** + * Builds an instance of DatetimeOperationAsyncClient class. + * + * @return an instance of DatetimeOperationAsyncClient. + */ + @Generated + public DatetimeOperationAsyncClient buildDatetimeOperationAsyncClient() { + return new DatetimeOperationAsyncClient(buildInnerClient().getDatetimeOperations()); + } + + /** + * Builds an instance of DurationOperationAsyncClient class. + * + * @return an instance of DurationOperationAsyncClient. + */ + @Generated + public DurationOperationAsyncClient buildDurationOperationAsyncClient() { + return new DurationOperationAsyncClient(buildInnerClient().getDurationOperations()); + } + + /** + * Builds an instance of EnumAsyncClient class. + * + * @return an instance of EnumAsyncClient. + */ + @Generated + public EnumAsyncClient buildEnumAsyncClient() { + return new EnumAsyncClient(buildInnerClient().getEnums()); + } + + /** + * Builds an instance of ExtensibleEnumAsyncClient class. + * + * @return an instance of ExtensibleEnumAsyncClient. + */ + @Generated + public ExtensibleEnumAsyncClient buildExtensibleEnumAsyncClient() { + return new ExtensibleEnumAsyncClient(buildInnerClient().getExtensibleEnums()); + } + + /** + * Builds an instance of ModelAsyncClient class. + * + * @return an instance of ModelAsyncClient. + */ + @Generated + public ModelAsyncClient buildModelAsyncClient() { + return new ModelAsyncClient(buildInnerClient().getModels()); + } + + /** + * Builds an instance of CollectionsStringAsyncClient class. + * + * @return an instance of CollectionsStringAsyncClient. + */ + @Generated + public CollectionsStringAsyncClient buildCollectionsStringAsyncClient() { + return new CollectionsStringAsyncClient(buildInnerClient().getCollectionsStrings()); + } + + /** + * Builds an instance of CollectionsIntAsyncClient class. + * + * @return an instance of CollectionsIntAsyncClient. + */ + @Generated + public CollectionsIntAsyncClient buildCollectionsIntAsyncClient() { + return new CollectionsIntAsyncClient(buildInnerClient().getCollectionsInts()); + } + + /** + * Builds an instance of CollectionsModelAsyncClient class. + * + * @return an instance of CollectionsModelAsyncClient. + */ + @Generated + public CollectionsModelAsyncClient buildCollectionsModelAsyncClient() { + return new CollectionsModelAsyncClient(buildInnerClient().getCollectionsModels()); + } + + /** + * Builds an instance of DictionaryStringAsyncClient class. + * + * @return an instance of DictionaryStringAsyncClient. + */ + @Generated + public DictionaryStringAsyncClient buildDictionaryStringAsyncClient() { + return new DictionaryStringAsyncClient(buildInnerClient().getDictionaryStrings()); + } + + /** + * Builds an instance of NeverAsyncClient class. + * + * @return an instance of NeverAsyncClient. + */ + @Generated + public NeverAsyncClient buildNeverAsyncClient() { + return new NeverAsyncClient(buildInnerClient().getNevers()); + } + + /** + * Builds an instance of UnknownStringAsyncClient class. + * + * @return an instance of UnknownStringAsyncClient. + */ + @Generated + public UnknownStringAsyncClient buildUnknownStringAsyncClient() { + return new UnknownStringAsyncClient(buildInnerClient().getUnknownStrings()); + } + + /** + * Builds an instance of UnknownIntAsyncClient class. + * + * @return an instance of UnknownIntAsyncClient. + */ + @Generated + public UnknownIntAsyncClient buildUnknownIntAsyncClient() { + return new UnknownIntAsyncClient(buildInnerClient().getUnknownInts()); + } + + /** + * Builds an instance of UnknownDictAsyncClient class. + * + * @return an instance of UnknownDictAsyncClient. + */ + @Generated + public UnknownDictAsyncClient buildUnknownDictAsyncClient() { + return new UnknownDictAsyncClient(buildInnerClient().getUnknownDicts()); + } + + /** + * Builds an instance of UnknownArrayAsyncClient class. + * + * @return an instance of UnknownArrayAsyncClient. + */ + @Generated + public UnknownArrayAsyncClient buildUnknownArrayAsyncClient() { + return new UnknownArrayAsyncClient(buildInnerClient().getUnknownArrays()); + } + + /** + * Builds an instance of StringLiteralAsyncClient class. + * + * @return an instance of StringLiteralAsyncClient. + */ + @Generated + public StringLiteralAsyncClient buildStringLiteralAsyncClient() { + return new StringLiteralAsyncClient(buildInnerClient().getStringLiterals()); + } + + /** + * Builds an instance of IntLiteralAsyncClient class. + * + * @return an instance of IntLiteralAsyncClient. + */ + @Generated + public IntLiteralAsyncClient buildIntLiteralAsyncClient() { + return new IntLiteralAsyncClient(buildInnerClient().getIntLiterals()); + } + + /** + * Builds an instance of FloatLiteralAsyncClient class. + * + * @return an instance of FloatLiteralAsyncClient. + */ + @Generated + public FloatLiteralAsyncClient buildFloatLiteralAsyncClient() { + return new FloatLiteralAsyncClient(buildInnerClient().getFloatLiterals()); + } + + /** + * Builds an instance of BooleanLiteralAsyncClient class. + * + * @return an instance of BooleanLiteralAsyncClient. + */ + @Generated + public BooleanLiteralAsyncClient buildBooleanLiteralAsyncClient() { + return new BooleanLiteralAsyncClient(buildInnerClient().getBooleanLiterals()); + } + + /** + * Builds an instance of UnionStringLiteralAsyncClient class. + * + * @return an instance of UnionStringLiteralAsyncClient. + */ + @Generated + public UnionStringLiteralAsyncClient buildUnionStringLiteralAsyncClient() { + return new UnionStringLiteralAsyncClient(buildInnerClient().getUnionStringLiterals()); + } + + /** + * Builds an instance of UnionIntLiteralAsyncClient class. + * + * @return an instance of UnionIntLiteralAsyncClient. + */ + @Generated + public UnionIntLiteralAsyncClient buildUnionIntLiteralAsyncClient() { + return new UnionIntLiteralAsyncClient(buildInnerClient().getUnionIntLiterals()); + } + + /** + * Builds an instance of UnionFloatLiteralAsyncClient class. + * + * @return an instance of UnionFloatLiteralAsyncClient. + */ + @Generated + public UnionFloatLiteralAsyncClient buildUnionFloatLiteralAsyncClient() { + return new UnionFloatLiteralAsyncClient(buildInnerClient().getUnionFloatLiterals()); + } + + /** + * Builds an instance of UnionEnumValueAsyncClient class. + * + * @return an instance of UnionEnumValueAsyncClient. + */ + @Generated + public UnionEnumValueAsyncClient buildUnionEnumValueAsyncClient() { + return new UnionEnumValueAsyncClient(buildInnerClient().getUnionEnumValues()); + } + + /** + * Builds an instance of BooleanOperationClient class. + * + * @return an instance of BooleanOperationClient. + */ + @Generated + public BooleanOperationClient buildBooleanOperationClient() { + return new BooleanOperationClient(buildInnerClient().getBooleanOperations()); + } + + /** + * Builds an instance of StringOperationClient class. + * + * @return an instance of StringOperationClient. + */ + @Generated + public StringOperationClient buildStringOperationClient() { + return new StringOperationClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of BytesClient class. + * + * @return an instance of BytesClient. + */ + @Generated + public BytesClient buildBytesClient() { + return new BytesClient(buildInnerClient().getBytes()); + } + + /** + * Builds an instance of IntClient class. + * + * @return an instance of IntClient. + */ + @Generated + public IntClient buildIntClient() { + return new IntClient(buildInnerClient().getInts()); + } + + /** + * Builds an instance of FloatOperationClient class. + * + * @return an instance of FloatOperationClient. + */ + @Generated + public FloatOperationClient buildFloatOperationClient() { + return new FloatOperationClient(buildInnerClient().getFloatOperations()); + } + + /** + * Builds an instance of DecimalClient class. + * + * @return an instance of DecimalClient. + */ + @Generated + public DecimalClient buildDecimalClient() { + return new DecimalClient(buildInnerClient().getDecimals()); + } + + /** + * Builds an instance of Decimal128Client class. + * + * @return an instance of Decimal128Client. + */ + @Generated + public Decimal128Client buildDecimal128Client() { + return new Decimal128Client(buildInnerClient().getDecimal128s()); + } + + /** + * Builds an instance of DatetimeOperationClient class. + * + * @return an instance of DatetimeOperationClient. + */ + @Generated + public DatetimeOperationClient buildDatetimeOperationClient() { + return new DatetimeOperationClient(buildInnerClient().getDatetimeOperations()); + } + + /** + * Builds an instance of DurationOperationClient class. + * + * @return an instance of DurationOperationClient. + */ + @Generated + public DurationOperationClient buildDurationOperationClient() { + return new DurationOperationClient(buildInnerClient().getDurationOperations()); + } + + /** + * Builds an instance of EnumClient class. + * + * @return an instance of EnumClient. + */ + @Generated + public EnumClient buildEnumClient() { + return new EnumClient(buildInnerClient().getEnums()); + } + + /** + * Builds an instance of ExtensibleEnumClient class. + * + * @return an instance of ExtensibleEnumClient. + */ + @Generated + public ExtensibleEnumClient buildExtensibleEnumClient() { + return new ExtensibleEnumClient(buildInnerClient().getExtensibleEnums()); + } + + /** + * Builds an instance of ModelClient class. + * + * @return an instance of ModelClient. + */ + @Generated + public ModelClient buildModelClient() { + return new ModelClient(buildInnerClient().getModels()); + } + + /** + * Builds an instance of CollectionsStringClient class. + * + * @return an instance of CollectionsStringClient. + */ + @Generated + public CollectionsStringClient buildCollectionsStringClient() { + return new CollectionsStringClient(buildInnerClient().getCollectionsStrings()); + } + + /** + * Builds an instance of CollectionsIntClient class. + * + * @return an instance of CollectionsIntClient. + */ + @Generated + public CollectionsIntClient buildCollectionsIntClient() { + return new CollectionsIntClient(buildInnerClient().getCollectionsInts()); + } + + /** + * Builds an instance of CollectionsModelClient class. + * + * @return an instance of CollectionsModelClient. + */ + @Generated + public CollectionsModelClient buildCollectionsModelClient() { + return new CollectionsModelClient(buildInnerClient().getCollectionsModels()); + } + + /** + * Builds an instance of DictionaryStringClient class. + * + * @return an instance of DictionaryStringClient. + */ + @Generated + public DictionaryStringClient buildDictionaryStringClient() { + return new DictionaryStringClient(buildInnerClient().getDictionaryStrings()); + } + + /** + * Builds an instance of NeverClient class. + * + * @return an instance of NeverClient. + */ + @Generated + public NeverClient buildNeverClient() { + return new NeverClient(buildInnerClient().getNevers()); + } + + /** + * Builds an instance of UnknownStringClient class. + * + * @return an instance of UnknownStringClient. + */ + @Generated + public UnknownStringClient buildUnknownStringClient() { + return new UnknownStringClient(buildInnerClient().getUnknownStrings()); + } + + /** + * Builds an instance of UnknownIntClient class. + * + * @return an instance of UnknownIntClient. + */ + @Generated + public UnknownIntClient buildUnknownIntClient() { + return new UnknownIntClient(buildInnerClient().getUnknownInts()); + } + + /** + * Builds an instance of UnknownDictClient class. + * + * @return an instance of UnknownDictClient. + */ + @Generated + public UnknownDictClient buildUnknownDictClient() { + return new UnknownDictClient(buildInnerClient().getUnknownDicts()); + } + + /** + * Builds an instance of UnknownArrayClient class. + * + * @return an instance of UnknownArrayClient. + */ + @Generated + public UnknownArrayClient buildUnknownArrayClient() { + return new UnknownArrayClient(buildInnerClient().getUnknownArrays()); + } + + /** + * Builds an instance of StringLiteralClient class. + * + * @return an instance of StringLiteralClient. + */ + @Generated + public StringLiteralClient buildStringLiteralClient() { + return new StringLiteralClient(buildInnerClient().getStringLiterals()); + } + + /** + * Builds an instance of IntLiteralClient class. + * + * @return an instance of IntLiteralClient. + */ + @Generated + public IntLiteralClient buildIntLiteralClient() { + return new IntLiteralClient(buildInnerClient().getIntLiterals()); + } + + /** + * Builds an instance of FloatLiteralClient class. + * + * @return an instance of FloatLiteralClient. + */ + @Generated + public FloatLiteralClient buildFloatLiteralClient() { + return new FloatLiteralClient(buildInnerClient().getFloatLiterals()); + } + + /** + * Builds an instance of BooleanLiteralClient class. + * + * @return an instance of BooleanLiteralClient. + */ + @Generated + public BooleanLiteralClient buildBooleanLiteralClient() { + return new BooleanLiteralClient(buildInnerClient().getBooleanLiterals()); + } + + /** + * Builds an instance of UnionStringLiteralClient class. + * + * @return an instance of UnionStringLiteralClient. + */ + @Generated + public UnionStringLiteralClient buildUnionStringLiteralClient() { + return new UnionStringLiteralClient(buildInnerClient().getUnionStringLiterals()); + } + + /** + * Builds an instance of UnionIntLiteralClient class. + * + * @return an instance of UnionIntLiteralClient. + */ + @Generated + public UnionIntLiteralClient buildUnionIntLiteralClient() { + return new UnionIntLiteralClient(buildInnerClient().getUnionIntLiterals()); + } + + /** + * Builds an instance of UnionFloatLiteralClient class. + * + * @return an instance of UnionFloatLiteralClient. + */ + @Generated + public UnionFloatLiteralClient buildUnionFloatLiteralClient() { + return new UnionFloatLiteralClient(buildInnerClient().getUnionFloatLiterals()); + } + + /** + * Builds an instance of UnionEnumValueClient class. + * + * @return an instance of UnionEnumValueClient. + */ + @Generated + public UnionEnumValueClient buildUnionEnumValueClient() { + return new UnionEnumValueClient(buildInnerClient().getUnionEnumValues()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ValueTypesClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/BooleanLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/BooleanLiteralsImpl.java new file mode 100644 index 000000000..5848e3691 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/BooleanLiteralsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 BooleanLiterals. + */ +public final class BooleanLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BooleanLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of BooleanLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BooleanLiteralsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(BooleanLiteralsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientBooleanLiterals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientBool") + public interface BooleanLiteralsService { + @Get("/type/property/value-types/boolean/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/boolean/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/boolean/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/boolean/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/BooleanOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/BooleanOperationsImpl.java new file mode 100644 index 000000000..9afe0ace2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/BooleanOperationsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 BooleanOperations. + */ +public final class BooleanOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BooleanOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of BooleanOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BooleanOperationsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(BooleanOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientBooleanOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientBool") + public interface BooleanOperationsService { + @Get("/type/property/value-types/boolean") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/boolean") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/boolean") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/boolean") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/BytesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/BytesImpl.java new file mode 100644 index 000000000..517428e4c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/BytesImpl.java @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Bytes. + */ +public final class BytesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BytesService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of BytesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BytesImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(BytesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientBytes to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientByte") + public interface BytesService { + @Get("/type/property/value-types/bytes") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/bytes") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/bytes") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/bytes") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: byte[] (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/CollectionsIntsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/CollectionsIntsImpl.java new file mode 100644 index 000000000..a91f37333 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/CollectionsIntsImpl.java @@ -0,0 +1,202 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 CollectionsInts. + */ +public final class CollectionsIntsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsIntsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of CollectionsIntsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsIntsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(CollectionsIntsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientCollectionsInts to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientColl") + public interface CollectionsIntsService { + @Get("/type/property/value-types/collections/int") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/collections/int") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/collections/int") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/collections/int") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/CollectionsModelsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/CollectionsModelsImpl.java new file mode 100644 index 000000000..791cce192 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/CollectionsModelsImpl.java @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 CollectionsModels. + */ +public final class CollectionsModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsModelsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of CollectionsModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsModelsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(CollectionsModelsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientCollectionsModels to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientColl") + public interface CollectionsModelsService { + @Get("/type/property/value-types/collections/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> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/collections/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 getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/collections/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> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/collections/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 putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *          (Required){
+     *             property: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *          (Required){
+     *             property: String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *          (Required){
+     *             property: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *          (Required){
+     *             property: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/CollectionsStringsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/CollectionsStringsImpl.java new file mode 100644 index 000000000..a67d59771 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/CollectionsStringsImpl.java @@ -0,0 +1,202 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 CollectionsStrings. + */ +public final class CollectionsStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsStringsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of CollectionsStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsStringsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(CollectionsStringsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientCollectionsStrings to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientColl") + public interface CollectionsStringsService { + @Get("/type/property/value-types/collections/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/collections/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/collections/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/collections/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         String (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): [
+     *         String (Required)
+     *     ]
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/DatetimeOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/DatetimeOperationsImpl.java new file mode 100644 index 000000000..592c4019b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/DatetimeOperationsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 DatetimeOperations. + */ +public final class DatetimeOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DatetimeOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of DatetimeOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DatetimeOperationsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(DatetimeOperationsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientDatetimeOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientDate") + public interface DatetimeOperationsService { + @Get("/type/property/value-types/datetime") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/datetime") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/datetime") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/datetime") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/Decimal128sImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/Decimal128sImpl.java new file mode 100644 index 000000000..b7a90b185 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/Decimal128sImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Decimal128s. + */ +public final class Decimal128sImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Decimal128sService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of Decimal128sImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Decimal128sImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(Decimal128sService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientDecimal128s to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientDeci") + public interface Decimal128sService { + @Get("/type/property/value-types/decimal128") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/decimal128") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/decimal128") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/decimal128") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/DecimalsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/DecimalsImpl.java new file mode 100644 index 000000000..9de39e4d7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/DecimalsImpl.java @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Decimals. + */ +public final class DecimalsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DecimalsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of DecimalsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DecimalsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(DecimalsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientDecimals to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientDeci") + public interface DecimalsService { + @Get("/type/property/value-types/decimal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/decimal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/decimal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/decimal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/DictionaryStringsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/DictionaryStringsImpl.java new file mode 100644 index 000000000..e9bbea556 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/DictionaryStringsImpl.java @@ -0,0 +1,202 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 DictionaryStrings. + */ +public final class DictionaryStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DictionaryStringsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of DictionaryStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DictionaryStringsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(DictionaryStringsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientDictionaryStrings to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientDict") + public interface DictionaryStringsService { + @Get("/type/property/value-types/dictionary/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/dictionary/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/dictionary/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/dictionary/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         String: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         String: String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/DurationOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/DurationOperationsImpl.java new file mode 100644 index 000000000..cdf87b14a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/DurationOperationsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 DurationOperations. + */ +public final class DurationOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DurationOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of DurationOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DurationOperationsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(DurationOperationsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientDurationOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientDura") + public interface DurationOperationsService { + @Get("/type/property/value-types/duration") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/duration") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/duration") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/duration") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Duration (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/EnumsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/EnumsImpl.java new file mode 100644 index 000000000..f62709f9d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/EnumsImpl.java @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Enums. + */ +public final class EnumsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EnumsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of EnumsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + EnumsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(EnumsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientEnums to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientEnum") + public interface EnumsService { + @Get("/type/property/value-types/enum") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/enum") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/enum") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/enum") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/ExtensibleEnumsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/ExtensibleEnumsImpl.java new file mode 100644 index 000000000..6146f8351 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/ExtensibleEnumsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 ExtensibleEnums. + */ +public final class ExtensibleEnumsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtensibleEnumsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of ExtensibleEnumsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtensibleEnumsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(ExtensibleEnumsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientExtensibleEnums to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientExte") + public interface ExtensibleEnumsService { + @Get("/type/property/value-types/extensible-enum") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/extensible-enum") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/extensible-enum") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/extensible-enum") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/FloatLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/FloatLiteralsImpl.java new file mode 100644 index 000000000..bd4c5042b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/FloatLiteralsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 FloatLiterals. + */ +public final class FloatLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FloatLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of FloatLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FloatLiteralsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(FloatLiteralsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientFloatLiterals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientFloa") + public interface FloatLiteralsService { + @Get("/type/property/value-types/float/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/float/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/float/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/float/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: double (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/FloatOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/FloatOperationsImpl.java new file mode 100644 index 000000000..4cc17f762 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/FloatOperationsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 FloatOperations. + */ +public final class FloatOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FloatOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of FloatOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FloatOperationsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(FloatOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientFloatOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientFloa") + public interface FloatOperationsService { + @Get("/type/property/value-types/float") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/float") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/float") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/float") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: double (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: double (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/IntLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/IntLiteralsImpl.java new file mode 100644 index 000000000..2449786fd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/IntLiteralsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 IntLiterals. + */ +public final class IntLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IntLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of IntLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IntLiteralsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(IntLiteralsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientIntLiterals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientIntL") + public interface IntLiteralsService { + @Get("/type/property/value-types/int/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/int/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/int/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/int/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: 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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: 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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/IntsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/IntsImpl.java new file mode 100644 index 000000000..0a68ae4be --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/IntsImpl.java @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Ints. + */ +public final class IntsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IntsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of IntsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IntsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(IntsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientInts to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientInts") + public interface IntsService { + @Get("/type/property/value-types/int") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/int") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/int") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/int") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: 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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: 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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/ModelsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/ModelsImpl.java new file mode 100644 index 000000000..04d5f1867 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/ModelsImpl.java @@ -0,0 +1,201 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Models. + */ +public final class ModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of ModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(ModelsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientModels to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientMode") + public interface ModelsService { + @Get("/type/property/value-types/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> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/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 getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/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> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/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 putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         property: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         property: String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         property: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property (Required): {
+     *         property: String (Required)
+     *     }
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/NeversImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/NeversImpl.java new file mode 100644 index 000000000..ab363c68c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/NeversImpl.java @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Nevers. + */ +public final class NeversImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NeversService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of NeversImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NeversImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(NeversService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientNevers to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientNeve") + public interface NeversService { + @Get("/type/property/value-types/never") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/never") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/never") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/never") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * { }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/StringLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/StringLiteralsImpl.java new file mode 100644 index 000000000..f0cfae22a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/StringLiteralsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 StringLiterals. + */ +public final class StringLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of StringLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringLiteralsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(StringLiteralsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientStringLiterals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientStri") + public interface StringLiteralsService { + @Get("/type/property/value-types/string/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/string/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/string/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/string/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/StringOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/StringOperationsImpl.java new file mode 100644 index 000000000..437a59265 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/StringOperationsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 StringOperations. + */ +public final class StringOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of StringOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringOperationsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(StringOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientStringOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientStri") + public interface StringOperationsService { + @Get("/type/property/value-types/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnionEnumValuesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnionEnumValuesImpl.java new file mode 100644 index 000000000..c18f9dc2c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnionEnumValuesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnionEnumValues. + */ +public final class UnionEnumValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionEnumValuesService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnionEnumValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionEnumValuesImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(UnionEnumValuesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnionEnumValues to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientUnio") + public interface UnionEnumValuesService { + @Get("/type/property/value-types/union-enum-value") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/union-enum-value") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/union-enum-value") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/union-enum-value") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(value2) (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(value2) (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(value2) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(value2) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnionFloatLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnionFloatLiteralsImpl.java new file mode 100644 index 000000000..c587c7094 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnionFloatLiteralsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnionFloatLiterals. + */ +public final class UnionFloatLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionFloatLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnionFloatLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionFloatLiteralsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(UnionFloatLiteralsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnionFloatLiterals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientUnio") + public interface UnionFloatLiteralsService { + @Get("/type/property/value-types/union/float/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/union/float/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/union/float/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/union/float/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(43.125/46.875) (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(43.125/46.875) (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(43.125/46.875) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(43.125/46.875) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnionIntLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnionIntLiteralsImpl.java new file mode 100644 index 000000000..47b1c3216 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnionIntLiteralsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnionIntLiterals. + */ +public final class UnionIntLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionIntLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnionIntLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionIntLiteralsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(UnionIntLiteralsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnionIntLiterals to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientUnio") + public interface UnionIntLiteralsService { + @Get("/type/property/value-types/union/int/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/union/int/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/union/int/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/union/int/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(42/43) (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(42/43) (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(42/43) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(42/43) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnionStringLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnionStringLiteralsImpl.java new file mode 100644 index 000000000..d9176261b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnionStringLiteralsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnionStringLiterals. + */ +public final class UnionStringLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionStringLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnionStringLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionStringLiteralsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(UnionStringLiteralsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnionStringLiterals to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientUnio") + public interface UnionStringLiteralsService { + @Get("/type/property/value-types/union/string/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/union/string/literal") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/union/string/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/union/string/literal") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: String(hello/world) (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnknownArraysImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnknownArraysImpl.java new file mode 100644 index 000000000..5e0ce54ca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnknownArraysImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnknownArrays. + */ +public final class UnknownArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownArraysService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnknownArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownArraysImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(UnknownArraysService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnknownArrays to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientUnkn") + public interface UnknownArraysService { + @Get("/type/property/value-types/unknown/array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/unknown/array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/unknown/array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/unknown/array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnknownDictsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnknownDictsImpl.java new file mode 100644 index 000000000..ddf7456a9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnknownDictsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnknownDicts. + */ +public final class UnknownDictsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownDictsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnknownDictsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownDictsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(UnknownDictsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnknownDicts to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientUnkn") + public interface UnknownDictsService { + @Get("/type/property/value-types/unknown/dict") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/unknown/dict") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/unknown/dict") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/unknown/dict") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnknownIntsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnknownIntsImpl.java new file mode 100644 index 000000000..c80551709 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnknownIntsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnknownInts. + */ +public final class UnknownIntsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownIntsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnknownIntsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownIntsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(UnknownIntsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnknownInts to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientUnkn") + public interface UnknownIntsService { + @Get("/type/property/value-types/unknown/int") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/unknown/int") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/unknown/int") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/unknown/int") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnknownStringsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnknownStringsImpl.java new file mode 100644 index 000000000..9d8d1b620 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/UnknownStringsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 UnknownStrings. + */ +public final class UnknownStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownStringsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnknownStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownStringsImpl(ValueTypesClientImpl client) { + this.service + = RestProxy.create(UnknownStringsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnknownStrings to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ValueTypesClientUnkn") + public interface UnknownStringsService { + @Get("/type/property/value-types/unknown/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/property/value-types/unknown/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/unknown/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/property/value-types/unknown/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (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 call along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     property: Object (Required)
+     * }
+     * }
+ * + * @param body body. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/ValueTypesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/ValueTypesClientImpl.java new file mode 100644 index 000000000..74ad9e1c0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/ValueTypesClientImpl.java @@ -0,0 +1,527 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the ValueTypesClient type. + */ +public final class ValueTypesClientImpl { + /** + * 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; + } + + /** + * The BooleanOperationsImpl object to access its operations. + */ + private final BooleanOperationsImpl booleanOperations; + + /** + * Gets the BooleanOperationsImpl object to access its operations. + * + * @return the BooleanOperationsImpl object. + */ + public BooleanOperationsImpl getBooleanOperations() { + return this.booleanOperations; + } + + /** + * The StringOperationsImpl object to access its operations. + */ + private final StringOperationsImpl stringOperations; + + /** + * Gets the StringOperationsImpl object to access its operations. + * + * @return the StringOperationsImpl object. + */ + public StringOperationsImpl getStringOperations() { + return this.stringOperations; + } + + /** + * The BytesImpl object to access its operations. + */ + private final BytesImpl bytes; + + /** + * Gets the BytesImpl object to access its operations. + * + * @return the BytesImpl object. + */ + public BytesImpl getBytes() { + return this.bytes; + } + + /** + * The IntsImpl object to access its operations. + */ + private final IntsImpl ints; + + /** + * Gets the IntsImpl object to access its operations. + * + * @return the IntsImpl object. + */ + public IntsImpl getInts() { + return this.ints; + } + + /** + * The FloatOperationsImpl object to access its operations. + */ + private final FloatOperationsImpl floatOperations; + + /** + * Gets the FloatOperationsImpl object to access its operations. + * + * @return the FloatOperationsImpl object. + */ + public FloatOperationsImpl getFloatOperations() { + return this.floatOperations; + } + + /** + * The DecimalsImpl object to access its operations. + */ + private final DecimalsImpl decimals; + + /** + * Gets the DecimalsImpl object to access its operations. + * + * @return the DecimalsImpl object. + */ + public DecimalsImpl getDecimals() { + return this.decimals; + } + + /** + * The Decimal128sImpl object to access its operations. + */ + private final Decimal128sImpl decimal128s; + + /** + * Gets the Decimal128sImpl object to access its operations. + * + * @return the Decimal128sImpl object. + */ + public Decimal128sImpl getDecimal128s() { + return this.decimal128s; + } + + /** + * The DatetimeOperationsImpl object to access its operations. + */ + private final DatetimeOperationsImpl datetimeOperations; + + /** + * Gets the DatetimeOperationsImpl object to access its operations. + * + * @return the DatetimeOperationsImpl object. + */ + public DatetimeOperationsImpl getDatetimeOperations() { + return this.datetimeOperations; + } + + /** + * The DurationOperationsImpl object to access its operations. + */ + private final DurationOperationsImpl durationOperations; + + /** + * Gets the DurationOperationsImpl object to access its operations. + * + * @return the DurationOperationsImpl object. + */ + public DurationOperationsImpl getDurationOperations() { + return this.durationOperations; + } + + /** + * The EnumsImpl object to access its operations. + */ + private final EnumsImpl enums; + + /** + * Gets the EnumsImpl object to access its operations. + * + * @return the EnumsImpl object. + */ + public EnumsImpl getEnums() { + return this.enums; + } + + /** + * The ExtensibleEnumsImpl object to access its operations. + */ + private final ExtensibleEnumsImpl extensibleEnums; + + /** + * Gets the ExtensibleEnumsImpl object to access its operations. + * + * @return the ExtensibleEnumsImpl object. + */ + public ExtensibleEnumsImpl getExtensibleEnums() { + return this.extensibleEnums; + } + + /** + * The ModelsImpl object to access its operations. + */ + private final ModelsImpl models; + + /** + * Gets the ModelsImpl object to access its operations. + * + * @return the ModelsImpl object. + */ + public ModelsImpl getModels() { + return this.models; + } + + /** + * The CollectionsStringsImpl object to access its operations. + */ + private final CollectionsStringsImpl collectionsStrings; + + /** + * Gets the CollectionsStringsImpl object to access its operations. + * + * @return the CollectionsStringsImpl object. + */ + public CollectionsStringsImpl getCollectionsStrings() { + return this.collectionsStrings; + } + + /** + * The CollectionsIntsImpl object to access its operations. + */ + private final CollectionsIntsImpl collectionsInts; + + /** + * Gets the CollectionsIntsImpl object to access its operations. + * + * @return the CollectionsIntsImpl object. + */ + public CollectionsIntsImpl getCollectionsInts() { + return this.collectionsInts; + } + + /** + * The CollectionsModelsImpl object to access its operations. + */ + private final CollectionsModelsImpl collectionsModels; + + /** + * Gets the CollectionsModelsImpl object to access its operations. + * + * @return the CollectionsModelsImpl object. + */ + public CollectionsModelsImpl getCollectionsModels() { + return this.collectionsModels; + } + + /** + * The DictionaryStringsImpl object to access its operations. + */ + private final DictionaryStringsImpl dictionaryStrings; + + /** + * Gets the DictionaryStringsImpl object to access its operations. + * + * @return the DictionaryStringsImpl object. + */ + public DictionaryStringsImpl getDictionaryStrings() { + return this.dictionaryStrings; + } + + /** + * The NeversImpl object to access its operations. + */ + private final NeversImpl nevers; + + /** + * Gets the NeversImpl object to access its operations. + * + * @return the NeversImpl object. + */ + public NeversImpl getNevers() { + return this.nevers; + } + + /** + * The UnknownStringsImpl object to access its operations. + */ + private final UnknownStringsImpl unknownStrings; + + /** + * Gets the UnknownStringsImpl object to access its operations. + * + * @return the UnknownStringsImpl object. + */ + public UnknownStringsImpl getUnknownStrings() { + return this.unknownStrings; + } + + /** + * The UnknownIntsImpl object to access its operations. + */ + private final UnknownIntsImpl unknownInts; + + /** + * Gets the UnknownIntsImpl object to access its operations. + * + * @return the UnknownIntsImpl object. + */ + public UnknownIntsImpl getUnknownInts() { + return this.unknownInts; + } + + /** + * The UnknownDictsImpl object to access its operations. + */ + private final UnknownDictsImpl unknownDicts; + + /** + * Gets the UnknownDictsImpl object to access its operations. + * + * @return the UnknownDictsImpl object. + */ + public UnknownDictsImpl getUnknownDicts() { + return this.unknownDicts; + } + + /** + * The UnknownArraysImpl object to access its operations. + */ + private final UnknownArraysImpl unknownArrays; + + /** + * Gets the UnknownArraysImpl object to access its operations. + * + * @return the UnknownArraysImpl object. + */ + public UnknownArraysImpl getUnknownArrays() { + return this.unknownArrays; + } + + /** + * The StringLiteralsImpl object to access its operations. + */ + private final StringLiteralsImpl stringLiterals; + + /** + * Gets the StringLiteralsImpl object to access its operations. + * + * @return the StringLiteralsImpl object. + */ + public StringLiteralsImpl getStringLiterals() { + return this.stringLiterals; + } + + /** + * The IntLiteralsImpl object to access its operations. + */ + private final IntLiteralsImpl intLiterals; + + /** + * Gets the IntLiteralsImpl object to access its operations. + * + * @return the IntLiteralsImpl object. + */ + public IntLiteralsImpl getIntLiterals() { + return this.intLiterals; + } + + /** + * The FloatLiteralsImpl object to access its operations. + */ + private final FloatLiteralsImpl floatLiterals; + + /** + * Gets the FloatLiteralsImpl object to access its operations. + * + * @return the FloatLiteralsImpl object. + */ + public FloatLiteralsImpl getFloatLiterals() { + return this.floatLiterals; + } + + /** + * The BooleanLiteralsImpl object to access its operations. + */ + private final BooleanLiteralsImpl booleanLiterals; + + /** + * Gets the BooleanLiteralsImpl object to access its operations. + * + * @return the BooleanLiteralsImpl object. + */ + public BooleanLiteralsImpl getBooleanLiterals() { + return this.booleanLiterals; + } + + /** + * The UnionStringLiteralsImpl object to access its operations. + */ + private final UnionStringLiteralsImpl unionStringLiterals; + + /** + * Gets the UnionStringLiteralsImpl object to access its operations. + * + * @return the UnionStringLiteralsImpl object. + */ + public UnionStringLiteralsImpl getUnionStringLiterals() { + return this.unionStringLiterals; + } + + /** + * The UnionIntLiteralsImpl object to access its operations. + */ + private final UnionIntLiteralsImpl unionIntLiterals; + + /** + * Gets the UnionIntLiteralsImpl object to access its operations. + * + * @return the UnionIntLiteralsImpl object. + */ + public UnionIntLiteralsImpl getUnionIntLiterals() { + return this.unionIntLiterals; + } + + /** + * The UnionFloatLiteralsImpl object to access its operations. + */ + private final UnionFloatLiteralsImpl unionFloatLiterals; + + /** + * Gets the UnionFloatLiteralsImpl object to access its operations. + * + * @return the UnionFloatLiteralsImpl object. + */ + public UnionFloatLiteralsImpl getUnionFloatLiterals() { + return this.unionFloatLiterals; + } + + /** + * The UnionEnumValuesImpl object to access its operations. + */ + private final UnionEnumValuesImpl unionEnumValues; + + /** + * Gets the UnionEnumValuesImpl object to access its operations. + * + * @return the UnionEnumValuesImpl object. + */ + public UnionEnumValuesImpl getUnionEnumValues() { + return this.unionEnumValues; + } + + /** + * Initializes an instance of ValueTypesClient client. + * + * @param endpoint Service host. + */ + public ValueTypesClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ValueTypesClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ValueTypesClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ValueTypesClient 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 ValueTypesClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.booleanOperations = new BooleanOperationsImpl(this); + this.stringOperations = new StringOperationsImpl(this); + this.bytes = new BytesImpl(this); + this.ints = new IntsImpl(this); + this.floatOperations = new FloatOperationsImpl(this); + this.decimals = new DecimalsImpl(this); + this.decimal128s = new Decimal128sImpl(this); + this.datetimeOperations = new DatetimeOperationsImpl(this); + this.durationOperations = new DurationOperationsImpl(this); + this.enums = new EnumsImpl(this); + this.extensibleEnums = new ExtensibleEnumsImpl(this); + this.models = new ModelsImpl(this); + this.collectionsStrings = new CollectionsStringsImpl(this); + this.collectionsInts = new CollectionsIntsImpl(this); + this.collectionsModels = new CollectionsModelsImpl(this); + this.dictionaryStrings = new DictionaryStringsImpl(this); + this.nevers = new NeversImpl(this); + this.unknownStrings = new UnknownStringsImpl(this); + this.unknownInts = new UnknownIntsImpl(this); + this.unknownDicts = new UnknownDictsImpl(this); + this.unknownArrays = new UnknownArraysImpl(this); + this.stringLiterals = new StringLiteralsImpl(this); + this.intLiterals = new IntLiteralsImpl(this); + this.floatLiterals = new FloatLiteralsImpl(this); + this.booleanLiterals = new BooleanLiteralsImpl(this); + this.unionStringLiterals = new UnionStringLiteralsImpl(this); + this.unionIntLiterals = new UnionIntLiteralsImpl(this); + this.unionFloatLiterals = new UnionFloatLiteralsImpl(this); + this.unionEnumValues = new UnionEnumValuesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/implementation/package-info.java new file mode 100644 index 000000000..5e3be8648 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/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 ValueTypes. + * Illustrates various property types for models. + * + */ +package com.type.property.valuetypes.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/BooleanLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/BooleanLiteralProperty.java new file mode 100644 index 000000000..e449fcb46 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/BooleanLiteralProperty.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 com.type.property.valuetypes.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; + +/** + * Model with a boolean literal property. + */ +@Immutable +public final class BooleanLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final boolean property = true; + + /** + * Creates an instance of BooleanLiteralProperty class. + */ + @Generated + public BooleanLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public boolean isProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BooleanLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BooleanLiteralProperty 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 BooleanLiteralProperty. + */ + @Generated + public static BooleanLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BooleanLiteralProperty deserializedBooleanLiteralProperty = new BooleanLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedBooleanLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/BooleanProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/BooleanProperty.java new file mode 100644 index 000000000..2374f27e7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/BooleanProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with a boolean property. + */ +@Immutable +public final class BooleanProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final boolean property; + + /** + * Creates an instance of BooleanProperty class. + * + * @param property the property value to set. + */ + @Generated + public BooleanProperty(boolean property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public boolean isProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BooleanProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BooleanProperty 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 BooleanProperty. + */ + @Generated + public static BooleanProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean property = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new BooleanProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/BytesProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/BytesProperty.java new file mode 100644 index 000000000..26045c400 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/BytesProperty.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a bytes property. + */ +@Immutable +public final class BytesProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final byte[] property; + + /** + * Creates an instance of BytesProperty class. + * + * @param property the property value to set. + */ + @Generated + public BytesProperty(byte[] property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public byte[] getProperty() { + return CoreUtils.clone(this.property); + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBinaryField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BytesProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BytesProperty 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 BytesProperty. + */ + @Generated + public static BytesProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + byte[] property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getBinary(); + } else { + reader.skipChildren(); + } + } + return new BytesProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/CollectionsIntProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/CollectionsIntProperty.java new file mode 100644 index 000000000..94f56bd78 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/CollectionsIntProperty.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; +import java.util.List; + +/** + * Model with collection int properties. + */ +@Immutable +public final class CollectionsIntProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final List property; + + /** + * Creates an instance of CollectionsIntProperty class. + * + * @param property the property value to set. + */ + @Generated + public CollectionsIntProperty(List property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public List getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("property", this.property, (writer, element) -> writer.writeInt(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsIntProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsIntProperty 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 CollectionsIntProperty. + */ + @Generated + public static CollectionsIntProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.readArray(reader1 -> reader1.getInt()); + } else { + reader.skipChildren(); + } + } + return new CollectionsIntProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/CollectionsModelProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/CollectionsModelProperty.java new file mode 100644 index 000000000..252f92ed2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/CollectionsModelProperty.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; +import java.util.List; + +/** + * Model with collection model properties. + */ +@Immutable +public final class CollectionsModelProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final List property; + + /** + * Creates an instance of CollectionsModelProperty class. + * + * @param property the property value to set. + */ + @Generated + public CollectionsModelProperty(List property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public List getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("property", this.property, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsModelProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsModelProperty 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 CollectionsModelProperty. + */ + @Generated + public static CollectionsModelProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.readArray(reader1 -> InnerModel.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new CollectionsModelProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/CollectionsStringProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/CollectionsStringProperty.java new file mode 100644 index 000000000..e576da2a3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/CollectionsStringProperty.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; +import java.util.List; + +/** + * Model with collection string properties. + */ +@Immutable +public final class CollectionsStringProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final List property; + + /** + * Creates an instance of CollectionsStringProperty class. + * + * @param property the property value to set. + */ + @Generated + public CollectionsStringProperty(List property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public List getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("property", this.property, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsStringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsStringProperty 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 CollectionsStringProperty. + */ + @Generated + public static CollectionsStringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.readArray(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + return new CollectionsStringProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/DatetimeProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/DatetimeProperty.java new file mode 100644 index 000000000..3f9358eb1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/DatetimeProperty.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 com.type.property.valuetypes.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Model with a datetime property. + */ +@Immutable +public final class DatetimeProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final OffsetDateTime property; + + /** + * Creates an instance of DatetimeProperty class. + * + * @param property the property value to set. + */ + @Generated + public DatetimeProperty(OffsetDateTime property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public OffsetDateTime getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", + this.property == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.property)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DatetimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DatetimeProperty 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 DatetimeProperty. + */ + @Generated + public static DatetimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new DatetimeProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/Decimal128Property.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/Decimal128Property.java new file mode 100644 index 000000000..936cdff70 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/Decimal128Property.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; +import java.math.BigDecimal; + +/** + * Model with a decimal128 property. + */ +@Immutable +public final class Decimal128Property implements JsonSerializable { + /* + * Property + */ + @Generated + private final BigDecimal property; + + /** + * Creates an instance of Decimal128Property class. + * + * @param property the property value to set. + */ + @Generated + public Decimal128Property(BigDecimal property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public BigDecimal getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Decimal128Property from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Decimal128Property 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 Decimal128Property. + */ + @Generated + public static Decimal128Property fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BigDecimal property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getNullable(nonNullReader -> new BigDecimal(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new Decimal128Property(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/DecimalProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/DecimalProperty.java new file mode 100644 index 000000000..209dd3f3b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/DecimalProperty.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; +import java.math.BigDecimal; + +/** + * Model with a decimal property. + */ +@Immutable +public final class DecimalProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final BigDecimal property; + + /** + * Creates an instance of DecimalProperty class. + * + * @param property the property value to set. + */ + @Generated + public DecimalProperty(BigDecimal property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public BigDecimal getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DecimalProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DecimalProperty 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 DecimalProperty. + */ + @Generated + public static DecimalProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BigDecimal property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getNullable(nonNullReader -> new BigDecimal(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new DecimalProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/DictionaryStringProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/DictionaryStringProperty.java new file mode 100644 index 000000000..dac2fd0ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/DictionaryStringProperty.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; +import java.util.Map; + +/** + * Model with dictionary string properties. + */ +@Immutable +public final class DictionaryStringProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final Map property; + + /** + * Creates an instance of DictionaryStringProperty class. + * + * @param property the property value to set. + */ + @Generated + public DictionaryStringProperty(Map property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public Map getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeMapField("property", this.property, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DictionaryStringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DictionaryStringProperty 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 DictionaryStringProperty. + */ + @Generated + public static DictionaryStringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Map property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + return new DictionaryStringProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/DurationProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/DurationProperty.java new file mode 100644 index 000000000..9ca692f26 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/DurationProperty.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 com.type.property.valuetypes.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +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.time.Duration; + +/** + * Model with a duration property. + */ +@Immutable +public final class DurationProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final Duration property; + + /** + * Creates an instance of DurationProperty class. + * + * @param property the property value to set. + */ + @Generated + public DurationProperty(Duration property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public Duration getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", CoreUtils.durationToStringWithDays(this.property)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DurationProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DurationProperty 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 DurationProperty. + */ + @Generated + public static DurationProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Duration property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new DurationProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/EnumProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/EnumProperty.java new file mode 100644 index 000000000..fdde64947 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/EnumProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with enum properties. + */ +@Immutable +public final class EnumProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final FixedInnerEnum property; + + /** + * Creates an instance of EnumProperty class. + * + * @param property the property value to set. + */ + @Generated + public EnumProperty(FixedInnerEnum property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public FixedInnerEnum getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property == null ? null : this.property.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EnumProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EnumProperty 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 EnumProperty. + */ + @Generated + public static EnumProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FixedInnerEnum property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = FixedInnerEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new EnumProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/ExtendedEnum.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/ExtendedEnum.java new file mode 100644 index 000000000..1038cfa2c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/ExtendedEnum.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for ExtendedEnum. + */ +public final class ExtendedEnum extends ExpandableStringEnum { + /** + * Static value value2 for ExtendedEnum. + */ + @Generated + public static final ExtendedEnum ENUM_VALUE2 = fromString("value2"); + + /** + * Creates a new instance of ExtendedEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ExtendedEnum() { + } + + /** + * Creates or finds a ExtendedEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding ExtendedEnum. + */ + @Generated + public static ExtendedEnum fromString(String name) { + return fromString(name, ExtendedEnum.class); + } + + /** + * Gets known ExtendedEnum values. + * + * @return known ExtendedEnum values. + */ + @Generated + public static Collection values() { + return values(ExtendedEnum.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/ExtensibleEnumProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/ExtensibleEnumProperty.java new file mode 100644 index 000000000..a8cd83020 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/ExtensibleEnumProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with extensible enum properties. + */ +@Immutable +public final class ExtensibleEnumProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final InnerEnum property; + + /** + * Creates an instance of ExtensibleEnumProperty class. + * + * @param property the property value to set. + */ + @Generated + public ExtensibleEnumProperty(InnerEnum property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public InnerEnum getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property == null ? null : this.property.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtensibleEnumProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtensibleEnumProperty 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 ExtensibleEnumProperty. + */ + @Generated + public static ExtensibleEnumProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + InnerEnum property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = InnerEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new ExtensibleEnumProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/FixedInnerEnum.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/FixedInnerEnum.java new file mode 100644 index 000000000..229a01f71 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/FixedInnerEnum.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 com.type.property.valuetypes.models; + +/** + * Enum that will be used as a property for model EnumProperty. Non-extensible. + */ +public enum FixedInnerEnum { + /** + * First value. + */ + VALUE_ONE("ValueOne"), + + /** + * Second value. + */ + VALUE_TWO("ValueTwo"); + + /** + * The actual serialized value for a FixedInnerEnum instance. + */ + private final String value; + + FixedInnerEnum(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a FixedInnerEnum instance. + * + * @param value the serialized value to parse. + * @return the parsed FixedInnerEnum object, or null if unable to parse. + */ + public static FixedInnerEnum fromString(String value) { + if (value == null) { + return null; + } + FixedInnerEnum[] items = FixedInnerEnum.values(); + for (FixedInnerEnum item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/FloatLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/FloatLiteralProperty.java new file mode 100644 index 000000000..5d5b3f406 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/FloatLiteralProperty.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 com.type.property.valuetypes.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; + +/** + * Model with a float literal property. + */ +@Immutable +public final class FloatLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final double property = 43.125; + + /** + * Creates an instance of FloatLiteralProperty class. + */ + @Generated + public FloatLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public double getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FloatLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FloatLiteralProperty 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 FloatLiteralProperty. + */ + @Generated + public static FloatLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FloatLiteralProperty deserializedFloatLiteralProperty = new FloatLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedFloatLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/FloatProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/FloatProperty.java new file mode 100644 index 000000000..55b9bbb4c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/FloatProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with a float property. + */ +@Immutable +public final class FloatProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final double property; + + /** + * Creates an instance of FloatProperty class. + * + * @param property the property value to set. + */ + @Generated + public FloatProperty(double property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public double getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FloatProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FloatProperty 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 FloatProperty. + */ + @Generated + public static FloatProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double property = 0.0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + return new FloatProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/InnerEnum.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/InnerEnum.java new file mode 100644 index 000000000..69669ea87 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/InnerEnum.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Enum that will be used as a property for model EnumProperty. Extensible. + */ +public final class InnerEnum extends ExpandableStringEnum { + /** + * First value. + */ + @Generated + public static final InnerEnum VALUE_ONE = fromString("ValueOne"); + + /** + * Second value. + */ + @Generated + public static final InnerEnum VALUE_TWO = fromString("ValueTwo"); + + /** + * Creates a new instance of InnerEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public InnerEnum() { + } + + /** + * Creates or finds a InnerEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding InnerEnum. + */ + @Generated + public static InnerEnum fromString(String name) { + return fromString(name, InnerEnum.class); + } + + /** + * Gets known InnerEnum values. + * + * @return known InnerEnum values. + */ + @Generated + public static Collection values() { + return values(InnerEnum.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/InnerModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/InnerModel.java new file mode 100644 index 000000000..3a4599a9b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/InnerModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Inner model. Will be a property type for ModelWithModelProperties. + */ +@Immutable +public final class InnerModel implements JsonSerializable { + /* + * Required string property + */ + @Generated + private final String property; + + /** + * Creates an instance of InnerModel class. + * + * @param property the property value to set. + */ + @Generated + public InnerModel(String property) { + this.property = property; + } + + /** + * Get the property property: Required string property. + * + * @return the property value. + */ + @Generated + public String getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerModel 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 InnerModel. + */ + @Generated + public static InnerModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new InnerModel(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/IntLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/IntLiteralProperty.java new file mode 100644 index 000000000..f48bdbb44 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/IntLiteralProperty.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 com.type.property.valuetypes.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; + +/** + * Model with a int literal property. + */ +@Immutable +public final class IntLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final int property = 42; + + /** + * Creates an instance of IntLiteralProperty class. + */ + @Generated + public IntLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public int getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IntLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IntLiteralProperty 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 IntLiteralProperty. + */ + @Generated + public static IntLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + IntLiteralProperty deserializedIntLiteralProperty = new IntLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedIntLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/IntProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/IntProperty.java new file mode 100644 index 000000000..b71dd829b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/IntProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with a int property. + */ +@Immutable +public final class IntProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final int property; + + /** + * Creates an instance of IntProperty class. + * + * @param property the property value to set. + */ + @Generated + public IntProperty(int property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public int getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IntProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IntProperty 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 IntProperty. + */ + @Generated + public static IntProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int property = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new IntProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/ModelProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/ModelProperty.java new file mode 100644 index 000000000..19c4a437f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/ModelProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with model properties. + */ +@Immutable +public final class ModelProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final InnerModel property; + + /** + * Creates an instance of ModelProperty class. + * + * @param property the property value to set. + */ + @Generated + public ModelProperty(InnerModel property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public InnerModel getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelProperty 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 ModelProperty. + */ + @Generated + public static ModelProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + InnerModel property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = InnerModel.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new ModelProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/NeverProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/NeverProperty.java new file mode 100644 index 000000000..c77d9e67b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/NeverProperty.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with a property never. (This property should not be included). + */ +@Immutable +public final class NeverProperty implements JsonSerializable { + /** + * Creates an instance of NeverProperty class. + */ + @Generated + public NeverProperty() { + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NeverProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NeverProperty 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 NeverProperty. + */ + @Generated + public static NeverProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + NeverProperty deserializedNeverProperty = new NeverProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedNeverProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/StringLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/StringLiteralProperty.java new file mode 100644 index 000000000..b35579289 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/StringLiteralProperty.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 com.type.property.valuetypes.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; + +/** + * Model with a string literal property. + */ +@Immutable +public final class StringLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final String property = "hello"; + + /** + * Creates an instance of StringLiteralProperty class. + */ + @Generated + public StringLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public String getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StringLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StringLiteralProperty 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 StringLiteralProperty. + */ + @Generated + public static StringLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringLiteralProperty deserializedStringLiteralProperty = new StringLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedStringLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/StringProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/StringProperty.java new file mode 100644 index 000000000..e2adb7075 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/StringProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with a string property. + */ +@Immutable +public final class StringProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final String property; + + /** + * Creates an instance of StringProperty class. + * + * @param property the property value to set. + */ + @Generated + public StringProperty(String property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public String getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StringProperty 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 StringProperty. + */ + @Generated + public static StringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new StringProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionEnumValueProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionEnumValueProperty.java new file mode 100644 index 000000000..cd0bfb320 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionEnumValueProperty.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 com.type.property.valuetypes.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; + +/** + * Template type for testing models with specific properties. Pass in the type of the property you are looking for. + */ +@Immutable +public final class UnionEnumValueProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final ExtendedEnum property = ExtendedEnum.ENUM_VALUE2; + + /** + * Creates an instance of UnionEnumValueProperty class. + */ + @Generated + public UnionEnumValueProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public ExtendedEnum getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property == null ? null : this.property.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionEnumValueProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionEnumValueProperty 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 UnionEnumValueProperty. + */ + @Generated + public static UnionEnumValueProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionEnumValueProperty deserializedUnionEnumValueProperty = new UnionEnumValueProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedUnionEnumValueProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionFloatLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionFloatLiteralProperty.java new file mode 100644 index 000000000..c8433d410 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionFloatLiteralProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with a union of float literal as property. + */ +@Immutable +public final class UnionFloatLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final UnionFloatLiteralPropertyProperty property; + + /** + * Creates an instance of UnionFloatLiteralProperty class. + * + * @param property the property value to set. + */ + @Generated + public UnionFloatLiteralProperty(UnionFloatLiteralPropertyProperty property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public UnionFloatLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property == null ? null : this.property.toDouble()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionFloatLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionFloatLiteralProperty 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 UnionFloatLiteralProperty. + */ + @Generated + public static UnionFloatLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionFloatLiteralPropertyProperty property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = UnionFloatLiteralPropertyProperty.fromDouble(reader.getDouble()); + } else { + reader.skipChildren(); + } + } + return new UnionFloatLiteralProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionFloatLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionFloatLiteralPropertyProperty.java new file mode 100644 index 000000000..8a34a1624 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionFloatLiteralPropertyProperty.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.models; + +/** + * Defines values for UnionFloatLiteralPropertyProperty. + */ +public enum UnionFloatLiteralPropertyProperty { + /** + * Enum value 43.125. + */ + FOUR_THREE_ONE_TWO_FIVE(43.125), + + /** + * Enum value 46.875. + */ + FOUR_SIX_EIGHT_SEVEN_FIVE(46.875); + + /** + * The actual serialized value for a UnionFloatLiteralPropertyProperty instance. + */ + private final double value; + + UnionFloatLiteralPropertyProperty(double value) { + this.value = value; + } + + /** + * Parses a serialized value to a UnionFloatLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed UnionFloatLiteralPropertyProperty object, or null if unable to parse. + */ + public static UnionFloatLiteralPropertyProperty fromDouble(double value) { + UnionFloatLiteralPropertyProperty[] items = UnionFloatLiteralPropertyProperty.values(); + for (UnionFloatLiteralPropertyProperty item : items) { + if (Double.doubleToLongBits(item.toDouble()) == Double.doubleToLongBits(value)) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to double value. + * + * @return the double value. + */ + public double toDouble() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionIntLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionIntLiteralProperty.java new file mode 100644 index 000000000..ca1aca9be --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionIntLiteralProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with a union of int literal as property. + */ +@Immutable +public final class UnionIntLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final UnionIntLiteralPropertyProperty property; + + /** + * Creates an instance of UnionIntLiteralProperty class. + * + * @param property the property value to set. + */ + @Generated + public UnionIntLiteralProperty(UnionIntLiteralPropertyProperty property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public UnionIntLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property == null ? null : this.property.toInt()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionIntLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionIntLiteralProperty 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 UnionIntLiteralProperty. + */ + @Generated + public static UnionIntLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionIntLiteralPropertyProperty property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = UnionIntLiteralPropertyProperty.fromInt(reader.getInt()); + } else { + reader.skipChildren(); + } + } + return new UnionIntLiteralProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionIntLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionIntLiteralPropertyProperty.java new file mode 100644 index 000000000..e311fbbad --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionIntLiteralPropertyProperty.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.models; + +/** + * Defines values for UnionIntLiteralPropertyProperty. + */ +public enum UnionIntLiteralPropertyProperty { + /** + * Enum value 42. + */ + FOUR_TWO(42), + + /** + * Enum value 43. + */ + FOUR_THREE(43); + + /** + * The actual serialized value for a UnionIntLiteralPropertyProperty instance. + */ + private final int value; + + UnionIntLiteralPropertyProperty(int value) { + this.value = value; + } + + /** + * Parses a serialized value to a UnionIntLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed UnionIntLiteralPropertyProperty object, or null if unable to parse. + */ + public static UnionIntLiteralPropertyProperty fromInt(int value) { + UnionIntLiteralPropertyProperty[] items = UnionIntLiteralPropertyProperty.values(); + for (UnionIntLiteralPropertyProperty item : items) { + if (item.toInt() == value) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to int value. + * + * @return the int value. + */ + public int toInt() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionStringLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionStringLiteralProperty.java new file mode 100644 index 000000000..3fdac6fea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionStringLiteralProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with a union of string literal as property. + */ +@Immutable +public final class UnionStringLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final UnionStringLiteralPropertyProperty property; + + /** + * Creates an instance of UnionStringLiteralProperty class. + * + * @param property the property value to set. + */ + @Generated + public UnionStringLiteralProperty(UnionStringLiteralPropertyProperty property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public UnionStringLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property == null ? null : this.property.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionStringLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionStringLiteralProperty 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 UnionStringLiteralProperty. + */ + @Generated + public static UnionStringLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionStringLiteralPropertyProperty property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = UnionStringLiteralPropertyProperty.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new UnionStringLiteralProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionStringLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionStringLiteralPropertyProperty.java new file mode 100644 index 000000000..94c3e42f6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnionStringLiteralPropertyProperty.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 com.type.property.valuetypes.models; + +/** + * Defines values for UnionStringLiteralPropertyProperty. + */ +public enum UnionStringLiteralPropertyProperty { + /** + * Enum value hello. + */ + HELLO("hello"), + + /** + * Enum value world. + */ + WORLD("world"); + + /** + * The actual serialized value for a UnionStringLiteralPropertyProperty instance. + */ + private final String value; + + UnionStringLiteralPropertyProperty(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a UnionStringLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed UnionStringLiteralPropertyProperty object, or null if unable to parse. + */ + public static UnionStringLiteralPropertyProperty fromString(String value) { + if (value == null) { + return null; + } + UnionStringLiteralPropertyProperty[] items = UnionStringLiteralPropertyProperty.values(); + for (UnionStringLiteralPropertyProperty item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnknownArrayProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnknownArrayProperty.java new file mode 100644 index 000000000..3b7fe6eb1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnknownArrayProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with a property unknown, and the data is an array. + */ +@Immutable +public final class UnknownArrayProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final Object property; + + /** + * Creates an instance of UnknownArrayProperty class. + * + * @param property the property value to set. + */ + @Generated + public UnknownArrayProperty(Object property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public Object getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeUntypedField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnknownArrayProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnknownArrayProperty 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 UnknownArrayProperty. + */ + @Generated + public static UnknownArrayProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Object property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.readUntyped(); + } else { + reader.skipChildren(); + } + } + return new UnknownArrayProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnknownDictProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnknownDictProperty.java new file mode 100644 index 000000000..615492968 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnknownDictProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with a property unknown, and the data is a dictionnary. + */ +@Immutable +public final class UnknownDictProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final Object property; + + /** + * Creates an instance of UnknownDictProperty class. + * + * @param property the property value to set. + */ + @Generated + public UnknownDictProperty(Object property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public Object getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeUntypedField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnknownDictProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnknownDictProperty 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 UnknownDictProperty. + */ + @Generated + public static UnknownDictProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Object property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.readUntyped(); + } else { + reader.skipChildren(); + } + } + return new UnknownDictProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnknownIntProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnknownIntProperty.java new file mode 100644 index 000000000..ff36b4db5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnknownIntProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with a property unknown, and the data is a int32. + */ +@Immutable +public final class UnknownIntProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final Object property; + + /** + * Creates an instance of UnknownIntProperty class. + * + * @param property the property value to set. + */ + @Generated + public UnknownIntProperty(Object property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public Object getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeUntypedField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnknownIntProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnknownIntProperty 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 UnknownIntProperty. + */ + @Generated + public static UnknownIntProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Object property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.readUntyped(); + } else { + reader.skipChildren(); + } + } + return new UnknownIntProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnknownStringProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnknownStringProperty.java new file mode 100644 index 000000000..14dd1176a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/UnknownStringProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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; + +/** + * Model with a property unknown, and the data is a string. + */ +@Immutable +public final class UnknownStringProperty implements JsonSerializable { + /* + * Property + */ + @Generated + private final Object property; + + /** + * Creates an instance of UnknownStringProperty class. + * + * @param property the property value to set. + */ + @Generated + public UnknownStringProperty(Object property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Generated + public Object getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeUntypedField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnknownStringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnknownStringProperty 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 UnknownStringProperty. + */ + @Generated + public static UnknownStringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Object property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.readUntyped(); + } else { + reader.skipChildren(); + } + } + return new UnknownStringProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/models/package-info.java new file mode 100644 index 000000000..de328d8a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/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 ValueTypes. + * Illustrates various property types for models. + * + */ +package com.type.property.valuetypes.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/package-info.java new file mode 100644 index 000000000..399765a30 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/property/valuetypes/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 ValueTypes. + * Illustrates various property types for models. + * + */ +package com.type.property.valuetypes; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/BooleanOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/BooleanOperationAsyncClient.java new file mode 100644 index 000000000..d5d00b831 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/BooleanOperationAsyncClient.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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 com.type.scalar.implementation.BooleanOperationsImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class, isAsync = true) +public final class BooleanOperationAsyncClient { + @Generated + private final BooleanOperationsImpl serviceClient; + + /** + * Initializes an instance of BooleanOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BooleanOperationAsyncClient(BooleanOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get boolean value. + *

Response Body Schema

+ * + *
{@code
+     * boolean
+     * }
+ * + * @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 boolean value along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * put boolean value. + *

Request Body Schema

+ * + *
{@code
+     * boolean
+     * }
+ * + * @param body _. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * get boolean value. + * + * @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 boolean value on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Boolean.class)); + } + + /** + * put boolean value. + * + * @param body _. + * @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 put(boolean body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/BooleanOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/BooleanOperationClient.java new file mode 100644 index 000000000..b3765fc21 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/BooleanOperationClient.java @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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.type.scalar.implementation.BooleanOperationsImpl; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class BooleanOperationClient { + @Generated + private final BooleanOperationsImpl serviceClient; + + /** + * Initializes an instance of BooleanOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + BooleanOperationClient(BooleanOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get boolean value. + *

Response Body Schema

+ * + *
{@code
+     * boolean
+     * }
+ * + * @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 boolean value along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * put boolean value. + *

Request Body Schema

+ * + *
{@code
+     * boolean
+     * }
+ * + * @param body _. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * get boolean value. + * + * @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 boolean value. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public boolean get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(Boolean.class); + } + + /** + * put boolean value. + * + * @param body _. + * @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 put(boolean body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/Decimal128TypeAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/Decimal128TypeAsyncClient.java new file mode 100644 index 000000000..1afee86e3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/Decimal128TypeAsyncClient.java @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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 com.type.scalar.implementation.Decimal128TypesImpl; +import java.math.BigDecimal; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class, isAsync = true) +public final class Decimal128TypeAsyncClient { + @Generated + private final Decimal128TypesImpl serviceClient; + + /** + * Initializes an instance of Decimal128TypeAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Decimal128TypeAsyncClient(Decimal128TypesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The responseBody operation. + *

Response Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @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 128-bit decimal number along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> responseBodyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.responseBodyWithResponseAsync(requestOptions); + } + + /** + * The requestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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> requestBodyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.requestBodyWithResponseAsync(body, requestOptions); + } + + /** + * The requestParameter operation. + * + * @param value The value 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> requestParameterWithResponse(BigDecimal value, RequestOptions requestOptions) { + return this.serviceClient.requestParameterWithResponseAsync(value, requestOptions); + } + + /** + * The responseBody 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 128-bit decimal number on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono responseBody() { + // Generated convenience method for responseBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return responseBodyWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BigDecimal.class)); + } + + /** + * The requestBody operation. + * + * @param body The body 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 requestBody(BigDecimal body) { + // Generated convenience method for requestBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return requestBodyWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The requestParameter operation. + * + * @param value The value 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 requestParameter(BigDecimal value) { + // Generated convenience method for requestParameterWithResponse + RequestOptions requestOptions = new RequestOptions(); + return requestParameterWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/Decimal128TypeClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/Decimal128TypeClient.java new file mode 100644 index 000000000..24ab91b98 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/Decimal128TypeClient.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 com.type.scalar; + +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.type.scalar.implementation.Decimal128TypesImpl; +import java.math.BigDecimal; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class Decimal128TypeClient { + @Generated + private final Decimal128TypesImpl serviceClient; + + /** + * Initializes an instance of Decimal128TypeClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Decimal128TypeClient(Decimal128TypesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The responseBody operation. + *

Response Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @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 128-bit decimal number along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response responseBodyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.responseBodyWithResponse(requestOptions); + } + + /** + * The requestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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 requestBodyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.requestBodyWithResponse(body, requestOptions); + } + + /** + * The requestParameter operation. + * + * @param value The value 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 requestParameterWithResponse(BigDecimal value, RequestOptions requestOptions) { + return this.serviceClient.requestParameterWithResponse(value, requestOptions); + } + + /** + * The responseBody 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 128-bit decimal number. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BigDecimal responseBody() { + // Generated convenience method for responseBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return responseBodyWithResponse(requestOptions).getValue().toObject(BigDecimal.class); + } + + /** + * The requestBody operation. + * + * @param body The body 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 requestBody(BigDecimal body) { + // Generated convenience method for requestBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + requestBodyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The requestParameter operation. + * + * @param value The value 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 requestParameter(BigDecimal value) { + // Generated convenience method for requestParameterWithResponse + RequestOptions requestOptions = new RequestOptions(); + requestParameterWithResponse(value, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/Decimal128VerifyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/Decimal128VerifyAsyncClient.java new file mode 100644 index 000000000..c915c7354 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/Decimal128VerifyAsyncClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.scalar.implementation.Decimal128VerifiesImpl; +import java.math.BigDecimal; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class, isAsync = true) +public final class Decimal128VerifyAsyncClient { + @Generated + private final Decimal128VerifiesImpl serviceClient; + + /** + * Initializes an instance of Decimal128VerifyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Decimal128VerifyAsyncClient(Decimal128VerifiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The prepareVerify operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     BigDecimal (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> prepareVerifyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.prepareVerifyWithResponseAsync(requestOptions); + } + + /** + * The verify operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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> verifyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.verifyWithResponseAsync(body, requestOptions); + } + + /** + * The prepareVerify 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> prepareVerify() { + // Generated convenience method for prepareVerifyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return prepareVerifyWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_BIG_DECIMAL)); + } + + /** + * The verify operation. + * + * @param body The body 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 verify(BigDecimal body) { + // Generated convenience method for verifyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return verifyWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_BIG_DECIMAL + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/Decimal128VerifyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/Decimal128VerifyClient.java new file mode 100644 index 000000000..a25aaf989 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/Decimal128VerifyClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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.serializer.TypeReference; +import com.type.scalar.implementation.Decimal128VerifiesImpl; +import java.math.BigDecimal; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class Decimal128VerifyClient { + @Generated + private final Decimal128VerifiesImpl serviceClient; + + /** + * Initializes an instance of Decimal128VerifyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + Decimal128VerifyClient(Decimal128VerifiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The prepareVerify operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     BigDecimal (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response prepareVerifyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.prepareVerifyWithResponse(requestOptions); + } + + /** + * The verify operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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 verifyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.verifyWithResponse(body, requestOptions); + } + + /** + * The prepareVerify 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List prepareVerify() { + // Generated convenience method for prepareVerifyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return prepareVerifyWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_BIG_DECIMAL); + } + + /** + * The verify operation. + * + * @param body The body 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 verify(BigDecimal body) { + // Generated convenience method for verifyWithResponse + RequestOptions requestOptions = new RequestOptions(); + verifyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_BIG_DECIMAL + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/DecimalTypeAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/DecimalTypeAsyncClient.java new file mode 100644 index 000000000..4d5ef15e1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/DecimalTypeAsyncClient.java @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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 com.type.scalar.implementation.DecimalTypesImpl; +import java.math.BigDecimal; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class, isAsync = true) +public final class DecimalTypeAsyncClient { + @Generated + private final DecimalTypesImpl serviceClient; + + /** + * Initializes an instance of DecimalTypeAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DecimalTypeAsyncClient(DecimalTypesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The responseBody operation. + *

Response Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @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 decimal number with any length and precision along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> responseBodyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.responseBodyWithResponseAsync(requestOptions); + } + + /** + * The requestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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> requestBodyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.requestBodyWithResponseAsync(body, requestOptions); + } + + /** + * The requestParameter operation. + * + * @param value The value 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> requestParameterWithResponse(BigDecimal value, RequestOptions requestOptions) { + return this.serviceClient.requestParameterWithResponseAsync(value, requestOptions); + } + + /** + * The responseBody 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 decimal number with any length and precision on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono responseBody() { + // Generated convenience method for responseBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return responseBodyWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BigDecimal.class)); + } + + /** + * The requestBody operation. + * + * @param body The body 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 requestBody(BigDecimal body) { + // Generated convenience method for requestBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return requestBodyWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The requestParameter operation. + * + * @param value The value 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 requestParameter(BigDecimal value) { + // Generated convenience method for requestParameterWithResponse + RequestOptions requestOptions = new RequestOptions(); + return requestParameterWithResponse(value, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/DecimalTypeClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/DecimalTypeClient.java new file mode 100644 index 000000000..983c89dee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/DecimalTypeClient.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 com.type.scalar; + +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.type.scalar.implementation.DecimalTypesImpl; +import java.math.BigDecimal; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class DecimalTypeClient { + @Generated + private final DecimalTypesImpl serviceClient; + + /** + * Initializes an instance of DecimalTypeClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DecimalTypeClient(DecimalTypesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The responseBody operation. + *

Response Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @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 decimal number with any length and precision along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response responseBodyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.responseBodyWithResponse(requestOptions); + } + + /** + * The requestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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 requestBodyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.requestBodyWithResponse(body, requestOptions); + } + + /** + * The requestParameter operation. + * + * @param value The value 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 requestParameterWithResponse(BigDecimal value, RequestOptions requestOptions) { + return this.serviceClient.requestParameterWithResponse(value, requestOptions); + } + + /** + * The responseBody 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 decimal number with any length and precision. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BigDecimal responseBody() { + // Generated convenience method for responseBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return responseBodyWithResponse(requestOptions).getValue().toObject(BigDecimal.class); + } + + /** + * The requestBody operation. + * + * @param body The body 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 requestBody(BigDecimal body) { + // Generated convenience method for requestBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + requestBodyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The requestParameter operation. + * + * @param value The value 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 requestParameter(BigDecimal value) { + // Generated convenience method for requestParameterWithResponse + RequestOptions requestOptions = new RequestOptions(); + requestParameterWithResponse(value, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/DecimalVerifyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/DecimalVerifyAsyncClient.java new file mode 100644 index 000000000..64bd4b28d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/DecimalVerifyAsyncClient.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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 com.azure.core.util.serializer.TypeReference; +import com.type.scalar.implementation.DecimalVerifiesImpl; +import java.math.BigDecimal; +import java.util.List; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class, isAsync = true) +public final class DecimalVerifyAsyncClient { + @Generated + private final DecimalVerifiesImpl serviceClient; + + /** + * Initializes an instance of DecimalVerifyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DecimalVerifyAsyncClient(DecimalVerifiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The prepareVerify operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     BigDecimal (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> prepareVerifyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.prepareVerifyWithResponseAsync(requestOptions); + } + + /** + * The verify operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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> verifyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.verifyWithResponseAsync(body, requestOptions); + } + + /** + * The prepareVerify 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> prepareVerify() { + // Generated convenience method for prepareVerifyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return prepareVerifyWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_BIG_DECIMAL)); + } + + /** + * The verify operation. + * + * @param body The body 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 verify(BigDecimal body) { + // Generated convenience method for verifyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return verifyWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_BIG_DECIMAL + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/DecimalVerifyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/DecimalVerifyClient.java new file mode 100644 index 000000000..d865fc9a5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/DecimalVerifyClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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.serializer.TypeReference; +import com.type.scalar.implementation.DecimalVerifiesImpl; +import java.math.BigDecimal; +import java.util.List; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class DecimalVerifyClient { + @Generated + private final DecimalVerifiesImpl serviceClient; + + /** + * Initializes an instance of DecimalVerifyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DecimalVerifyClient(DecimalVerifiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The prepareVerify operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     BigDecimal (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response prepareVerifyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.prepareVerifyWithResponse(requestOptions); + } + + /** + * The verify operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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 verifyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.verifyWithResponse(body, requestOptions); + } + + /** + * The prepareVerify 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List prepareVerify() { + // Generated convenience method for prepareVerifyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return prepareVerifyWithResponse(requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_BIG_DECIMAL); + } + + /** + * The verify operation. + * + * @param body The body 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 verify(BigDecimal body) { + // Generated convenience method for verifyWithResponse + RequestOptions requestOptions = new RequestOptions(); + verifyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + @Generated + private static final TypeReference> TYPE_REFERENCE_LIST_BIG_DECIMAL + = new TypeReference>() { + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/ScalarClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/ScalarClientBuilder.java new file mode 100644 index 000000000..8b71294c9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/ScalarClientBuilder.java @@ -0,0 +1,422 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.scalar.implementation.ScalarClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ScalarClient type. + */ +@ServiceClientBuilder( + serviceClients = { + StringOperationClient.class, + BooleanOperationClient.class, + UnknownClient.class, + DecimalTypeClient.class, + Decimal128TypeClient.class, + DecimalVerifyClient.class, + Decimal128VerifyClient.class, + StringOperationAsyncClient.class, + BooleanOperationAsyncClient.class, + UnknownAsyncClient.class, + DecimalTypeAsyncClient.class, + Decimal128TypeAsyncClient.class, + DecimalVerifyAsyncClient.class, + Decimal128VerifyAsyncClient.class }) +public final class ScalarClientBuilder 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("type-scalar.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ScalarClientBuilder. + */ + @Generated + public ScalarClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ScalarClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ScalarClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ScalarClientBuilder 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 ScalarClientBuilder 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 ScalarClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ScalarClientBuilder 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 ScalarClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ScalarClientBuilder 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 ScalarClientBuilder. + */ + @Generated + public ScalarClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ScalarClientImpl with the provided parameters. + * + * @return an instance of ScalarClientImpl. + */ + @Generated + private ScalarClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ScalarClientImpl client + = new ScalarClientImpl(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 StringOperationAsyncClient class. + * + * @return an instance of StringOperationAsyncClient. + */ + @Generated + public StringOperationAsyncClient buildStringOperationAsyncClient() { + return new StringOperationAsyncClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of BooleanOperationAsyncClient class. + * + * @return an instance of BooleanOperationAsyncClient. + */ + @Generated + public BooleanOperationAsyncClient buildBooleanOperationAsyncClient() { + return new BooleanOperationAsyncClient(buildInnerClient().getBooleanOperations()); + } + + /** + * Builds an instance of UnknownAsyncClient class. + * + * @return an instance of UnknownAsyncClient. + */ + @Generated + public UnknownAsyncClient buildUnknownAsyncClient() { + return new UnknownAsyncClient(buildInnerClient().getUnknowns()); + } + + /** + * Builds an instance of DecimalTypeAsyncClient class. + * + * @return an instance of DecimalTypeAsyncClient. + */ + @Generated + public DecimalTypeAsyncClient buildDecimalTypeAsyncClient() { + return new DecimalTypeAsyncClient(buildInnerClient().getDecimalTypes()); + } + + /** + * Builds an instance of Decimal128TypeAsyncClient class. + * + * @return an instance of Decimal128TypeAsyncClient. + */ + @Generated + public Decimal128TypeAsyncClient buildDecimal128TypeAsyncClient() { + return new Decimal128TypeAsyncClient(buildInnerClient().getDecimal128Types()); + } + + /** + * Builds an instance of DecimalVerifyAsyncClient class. + * + * @return an instance of DecimalVerifyAsyncClient. + */ + @Generated + public DecimalVerifyAsyncClient buildDecimalVerifyAsyncClient() { + return new DecimalVerifyAsyncClient(buildInnerClient().getDecimalVerifies()); + } + + /** + * Builds an instance of Decimal128VerifyAsyncClient class. + * + * @return an instance of Decimal128VerifyAsyncClient. + */ + @Generated + public Decimal128VerifyAsyncClient buildDecimal128VerifyAsyncClient() { + return new Decimal128VerifyAsyncClient(buildInnerClient().getDecimal128Verifies()); + } + + /** + * Builds an instance of StringOperationClient class. + * + * @return an instance of StringOperationClient. + */ + @Generated + public StringOperationClient buildStringOperationClient() { + return new StringOperationClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of BooleanOperationClient class. + * + * @return an instance of BooleanOperationClient. + */ + @Generated + public BooleanOperationClient buildBooleanOperationClient() { + return new BooleanOperationClient(buildInnerClient().getBooleanOperations()); + } + + /** + * Builds an instance of UnknownClient class. + * + * @return an instance of UnknownClient. + */ + @Generated + public UnknownClient buildUnknownClient() { + return new UnknownClient(buildInnerClient().getUnknowns()); + } + + /** + * Builds an instance of DecimalTypeClient class. + * + * @return an instance of DecimalTypeClient. + */ + @Generated + public DecimalTypeClient buildDecimalTypeClient() { + return new DecimalTypeClient(buildInnerClient().getDecimalTypes()); + } + + /** + * Builds an instance of Decimal128TypeClient class. + * + * @return an instance of Decimal128TypeClient. + */ + @Generated + public Decimal128TypeClient buildDecimal128TypeClient() { + return new Decimal128TypeClient(buildInnerClient().getDecimal128Types()); + } + + /** + * Builds an instance of DecimalVerifyClient class. + * + * @return an instance of DecimalVerifyClient. + */ + @Generated + public DecimalVerifyClient buildDecimalVerifyClient() { + return new DecimalVerifyClient(buildInnerClient().getDecimalVerifies()); + } + + /** + * Builds an instance of Decimal128VerifyClient class. + * + * @return an instance of Decimal128VerifyClient. + */ + @Generated + public Decimal128VerifyClient buildDecimal128VerifyClient() { + return new Decimal128VerifyClient(buildInnerClient().getDecimal128Verifies()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ScalarClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/StringOperationAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/StringOperationAsyncClient.java new file mode 100644 index 000000000..a08bd9dfc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/StringOperationAsyncClient.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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 com.type.scalar.implementation.StringOperationsImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class, isAsync = true) +public final class StringOperationAsyncClient { + @Generated + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of StringOperationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringOperationAsyncClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get string value. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 string value along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * put string value. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param body _. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * get string value. + * + * @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 string value on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } + + /** + * put string value. + * + * @param body _. + * @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 put(String body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/StringOperationClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/StringOperationClient.java new file mode 100644 index 000000000..f3b4f7715 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/StringOperationClient.java @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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.type.scalar.implementation.StringOperationsImpl; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class StringOperationClient { + @Generated + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of StringOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringOperationClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get string value. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 string value along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * put string value. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param body _. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * get string value. + * + * @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 string value. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(String.class); + } + + /** + * put string value. + * + * @param body _. + * @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 put(String body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/UnknownAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/UnknownAsyncClient.java new file mode 100644 index 000000000..1a0c97e69 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/UnknownAsyncClient.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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 com.type.scalar.implementation.UnknownsImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class, isAsync = true) +public final class UnknownAsyncClient { + @Generated + private final UnknownsImpl serviceClient; + + /** + * Initializes an instance of UnknownAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownAsyncClient(UnknownsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get unknown value. + *

Response Body Schema

+ * + *
{@code
+     * Object
+     * }
+ * + * @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 unknown value along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * put unknown value. + *

Request Body Schema

+ * + *
{@code
+     * Object
+     * }
+ * + * @param body _. + * @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> putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponseAsync(body, requestOptions); + } + + /** + * get unknown value. + * + * @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 unknown value on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Object.class)); + } + + /** + * put unknown value. + * + * @param body _. + * @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 put(Object body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/UnknownClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/UnknownClient.java new file mode 100644 index 000000000..6a09092ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/UnknownClient.java @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar; + +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.type.scalar.implementation.UnknownsImpl; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class UnknownClient { + @Generated + private final UnknownsImpl serviceClient; + + /** + * Initializes an instance of UnknownClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + UnknownClient(UnknownsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get unknown value. + *

Response Body Schema

+ * + *
{@code
+     * Object
+     * }
+ * + * @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 unknown value along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * put unknown value. + *

Request Body Schema

+ * + *
{@code
+     * Object
+     * }
+ * + * @param body _. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * get unknown value. + * + * @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 unknown value. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Object get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(Object.class); + } + + /** + * put unknown value. + * + * @param body _. + * @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 put(Object body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/BooleanOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/BooleanOperationsImpl.java new file mode 100644 index 000000000..de2b4533c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/BooleanOperationsImpl.java @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 BooleanOperations. + */ +public final class BooleanOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BooleanOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of BooleanOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BooleanOperationsImpl(ScalarClientImpl client) { + this.service + = RestProxy.create(BooleanOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientBooleanOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ScalarClientBooleanO") + public interface BooleanOperationsService { + @Get("/type/scalar/boolean") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/scalar/boolean") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/scalar/boolean") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/scalar/boolean") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * get boolean value. + *

Response Body Schema

+ * + *
{@code
+     * boolean
+     * }
+ * + * @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 boolean value along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * get boolean value. + *

Response Body Schema

+ * + *
{@code
+     * boolean
+     * }
+ * + * @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 boolean value along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * put boolean value. + *

Request Body Schema

+ * + *
{@code
+     * boolean
+     * }
+ * + * @param body _. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * put boolean value. + *

Request Body Schema

+ * + *
{@code
+     * boolean
+     * }
+ * + * @param body _. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/Decimal128TypesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/Decimal128TypesImpl.java new file mode 100644 index 000000000..485753a5a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/Decimal128TypesImpl.java @@ -0,0 +1,241 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +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.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.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.math.BigDecimal; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Decimal128Types. + */ +public final class Decimal128TypesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Decimal128TypesService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of Decimal128TypesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Decimal128TypesImpl(ScalarClientImpl client) { + this.service + = RestProxy.create(Decimal128TypesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientDecimal128Types to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ScalarClientDecimal1") + public interface Decimal128TypesService { + @Get("/type/scalar/decimal128/response_body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> responseBody(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/scalar/decimal128/response_body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response responseBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/scalar/decimal128/resquest_body") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> requestBody(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/scalar/decimal128/resquest_body") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response requestBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Get("/type/scalar/decimal128/request_parameter") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> requestParameter(@HostParam("endpoint") String endpoint, + @QueryParam("value") BigDecimal value, RequestOptions requestOptions, Context context); + + @Get("/type/scalar/decimal128/request_parameter") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response requestParameterSync(@HostParam("endpoint") String endpoint, + @QueryParam("value") BigDecimal value, RequestOptions requestOptions, Context context); + } + + /** + * The responseBody operation. + *

Response Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @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 128-bit decimal number along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> responseBodyWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.responseBody(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The responseBody operation. + *

Response Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @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 128-bit decimal number along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response responseBodyWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.responseBodySync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The requestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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> requestBodyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.requestBody(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The requestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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 requestBodyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.requestBodySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The requestParameter operation. + * + * @param value The value 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> requestParameterWithResponseAsync(BigDecimal value, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.requestParameter(this.client.getEndpoint(), value, requestOptions, context)); + } + + /** + * The requestParameter operation. + * + * @param value The value 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 requestParameterWithResponse(BigDecimal value, RequestOptions requestOptions) { + return service.requestParameterSync(this.client.getEndpoint(), value, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/Decimal128VerifiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/Decimal128VerifiesImpl.java new file mode 100644 index 000000000..60333b644 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/Decimal128VerifiesImpl.java @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Decimal128Verifies. + */ +public final class Decimal128VerifiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Decimal128VerifiesService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of Decimal128VerifiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Decimal128VerifiesImpl(ScalarClientImpl client) { + this.service = RestProxy.create(Decimal128VerifiesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientDecimal128Verifies to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ScalarClientDecimal1") + public interface Decimal128VerifiesService { + @Get("/type/scalar/decimal128/prepare_verify") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> prepareVerify(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/scalar/decimal128/prepare_verify") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response prepareVerifySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/type/scalar/decimal128/verify") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> verify(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/type/scalar/decimal128/verify") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response verifySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The prepareVerify operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     BigDecimal (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> prepareVerifyWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.prepareVerify(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The prepareVerify operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     BigDecimal (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response prepareVerifyWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.prepareVerifySync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The verify operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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> verifyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.verify(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The verify operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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 verifyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.verifySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/DecimalTypesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/DecimalTypesImpl.java new file mode 100644 index 000000000..f4883c57e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/DecimalTypesImpl.java @@ -0,0 +1,242 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +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.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.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.math.BigDecimal; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in DecimalTypes. + */ +public final class DecimalTypesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DecimalTypesService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of DecimalTypesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DecimalTypesImpl(ScalarClientImpl client) { + this.service + = RestProxy.create(DecimalTypesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientDecimalTypes to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ScalarClientDecimalT") + public interface DecimalTypesService { + @Get("/type/scalar/decimal/response_body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> responseBody(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/scalar/decimal/response_body") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response responseBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Put("/type/scalar/decimal/resquest_body") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> requestBody(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/scalar/decimal/resquest_body") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response requestBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Get("/type/scalar/decimal/request_parameter") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> requestParameter(@HostParam("endpoint") String endpoint, + @QueryParam("value") BigDecimal value, RequestOptions requestOptions, Context context); + + @Get("/type/scalar/decimal/request_parameter") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response requestParameterSync(@HostParam("endpoint") String endpoint, + @QueryParam("value") BigDecimal value, RequestOptions requestOptions, Context context); + } + + /** + * The responseBody operation. + *

Response Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @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 decimal number with any length and precision along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> responseBodyWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.responseBody(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The responseBody operation. + *

Response Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @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 decimal number with any length and precision along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response responseBodyWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.responseBodySync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The requestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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> requestBodyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.requestBody(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The requestBody operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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 requestBodyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.requestBodySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } + + /** + * The requestParameter operation. + * + * @param value The value 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> requestParameterWithResponseAsync(BigDecimal value, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.requestParameter(this.client.getEndpoint(), value, requestOptions, context)); + } + + /** + * The requestParameter operation. + * + * @param value The value 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 requestParameterWithResponse(BigDecimal value, RequestOptions requestOptions) { + return service.requestParameterSync(this.client.getEndpoint(), value, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/DecimalVerifiesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/DecimalVerifiesImpl.java new file mode 100644 index 000000000..a74d656a7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/DecimalVerifiesImpl.java @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in DecimalVerifies. + */ +public final class DecimalVerifiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DecimalVerifiesService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of DecimalVerifiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DecimalVerifiesImpl(ScalarClientImpl client) { + this.service + = RestProxy.create(DecimalVerifiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientDecimalVerifies to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ScalarClientDecimalV") + public interface DecimalVerifiesService { + @Get("/type/scalar/decimal/prepare_verify") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> prepareVerify(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/scalar/decimal/prepare_verify") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response prepareVerifySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/type/scalar/decimal/verify") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> verify(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/type/scalar/decimal/verify") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response verifySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The prepareVerify operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     BigDecimal (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> prepareVerifyWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.prepareVerify(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The prepareVerify operation. + *

Response Body Schema

+ * + *
{@code
+     * [
+     *     BigDecimal (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response prepareVerifyWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.prepareVerifySync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The verify operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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> verifyWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.verify(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The verify operation. + *

Request Body Schema

+ * + *
{@code
+     * BigDecimal
+     * }
+ * + * @param body The body 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 verifyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.verifySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/ScalarClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/ScalarClientImpl.java new file mode 100644 index 000000000..1da15a1e6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/ScalarClientImpl.java @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the ScalarClient type. + */ +public final class ScalarClientImpl { + /** + * 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; + } + + /** + * The StringOperationsImpl object to access its operations. + */ + private final StringOperationsImpl stringOperations; + + /** + * Gets the StringOperationsImpl object to access its operations. + * + * @return the StringOperationsImpl object. + */ + public StringOperationsImpl getStringOperations() { + return this.stringOperations; + } + + /** + * The BooleanOperationsImpl object to access its operations. + */ + private final BooleanOperationsImpl booleanOperations; + + /** + * Gets the BooleanOperationsImpl object to access its operations. + * + * @return the BooleanOperationsImpl object. + */ + public BooleanOperationsImpl getBooleanOperations() { + return this.booleanOperations; + } + + /** + * The UnknownsImpl object to access its operations. + */ + private final UnknownsImpl unknowns; + + /** + * Gets the UnknownsImpl object to access its operations. + * + * @return the UnknownsImpl object. + */ + public UnknownsImpl getUnknowns() { + return this.unknowns; + } + + /** + * The DecimalTypesImpl object to access its operations. + */ + private final DecimalTypesImpl decimalTypes; + + /** + * Gets the DecimalTypesImpl object to access its operations. + * + * @return the DecimalTypesImpl object. + */ + public DecimalTypesImpl getDecimalTypes() { + return this.decimalTypes; + } + + /** + * The Decimal128TypesImpl object to access its operations. + */ + private final Decimal128TypesImpl decimal128Types; + + /** + * Gets the Decimal128TypesImpl object to access its operations. + * + * @return the Decimal128TypesImpl object. + */ + public Decimal128TypesImpl getDecimal128Types() { + return this.decimal128Types; + } + + /** + * The DecimalVerifiesImpl object to access its operations. + */ + private final DecimalVerifiesImpl decimalVerifies; + + /** + * Gets the DecimalVerifiesImpl object to access its operations. + * + * @return the DecimalVerifiesImpl object. + */ + public DecimalVerifiesImpl getDecimalVerifies() { + return this.decimalVerifies; + } + + /** + * The Decimal128VerifiesImpl object to access its operations. + */ + private final Decimal128VerifiesImpl decimal128Verifies; + + /** + * Gets the Decimal128VerifiesImpl object to access its operations. + * + * @return the Decimal128VerifiesImpl object. + */ + public Decimal128VerifiesImpl getDecimal128Verifies() { + return this.decimal128Verifies; + } + + /** + * Initializes an instance of ScalarClient client. + * + * @param endpoint Service host. + */ + public ScalarClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ScalarClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ScalarClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of ScalarClient 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 ScalarClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.stringOperations = new StringOperationsImpl(this); + this.booleanOperations = new BooleanOperationsImpl(this); + this.unknowns = new UnknownsImpl(this); + this.decimalTypes = new DecimalTypesImpl(this); + this.decimal128Types = new Decimal128TypesImpl(this); + this.decimalVerifies = new DecimalVerifiesImpl(this); + this.decimal128Verifies = new Decimal128VerifiesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/StringOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/StringOperationsImpl.java new file mode 100644 index 000000000..de7b8ad0c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/StringOperationsImpl.java @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 StringOperations. + */ +public final class StringOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of StringOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringOperationsImpl(ScalarClientImpl client) { + this.service + = RestProxy.create(StringOperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientStringOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ScalarClientStringOp") + public interface StringOperationsService { + @Get("/type/scalar/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/scalar/string") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/scalar/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/scalar/string") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * get string value. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 string value along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * get string value. + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @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 string value along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * put string value. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param body _. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * put string value. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param body _. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/UnknownsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/UnknownsImpl.java new file mode 100644 index 000000000..584c56319 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/UnknownsImpl.java @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar.implementation; + +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.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Put; +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.BinaryData; +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 Unknowns. + */ +public final class UnknownsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownsService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of UnknownsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownsImpl(ScalarClientImpl client) { + this.service = RestProxy.create(UnknownsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientUnknowns to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ScalarClientUnknowns") + public interface UnknownsService { + @Get("/type/scalar/unknown") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/scalar/unknown") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Put("/type/scalar/unknown") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> put(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Put("/type/scalar/unknown") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * get unknown value. + *

Response Body Schema

+ * + *
{@code
+     * Object
+     * }
+ * + * @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 unknown value along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * get unknown value. + *

Response Body Schema

+ * + *
{@code
+     * Object
+     * }
+ * + * @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 unknown value along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * put unknown value. + *

Request Body Schema

+ * + *
{@code
+     * Object
+     * }
+ * + * @param body _. + * @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> putWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil + .withContext(context -> service.put(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * put unknown value. + *

Request Body Schema

+ * + *
{@code
+     * Object
+     * }
+ * + * @param body _. + * @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 putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/package-info.java new file mode 100644 index 000000000..b8d9dd890 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Scalar. + * + */ +package com.type.scalar.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/package-info.java new file mode 100644 index 000000000..341d1ad35 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/scalar/package-info.java @@ -0,0 +1,10 @@ +// 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 Scalar. + * + */ +package com.type.scalar; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/EnumsOnlyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/EnumsOnlyAsyncClient.java new file mode 100644 index 000000000..2ffdd54d2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/EnumsOnlyAsyncClient.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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 com.type.union.implementation.EnumsOnliesImpl; +import com.type.union.implementation.models.SendRequest6; +import com.type.union.models.EnumsOnlyCases; +import com.type.union.models.GetResponse3; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class, isAsync = true) +public final class EnumsOnlyAsyncClient { + @Generated + private final EnumsOnliesImpl serviceClient; + + /** + * Initializes an instance of EnumsOnlyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EnumsOnlyAsyncClient(EnumsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         lr: String(left/right/up/down) (Required)
+     *         ud: String(up/down) (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         lr: String(left/right/up/down) (Required)
+     *         ud: String(up/down) (Required)
+     *     }
+     * }
+     * }
+ * + * @param sendRequest3 The sendRequest3 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> sendWithResponse(BinaryData sendRequest3, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(sendRequest3, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetResponse3.class)); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(EnumsOnlyCases prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest6 sendRequest3Obj = new SendRequest6(prop); + BinaryData sendRequest3 = BinaryData.fromObject(sendRequest3Obj); + return sendWithResponse(sendRequest3, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/EnumsOnlyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/EnumsOnlyClient.java new file mode 100644 index 000000000..769c87466 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/EnumsOnlyClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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.type.union.implementation.EnumsOnliesImpl; +import com.type.union.implementation.models.SendRequest6; +import com.type.union.models.EnumsOnlyCases; +import com.type.union.models.GetResponse3; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class EnumsOnlyClient { + @Generated + private final EnumsOnliesImpl serviceClient; + + /** + * Initializes an instance of EnumsOnlyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + EnumsOnlyClient(EnumsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         lr: String(left/right/up/down) (Required)
+     *         ud: String(up/down) (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         lr: String(left/right/up/down) (Required)
+     *         ud: String(up/down) (Required)
+     *     }
+     * }
+     * }
+ * + * @param sendRequest3 The sendRequest3 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 sendWithResponse(BinaryData sendRequest3, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest3, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public GetResponse3 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(GetResponse3.class); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(EnumsOnlyCases prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest6 sendRequest3Obj = new SendRequest6(prop); + BinaryData sendRequest3 = BinaryData.fromObject(sendRequest3Obj); + sendWithResponse(sendRequest3, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/FloatsOnlyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/FloatsOnlyAsyncClient.java new file mode 100644 index 000000000..36aded8ce --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/FloatsOnlyAsyncClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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 com.type.union.implementation.FloatsOnliesImpl; +import com.type.union.implementation.models.SendRequest4; +import com.type.union.models.GetResponse5; +import com.type.union.models.GetResponseProp1; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class, isAsync = true) +public final class FloatsOnlyAsyncClient { + @Generated + private final FloatsOnliesImpl serviceClient; + + /** + * Initializes an instance of FloatsOnlyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FloatsOnlyAsyncClient(FloatsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1.1/2.2/3.3) (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1.1/2.2/3.3) (Required)
+     * }
+     * }
+ * + * @param sendRequest5 The sendRequest5 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> sendWithResponse(BinaryData sendRequest5, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(sendRequest5, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetResponse5.class)); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(GetResponseProp1 prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest4 sendRequest5Obj = new SendRequest4(prop); + BinaryData sendRequest5 = BinaryData.fromObject(sendRequest5Obj); + return sendWithResponse(sendRequest5, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/FloatsOnlyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/FloatsOnlyClient.java new file mode 100644 index 000000000..89810763e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/FloatsOnlyClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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.type.union.implementation.FloatsOnliesImpl; +import com.type.union.implementation.models.SendRequest4; +import com.type.union.models.GetResponse5; +import com.type.union.models.GetResponseProp1; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class FloatsOnlyClient { + @Generated + private final FloatsOnliesImpl serviceClient; + + /** + * Initializes an instance of FloatsOnlyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FloatsOnlyClient(FloatsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1.1/2.2/3.3) (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1.1/2.2/3.3) (Required)
+     * }
+     * }
+ * + * @param sendRequest5 The sendRequest5 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 sendWithResponse(BinaryData sendRequest5, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest5, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public GetResponse5 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(GetResponse5.class); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(GetResponseProp1 prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest4 sendRequest5Obj = new SendRequest4(prop); + BinaryData sendRequest5 = BinaryData.fromObject(sendRequest5Obj); + sendWithResponse(sendRequest5, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/IntsOnlyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/IntsOnlyAsyncClient.java new file mode 100644 index 000000000..37dae5d8a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/IntsOnlyAsyncClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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 com.type.union.implementation.IntsOnliesImpl; +import com.type.union.implementation.models.SendRequest3; +import com.type.union.models.GetResponse6; +import com.type.union.models.GetResponseProp2; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class, isAsync = true) +public final class IntsOnlyAsyncClient { + @Generated + private final IntsOnliesImpl serviceClient; + + /** + * Initializes an instance of IntsOnlyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IntsOnlyAsyncClient(IntsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1/2/3) (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1/2/3) (Required)
+     * }
+     * }
+ * + * @param sendRequest6 The sendRequest6 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> sendWithResponse(BinaryData sendRequest6, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(sendRequest6, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetResponse6.class)); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(GetResponseProp2 prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest3 sendRequest6Obj = new SendRequest3(prop); + BinaryData sendRequest6 = BinaryData.fromObject(sendRequest6Obj); + return sendWithResponse(sendRequest6, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/IntsOnlyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/IntsOnlyClient.java new file mode 100644 index 000000000..41afa4d63 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/IntsOnlyClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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.type.union.implementation.IntsOnliesImpl; +import com.type.union.implementation.models.SendRequest3; +import com.type.union.models.GetResponse6; +import com.type.union.models.GetResponseProp2; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class IntsOnlyClient { + @Generated + private final IntsOnliesImpl serviceClient; + + /** + * Initializes an instance of IntsOnlyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IntsOnlyClient(IntsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1/2/3) (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1/2/3) (Required)
+     * }
+     * }
+ * + * @param sendRequest6 The sendRequest6 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 sendWithResponse(BinaryData sendRequest6, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest6, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public GetResponse6 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(GetResponse6.class); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(GetResponseProp2 prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest3 sendRequest6Obj = new SendRequest3(prop); + BinaryData sendRequest6 = BinaryData.fromObject(sendRequest6Obj); + sendWithResponse(sendRequest6, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/MixedLiteralsAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/MixedLiteralsAsyncClient.java new file mode 100644 index 000000000..7f0d86c52 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/MixedLiteralsAsyncClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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 com.type.union.implementation.MixedLiteralsImpl; +import com.type.union.implementation.models.SendRequest8; +import com.type.union.models.GetResponse1; +import com.type.union.models.MixedLiteralsCases; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class, isAsync = true) +public final class MixedLiteralsAsyncClient { + @Generated + private final MixedLiteralsImpl serviceClient; + + /** + * Initializes an instance of MixedLiteralsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MixedLiteralsAsyncClient(MixedLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         stringLiteral: BinaryData (Required)
+     *         intLiteral: BinaryData (Required)
+     *         floatLiteral: BinaryData (Required)
+     *         booleanLiteral: BinaryData (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         stringLiteral: BinaryData (Required)
+     *         intLiteral: BinaryData (Required)
+     *         floatLiteral: BinaryData (Required)
+     *         booleanLiteral: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param sendRequest1 The sendRequest1 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> sendWithResponse(BinaryData sendRequest1, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(sendRequest1, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetResponse1.class)); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(MixedLiteralsCases prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest8 sendRequest1Obj = new SendRequest8(prop); + BinaryData sendRequest1 = BinaryData.fromObject(sendRequest1Obj); + return sendWithResponse(sendRequest1, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/MixedLiteralsClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/MixedLiteralsClient.java new file mode 100644 index 000000000..afbedea7b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/MixedLiteralsClient.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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.type.union.implementation.MixedLiteralsImpl; +import com.type.union.implementation.models.SendRequest8; +import com.type.union.models.GetResponse1; +import com.type.union.models.MixedLiteralsCases; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class MixedLiteralsClient { + @Generated + private final MixedLiteralsImpl serviceClient; + + /** + * Initializes an instance of MixedLiteralsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MixedLiteralsClient(MixedLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         stringLiteral: BinaryData (Required)
+     *         intLiteral: BinaryData (Required)
+     *         floatLiteral: BinaryData (Required)
+     *         booleanLiteral: BinaryData (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         stringLiteral: BinaryData (Required)
+     *         intLiteral: BinaryData (Required)
+     *         floatLiteral: BinaryData (Required)
+     *         booleanLiteral: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param sendRequest1 The sendRequest1 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 sendWithResponse(BinaryData sendRequest1, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest1, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public GetResponse1 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(GetResponse1.class); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(MixedLiteralsCases prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest8 sendRequest1Obj = new SendRequest8(prop); + BinaryData sendRequest1 = BinaryData.fromObject(sendRequest1Obj); + sendWithResponse(sendRequest1, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/MixedTypesAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/MixedTypesAsyncClient.java new file mode 100644 index 000000000..b656c96c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/MixedTypesAsyncClient.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 com.type.union; + +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 com.type.union.implementation.MixedTypesImpl; +import com.type.union.implementation.models.SendRequest9; +import com.type.union.models.GetResponse; +import com.type.union.models.MixedTypesCases; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class, isAsync = true) +public final class MixedTypesAsyncClient { + @Generated + private final MixedTypesImpl serviceClient; + + /** + * Initializes an instance of MixedTypesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MixedTypesAsyncClient(MixedTypesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         model: BinaryData (Required)
+     *         literal: BinaryData (Required)
+     *         int: BinaryData (Required)
+     *         boolean: BinaryData (Required)
+     *         array (Required): [
+     *             BinaryData (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         model: BinaryData (Required)
+     *         literal: BinaryData (Required)
+     *         int: BinaryData (Required)
+     *         boolean: BinaryData (Required)
+     *         array (Required): [
+     *             BinaryData (Required)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param sendRequest The sendRequest 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> sendWithResponse(BinaryData sendRequest, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(sendRequest, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetResponse.class)); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(MixedTypesCases prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest9 sendRequestObj = new SendRequest9(prop); + BinaryData sendRequest = BinaryData.fromObject(sendRequestObj); + return sendWithResponse(sendRequest, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/MixedTypesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/MixedTypesClient.java new file mode 100644 index 000000000..a289ac1d2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/MixedTypesClient.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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.type.union.implementation.MixedTypesImpl; +import com.type.union.implementation.models.SendRequest9; +import com.type.union.models.GetResponse; +import com.type.union.models.MixedTypesCases; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class MixedTypesClient { + @Generated + private final MixedTypesImpl serviceClient; + + /** + * Initializes an instance of MixedTypesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MixedTypesClient(MixedTypesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         model: BinaryData (Required)
+     *         literal: BinaryData (Required)
+     *         int: BinaryData (Required)
+     *         boolean: BinaryData (Required)
+     *         array (Required): [
+     *             BinaryData (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         model: BinaryData (Required)
+     *         literal: BinaryData (Required)
+     *         int: BinaryData (Required)
+     *         boolean: BinaryData (Required)
+     *         array (Required): [
+     *             BinaryData (Required)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param sendRequest The sendRequest 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 sendWithResponse(BinaryData sendRequest, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public GetResponse get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(GetResponse.class); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(MixedTypesCases prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest9 sendRequestObj = new SendRequest9(prop); + BinaryData sendRequest = BinaryData.fromObject(sendRequestObj); + sendWithResponse(sendRequest, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/ModelsOnlyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/ModelsOnlyAsyncClient.java new file mode 100644 index 000000000..38bd977e6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/ModelsOnlyAsyncClient.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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 com.type.union.implementation.ModelsOnliesImpl; +import com.type.union.implementation.models.SendRequest5; +import com.type.union.models.GetResponse4; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class, isAsync = true) +public final class ModelsOnlyAsyncClient { + @Generated + private final ModelsOnliesImpl serviceClient; + + /** + * Initializes an instance of ModelsOnlyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelsOnlyAsyncClient(ModelsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: BinaryData (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: BinaryData (Required)
+     * }
+     * }
+ * + * @param sendRequest4 The sendRequest4 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> sendWithResponse(BinaryData sendRequest4, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(sendRequest4, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetResponse4.class)); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(BinaryData prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest5 sendRequest4Obj = new SendRequest5(prop); + BinaryData sendRequest4 = BinaryData.fromObject(sendRequest4Obj); + return sendWithResponse(sendRequest4, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/ModelsOnlyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/ModelsOnlyClient.java new file mode 100644 index 000000000..127f6c388 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/ModelsOnlyClient.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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.type.union.implementation.ModelsOnliesImpl; +import com.type.union.implementation.models.SendRequest5; +import com.type.union.models.GetResponse4; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class ModelsOnlyClient { + @Generated + private final ModelsOnliesImpl serviceClient; + + /** + * Initializes an instance of ModelsOnlyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ModelsOnlyClient(ModelsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: BinaryData (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: BinaryData (Required)
+     * }
+     * }
+ * + * @param sendRequest4 The sendRequest4 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 sendWithResponse(BinaryData sendRequest4, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest4, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public GetResponse4 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(GetResponse4.class); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(BinaryData prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest5 sendRequest4Obj = new SendRequest5(prop); + BinaryData sendRequest4 = BinaryData.fromObject(sendRequest4Obj); + sendWithResponse(sendRequest4, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringAndArrayAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringAndArrayAsyncClient.java new file mode 100644 index 000000000..a014aafd6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringAndArrayAsyncClient.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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 com.type.union.implementation.StringAndArraysImpl; +import com.type.union.implementation.models.SendRequest7; +import com.type.union.models.GetResponse2; +import com.type.union.models.StringAndArrayCases; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class, isAsync = true) +public final class StringAndArrayAsyncClient { + @Generated + private final StringAndArraysImpl serviceClient; + + /** + * Initializes an instance of StringAndArrayAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringAndArrayAsyncClient(StringAndArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         string: BinaryData (Required)
+     *         array: BinaryData (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         string: BinaryData (Required)
+     *         array: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param sendRequest2 The sendRequest2 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> sendWithResponse(BinaryData sendRequest2, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(sendRequest2, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetResponse2.class)); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(StringAndArrayCases prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest7 sendRequest2Obj = new SendRequest7(prop); + BinaryData sendRequest2 = BinaryData.fromObject(sendRequest2Obj); + return sendWithResponse(sendRequest2, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringAndArrayClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringAndArrayClient.java new file mode 100644 index 000000000..73dce75b7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringAndArrayClient.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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.type.union.implementation.StringAndArraysImpl; +import com.type.union.implementation.models.SendRequest7; +import com.type.union.models.GetResponse2; +import com.type.union.models.StringAndArrayCases; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class StringAndArrayClient { + @Generated + private final StringAndArraysImpl serviceClient; + + /** + * Initializes an instance of StringAndArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringAndArrayClient(StringAndArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         string: BinaryData (Required)
+     *         array: BinaryData (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         string: BinaryData (Required)
+     *         array: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param sendRequest2 The sendRequest2 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 sendWithResponse(BinaryData sendRequest2, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest2, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public GetResponse2 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(GetResponse2.class); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(StringAndArrayCases prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest7 sendRequest2Obj = new SendRequest7(prop); + BinaryData sendRequest2 = BinaryData.fromObject(sendRequest2Obj); + sendWithResponse(sendRequest2, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringExtensibleAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringExtensibleAsyncClient.java new file mode 100644 index 000000000..ca9899924 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringExtensibleAsyncClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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 com.type.union.implementation.StringExtensiblesImpl; +import com.type.union.implementation.models.SendRequest1; +import com.type.union.models.GetResponse8; +import com.type.union.models.GetResponseProp3; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class, isAsync = true) +public final class StringExtensibleAsyncClient { + @Generated + private final StringExtensiblesImpl serviceClient; + + /** + * Initializes an instance of StringExtensibleAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringExtensibleAsyncClient(StringExtensiblesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+ * + * @param sendRequest8 The sendRequest8 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> sendWithResponse(BinaryData sendRequest8, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(sendRequest8, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetResponse8.class)); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(GetResponseProp3 prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest1 sendRequest8Obj = new SendRequest1(prop); + BinaryData sendRequest8 = BinaryData.fromObject(sendRequest8Obj); + return sendWithResponse(sendRequest8, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringExtensibleClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringExtensibleClient.java new file mode 100644 index 000000000..c6f749c45 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringExtensibleClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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.type.union.implementation.StringExtensiblesImpl; +import com.type.union.implementation.models.SendRequest1; +import com.type.union.models.GetResponse8; +import com.type.union.models.GetResponseProp3; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class StringExtensibleClient { + @Generated + private final StringExtensiblesImpl serviceClient; + + /** + * Initializes an instance of StringExtensibleClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringExtensibleClient(StringExtensiblesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+ * + * @param sendRequest8 The sendRequest8 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 sendWithResponse(BinaryData sendRequest8, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest8, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public GetResponse8 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(GetResponse8.class); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(GetResponseProp3 prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest1 sendRequest8Obj = new SendRequest1(prop); + BinaryData sendRequest8 = BinaryData.fromObject(sendRequest8Obj); + sendWithResponse(sendRequest8, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringExtensibleNamedAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringExtensibleNamedAsyncClient.java new file mode 100644 index 000000000..99f53508a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringExtensibleNamedAsyncClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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 com.type.union.implementation.StringExtensibleNamedsImpl; +import com.type.union.implementation.models.SendRequest2; +import com.type.union.models.GetResponse7; +import com.type.union.models.StringExtensibleNamedUnion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class, isAsync = true) +public final class StringExtensibleNamedAsyncClient { + @Generated + private final StringExtensibleNamedsImpl serviceClient; + + /** + * Initializes an instance of StringExtensibleNamedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringExtensibleNamedAsyncClient(StringExtensibleNamedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+ * + * @param sendRequest7 The sendRequest7 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> sendWithResponse(BinaryData sendRequest7, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(sendRequest7, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetResponse7.class)); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(StringExtensibleNamedUnion prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest2 sendRequest7Obj = new SendRequest2(prop); + BinaryData sendRequest7 = BinaryData.fromObject(sendRequest7Obj); + return sendWithResponse(sendRequest7, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringExtensibleNamedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringExtensibleNamedClient.java new file mode 100644 index 000000000..1f46812f0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringExtensibleNamedClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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.type.union.implementation.StringExtensibleNamedsImpl; +import com.type.union.implementation.models.SendRequest2; +import com.type.union.models.GetResponse7; +import com.type.union.models.StringExtensibleNamedUnion; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class StringExtensibleNamedClient { + @Generated + private final StringExtensibleNamedsImpl serviceClient; + + /** + * Initializes an instance of StringExtensibleNamedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringExtensibleNamedClient(StringExtensibleNamedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+ * + * @param sendRequest7 The sendRequest7 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 sendWithResponse(BinaryData sendRequest7, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest7, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public GetResponse7 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(GetResponse7.class); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(StringExtensibleNamedUnion prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest2 sendRequest7Obj = new SendRequest2(prop); + BinaryData sendRequest7 = BinaryData.fromObject(sendRequest7Obj); + sendWithResponse(sendRequest7, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringsOnlyAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringsOnlyAsyncClient.java new file mode 100644 index 000000000..33f7f8482 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringsOnlyAsyncClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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 com.type.union.implementation.StringsOnliesImpl; +import com.type.union.implementation.models.SendRequest; +import com.type.union.models.GetResponse9; +import com.type.union.models.GetResponseProp4; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class, isAsync = true) +public final class StringsOnlyAsyncClient { + @Generated + private final StringsOnliesImpl serviceClient; + + /** + * Initializes an instance of StringsOnlyAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringsOnlyAsyncClient(StringsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(a/b/c) (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponseAsync(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(a/b/c) (Required)
+     * }
+     * }
+ * + * @param sendRequest9 The sendRequest9 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> sendWithResponse(BinaryData sendRequest9, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponseAsync(sendRequest9, requestOptions); + } + + /** + * The get 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetResponse9.class)); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(GetResponseProp4 prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest sendRequest9Obj = new SendRequest(prop); + BinaryData sendRequest9 = BinaryData.fromObject(sendRequest9Obj); + return sendWithResponse(sendRequest9, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringsOnlyClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringsOnlyClient.java new file mode 100644 index 000000000..2700b5b7a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/StringsOnlyClient.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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.type.union.implementation.StringsOnliesImpl; +import com.type.union.implementation.models.SendRequest; +import com.type.union.models.GetResponse9; +import com.type.union.models.GetResponseProp4; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class StringsOnlyClient { + @Generated + private final StringsOnliesImpl serviceClient; + + /** + * Initializes an instance of StringsOnlyClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + StringsOnlyClient(StringsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(a/b/c) (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 the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(a/b/c) (Required)
+     * }
+     * }
+ * + * @param sendRequest9 The sendRequest9 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 sendWithResponse(BinaryData sendRequest9, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest9, requestOptions); + } + + /** + * The get 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public GetResponse9 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue().toObject(GetResponse9.class); + } + + /** + * The send operation. + * + * @param prop The prop 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 send(GetResponseProp4 prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest sendRequest9Obj = new SendRequest(prop); + BinaryData sendRequest9 = BinaryData.fromObject(sendRequest9Obj); + sendWithResponse(sendRequest9, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/UnionClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/UnionClientBuilder.java new file mode 100644 index 000000000..25c011749 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/UnionClientBuilder.java @@ -0,0 +1,488 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.type.union.implementation.UnionClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the UnionClient type. + */ +@ServiceClientBuilder( + serviceClients = { + StringsOnlyClient.class, + StringExtensibleClient.class, + StringExtensibleNamedClient.class, + IntsOnlyClient.class, + FloatsOnlyClient.class, + ModelsOnlyClient.class, + EnumsOnlyClient.class, + StringAndArrayClient.class, + MixedLiteralsClient.class, + MixedTypesClient.class, + StringsOnlyAsyncClient.class, + StringExtensibleAsyncClient.class, + StringExtensibleNamedAsyncClient.class, + IntsOnlyAsyncClient.class, + FloatsOnlyAsyncClient.class, + ModelsOnlyAsyncClient.class, + EnumsOnlyAsyncClient.class, + StringAndArrayAsyncClient.class, + MixedLiteralsAsyncClient.class, + MixedTypesAsyncClient.class }) +public final class UnionClientBuilder 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("type-union.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the UnionClientBuilder. + */ + @Generated + public UnionClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder 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 UnionClientBuilder 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 UnionClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder 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 UnionClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public UnionClientBuilder 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 UnionClientBuilder. + */ + @Generated + public UnionClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of UnionClientImpl with the provided parameters. + * + * @return an instance of UnionClientImpl. + */ + @Generated + private UnionClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + UnionClientImpl client + = new UnionClientImpl(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 StringsOnlyAsyncClient class. + * + * @return an instance of StringsOnlyAsyncClient. + */ + @Generated + public StringsOnlyAsyncClient buildStringsOnlyAsyncClient() { + return new StringsOnlyAsyncClient(buildInnerClient().getStringsOnlies()); + } + + /** + * Builds an instance of StringExtensibleAsyncClient class. + * + * @return an instance of StringExtensibleAsyncClient. + */ + @Generated + public StringExtensibleAsyncClient buildStringExtensibleAsyncClient() { + return new StringExtensibleAsyncClient(buildInnerClient().getStringExtensibles()); + } + + /** + * Builds an instance of StringExtensibleNamedAsyncClient class. + * + * @return an instance of StringExtensibleNamedAsyncClient. + */ + @Generated + public StringExtensibleNamedAsyncClient buildStringExtensibleNamedAsyncClient() { + return new StringExtensibleNamedAsyncClient(buildInnerClient().getStringExtensibleNameds()); + } + + /** + * Builds an instance of IntsOnlyAsyncClient class. + * + * @return an instance of IntsOnlyAsyncClient. + */ + @Generated + public IntsOnlyAsyncClient buildIntsOnlyAsyncClient() { + return new IntsOnlyAsyncClient(buildInnerClient().getIntsOnlies()); + } + + /** + * Builds an instance of FloatsOnlyAsyncClient class. + * + * @return an instance of FloatsOnlyAsyncClient. + */ + @Generated + public FloatsOnlyAsyncClient buildFloatsOnlyAsyncClient() { + return new FloatsOnlyAsyncClient(buildInnerClient().getFloatsOnlies()); + } + + /** + * Builds an instance of ModelsOnlyAsyncClient class. + * + * @return an instance of ModelsOnlyAsyncClient. + */ + @Generated + public ModelsOnlyAsyncClient buildModelsOnlyAsyncClient() { + return new ModelsOnlyAsyncClient(buildInnerClient().getModelsOnlies()); + } + + /** + * Builds an instance of EnumsOnlyAsyncClient class. + * + * @return an instance of EnumsOnlyAsyncClient. + */ + @Generated + public EnumsOnlyAsyncClient buildEnumsOnlyAsyncClient() { + return new EnumsOnlyAsyncClient(buildInnerClient().getEnumsOnlies()); + } + + /** + * Builds an instance of StringAndArrayAsyncClient class. + * + * @return an instance of StringAndArrayAsyncClient. + */ + @Generated + public StringAndArrayAsyncClient buildStringAndArrayAsyncClient() { + return new StringAndArrayAsyncClient(buildInnerClient().getStringAndArrays()); + } + + /** + * Builds an instance of MixedLiteralsAsyncClient class. + * + * @return an instance of MixedLiteralsAsyncClient. + */ + @Generated + public MixedLiteralsAsyncClient buildMixedLiteralsAsyncClient() { + return new MixedLiteralsAsyncClient(buildInnerClient().getMixedLiterals()); + } + + /** + * Builds an instance of MixedTypesAsyncClient class. + * + * @return an instance of MixedTypesAsyncClient. + */ + @Generated + public MixedTypesAsyncClient buildMixedTypesAsyncClient() { + return new MixedTypesAsyncClient(buildInnerClient().getMixedTypes()); + } + + /** + * Builds an instance of StringsOnlyClient class. + * + * @return an instance of StringsOnlyClient. + */ + @Generated + public StringsOnlyClient buildStringsOnlyClient() { + return new StringsOnlyClient(buildInnerClient().getStringsOnlies()); + } + + /** + * Builds an instance of StringExtensibleClient class. + * + * @return an instance of StringExtensibleClient. + */ + @Generated + public StringExtensibleClient buildStringExtensibleClient() { + return new StringExtensibleClient(buildInnerClient().getStringExtensibles()); + } + + /** + * Builds an instance of StringExtensibleNamedClient class. + * + * @return an instance of StringExtensibleNamedClient. + */ + @Generated + public StringExtensibleNamedClient buildStringExtensibleNamedClient() { + return new StringExtensibleNamedClient(buildInnerClient().getStringExtensibleNameds()); + } + + /** + * Builds an instance of IntsOnlyClient class. + * + * @return an instance of IntsOnlyClient. + */ + @Generated + public IntsOnlyClient buildIntsOnlyClient() { + return new IntsOnlyClient(buildInnerClient().getIntsOnlies()); + } + + /** + * Builds an instance of FloatsOnlyClient class. + * + * @return an instance of FloatsOnlyClient. + */ + @Generated + public FloatsOnlyClient buildFloatsOnlyClient() { + return new FloatsOnlyClient(buildInnerClient().getFloatsOnlies()); + } + + /** + * Builds an instance of ModelsOnlyClient class. + * + * @return an instance of ModelsOnlyClient. + */ + @Generated + public ModelsOnlyClient buildModelsOnlyClient() { + return new ModelsOnlyClient(buildInnerClient().getModelsOnlies()); + } + + /** + * Builds an instance of EnumsOnlyClient class. + * + * @return an instance of EnumsOnlyClient. + */ + @Generated + public EnumsOnlyClient buildEnumsOnlyClient() { + return new EnumsOnlyClient(buildInnerClient().getEnumsOnlies()); + } + + /** + * Builds an instance of StringAndArrayClient class. + * + * @return an instance of StringAndArrayClient. + */ + @Generated + public StringAndArrayClient buildStringAndArrayClient() { + return new StringAndArrayClient(buildInnerClient().getStringAndArrays()); + } + + /** + * Builds an instance of MixedLiteralsClient class. + * + * @return an instance of MixedLiteralsClient. + */ + @Generated + public MixedLiteralsClient buildMixedLiteralsClient() { + return new MixedLiteralsClient(buildInnerClient().getMixedLiterals()); + } + + /** + * Builds an instance of MixedTypesClient class. + * + * @return an instance of MixedTypesClient. + */ + @Generated + public MixedTypesClient buildMixedTypesClient() { + return new MixedTypesClient(buildInnerClient().getMixedTypes()); + } + + private static final ClientLogger LOGGER = new ClientLogger(UnionClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/EnumsOnliesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/EnumsOnliesImpl.java new file mode 100644 index 000000000..0c996a566 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/EnumsOnliesImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in EnumsOnlies. + */ +public final class EnumsOnliesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EnumsOnliesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of EnumsOnliesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + EnumsOnliesImpl(UnionClientImpl client) { + this.service + = RestProxy.create(EnumsOnliesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientEnumsOnlies to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UnionClientEnumsOnli") + public interface EnumsOnliesService { + @Get("/type/union/enums-only") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/union/enums-only") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/type/union/enums-only") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest3, + RequestOptions requestOptions, Context context); + + @Post("/type/union/enums-only") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest3, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         lr: String(left/right/up/down) (Required)
+     *         ud: String(up/down) (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         lr: String(left/right/up/down) (Required)
+     *         ud: String(up/down) (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         lr: String(left/right/up/down) (Required)
+     *         ud: String(up/down) (Required)
+     *     }
+     * }
+     * }
+ * + * @param sendRequest3 The sendRequest3 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> sendWithResponseAsync(BinaryData sendRequest3, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest3, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         lr: String(left/right/up/down) (Required)
+     *         ud: String(up/down) (Required)
+     *     }
+     * }
+     * }
+ * + * @param sendRequest3 The sendRequest3 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 sendWithResponse(BinaryData sendRequest3, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest3, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/FloatsOnliesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/FloatsOnliesImpl.java new file mode 100644 index 000000000..535a35f0b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/FloatsOnliesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in FloatsOnlies. + */ +public final class FloatsOnliesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FloatsOnliesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of FloatsOnliesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FloatsOnliesImpl(UnionClientImpl client) { + this.service + = RestProxy.create(FloatsOnliesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientFloatsOnlies to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UnionClientFloatsOnl") + public interface FloatsOnliesService { + @Get("/type/union/floats-only") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/union/floats-only") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/type/union/floats-only") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest5, + RequestOptions requestOptions, Context context); + + @Post("/type/union/floats-only") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest5, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1.1/2.2/3.3) (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1.1/2.2/3.3) (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1.1/2.2/3.3) (Required)
+     * }
+     * }
+ * + * @param sendRequest5 The sendRequest5 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> sendWithResponseAsync(BinaryData sendRequest5, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest5, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1.1/2.2/3.3) (Required)
+     * }
+     * }
+ * + * @param sendRequest5 The sendRequest5 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 sendWithResponse(BinaryData sendRequest5, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest5, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/IntsOnliesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/IntsOnliesImpl.java new file mode 100644 index 000000000..3fb60afe1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/IntsOnliesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in IntsOnlies. + */ +public final class IntsOnliesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IntsOnliesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of IntsOnliesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IntsOnliesImpl(UnionClientImpl client) { + this.service + = RestProxy.create(IntsOnliesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientIntsOnlies to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UnionClientIntsOnlie") + public interface IntsOnliesService { + @Get("/type/union/ints-only") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/union/ints-only") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/type/union/ints-only") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest6, + RequestOptions requestOptions, Context context); + + @Post("/type/union/ints-only") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest6, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1/2/3) (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1/2/3) (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1/2/3) (Required)
+     * }
+     * }
+ * + * @param sendRequest6 The sendRequest6 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> sendWithResponseAsync(BinaryData sendRequest6, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest6, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(1/2/3) (Required)
+     * }
+     * }
+ * + * @param sendRequest6 The sendRequest6 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 sendWithResponse(BinaryData sendRequest6, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest6, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/MixedLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/MixedLiteralsImpl.java new file mode 100644 index 000000000..ba55149b2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/MixedLiteralsImpl.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in MixedLiterals. + */ +public final class MixedLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MixedLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of MixedLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + MixedLiteralsImpl(UnionClientImpl client) { + this.service + = RestProxy.create(MixedLiteralsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientMixedLiterals to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UnionClientMixedLite") + public interface MixedLiteralsService { + @Get("/type/union/mixed-literals") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/union/mixed-literals") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/type/union/mixed-literals") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest1, + RequestOptions requestOptions, Context context); + + @Post("/type/union/mixed-literals") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest1, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         stringLiteral: BinaryData (Required)
+     *         intLiteral: BinaryData (Required)
+     *         floatLiteral: BinaryData (Required)
+     *         booleanLiteral: BinaryData (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         stringLiteral: BinaryData (Required)
+     *         intLiteral: BinaryData (Required)
+     *         floatLiteral: BinaryData (Required)
+     *         booleanLiteral: BinaryData (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         stringLiteral: BinaryData (Required)
+     *         intLiteral: BinaryData (Required)
+     *         floatLiteral: BinaryData (Required)
+     *         booleanLiteral: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param sendRequest1 The sendRequest1 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> sendWithResponseAsync(BinaryData sendRequest1, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest1, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         stringLiteral: BinaryData (Required)
+     *         intLiteral: BinaryData (Required)
+     *         floatLiteral: BinaryData (Required)
+     *         booleanLiteral: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param sendRequest1 The sendRequest1 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 sendWithResponse(BinaryData sendRequest1, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest1, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/MixedTypesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/MixedTypesImpl.java new file mode 100644 index 000000000..addcec99e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/MixedTypesImpl.java @@ -0,0 +1,226 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in MixedTypes. + */ +public final class MixedTypesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MixedTypesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of MixedTypesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + MixedTypesImpl(UnionClientImpl client) { + this.service + = RestProxy.create(MixedTypesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientMixedTypes to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UnionClientMixedType") + public interface MixedTypesService { + @Get("/type/union/mixed-types") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/union/mixed-types") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/type/union/mixed-types") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest, + RequestOptions requestOptions, Context context); + + @Post("/type/union/mixed-types") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         model: BinaryData (Required)
+     *         literal: BinaryData (Required)
+     *         int: BinaryData (Required)
+     *         boolean: BinaryData (Required)
+     *         array (Required): [
+     *             BinaryData (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         model: BinaryData (Required)
+     *         literal: BinaryData (Required)
+     *         int: BinaryData (Required)
+     *         boolean: BinaryData (Required)
+     *         array (Required): [
+     *             BinaryData (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         model: BinaryData (Required)
+     *         literal: BinaryData (Required)
+     *         int: BinaryData (Required)
+     *         boolean: BinaryData (Required)
+     *         array (Required): [
+     *             BinaryData (Required)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param sendRequest The sendRequest 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> sendWithResponseAsync(BinaryData sendRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         model: BinaryData (Required)
+     *         literal: BinaryData (Required)
+     *         int: BinaryData (Required)
+     *         boolean: BinaryData (Required)
+     *         array (Required): [
+     *             BinaryData (Required)
+     *         ]
+     *     }
+     * }
+     * }
+ * + * @param sendRequest The sendRequest 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 sendWithResponse(BinaryData sendRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/ModelsOnliesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/ModelsOnliesImpl.java new file mode 100644 index 000000000..fcb3375e2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/ModelsOnliesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ModelsOnlies. + */ +public final class ModelsOnliesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelsOnliesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of ModelsOnliesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelsOnliesImpl(UnionClientImpl client) { + this.service + = RestProxy.create(ModelsOnliesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientModelsOnlies to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UnionClientModelsOnl") + public interface ModelsOnliesService { + @Get("/type/union/models-only") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/union/models-only") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/type/union/models-only") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest4, + RequestOptions requestOptions, Context context); + + @Post("/type/union/models-only") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest4, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: BinaryData (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: BinaryData (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: BinaryData (Required)
+     * }
+     * }
+ * + * @param sendRequest4 The sendRequest4 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> sendWithResponseAsync(BinaryData sendRequest4, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest4, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: BinaryData (Required)
+     * }
+     * }
+ * + * @param sendRequest4 The sendRequest4 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 sendWithResponse(BinaryData sendRequest4, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest4, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/StringAndArraysImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/StringAndArraysImpl.java new file mode 100644 index 000000000..671d05b44 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/StringAndArraysImpl.java @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in StringAndArrays. + */ +public final class StringAndArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringAndArraysService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of StringAndArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringAndArraysImpl(UnionClientImpl client) { + this.service + = RestProxy.create(StringAndArraysService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientStringAndArrays to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UnionClientStringAnd") + public interface StringAndArraysService { + @Get("/type/union/string-and-array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/union/string-and-array") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/type/union/string-and-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest2, + RequestOptions requestOptions, Context context); + + @Post("/type/union/string-and-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest2, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         string: BinaryData (Required)
+     *         array: BinaryData (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         string: BinaryData (Required)
+     *         array: BinaryData (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         string: BinaryData (Required)
+     *         array: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param sendRequest2 The sendRequest2 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> sendWithResponseAsync(BinaryData sendRequest2, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest2, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop (Required): {
+     *         string: BinaryData (Required)
+     *         array: BinaryData (Required)
+     *     }
+     * }
+     * }
+ * + * @param sendRequest2 The sendRequest2 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 sendWithResponse(BinaryData sendRequest2, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest2, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/StringExtensibleNamedsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/StringExtensibleNamedsImpl.java new file mode 100644 index 000000000..8e6c8c197 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/StringExtensibleNamedsImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in StringExtensibleNameds. + */ +public final class StringExtensibleNamedsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringExtensibleNamedsService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of StringExtensibleNamedsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringExtensibleNamedsImpl(UnionClientImpl client) { + this.service = RestProxy.create(StringExtensibleNamedsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientStringExtensibleNameds to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UnionClientStringExt") + public interface StringExtensibleNamedsService { + @Get("/type/union/string-extensible-named") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/union/string-extensible-named") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/type/union/string-extensible-named") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest7, + RequestOptions requestOptions, Context context); + + @Post("/type/union/string-extensible-named") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest7, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+ * + * @param sendRequest7 The sendRequest7 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> sendWithResponseAsync(BinaryData sendRequest7, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest7, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+ * + * @param sendRequest7 The sendRequest7 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 sendWithResponse(BinaryData sendRequest7, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest7, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/StringExtensiblesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/StringExtensiblesImpl.java new file mode 100644 index 000000000..fd556aca1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/StringExtensiblesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in StringExtensibles. + */ +public final class StringExtensiblesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringExtensiblesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of StringExtensiblesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringExtensiblesImpl(UnionClientImpl client) { + this.service + = RestProxy.create(StringExtensiblesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientStringExtensibles to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UnionClientStringExt") + public interface StringExtensiblesService { + @Get("/type/union/string-extensible") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/union/string-extensible") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/type/union/string-extensible") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest8, + RequestOptions requestOptions, Context context); + + @Post("/type/union/string-extensible") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest8, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+ * + * @param sendRequest8 The sendRequest8 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> sendWithResponseAsync(BinaryData sendRequest8, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest8, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+ * + * @param sendRequest8 The sendRequest8 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 sendWithResponse(BinaryData sendRequest8, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest8, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/StringsOnliesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/StringsOnliesImpl.java new file mode 100644 index 000000000..902e49164 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/StringsOnliesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation; + +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.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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in StringsOnlies. + */ +public final class StringsOnliesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringsOnliesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of StringsOnliesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringsOnliesImpl(UnionClientImpl client) { + this.service + = RestProxy.create(StringsOnliesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientStringsOnlies to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "UnionClientStringsOn") + public interface StringsOnliesService { + @Get("/type/union/strings-only") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> get(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/type/union/strings-only") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/type/union/strings-only") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> send(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData sendRequest9, + RequestOptions requestOptions, Context context); + + @Post("/type/union/strings-only") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest9, RequestOptions requestOptions, Context context); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(a/b/c) (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 the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(a/b/c) (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 the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(a/b/c) (Required)
+     * }
+     * }
+ * + * @param sendRequest9 The sendRequest9 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> sendWithResponseAsync(BinaryData sendRequest9, RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext( + context -> service.send(this.client.getEndpoint(), contentType, sendRequest9, requestOptions, context)); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String(a/b/c) (Required)
+     * }
+     * }
+ * + * @param sendRequest9 The sendRequest9 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 sendWithResponse(BinaryData sendRequest9, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest9, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/UnionClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/UnionClientImpl.java new file mode 100644 index 000000000..7a4459ca7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/UnionClientImpl.java @@ -0,0 +1,242 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the UnionClient type. + */ +public final class UnionClientImpl { + /** + * 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; + } + + /** + * The StringsOnliesImpl object to access its operations. + */ + private final StringsOnliesImpl stringsOnlies; + + /** + * Gets the StringsOnliesImpl object to access its operations. + * + * @return the StringsOnliesImpl object. + */ + public StringsOnliesImpl getStringsOnlies() { + return this.stringsOnlies; + } + + /** + * The StringExtensiblesImpl object to access its operations. + */ + private final StringExtensiblesImpl stringExtensibles; + + /** + * Gets the StringExtensiblesImpl object to access its operations. + * + * @return the StringExtensiblesImpl object. + */ + public StringExtensiblesImpl getStringExtensibles() { + return this.stringExtensibles; + } + + /** + * The StringExtensibleNamedsImpl object to access its operations. + */ + private final StringExtensibleNamedsImpl stringExtensibleNameds; + + /** + * Gets the StringExtensibleNamedsImpl object to access its operations. + * + * @return the StringExtensibleNamedsImpl object. + */ + public StringExtensibleNamedsImpl getStringExtensibleNameds() { + return this.stringExtensibleNameds; + } + + /** + * The IntsOnliesImpl object to access its operations. + */ + private final IntsOnliesImpl intsOnlies; + + /** + * Gets the IntsOnliesImpl object to access its operations. + * + * @return the IntsOnliesImpl object. + */ + public IntsOnliesImpl getIntsOnlies() { + return this.intsOnlies; + } + + /** + * The FloatsOnliesImpl object to access its operations. + */ + private final FloatsOnliesImpl floatsOnlies; + + /** + * Gets the FloatsOnliesImpl object to access its operations. + * + * @return the FloatsOnliesImpl object. + */ + public FloatsOnliesImpl getFloatsOnlies() { + return this.floatsOnlies; + } + + /** + * The ModelsOnliesImpl object to access its operations. + */ + private final ModelsOnliesImpl modelsOnlies; + + /** + * Gets the ModelsOnliesImpl object to access its operations. + * + * @return the ModelsOnliesImpl object. + */ + public ModelsOnliesImpl getModelsOnlies() { + return this.modelsOnlies; + } + + /** + * The EnumsOnliesImpl object to access its operations. + */ + private final EnumsOnliesImpl enumsOnlies; + + /** + * Gets the EnumsOnliesImpl object to access its operations. + * + * @return the EnumsOnliesImpl object. + */ + public EnumsOnliesImpl getEnumsOnlies() { + return this.enumsOnlies; + } + + /** + * The StringAndArraysImpl object to access its operations. + */ + private final StringAndArraysImpl stringAndArrays; + + /** + * Gets the StringAndArraysImpl object to access its operations. + * + * @return the StringAndArraysImpl object. + */ + public StringAndArraysImpl getStringAndArrays() { + return this.stringAndArrays; + } + + /** + * The MixedLiteralsImpl object to access its operations. + */ + private final MixedLiteralsImpl mixedLiterals; + + /** + * Gets the MixedLiteralsImpl object to access its operations. + * + * @return the MixedLiteralsImpl object. + */ + public MixedLiteralsImpl getMixedLiterals() { + return this.mixedLiterals; + } + + /** + * The MixedTypesImpl object to access its operations. + */ + private final MixedTypesImpl mixedTypes; + + /** + * Gets the MixedTypesImpl object to access its operations. + * + * @return the MixedTypesImpl object. + */ + public MixedTypesImpl getMixedTypes() { + return this.mixedTypes; + } + + /** + * Initializes an instance of UnionClient client. + * + * @param endpoint Service host. + */ + public UnionClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of UnionClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public UnionClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of UnionClient 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 UnionClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.stringsOnlies = new StringsOnliesImpl(this); + this.stringExtensibles = new StringExtensiblesImpl(this); + this.stringExtensibleNameds = new StringExtensibleNamedsImpl(this); + this.intsOnlies = new IntsOnliesImpl(this); + this.floatsOnlies = new FloatsOnliesImpl(this); + this.modelsOnlies = new ModelsOnliesImpl(this); + this.enumsOnlies = new EnumsOnliesImpl(this); + this.stringAndArrays = new StringAndArraysImpl(this); + this.mixedLiterals = new MixedLiteralsImpl(this); + this.mixedTypes = new MixedTypesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest.java new file mode 100644 index 000000000..61d84b493 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation.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 com.type.union.models.GetResponseProp4; +import java.io.IOException; + +/** + * The SendRequest model. + */ +@Immutable +public final class SendRequest implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final GetResponseProp4 prop; + + /** + * Creates an instance of SendRequest class. + * + * @param prop the prop value to set. + */ + @Generated + public SendRequest(GetResponseProp4 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public GetResponseProp4 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop == null ? null : this.prop.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest 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 SendRequest. + */ + @Generated + public static SendRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp4 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp4.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new SendRequest(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest1.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest1.java new file mode 100644 index 000000000..6d355540c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest1.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation.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 com.type.union.models.GetResponseProp3; +import java.io.IOException; + +/** + * The SendRequest1 model. + */ +@Immutable +public final class SendRequest1 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final GetResponseProp3 prop; + + /** + * Creates an instance of SendRequest1 class. + * + * @param prop the prop value to set. + */ + @Generated + public SendRequest1(GetResponseProp3 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public GetResponseProp3 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop == null ? null : this.prop.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest1 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest1 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 SendRequest1. + */ + @Generated + public static SendRequest1 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp3 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp3.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new SendRequest1(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest2.java new file mode 100644 index 000000000..ed771bc80 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest2.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation.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 com.type.union.models.StringExtensibleNamedUnion; +import java.io.IOException; + +/** + * The SendRequest2 model. + */ +@Immutable +public final class SendRequest2 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final StringExtensibleNamedUnion prop; + + /** + * Creates an instance of SendRequest2 class. + * + * @param prop the prop value to set. + */ + @Generated + public SendRequest2(StringExtensibleNamedUnion prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public StringExtensibleNamedUnion getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop == null ? null : this.prop.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest2 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 SendRequest2. + */ + @Generated + public static SendRequest2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringExtensibleNamedUnion prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = StringExtensibleNamedUnion.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new SendRequest2(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest3.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest3.java new file mode 100644 index 000000000..d3970dfa9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest3.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation.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 com.type.union.models.GetResponseProp2; +import java.io.IOException; + +/** + * The SendRequest3 model. + */ +@Immutable +public final class SendRequest3 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final GetResponseProp2 prop; + + /** + * Creates an instance of SendRequest3 class. + * + * @param prop the prop value to set. + */ + @Generated + public SendRequest3(GetResponseProp2 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public GetResponseProp2 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("prop", this.prop == null ? null : this.prop.toInt()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest3 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest3 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 SendRequest3. + */ + @Generated + public static SendRequest3 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp2 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp2.fromInt(reader.getInt()); + } else { + reader.skipChildren(); + } + } + return new SendRequest3(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest4.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest4.java new file mode 100644 index 000000000..923bcefe9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest4.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation.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 com.type.union.models.GetResponseProp1; +import java.io.IOException; + +/** + * The SendRequest4 model. + */ +@Immutable +public final class SendRequest4 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final GetResponseProp1 prop; + + /** + * Creates an instance of SendRequest4 class. + * + * @param prop the prop value to set. + */ + @Generated + public SendRequest4(GetResponseProp1 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public GetResponseProp1 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("prop", this.prop == null ? null : this.prop.toDouble()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest4 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest4 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 SendRequest4. + */ + @Generated + public static SendRequest4 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp1 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp1.fromDouble(reader.getDouble()); + } else { + reader.skipChildren(); + } + } + return new SendRequest4(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest5.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest5.java new file mode 100644 index 000000000..02a3d5d94 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest5.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.BinaryData; +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 SendRequest5 model. + */ +@Immutable +public final class SendRequest5 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final BinaryData prop; + + /** + * Creates an instance of SendRequest5 class. + * + * @param prop the prop value to set. + */ + @Generated + public SendRequest5(BinaryData prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public BinaryData getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeUntypedField("prop", this.prop.toObject(Object.class)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest5 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest5 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 SendRequest5. + */ + @Generated + public static SendRequest5 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new SendRequest5(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest6.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest6.java new file mode 100644 index 000000000..e6a10e893 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest6.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation.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 com.type.union.models.EnumsOnlyCases; +import java.io.IOException; + +/** + * The SendRequest6 model. + */ +@Immutable +public final class SendRequest6 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final EnumsOnlyCases prop; + + /** + * Creates an instance of SendRequest6 class. + * + * @param prop the prop value to set. + */ + @Generated + public SendRequest6(EnumsOnlyCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public EnumsOnlyCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest6 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest6 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 SendRequest6. + */ + @Generated + public static SendRequest6 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EnumsOnlyCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = EnumsOnlyCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new SendRequest6(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest7.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest7.java new file mode 100644 index 000000000..686b6dd78 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest7.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation.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 com.type.union.models.StringAndArrayCases; +import java.io.IOException; + +/** + * The SendRequest7 model. + */ +@Immutable +public final class SendRequest7 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final StringAndArrayCases prop; + + /** + * Creates an instance of SendRequest7 class. + * + * @param prop the prop value to set. + */ + @Generated + public SendRequest7(StringAndArrayCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public StringAndArrayCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest7 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest7 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 SendRequest7. + */ + @Generated + public static SendRequest7 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringAndArrayCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = StringAndArrayCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new SendRequest7(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest8.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest8.java new file mode 100644 index 000000000..868187494 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest8.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation.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 com.type.union.models.MixedLiteralsCases; +import java.io.IOException; + +/** + * The SendRequest8 model. + */ +@Immutable +public final class SendRequest8 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final MixedLiteralsCases prop; + + /** + * Creates an instance of SendRequest8 class. + * + * @param prop the prop value to set. + */ + @Generated + public SendRequest8(MixedLiteralsCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public MixedLiteralsCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest8 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest8 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 SendRequest8. + */ + @Generated + public static SendRequest8 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MixedLiteralsCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = MixedLiteralsCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new SendRequest8(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest9.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest9.java new file mode 100644 index 000000000..ba9d1e14f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/SendRequest9.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.implementation.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 com.type.union.models.MixedTypesCases; +import java.io.IOException; + +/** + * The SendRequest9 model. + */ +@Immutable +public final class SendRequest9 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final MixedTypesCases prop; + + /** + * Creates an instance of SendRequest9 class. + * + * @param prop the prop value to set. + */ + @Generated + public SendRequest9(MixedTypesCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public MixedTypesCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest9 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest9 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 SendRequest9. + */ + @Generated + public static SendRequest9 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MixedTypesCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = MixedTypesCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new SendRequest9(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/models/package-info.java new file mode 100644 index 000000000..c514e569a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/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 Union. + * Describe scenarios for various combinations of unions. + * + */ +package com.type.union.implementation.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/implementation/package-info.java new file mode 100644 index 000000000..7710b72ba --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/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 Union. + * Describe scenarios for various combinations of unions. + * + */ +package com.type.union.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/Cat.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/Cat.java new file mode 100644 index 000000000..a10e8d937 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/Cat.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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; + +/** + * The Cat model. + */ +@Immutable +public final class Cat implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of Cat class. + * + * @param name the name value to set. + */ + @Generated + public Cat(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Cat from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Cat 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 Cat. + */ + @Generated + public static Cat fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Cat(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/Dog.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/Dog.java new file mode 100644 index 000000000..4fd3f4371 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/Dog.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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; + +/** + * The Dog model. + */ +@Immutable +public final class Dog implements JsonSerializable { + /* + * The bark property. + */ + @Generated + private final String bark; + + /** + * Creates an instance of Dog class. + * + * @param bark the bark value to set. + */ + @Generated + public Dog(String bark) { + this.bark = bark; + } + + /** + * Get the bark property: The bark property. + * + * @return the bark value. + */ + @Generated + public String getBark() { + return this.bark; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("bark", this.bark); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Dog from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Dog 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 Dog. + */ + @Generated + public static Dog fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String bark = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("bark".equals(fieldName)) { + bark = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Dog(bark); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/EnumsOnlyCases.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/EnumsOnlyCases.java new file mode 100644 index 000000000..976e847d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/EnumsOnlyCases.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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; + +/** + * The EnumsOnlyCases model. + */ +@Immutable +public final class EnumsOnlyCases implements JsonSerializable { + /* + * This should be receive/send the left variant + */ + @Generated + private final EnumsOnlyCasesLr lr; + + /* + * This should be receive/send the up variant + */ + @Generated + private final EnumsOnlyCasesUd ud; + + /** + * Creates an instance of EnumsOnlyCases class. + * + * @param lr the lr value to set. + * @param ud the ud value to set. + */ + @Generated + public EnumsOnlyCases(EnumsOnlyCasesLr lr, EnumsOnlyCasesUd ud) { + this.lr = lr; + this.ud = ud; + } + + /** + * Get the lr property: This should be receive/send the left variant. + * + * @return the lr value. + */ + @Generated + public EnumsOnlyCasesLr getLr() { + return this.lr; + } + + /** + * Get the ud property: This should be receive/send the up variant. + * + * @return the ud value. + */ + @Generated + public EnumsOnlyCasesUd getUd() { + return this.ud; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("lr", this.lr == null ? null : this.lr.toString()); + jsonWriter.writeStringField("ud", this.ud == null ? null : this.ud.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EnumsOnlyCases from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EnumsOnlyCases 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 EnumsOnlyCases. + */ + @Generated + public static EnumsOnlyCases fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EnumsOnlyCasesLr lr = null; + EnumsOnlyCasesUd ud = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("lr".equals(fieldName)) { + lr = EnumsOnlyCasesLr.fromString(reader.getString()); + } else if ("ud".equals(fieldName)) { + ud = EnumsOnlyCasesUd.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new EnumsOnlyCases(lr, ud); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/EnumsOnlyCasesLr.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/EnumsOnlyCasesLr.java new file mode 100644 index 000000000..2000b58bd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/EnumsOnlyCasesLr.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.models; + +/** + * Defines values for EnumsOnlyCasesLr. + */ +public enum EnumsOnlyCasesLr { + /** + * Enum value left. + */ + LEFT("left"), + + /** + * Enum value right. + */ + RIGHT("right"), + + /** + * Enum value up. + */ + UP("up"), + + /** + * Enum value down. + */ + DOWN("down"); + + /** + * The actual serialized value for a EnumsOnlyCasesLr instance. + */ + private final String value; + + EnumsOnlyCasesLr(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a EnumsOnlyCasesLr instance. + * + * @param value the serialized value to parse. + * @return the parsed EnumsOnlyCasesLr object, or null if unable to parse. + */ + public static EnumsOnlyCasesLr fromString(String value) { + if (value == null) { + return null; + } + EnumsOnlyCasesLr[] items = EnumsOnlyCasesLr.values(); + for (EnumsOnlyCasesLr item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/EnumsOnlyCasesUd.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/EnumsOnlyCasesUd.java new file mode 100644 index 000000000..3320ef1d6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/EnumsOnlyCasesUd.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 com.type.union.models; + +/** + * Defines values for EnumsOnlyCasesUd. + */ +public enum EnumsOnlyCasesUd { + /** + * Enum value up. + */ + UP("up"), + + /** + * Enum value down. + */ + DOWN("down"); + + /** + * The actual serialized value for a EnumsOnlyCasesUd instance. + */ + private final String value; + + EnumsOnlyCasesUd(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a EnumsOnlyCasesUd instance. + * + * @param value the serialized value to parse. + * @return the parsed EnumsOnlyCasesUd object, or null if unable to parse. + */ + public static EnumsOnlyCasesUd fromString(String value) { + if (value == null) { + return null; + } + EnumsOnlyCasesUd[] items = EnumsOnlyCasesUd.values(); + for (EnumsOnlyCasesUd item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse.java new file mode 100644 index 000000000..411d799f4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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; + +/** + * The GetResponse model. + */ +@Immutable +public final class GetResponse implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final MixedTypesCases prop; + + /** + * Creates an instance of GetResponse class. + * + * @param prop the prop value to set. + */ + @Generated + private GetResponse(MixedTypesCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public MixedTypesCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse 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 GetResponse. + */ + @Generated + public static GetResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MixedTypesCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = MixedTypesCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new GetResponse(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse1.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse1.java new file mode 100644 index 000000000..ed8a0f673 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse1.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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; + +/** + * The GetResponse1 model. + */ +@Immutable +public final class GetResponse1 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final MixedLiteralsCases prop; + + /** + * Creates an instance of GetResponse1 class. + * + * @param prop the prop value to set. + */ + @Generated + private GetResponse1(MixedLiteralsCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public MixedLiteralsCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse1 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse1 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 GetResponse1. + */ + @Generated + public static GetResponse1 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MixedLiteralsCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = MixedLiteralsCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new GetResponse1(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse2.java new file mode 100644 index 000000000..a3453625c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse2.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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; + +/** + * The GetResponse2 model. + */ +@Immutable +public final class GetResponse2 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final StringAndArrayCases prop; + + /** + * Creates an instance of GetResponse2 class. + * + * @param prop the prop value to set. + */ + @Generated + private GetResponse2(StringAndArrayCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public StringAndArrayCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse2 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 GetResponse2. + */ + @Generated + public static GetResponse2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringAndArrayCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = StringAndArrayCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new GetResponse2(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse3.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse3.java new file mode 100644 index 000000000..3df189e7e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse3.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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; + +/** + * The GetResponse3 model. + */ +@Immutable +public final class GetResponse3 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final EnumsOnlyCases prop; + + /** + * Creates an instance of GetResponse3 class. + * + * @param prop the prop value to set. + */ + @Generated + private GetResponse3(EnumsOnlyCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public EnumsOnlyCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse3 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse3 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 GetResponse3. + */ + @Generated + public static GetResponse3 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EnumsOnlyCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = EnumsOnlyCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new GetResponse3(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse4.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse4.java new file mode 100644 index 000000000..a844c7709 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse4.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.BinaryData; +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 GetResponse4 model. + */ +@Immutable +public final class GetResponse4 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final BinaryData prop; + + /** + * Creates an instance of GetResponse4 class. + * + * @param prop the prop value to set. + */ + @Generated + private GetResponse4(BinaryData prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public BinaryData getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeUntypedField("prop", this.prop.toObject(Object.class)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse4 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse4 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 GetResponse4. + */ + @Generated + public static GetResponse4 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new GetResponse4(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse5.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse5.java new file mode 100644 index 000000000..895c3a3d8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse5.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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; + +/** + * The GetResponse5 model. + */ +@Immutable +public final class GetResponse5 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final GetResponseProp1 prop; + + /** + * Creates an instance of GetResponse5 class. + * + * @param prop the prop value to set. + */ + @Generated + private GetResponse5(GetResponseProp1 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public GetResponseProp1 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("prop", this.prop == null ? null : this.prop.toDouble()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse5 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse5 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 GetResponse5. + */ + @Generated + public static GetResponse5 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp1 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp1.fromDouble(reader.getDouble()); + } else { + reader.skipChildren(); + } + } + return new GetResponse5(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse6.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse6.java new file mode 100644 index 000000000..bf2939ae7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse6.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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; + +/** + * The GetResponse6 model. + */ +@Immutable +public final class GetResponse6 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final GetResponseProp2 prop; + + /** + * Creates an instance of GetResponse6 class. + * + * @param prop the prop value to set. + */ + @Generated + private GetResponse6(GetResponseProp2 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public GetResponseProp2 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("prop", this.prop == null ? null : this.prop.toInt()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse6 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse6 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 GetResponse6. + */ + @Generated + public static GetResponse6 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp2 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp2.fromInt(reader.getInt()); + } else { + reader.skipChildren(); + } + } + return new GetResponse6(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse7.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse7.java new file mode 100644 index 000000000..5b35574a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse7.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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; + +/** + * The GetResponse7 model. + */ +@Immutable +public final class GetResponse7 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final StringExtensibleNamedUnion prop; + + /** + * Creates an instance of GetResponse7 class. + * + * @param prop the prop value to set. + */ + @Generated + private GetResponse7(StringExtensibleNamedUnion prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public StringExtensibleNamedUnion getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop == null ? null : this.prop.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse7 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse7 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 GetResponse7. + */ + @Generated + public static GetResponse7 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringExtensibleNamedUnion prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = StringExtensibleNamedUnion.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new GetResponse7(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse8.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse8.java new file mode 100644 index 000000000..c30aa8fe8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse8.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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; + +/** + * The GetResponse8 model. + */ +@Immutable +public final class GetResponse8 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final GetResponseProp3 prop; + + /** + * Creates an instance of GetResponse8 class. + * + * @param prop the prop value to set. + */ + @Generated + private GetResponse8(GetResponseProp3 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public GetResponseProp3 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop == null ? null : this.prop.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse8 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse8 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 GetResponse8. + */ + @Generated + public static GetResponse8 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp3 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp3.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new GetResponse8(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse9.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse9.java new file mode 100644 index 000000000..098299d31 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponse9.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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; + +/** + * The GetResponse9 model. + */ +@Immutable +public final class GetResponse9 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final GetResponseProp4 prop; + + /** + * Creates an instance of GetResponse9 class. + * + * @param prop the prop value to set. + */ + @Generated + private GetResponse9(GetResponseProp4 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public GetResponseProp4 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop == null ? null : this.prop.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse9 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse9 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 GetResponse9. + */ + @Generated + public static GetResponse9 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp4 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp4.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new GetResponse9(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponseProp1.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponseProp1.java new file mode 100644 index 000000000..b58dd94c0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponseProp1.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.models; + +/** + * Defines values for GetResponseProp1. + */ +public enum GetResponseProp1 { + /** + * Enum value 1.1. + */ + ONE_ONE(1.1), + + /** + * Enum value 2.2. + */ + TWO_TWO(2.2), + + /** + * Enum value 3.3. + */ + THREE_THREE(3.3); + + /** + * The actual serialized value for a GetResponseProp1 instance. + */ + private final double value; + + GetResponseProp1(double value) { + this.value = value; + } + + /** + * Parses a serialized value to a GetResponseProp1 instance. + * + * @param value the serialized value to parse. + * @return the parsed GetResponseProp1 object, or null if unable to parse. + */ + public static GetResponseProp1 fromDouble(double value) { + GetResponseProp1[] items = GetResponseProp1.values(); + for (GetResponseProp1 item : items) { + if (Double.doubleToLongBits(item.toDouble()) == Double.doubleToLongBits(value)) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to double value. + * + * @return the double value. + */ + public double toDouble() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponseProp2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponseProp2.java new file mode 100644 index 000000000..68a8a0c79 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponseProp2.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.models; + +/** + * Defines values for GetResponseProp2. + */ +public enum GetResponseProp2 { + /** + * Enum value 1. + */ + ONE(1), + + /** + * Enum value 2. + */ + TWO(2), + + /** + * Enum value 3. + */ + THREE(3); + + /** + * The actual serialized value for a GetResponseProp2 instance. + */ + private final int value; + + GetResponseProp2(int value) { + this.value = value; + } + + /** + * Parses a serialized value to a GetResponseProp2 instance. + * + * @param value the serialized value to parse. + * @return the parsed GetResponseProp2 object, or null if unable to parse. + */ + public static GetResponseProp2 fromInt(int value) { + GetResponseProp2[] items = GetResponseProp2.values(); + for (GetResponseProp2 item : items) { + if (item.toInt() == value) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to int value. + * + * @return the int value. + */ + public int toInt() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponseProp3.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponseProp3.java new file mode 100644 index 000000000..887c9a2b7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponseProp3.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for GetResponseProp3. + */ +public final class GetResponseProp3 extends ExpandableStringEnum { + /** + * Static value b for GetResponseProp3. + */ + @Generated + public static final GetResponseProp3 B = fromString("b"); + + /** + * Static value c for GetResponseProp3. + */ + @Generated + public static final GetResponseProp3 C = fromString("c"); + + /** + * Creates a new instance of GetResponseProp3 value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public GetResponseProp3() { + } + + /** + * Creates or finds a GetResponseProp3 from its string representation. + * + * @param name a name to look for. + * @return the corresponding GetResponseProp3. + */ + @Generated + public static GetResponseProp3 fromString(String name) { + return fromString(name, GetResponseProp3.class); + } + + /** + * Gets known GetResponseProp3 values. + * + * @return known GetResponseProp3 values. + */ + @Generated + public static Collection values() { + return values(GetResponseProp3.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponseProp4.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponseProp4.java new file mode 100644 index 000000000..fba34d3ce --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/GetResponseProp4.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.models; + +/** + * Defines values for GetResponseProp4. + */ +public enum GetResponseProp4 { + /** + * Enum value a. + */ + A("a"), + + /** + * Enum value b. + */ + B("b"), + + /** + * Enum value c. + */ + C("c"); + + /** + * The actual serialized value for a GetResponseProp4 instance. + */ + private final String value; + + GetResponseProp4(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a GetResponseProp4 instance. + * + * @param value the serialized value to parse. + * @return the parsed GetResponseProp4 object, or null if unable to parse. + */ + public static GetResponseProp4 fromString(String value) { + if (value == null) { + return null; + } + GetResponseProp4[] items = GetResponseProp4.values(); + for (GetResponseProp4 item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/MixedLiteralsCases.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/MixedLiteralsCases.java new file mode 100644 index 000000000..bca890086 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/MixedLiteralsCases.java @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.BinaryData; +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 MixedLiteralsCases model. + */ +@Immutable +public final class MixedLiteralsCases implements JsonSerializable { + /* + * This should be receive/send the "a" variant + */ + @Generated + private final BinaryData stringLiteral; + + /* + * This should be receive/send the 2 variant + */ + @Generated + private final BinaryData intLiteral; + + /* + * This should be receive/send the 3.3 variant + */ + @Generated + private final BinaryData floatLiteral; + + /* + * This should be receive/send the true variant + */ + @Generated + private final BinaryData booleanLiteral; + + /** + * Creates an instance of MixedLiteralsCases class. + * + * @param stringLiteral the stringLiteral value to set. + * @param intLiteral the intLiteral value to set. + * @param floatLiteral the floatLiteral value to set. + * @param booleanLiteral the booleanLiteral value to set. + */ + @Generated + public MixedLiteralsCases(BinaryData stringLiteral, BinaryData intLiteral, BinaryData floatLiteral, + BinaryData booleanLiteral) { + this.stringLiteral = stringLiteral; + this.intLiteral = intLiteral; + this.floatLiteral = floatLiteral; + this.booleanLiteral = booleanLiteral; + } + + /** + * Get the stringLiteral property: This should be receive/send the "a" variant. + * + * @return the stringLiteral value. + */ + @Generated + public BinaryData getStringLiteral() { + return this.stringLiteral; + } + + /** + * Get the intLiteral property: This should be receive/send the 2 variant. + * + * @return the intLiteral value. + */ + @Generated + public BinaryData getIntLiteral() { + return this.intLiteral; + } + + /** + * Get the floatLiteral property: This should be receive/send the 3.3 variant. + * + * @return the floatLiteral value. + */ + @Generated + public BinaryData getFloatLiteral() { + return this.floatLiteral; + } + + /** + * Get the booleanLiteral property: This should be receive/send the true variant. + * + * @return the booleanLiteral value. + */ + @Generated + public BinaryData getBooleanLiteral() { + return this.booleanLiteral; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeUntypedField("stringLiteral", this.stringLiteral.toObject(Object.class)); + jsonWriter.writeUntypedField("intLiteral", this.intLiteral.toObject(Object.class)); + jsonWriter.writeUntypedField("floatLiteral", this.floatLiteral.toObject(Object.class)); + jsonWriter.writeUntypedField("booleanLiteral", this.booleanLiteral.toObject(Object.class)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MixedLiteralsCases from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MixedLiteralsCases 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 MixedLiteralsCases. + */ + @Generated + public static MixedLiteralsCases fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData stringLiteral = null; + BinaryData intLiteral = null; + BinaryData floatLiteral = null; + BinaryData booleanLiteral = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("stringLiteral".equals(fieldName)) { + stringLiteral + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("intLiteral".equals(fieldName)) { + intLiteral + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("floatLiteral".equals(fieldName)) { + floatLiteral + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("booleanLiteral".equals(fieldName)) { + booleanLiteral + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new MixedLiteralsCases(stringLiteral, intLiteral, floatLiteral, booleanLiteral); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/MixedTypesCases.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/MixedTypesCases.java new file mode 100644 index 000000000..c2f23108f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/MixedTypesCases.java @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.BinaryData; +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 MixedTypesCases model. + */ +@Immutable +public final class MixedTypesCases implements JsonSerializable { + /* + * This should be receive/send the Cat variant + */ + @Generated + private final BinaryData model; + + /* + * This should be receive/send the "a" variant + */ + @Generated + private final BinaryData literal; + + /* + * This should be receive/send the int variant + */ + @Generated + private final BinaryData intProperty; + + /* + * This should be receive/send the boolean variant + */ + @Generated + private final BinaryData booleanProperty; + + /* + * This should be receive/send 4 element with Cat, "a", int, and boolean + */ + @Generated + private final List array; + + /** + * Creates an instance of MixedTypesCases class. + * + * @param model the model value to set. + * @param literal the literal value to set. + * @param intProperty the intProperty value to set. + * @param booleanProperty the booleanProperty value to set. + * @param array the array value to set. + */ + @Generated + public MixedTypesCases(BinaryData model, BinaryData literal, BinaryData intProperty, BinaryData booleanProperty, + List array) { + this.model = model; + this.literal = literal; + this.intProperty = intProperty; + this.booleanProperty = booleanProperty; + this.array = array; + } + + /** + * Get the model property: This should be receive/send the Cat variant. + * + * @return the model value. + */ + @Generated + public BinaryData getModel() { + return this.model; + } + + /** + * Get the literal property: This should be receive/send the "a" variant. + * + * @return the literal value. + */ + @Generated + public BinaryData getLiteral() { + return this.literal; + } + + /** + * Get the intProperty property: This should be receive/send the int variant. + * + * @return the intProperty value. + */ + @Generated + public BinaryData getIntProperty() { + return this.intProperty; + } + + /** + * Get the booleanProperty property: This should be receive/send the boolean variant. + * + * @return the booleanProperty value. + */ + @Generated + public BinaryData getBooleanProperty() { + return this.booleanProperty; + } + + /** + * Get the array property: This should be receive/send 4 element with Cat, "a", int, and boolean. + * + * @return the array value. + */ + @Generated + public List getArray() { + return this.array; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeUntypedField("model", this.model.toObject(Object.class)); + jsonWriter.writeUntypedField("literal", this.literal.toObject(Object.class)); + jsonWriter.writeUntypedField("int", this.intProperty.toObject(Object.class)); + jsonWriter.writeUntypedField("boolean", this.booleanProperty.toObject(Object.class)); + jsonWriter.writeArrayField("array", this.array, + (writer, element) -> writer.writeUntyped(element == null ? null : element.toObject(Object.class))); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MixedTypesCases from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MixedTypesCases 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 MixedTypesCases. + */ + @Generated + public static MixedTypesCases fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData model = null; + BinaryData literal = null; + BinaryData intProperty = null; + BinaryData booleanProperty = null; + List array = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("model".equals(fieldName)) { + model = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("literal".equals(fieldName)) { + literal = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("int".equals(fieldName)) { + intProperty + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("boolean".equals(fieldName)) { + booleanProperty + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("array".equals(fieldName)) { + array = reader.readArray(reader1 -> reader1 + .getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } else { + reader.skipChildren(); + } + } + return new MixedTypesCases(model, literal, intProperty, booleanProperty, array); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/StringAndArrayCases.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/StringAndArrayCases.java new file mode 100644 index 000000000..4e436837a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/StringAndArrayCases.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 com.type.union.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.BinaryData; +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 StringAndArrayCases model. + */ +@Immutable +public final class StringAndArrayCases implements JsonSerializable { + /* + * This should be receive/send the string variant + */ + @Generated + private final BinaryData string; + + /* + * This should be receive/send the array variant + */ + @Generated + private final BinaryData array; + + /** + * Creates an instance of StringAndArrayCases class. + * + * @param string the string value to set. + * @param array the array value to set. + */ + @Generated + public StringAndArrayCases(BinaryData string, BinaryData array) { + this.string = string; + this.array = array; + } + + /** + * Get the string property: This should be receive/send the string variant. + * + * @return the string value. + */ + @Generated + public BinaryData getString() { + return this.string; + } + + /** + * Get the array property: This should be receive/send the array variant. + * + * @return the array value. + */ + @Generated + public BinaryData getArray() { + return this.array; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeUntypedField("string", this.string.toObject(Object.class)); + jsonWriter.writeUntypedField("array", this.array.toObject(Object.class)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StringAndArrayCases from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StringAndArrayCases 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 StringAndArrayCases. + */ + @Generated + public static StringAndArrayCases fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData string = null; + BinaryData array = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("string".equals(fieldName)) { + string = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("array".equals(fieldName)) { + array = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new StringAndArrayCases(string, array); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/StringExtensibleNamedUnion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/StringExtensibleNamedUnion.java new file mode 100644 index 000000000..6a0f1c497 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/StringExtensibleNamedUnion.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for StringExtensibleNamedUnion. + */ +public final class StringExtensibleNamedUnion extends ExpandableStringEnum { + /** + * Static value b for StringExtensibleNamedUnion. + */ + @Generated + public static final StringExtensibleNamedUnion OPTIONB = fromString("b"); + + /** + * Static value c for StringExtensibleNamedUnion. + */ + @Generated + public static final StringExtensibleNamedUnion C = fromString("c"); + + /** + * Creates a new instance of StringExtensibleNamedUnion value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public StringExtensibleNamedUnion() { + } + + /** + * Creates or finds a StringExtensibleNamedUnion from its string representation. + * + * @param name a name to look for. + * @return the corresponding StringExtensibleNamedUnion. + */ + @Generated + public static StringExtensibleNamedUnion fromString(String name) { + return fromString(name, StringExtensibleNamedUnion.class); + } + + /** + * Gets known StringExtensibleNamedUnion values. + * + * @return known StringExtensibleNamedUnion values. + */ + @Generated + public static Collection values() { + return values(StringExtensibleNamedUnion.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/models/package-info.java new file mode 100644 index 000000000..e2c063fcb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/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 Union. + * Describe scenarios for various combinations of unions. + * + */ +package com.type.union.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/package-info.java new file mode 100644 index 000000000..90818cfcd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/type/union/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 Union. + * Describe scenarios for various combinations of unions. + * + */ +package com.type.union; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/AddedAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/AddedAsyncClient.java new file mode 100644 index 000000000..9f8732d8e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/AddedAsyncClient.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 com.versioning.added; + +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 com.versioning.added.implementation.AddedClientImpl; +import com.versioning.added.models.ModelV1; +import com.versioning.added.models.ModelV2; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AddedClient type. + */ +@ServiceClient(builder = AddedClientBuilder.class, isAsync = true) +public final class AddedAsyncClient { + @Generated + private final AddedClientImpl serviceClient; + + /** + * Initializes an instance of AddedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + AddedAsyncClient(AddedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The v1 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param headerV2 The headerV2 parameter. + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> v1WithResponse(String headerV2, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.v1WithResponseAsync(headerV2, body, requestOptions); + } + + /** + * The v2 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> v2WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.v2WithResponseAsync(body, requestOptions); + } + + /** + * The v1 operation. + * + * @param headerV2 The headerV2 parameter. + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono v1(String headerV2, ModelV1 body) { + // Generated convenience method for v1WithResponse + RequestOptions requestOptions = new RequestOptions(); + return v1WithResponse(headerV2, BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ModelV1.class)); + } + + /** + * The v2 operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono v2(ModelV2 body) { + // Generated convenience method for v2WithResponse + RequestOptions requestOptions = new RequestOptions(); + return v2WithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ModelV2.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/AddedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/AddedClient.java new file mode 100644 index 000000000..4954e6db5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/AddedClient.java @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.added; + +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.versioning.added.implementation.AddedClientImpl; +import com.versioning.added.models.ModelV1; +import com.versioning.added.models.ModelV2; + +/** + * Initializes a new instance of the synchronous AddedClient type. + */ +@ServiceClient(builder = AddedClientBuilder.class) +public final class AddedClient { + @Generated + private final AddedClientImpl serviceClient; + + /** + * Initializes an instance of AddedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + AddedClient(AddedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The v1 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param headerV2 The headerV2 parameter. + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response v1WithResponse(String headerV2, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.v1WithResponse(headerV2, body, requestOptions); + } + + /** + * The v2 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response v2WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.v2WithResponse(body, requestOptions); + } + + /** + * The v1 operation. + * + * @param headerV2 The headerV2 parameter. + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ModelV1 v1(String headerV2, ModelV1 body) { + // Generated convenience method for v1WithResponse + RequestOptions requestOptions = new RequestOptions(); + return v1WithResponse(headerV2, BinaryData.fromObject(body), requestOptions).getValue().toObject(ModelV1.class); + } + + /** + * The v2 operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ModelV2 v2(ModelV2 body) { + // Generated convenience method for v2WithResponse + RequestOptions requestOptions = new RequestOptions(); + return v2WithResponse(BinaryData.fromObject(body), requestOptions).getValue().toObject(ModelV2.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/AddedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/AddedClientBuilder.java new file mode 100644 index 000000000..c0864b8c5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/AddedClientBuilder.java @@ -0,0 +1,351 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.added; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.versioning.added.implementation.AddedClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the AddedClient type. + */ +@ServiceClientBuilder( + serviceClients = { + AddedClient.class, + InterfaceV2Client.class, + AddedAsyncClient.class, + InterfaceV2AsyncClient.class }) +public final class AddedClientBuilder 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("versioning-added.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the AddedClientBuilder. + */ + @Generated + public AddedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AddedClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AddedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AddedClientBuilder 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 AddedClientBuilder 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 AddedClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AddedClientBuilder 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 AddedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public AddedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'v1' or 'v2' in client. + */ + @Generated + private String version; + + /** + * Sets Need to be set as 'v1' or 'v2' in client. + * + * @param version the version value. + * @return the AddedClientBuilder. + */ + @Generated + public AddedClientBuilder version(String version) { + this.version = version; + return this; + } + + /* + * Service version + */ + @Generated + private AddedServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the AddedClientBuilder. + */ + @Generated + public AddedClientBuilder serviceVersion(AddedServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 AddedClientBuilder. + */ + @Generated + public AddedClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of AddedClientImpl with the provided parameters. + * + * @return an instance of AddedClientImpl. + */ + @Generated + private AddedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + AddedServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : AddedServiceVersion.getLatest(); + AddedClientImpl client = new AddedClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, this.version, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(version, "'version' cannot be null."); + } + + @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 AddedAsyncClient class. + * + * @return an instance of AddedAsyncClient. + */ + @Generated + public AddedAsyncClient buildAsyncClient() { + return new AddedAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of InterfaceV2AsyncClient class. + * + * @return an instance of InterfaceV2AsyncClient. + */ + @Generated + public InterfaceV2AsyncClient buildInterfaceV2AsyncClient() { + return new InterfaceV2AsyncClient(buildInnerClient().getInterfaceV2s()); + } + + /** + * Builds an instance of AddedClient class. + * + * @return an instance of AddedClient. + */ + @Generated + public AddedClient buildClient() { + return new AddedClient(buildInnerClient()); + } + + /** + * Builds an instance of InterfaceV2Client class. + * + * @return an instance of InterfaceV2Client. + */ + @Generated + public InterfaceV2Client buildInterfaceV2Client() { + return new InterfaceV2Client(buildInnerClient().getInterfaceV2s()); + } + + private static final ClientLogger LOGGER = new ClientLogger(AddedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/AddedServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/AddedServiceVersion.java new file mode 100644 index 000000000..59456a28b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/AddedServiceVersion.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.added; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of AddedClient. + */ +public enum AddedServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + AddedServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link AddedServiceVersion}. + */ + public static AddedServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/InterfaceV2AsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/InterfaceV2AsyncClient.java new file mode 100644 index 000000000..ff97118a6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/InterfaceV2AsyncClient.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.added; + +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 com.versioning.added.implementation.InterfaceV2sImpl; +import com.versioning.added.models.ModelV2; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous AddedClient type. + */ +@ServiceClient(builder = AddedClientBuilder.class, isAsync = true) +public final class InterfaceV2AsyncClient { + @Generated + private final InterfaceV2sImpl serviceClient; + + /** + * Initializes an instance of InterfaceV2AsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + InterfaceV2AsyncClient(InterfaceV2sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The v2InInterface operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> v2InInterfaceWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.v2InInterfaceWithResponseAsync(body, requestOptions); + } + + /** + * The v2InInterface operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono v2InInterface(ModelV2 body) { + // Generated convenience method for v2InInterfaceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return v2InInterfaceWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ModelV2.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/InterfaceV2Client.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/InterfaceV2Client.java new file mode 100644 index 000000000..3c36ad05c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/InterfaceV2Client.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.added; + +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.versioning.added.implementation.InterfaceV2sImpl; +import com.versioning.added.models.ModelV2; + +/** + * Initializes a new instance of the synchronous AddedClient type. + */ +@ServiceClient(builder = AddedClientBuilder.class) +public final class InterfaceV2Client { + @Generated + private final InterfaceV2sImpl serviceClient; + + /** + * Initializes an instance of InterfaceV2Client class. + * + * @param serviceClient the service client implementation. + */ + @Generated + InterfaceV2Client(InterfaceV2sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The v2InInterface operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response v2InInterfaceWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.v2InInterfaceWithResponse(body, requestOptions); + } + + /** + * The v2InInterface operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ModelV2 v2InInterface(ModelV2 body) { + // Generated convenience method for v2InInterfaceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return v2InInterfaceWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(ModelV2.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/implementation/AddedClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/implementation/AddedClientImpl.java new file mode 100644 index 000000000..76f0d2790 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/implementation/AddedClientImpl.java @@ -0,0 +1,377 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.added.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 com.versioning.added.AddedServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the AddedClient type. + */ +public final class AddedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final AddedClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'v1' or 'v2' in client. + */ + private final String version; + + /** + * Gets Need to be set as 'v1' or 'v2' in client. + * + * @return the version value. + */ + public String getVersion() { + return this.version; + } + + /** + * Service version. + */ + private final AddedServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AddedServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * The InterfaceV2sImpl object to access its operations. + */ + private final InterfaceV2sImpl interfaceV2s; + + /** + * Gets the InterfaceV2sImpl object to access its operations. + * + * @return the InterfaceV2sImpl object. + */ + public InterfaceV2sImpl getInterfaceV2s() { + return this.interfaceV2s; + } + + /** + * Initializes an instance of AddedClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public AddedClientImpl(String endpoint, String version, AddedServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, version, serviceVersion); + } + + /** + * Initializes an instance of AddedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public AddedClientImpl(HttpPipeline httpPipeline, String endpoint, String version, + AddedServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, version, serviceVersion); + } + + /** + * Initializes an instance of AddedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public AddedClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + String version, AddedServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.version = version; + this.serviceVersion = serviceVersion; + this.interfaceV2s = new InterfaceV2sImpl(this); + this.service = RestProxy.create(AddedClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for AddedClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}/versioning/added/api-version:{version}") + @ServiceInterface(name = "AddedClient") + public interface AddedClientService { + @Post("/v1") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> v1(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @HeaderParam("header-v2") String headerV2, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/v1") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response v1Sync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @HeaderParam("header-v2") String headerV2, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/v2") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> v2(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/v2") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response v2Sync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The v1 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param headerV2 The headerV2 parameter. + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> v1WithResponseAsync(String headerV2, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.v1(this.getEndpoint(), this.getVersion(), headerV2, contentType, + accept, body, requestOptions, context)); + } + + /** + * The v1 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param headerV2 The headerV2 parameter. + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response v1WithResponse(String headerV2, BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.v1Sync(this.getEndpoint(), this.getVersion(), headerV2, contentType, accept, body, + requestOptions, Context.NONE); + } + + /** + * The v2 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> v2WithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.v2(this.getEndpoint(), this.getVersion(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The v2 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response v2WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.v2Sync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/implementation/InterfaceV2sImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/implementation/InterfaceV2sImpl.java new file mode 100644 index 000000000..a032c9359 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/implementation/InterfaceV2sImpl.java @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.added.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.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.versioning.added.AddedServiceVersion; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in InterfaceV2s. + */ +public final class InterfaceV2sImpl { + /** + * The proxy service used to perform REST calls. + */ + private final InterfaceV2sService service; + + /** + * The service client containing this operation class. + */ + private final AddedClientImpl client; + + /** + * Initializes an instance of InterfaceV2sImpl. + * + * @param client the instance of the service client containing this operation class. + */ + InterfaceV2sImpl(AddedClientImpl client) { + this.service + = RestProxy.create(InterfaceV2sService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AddedServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for AddedClientInterfaceV2s to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}/versioning/added/api-version:{version}") + @ServiceInterface(name = "AddedClientInterface") + public interface InterfaceV2sService { + @Post("/interface-v2/v2") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> v2InInterface(@HostParam("endpoint") String endpoint, + @HostParam("version") String version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/interface-v2/v2") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response v2InInterfaceSync(@HostParam("endpoint") String endpoint, + @HostParam("version") String version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The v2InInterface operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> v2InInterfaceWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.v2InInterface(this.client.getEndpoint(), + this.client.getVersion(), contentType, accept, body, requestOptions, context)); + } + + /** + * The v2InInterface operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response v2InInterfaceWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.v2InInterfaceSync(this.client.getEndpoint(), this.client.getVersion(), contentType, accept, body, + requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/implementation/package-info.java new file mode 100644 index 000000000..aa6273e71 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/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 Added. + * Test for the `@added` decorator. + * + */ +package com.versioning.added.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/EnumV1.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/EnumV1.java new file mode 100644 index 000000000..35a2adf32 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/EnumV1.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 com.versioning.added.models; + +/** + * Defines values for EnumV1. + */ +public enum EnumV1 { + /** + * Enum value enumMemberV1. + */ + ENUM_MEMBER_V1("enumMemberV1"), + + /** + * Enum value enumMemberV2. + */ + ENUM_MEMBER_V2("enumMemberV2"); + + /** + * The actual serialized value for a EnumV1 instance. + */ + private final String value; + + EnumV1(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a EnumV1 instance. + * + * @param value the serialized value to parse. + * @return the parsed EnumV1 object, or null if unable to parse. + */ + public static EnumV1 fromString(String value) { + if (value == null) { + return null; + } + EnumV1[] items = EnumV1.values(); + for (EnumV1 item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/EnumV2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/EnumV2.java new file mode 100644 index 000000000..0b9382c29 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/EnumV2.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.added.models; + +/** + * Defines values for EnumV2. + */ +public enum EnumV2 { + /** + * Enum value enumMember. + */ + ENUM_MEMBER("enumMember"); + + /** + * The actual serialized value for a EnumV2 instance. + */ + private final String value; + + EnumV2(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a EnumV2 instance. + * + * @param value the serialized value to parse. + * @return the parsed EnumV2 object, or null if unable to parse. + */ + public static EnumV2 fromString(String value) { + if (value == null) { + return null; + } + EnumV2[] items = EnumV2.values(); + for (EnumV2 item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/ModelV1.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/ModelV1.java new file mode 100644 index 000000000..8547dbb35 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/ModelV1.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.added.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.BinaryData; +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 ModelV1 model. + */ +@Immutable +public final class ModelV1 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final String prop; + + /* + * The enumProp property. + */ + @Generated + private final EnumV1 enumProp; + + /* + * The unionProp property. + */ + @Generated + private final BinaryData unionProp; + + /** + * Creates an instance of ModelV1 class. + * + * @param prop the prop value to set. + * @param enumProp the enumProp value to set. + * @param unionProp the unionProp value to set. + */ + @Generated + public ModelV1(String prop, EnumV1 enumProp, BinaryData unionProp) { + this.prop = prop; + this.enumProp = enumProp; + this.unionProp = unionProp; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public String getProp() { + return this.prop; + } + + /** + * Get the enumProp property: The enumProp property. + * + * @return the enumProp value. + */ + @Generated + public EnumV1 getEnumProp() { + return this.enumProp; + } + + /** + * Get the unionProp property: The unionProp property. + * + * @return the unionProp value. + */ + @Generated + public BinaryData getUnionProp() { + return this.unionProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop); + jsonWriter.writeStringField("enumProp", this.enumProp == null ? null : this.enumProp.toString()); + jsonWriter.writeUntypedField("unionProp", this.unionProp.toObject(Object.class)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelV1 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelV1 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 ModelV1. + */ + @Generated + public static ModelV1 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prop = null; + EnumV1 enumProp = null; + BinaryData unionProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getString(); + } else if ("enumProp".equals(fieldName)) { + enumProp = EnumV1.fromString(reader.getString()); + } else if ("unionProp".equals(fieldName)) { + unionProp = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new ModelV1(prop, enumProp, unionProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/ModelV2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/ModelV2.java new file mode 100644 index 000000000..6132f119e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/ModelV2.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.added.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.BinaryData; +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 ModelV2 model. + */ +@Immutable +public final class ModelV2 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final String prop; + + /* + * The enumProp property. + */ + @Generated + private final EnumV2 enumProp; + + /* + * The unionProp property. + */ + @Generated + private final BinaryData unionProp; + + /** + * Creates an instance of ModelV2 class. + * + * @param prop the prop value to set. + * @param enumProp the enumProp value to set. + * @param unionProp the unionProp value to set. + */ + @Generated + public ModelV2(String prop, EnumV2 enumProp, BinaryData unionProp) { + this.prop = prop; + this.enumProp = enumProp; + this.unionProp = unionProp; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public String getProp() { + return this.prop; + } + + /** + * Get the enumProp property: The enumProp property. + * + * @return the enumProp value. + */ + @Generated + public EnumV2 getEnumProp() { + return this.enumProp; + } + + /** + * Get the unionProp property: The unionProp property. + * + * @return the unionProp value. + */ + @Generated + public BinaryData getUnionProp() { + return this.unionProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop); + jsonWriter.writeStringField("enumProp", this.enumProp == null ? null : this.enumProp.toString()); + jsonWriter.writeUntypedField("unionProp", this.unionProp.toObject(Object.class)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelV2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelV2 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 ModelV2. + */ + @Generated + public static ModelV2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prop = null; + EnumV2 enumProp = null; + BinaryData unionProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getString(); + } else if ("enumProp".equals(fieldName)) { + enumProp = EnumV2.fromString(reader.getString()); + } else if ("unionProp".equals(fieldName)) { + unionProp = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new ModelV2(prop, enumProp, unionProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/models/package-info.java new file mode 100644 index 000000000..cae01127a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/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 Added. + * Test for the `@added` decorator. + * + */ +package com.versioning.added.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/package-info.java new file mode 100644 index 000000000..84e3d233a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/added/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 Added. + * Test for the `@added` decorator. + * + */ +package com.versioning.added; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/MadeOptionalAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/MadeOptionalAsyncClient.java new file mode 100644 index 000000000..ec7eca46c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/MadeOptionalAsyncClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.madeoptional; + +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 com.versioning.madeoptional.implementation.MadeOptionalClientImpl; +import com.versioning.madeoptional.models.TestModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous MadeOptionalClient type. + */ +@ServiceClient(builder = MadeOptionalClientBuilder.class, isAsync = true) +public final class MadeOptionalAsyncClient { + @Generated + private final MadeOptionalClientImpl serviceClient; + + /** + * Initializes an instance of MadeOptionalAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MadeOptionalAsyncClient(MadeOptionalClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The test operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
paramStringNoThe param parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> testWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.testWithResponseAsync(body, requestOptions); + } + + /** + * The test operation. + * + * @param body The body parameter. + * @param param The param 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono test(TestModel body, String param) { + // Generated convenience method for testWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (param != null) { + requestOptions.addQueryParam("param", param, false); + } + return testWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TestModel.class)); + } + + /** + * The test operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono test(TestModel body) { + // Generated convenience method for testWithResponse + RequestOptions requestOptions = new RequestOptions(); + return testWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TestModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/MadeOptionalClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/MadeOptionalClient.java new file mode 100644 index 000000000..87caefa6f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/MadeOptionalClient.java @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.madeoptional; + +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.versioning.madeoptional.implementation.MadeOptionalClientImpl; +import com.versioning.madeoptional.models.TestModel; + +/** + * Initializes a new instance of the synchronous MadeOptionalClient type. + */ +@ServiceClient(builder = MadeOptionalClientBuilder.class) +public final class MadeOptionalClient { + @Generated + private final MadeOptionalClientImpl serviceClient; + + /** + * Initializes an instance of MadeOptionalClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MadeOptionalClient(MadeOptionalClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The test operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
paramStringNoThe param parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response testWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.testWithResponse(body, requestOptions); + } + + /** + * The test operation. + * + * @param body The body parameter. + * @param param The param 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public TestModel test(TestModel body, String param) { + // Generated convenience method for testWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (param != null) { + requestOptions.addQueryParam("param", param, false); + } + return testWithResponse(BinaryData.fromObject(body), requestOptions).getValue().toObject(TestModel.class); + } + + /** + * The test operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public TestModel test(TestModel body) { + // Generated convenience method for testWithResponse + RequestOptions requestOptions = new RequestOptions(); + return testWithResponse(BinaryData.fromObject(body), requestOptions).getValue().toObject(TestModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/MadeOptionalClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/MadeOptionalClientBuilder.java new file mode 100644 index 000000000..d50e71934 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/MadeOptionalClientBuilder.java @@ -0,0 +1,326 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.madeoptional; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.versioning.madeoptional.implementation.MadeOptionalClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the MadeOptionalClient type. + */ +@ServiceClientBuilder(serviceClients = { MadeOptionalClient.class, MadeOptionalAsyncClient.class }) +public final class MadeOptionalClientBuilder 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("versioning-madeoptional.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the MadeOptionalClientBuilder. + */ + @Generated + public MadeOptionalClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MadeOptionalClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MadeOptionalClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MadeOptionalClientBuilder 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 MadeOptionalClientBuilder 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 MadeOptionalClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MadeOptionalClientBuilder 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 MadeOptionalClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public MadeOptionalClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'v1' or 'v2' in client. + */ + @Generated + private String version; + + /** + * Sets Need to be set as 'v1' or 'v2' in client. + * + * @param version the version value. + * @return the MadeOptionalClientBuilder. + */ + @Generated + public MadeOptionalClientBuilder version(String version) { + this.version = version; + return this; + } + + /* + * Service version + */ + @Generated + private MadeOptionalServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the MadeOptionalClientBuilder. + */ + @Generated + public MadeOptionalClientBuilder serviceVersion(MadeOptionalServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 MadeOptionalClientBuilder. + */ + @Generated + public MadeOptionalClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of MadeOptionalClientImpl with the provided parameters. + * + * @return an instance of MadeOptionalClientImpl. + */ + @Generated + private MadeOptionalClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + MadeOptionalServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : MadeOptionalServiceVersion.getLatest(); + MadeOptionalClientImpl client = new MadeOptionalClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, this.version, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(version, "'version' cannot be null."); + } + + @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 MadeOptionalAsyncClient class. + * + * @return an instance of MadeOptionalAsyncClient. + */ + @Generated + public MadeOptionalAsyncClient buildAsyncClient() { + return new MadeOptionalAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of MadeOptionalClient class. + * + * @return an instance of MadeOptionalClient. + */ + @Generated + public MadeOptionalClient buildClient() { + return new MadeOptionalClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(MadeOptionalClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/MadeOptionalServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/MadeOptionalServiceVersion.java new file mode 100644 index 000000000..7409d775c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/MadeOptionalServiceVersion.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.madeoptional; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of MadeOptionalClient. + */ +public enum MadeOptionalServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + MadeOptionalServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link MadeOptionalServiceVersion}. + */ + public static MadeOptionalServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/implementation/MadeOptionalClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/implementation/MadeOptionalClientImpl.java new file mode 100644 index 000000000..fc57f6064 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/implementation/MadeOptionalClientImpl.java @@ -0,0 +1,273 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.madeoptional.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 com.versioning.madeoptional.MadeOptionalServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the MadeOptionalClient type. + */ +public final class MadeOptionalClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MadeOptionalClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'v1' or 'v2' in client. + */ + private final String version; + + /** + * Gets Need to be set as 'v1' or 'v2' in client. + * + * @return the version value. + */ + public String getVersion() { + return this.version; + } + + /** + * Service version. + */ + private final MadeOptionalServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public MadeOptionalServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 MadeOptionalClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public MadeOptionalClientImpl(String endpoint, String version, MadeOptionalServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, version, serviceVersion); + } + + /** + * Initializes an instance of MadeOptionalClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public MadeOptionalClientImpl(HttpPipeline httpPipeline, String endpoint, String version, + MadeOptionalServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, version, serviceVersion); + } + + /** + * Initializes an instance of MadeOptionalClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public MadeOptionalClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + String version, MadeOptionalServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.version = version; + this.serviceVersion = serviceVersion; + this.service + = RestProxy.create(MadeOptionalClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for MadeOptionalClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}/versioning/made-optional/api-version:{version}") + @ServiceInterface(name = "MadeOptionalClient") + public interface MadeOptionalClientService { + @Post("/test") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> test(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/test") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response testSync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The test operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
paramStringNoThe param parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> testWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.test(this.getEndpoint(), this.getVersion(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The test operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
paramStringNoThe param parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Optional)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Optional)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response testWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.testSync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/implementation/package-info.java new file mode 100644 index 000000000..695458b21 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/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 MadeOptional. + * Test for the `@madeOptional` decorator. + * + */ +package com.versioning.madeoptional.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/models/TestModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/models/TestModel.java new file mode 100644 index 000000000..4ba85f38a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/models/TestModel.java @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.madeoptional.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 TestModel model. + */ +@Fluent +public final class TestModel implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final String prop; + + /* + * The changedProp property. + */ + @Generated + private String changedProp; + + /** + * Creates an instance of TestModel class. + * + * @param prop the prop value to set. + */ + @Generated + public TestModel(String prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public String getProp() { + return this.prop; + } + + /** + * Get the changedProp property: The changedProp property. + * + * @return the changedProp value. + */ + @Generated + public String getChangedProp() { + return this.changedProp; + } + + /** + * Set the changedProp property: The changedProp property. + * + * @param changedProp the changedProp value to set. + * @return the TestModel object itself. + */ + @Generated + public TestModel setChangedProp(String changedProp) { + this.changedProp = changedProp; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop); + jsonWriter.writeStringField("changedProp", this.changedProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TestModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TestModel 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 TestModel. + */ + @Generated + public static TestModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prop = null; + String changedProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getString(); + } else if ("changedProp".equals(fieldName)) { + changedProp = reader.getString(); + } else { + reader.skipChildren(); + } + } + TestModel deserializedTestModel = new TestModel(prop); + deserializedTestModel.changedProp = changedProp; + + return deserializedTestModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/models/package-info.java new file mode 100644 index 000000000..809398f86 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/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 MadeOptional. + * Test for the `@madeOptional` decorator. + * + */ +package com.versioning.madeoptional.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/package-info.java new file mode 100644 index 000000000..df438bc48 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/madeoptional/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 MadeOptional. + * Test for the `@madeOptional` decorator. + * + */ +package com.versioning.madeoptional; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/RemovedAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/RemovedAsyncClient.java new file mode 100644 index 000000000..d3f2a34e9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/RemovedAsyncClient.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.removed; + +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 com.versioning.removed.implementation.RemovedClientImpl; +import com.versioning.removed.models.ModelV2; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous RemovedClient type. + */ +@ServiceClient(builder = RemovedClientBuilder.class, isAsync = true) +public final class RemovedAsyncClient { + @Generated + private final RemovedClientImpl serviceClient; + + /** + * Initializes an instance of RemovedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RemovedAsyncClient(RemovedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The v2 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> v2WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.v2WithResponseAsync(body, requestOptions); + } + + /** + * The v2 operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono v2(ModelV2 body) { + // Generated convenience method for v2WithResponse + RequestOptions requestOptions = new RequestOptions(); + return v2WithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ModelV2.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/RemovedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/RemovedClient.java new file mode 100644 index 000000000..0591ab7c5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/RemovedClient.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.removed; + +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.versioning.removed.implementation.RemovedClientImpl; +import com.versioning.removed.models.ModelV2; + +/** + * Initializes a new instance of the synchronous RemovedClient type. + */ +@ServiceClient(builder = RemovedClientBuilder.class) +public final class RemovedClient { + @Generated + private final RemovedClientImpl serviceClient; + + /** + * Initializes an instance of RemovedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RemovedClient(RemovedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The v2 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response v2WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.v2WithResponse(body, requestOptions); + } + + /** + * The v2 operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ModelV2 v2(ModelV2 body) { + // Generated convenience method for v2WithResponse + RequestOptions requestOptions = new RequestOptions(); + return v2WithResponse(BinaryData.fromObject(body), requestOptions).getValue().toObject(ModelV2.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/RemovedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/RemovedClientBuilder.java new file mode 100644 index 000000000..1a910c584 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/RemovedClientBuilder.java @@ -0,0 +1,326 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.removed; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.versioning.removed.implementation.RemovedClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the RemovedClient type. + */ +@ServiceClientBuilder(serviceClients = { RemovedClient.class, RemovedAsyncClient.class }) +public final class RemovedClientBuilder 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("versioning-removed.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the RemovedClientBuilder. + */ + @Generated + public RemovedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RemovedClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RemovedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RemovedClientBuilder 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 RemovedClientBuilder 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 RemovedClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RemovedClientBuilder 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 RemovedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RemovedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'v1' or 'v2' in client. + */ + @Generated + private String version; + + /** + * Sets Need to be set as 'v1' or 'v2' in client. + * + * @param version the version value. + * @return the RemovedClientBuilder. + */ + @Generated + public RemovedClientBuilder version(String version) { + this.version = version; + return this; + } + + /* + * Service version + */ + @Generated + private RemovedServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the RemovedClientBuilder. + */ + @Generated + public RemovedClientBuilder serviceVersion(RemovedServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 RemovedClientBuilder. + */ + @Generated + public RemovedClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of RemovedClientImpl with the provided parameters. + * + * @return an instance of RemovedClientImpl. + */ + @Generated + private RemovedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + RemovedServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : RemovedServiceVersion.getLatest(); + RemovedClientImpl client = new RemovedClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, this.version, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(version, "'version' cannot be null."); + } + + @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 RemovedAsyncClient class. + * + * @return an instance of RemovedAsyncClient. + */ + @Generated + public RemovedAsyncClient buildAsyncClient() { + return new RemovedAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of RemovedClient class. + * + * @return an instance of RemovedClient. + */ + @Generated + public RemovedClient buildClient() { + return new RemovedClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(RemovedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/RemovedServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/RemovedServiceVersion.java new file mode 100644 index 000000000..4e2371c64 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/RemovedServiceVersion.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.removed; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of RemovedClient. + */ +public enum RemovedServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + RemovedServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link RemovedServiceVersion}. + */ + public static RemovedServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/implementation/RemovedClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/implementation/RemovedClientImpl.java new file mode 100644 index 000000000..74936454a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/implementation/RemovedClientImpl.java @@ -0,0 +1,261 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.removed.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 com.versioning.removed.RemovedServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the RemovedClient type. + */ +public final class RemovedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RemovedClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'v1' or 'v2' in client. + */ + private final String version; + + /** + * Gets Need to be set as 'v1' or 'v2' in client. + * + * @return the version value. + */ + public String getVersion() { + return this.version; + } + + /** + * Service version. + */ + private final RemovedServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public RemovedServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 RemovedClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public RemovedClientImpl(String endpoint, String version, RemovedServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, version, serviceVersion); + } + + /** + * Initializes an instance of RemovedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public RemovedClientImpl(HttpPipeline httpPipeline, String endpoint, String version, + RemovedServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, version, serviceVersion); + } + + /** + * Initializes an instance of RemovedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public RemovedClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + String version, RemovedServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.version = version; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(RemovedClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for RemovedClient to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}/versioning/removed/api-version:{version}") + @ServiceInterface(name = "RemovedClient") + public interface RemovedClientService { + @Post("/v2") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> v2(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/v2") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response v2Sync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The v2 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> v2WithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.v2(this.getEndpoint(), this.getVersion(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The v2 operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response v2WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.v2Sync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/implementation/package-info.java new file mode 100644 index 000000000..0209736a7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/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 Removed. + * Test for the `@removed` decorator. + * + */ +package com.versioning.removed.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/models/EnumV2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/models/EnumV2.java new file mode 100644 index 000000000..9a64c307a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/models/EnumV2.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.removed.models; + +/** + * Defines values for EnumV2. + */ +public enum EnumV2 { + /** + * Enum value enumMemberV2. + */ + ENUM_MEMBER_V2("enumMemberV2"); + + /** + * The actual serialized value for a EnumV2 instance. + */ + private final String value; + + EnumV2(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a EnumV2 instance. + * + * @param value the serialized value to parse. + * @return the parsed EnumV2 object, or null if unable to parse. + */ + public static EnumV2 fromString(String value) { + if (value == null) { + return null; + } + EnumV2[] items = EnumV2.values(); + for (EnumV2 item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/models/ModelV2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/models/ModelV2.java new file mode 100644 index 000000000..c6f8d63b9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/models/ModelV2.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.removed.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.BinaryData; +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 ModelV2 model. + */ +@Immutable +public final class ModelV2 implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final String prop; + + /* + * The enumProp property. + */ + @Generated + private final EnumV2 enumProp; + + /* + * The unionProp property. + */ + @Generated + private final BinaryData unionProp; + + /** + * Creates an instance of ModelV2 class. + * + * @param prop the prop value to set. + * @param enumProp the enumProp value to set. + * @param unionProp the unionProp value to set. + */ + @Generated + public ModelV2(String prop, EnumV2 enumProp, BinaryData unionProp) { + this.prop = prop; + this.enumProp = enumProp; + this.unionProp = unionProp; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public String getProp() { + return this.prop; + } + + /** + * Get the enumProp property: The enumProp property. + * + * @return the enumProp value. + */ + @Generated + public EnumV2 getEnumProp() { + return this.enumProp; + } + + /** + * Get the unionProp property: The unionProp property. + * + * @return the unionProp value. + */ + @Generated + public BinaryData getUnionProp() { + return this.unionProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop); + jsonWriter.writeStringField("enumProp", this.enumProp == null ? null : this.enumProp.toString()); + jsonWriter.writeUntypedField("unionProp", this.unionProp.toObject(Object.class)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelV2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelV2 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 ModelV2. + */ + @Generated + public static ModelV2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prop = null; + EnumV2 enumProp = null; + BinaryData unionProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getString(); + } else if ("enumProp".equals(fieldName)) { + enumProp = EnumV2.fromString(reader.getString()); + } else if ("unionProp".equals(fieldName)) { + unionProp = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new ModelV2(prop, enumProp, unionProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/models/package-info.java new file mode 100644 index 000000000..f18d2ac0a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/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 Removed. + * Test for the `@removed` decorator. + * + */ +package com.versioning.removed.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/package-info.java new file mode 100644 index 000000000..17be0dc9f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/removed/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 Removed. + * Test for the `@removed` decorator. + * + */ +package com.versioning.removed; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/NewInterfaceAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/NewInterfaceAsyncClient.java new file mode 100644 index 000000000..ba3799350 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/NewInterfaceAsyncClient.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.renamedfrom; + +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 com.versioning.renamedfrom.implementation.NewInterfacesImpl; +import com.versioning.renamedfrom.models.NewModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous RenamedFromClient type. + */ +@ServiceClient(builder = RenamedFromClientBuilder.class, isAsync = true) +public final class NewInterfaceAsyncClient { + @Generated + private final NewInterfacesImpl serviceClient; + + /** + * Initializes an instance of NewInterfaceAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NewInterfaceAsyncClient(NewInterfacesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The newOpInNewInterface operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> newOpInNewInterfaceWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.newOpInNewInterfaceWithResponseAsync(body, requestOptions); + } + + /** + * The newOpInNewInterface operation. + * + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono newOpInNewInterface(NewModel body) { + // Generated convenience method for newOpInNewInterfaceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return newOpInNewInterfaceWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(NewModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/NewInterfaceClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/NewInterfaceClient.java new file mode 100644 index 000000000..169d5be3a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/NewInterfaceClient.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.renamedfrom; + +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.versioning.renamedfrom.implementation.NewInterfacesImpl; +import com.versioning.renamedfrom.models.NewModel; + +/** + * Initializes a new instance of the synchronous RenamedFromClient type. + */ +@ServiceClient(builder = RenamedFromClientBuilder.class) +public final class NewInterfaceClient { + @Generated + private final NewInterfacesImpl serviceClient; + + /** + * Initializes an instance of NewInterfaceClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + NewInterfaceClient(NewInterfacesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The newOpInNewInterface operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response newOpInNewInterfaceWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.newOpInNewInterfaceWithResponse(body, requestOptions); + } + + /** + * The newOpInNewInterface operation. + * + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public NewModel newOpInNewInterface(NewModel body) { + // Generated convenience method for newOpInNewInterfaceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return newOpInNewInterfaceWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(NewModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/RenamedFromAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/RenamedFromAsyncClient.java new file mode 100644 index 000000000..b919a7c0c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/RenamedFromAsyncClient.java @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.renamedfrom; + +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 com.versioning.renamedfrom.implementation.RenamedFromClientImpl; +import com.versioning.renamedfrom.models.NewModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous RenamedFromClient type. + */ +@ServiceClient(builder = RenamedFromClientBuilder.class, isAsync = true) +public final class RenamedFromAsyncClient { + @Generated + private final RenamedFromClientImpl serviceClient; + + /** + * Initializes an instance of RenamedFromAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RenamedFromAsyncClient(RenamedFromClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The newOp operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param newQuery The newQuery parameter. + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> newOpWithResponse(String newQuery, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.newOpWithResponseAsync(newQuery, body, requestOptions); + } + + /** + * The newOp operation. + * + * @param newQuery The newQuery parameter. + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono newOp(String newQuery, NewModel body) { + // Generated convenience method for newOpWithResponse + RequestOptions requestOptions = new RequestOptions(); + return newOpWithResponse(newQuery, BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(NewModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/RenamedFromClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/RenamedFromClient.java new file mode 100644 index 000000000..5d17e3855 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/RenamedFromClient.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.renamedfrom; + +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.versioning.renamedfrom.implementation.RenamedFromClientImpl; +import com.versioning.renamedfrom.models.NewModel; + +/** + * Initializes a new instance of the synchronous RenamedFromClient type. + */ +@ServiceClient(builder = RenamedFromClientBuilder.class) +public final class RenamedFromClient { + @Generated + private final RenamedFromClientImpl serviceClient; + + /** + * Initializes an instance of RenamedFromClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RenamedFromClient(RenamedFromClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The newOp operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param newQuery The newQuery parameter. + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response newOpWithResponse(String newQuery, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.newOpWithResponse(newQuery, body, requestOptions); + } + + /** + * The newOp operation. + * + * @param newQuery The newQuery parameter. + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public NewModel newOp(String newQuery, NewModel body) { + // Generated convenience method for newOpWithResponse + RequestOptions requestOptions = new RequestOptions(); + return newOpWithResponse(newQuery, BinaryData.fromObject(body), requestOptions).getValue() + .toObject(NewModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/RenamedFromClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/RenamedFromClientBuilder.java new file mode 100644 index 000000000..b9cb2c5c9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/RenamedFromClientBuilder.java @@ -0,0 +1,351 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.renamedfrom; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.versioning.renamedfrom.implementation.RenamedFromClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the RenamedFromClient type. + */ +@ServiceClientBuilder( + serviceClients = { + RenamedFromClient.class, + NewInterfaceClient.class, + RenamedFromAsyncClient.class, + NewInterfaceAsyncClient.class }) +public final class RenamedFromClientBuilder 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("versioning-renamedfrom.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the RenamedFromClientBuilder. + */ + @Generated + public RenamedFromClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RenamedFromClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RenamedFromClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RenamedFromClientBuilder 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 RenamedFromClientBuilder 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 RenamedFromClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RenamedFromClientBuilder 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 RenamedFromClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public RenamedFromClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'v1' or 'v2' in client. + */ + @Generated + private String version; + + /** + * Sets Need to be set as 'v1' or 'v2' in client. + * + * @param version the version value. + * @return the RenamedFromClientBuilder. + */ + @Generated + public RenamedFromClientBuilder version(String version) { + this.version = version; + return this; + } + + /* + * Service version + */ + @Generated + private RenamedFromServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the RenamedFromClientBuilder. + */ + @Generated + public RenamedFromClientBuilder serviceVersion(RenamedFromServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 RenamedFromClientBuilder. + */ + @Generated + public RenamedFromClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of RenamedFromClientImpl with the provided parameters. + * + * @return an instance of RenamedFromClientImpl. + */ + @Generated + private RenamedFromClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + RenamedFromServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : RenamedFromServiceVersion.getLatest(); + RenamedFromClientImpl client = new RenamedFromClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, this.version, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(version, "'version' cannot be null."); + } + + @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 RenamedFromAsyncClient class. + * + * @return an instance of RenamedFromAsyncClient. + */ + @Generated + public RenamedFromAsyncClient buildAsyncClient() { + return new RenamedFromAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of NewInterfaceAsyncClient class. + * + * @return an instance of NewInterfaceAsyncClient. + */ + @Generated + public NewInterfaceAsyncClient buildNewInterfaceAsyncClient() { + return new NewInterfaceAsyncClient(buildInnerClient().getNewInterfaces()); + } + + /** + * Builds an instance of RenamedFromClient class. + * + * @return an instance of RenamedFromClient. + */ + @Generated + public RenamedFromClient buildClient() { + return new RenamedFromClient(buildInnerClient()); + } + + /** + * Builds an instance of NewInterfaceClient class. + * + * @return an instance of NewInterfaceClient. + */ + @Generated + public NewInterfaceClient buildNewInterfaceClient() { + return new NewInterfaceClient(buildInnerClient().getNewInterfaces()); + } + + private static final ClientLogger LOGGER = new ClientLogger(RenamedFromClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/RenamedFromServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/RenamedFromServiceVersion.java new file mode 100644 index 000000000..9acf99343 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/RenamedFromServiceVersion.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.renamedfrom; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of RenamedFromClient. + */ +public enum RenamedFromServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + RenamedFromServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link RenamedFromServiceVersion}. + */ + public static RenamedFromServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/implementation/NewInterfacesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/implementation/NewInterfacesImpl.java new file mode 100644 index 000000000..4f6dd02c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/implementation/NewInterfacesImpl.java @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.renamedfrom.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.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.versioning.renamedfrom.RenamedFromServiceVersion; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in NewInterfaces. + */ +public final class NewInterfacesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NewInterfacesService service; + + /** + * The service client containing this operation class. + */ + private final RenamedFromClientImpl client; + + /** + * Initializes an instance of NewInterfacesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NewInterfacesImpl(RenamedFromClientImpl client) { + this.service + = RestProxy.create(NewInterfacesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public RenamedFromServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for RenamedFromClientNewInterfaces to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}/versioning/renamed-from/api-version:{version}") + @ServiceInterface(name = "RenamedFromClientNew") + public interface NewInterfacesService { + @Post("/interface/test") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> newOpInNewInterface(@HostParam("endpoint") String endpoint, + @HostParam("version") String version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/interface/test") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response newOpInNewInterfaceSync(@HostParam("endpoint") String endpoint, + @HostParam("version") String version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The newOpInNewInterface operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> newOpInNewInterfaceWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.newOpInNewInterface(this.client.getEndpoint(), + this.client.getVersion(), contentType, accept, body, requestOptions, context)); + } + + /** + * The newOpInNewInterface operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response newOpInNewInterfaceWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.newOpInNewInterfaceSync(this.client.getEndpoint(), this.client.getVersion(), contentType, accept, + body, requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/implementation/RenamedFromClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/implementation/RenamedFromClientImpl.java new file mode 100644 index 000000000..4b3e777ef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/implementation/RenamedFromClientImpl.java @@ -0,0 +1,283 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.renamedfrom.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.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.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 com.versioning.renamedfrom.RenamedFromServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the RenamedFromClient type. + */ +public final class RenamedFromClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RenamedFromClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'v1' or 'v2' in client. + */ + private final String version; + + /** + * Gets Need to be set as 'v1' or 'v2' in client. + * + * @return the version value. + */ + public String getVersion() { + return this.version; + } + + /** + * Service version. + */ + private final RenamedFromServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public RenamedFromServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * The NewInterfacesImpl object to access its operations. + */ + private final NewInterfacesImpl newInterfaces; + + /** + * Gets the NewInterfacesImpl object to access its operations. + * + * @return the NewInterfacesImpl object. + */ + public NewInterfacesImpl getNewInterfaces() { + return this.newInterfaces; + } + + /** + * Initializes an instance of RenamedFromClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public RenamedFromClientImpl(String endpoint, String version, RenamedFromServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, version, serviceVersion); + } + + /** + * Initializes an instance of RenamedFromClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public RenamedFromClientImpl(HttpPipeline httpPipeline, String endpoint, String version, + RenamedFromServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, version, serviceVersion); + } + + /** + * Initializes an instance of RenamedFromClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public RenamedFromClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + String version, RenamedFromServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.version = version; + this.serviceVersion = serviceVersion; + this.newInterfaces = new NewInterfacesImpl(this); + this.service = RestProxy.create(RenamedFromClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for RenamedFromClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}/versioning/renamed-from/api-version:{version}") + @ServiceInterface(name = "RenamedFromClient") + public interface RenamedFromClientService { + @Post("/test") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> newOp(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @QueryParam("newQuery") String newQuery, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/test") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response newOpSync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @QueryParam("newQuery") String newQuery, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The newOp operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param newQuery The newQuery parameter. + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> newOpWithResponseAsync(String newQuery, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.newOp(this.getEndpoint(), this.getVersion(), newQuery, + contentType, accept, body, requestOptions, context)); + } + + /** + * The newOp operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+ * + * @param newQuery The newQuery parameter. + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response newOpWithResponse(String newQuery, BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.newOpSync(this.getEndpoint(), this.getVersion(), newQuery, contentType, accept, body, + requestOptions, Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/implementation/package-info.java new file mode 100644 index 000000000..dbeb789cb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/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 RenamedFrom. + * Test for the `@renamedFrom` decorator. + * + */ +package com.versioning.renamedfrom.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/models/NewEnum.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/models/NewEnum.java new file mode 100644 index 000000000..7206ee258 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/models/NewEnum.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.renamedfrom.models; + +/** + * Defines values for NewEnum. + */ +public enum NewEnum { + /** + * Enum value newEnumMember. + */ + NEW_ENUM_MEMBER("newEnumMember"); + + /** + * The actual serialized value for a NewEnum instance. + */ + private final String value; + + NewEnum(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a NewEnum instance. + * + * @param value the serialized value to parse. + * @return the parsed NewEnum object, or null if unable to parse. + */ + public static NewEnum fromString(String value) { + if (value == null) { + return null; + } + NewEnum[] items = NewEnum.values(); + for (NewEnum item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/models/NewModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/models/NewModel.java new file mode 100644 index 000000000..5d53670c3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/models/NewModel.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.renamedfrom.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.BinaryData; +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 NewModel model. + */ +@Immutable +public final class NewModel implements JsonSerializable { + /* + * The newProp property. + */ + @Generated + private final String newProp; + + /* + * The enumProp property. + */ + @Generated + private final NewEnum enumProp; + + /* + * The unionProp property. + */ + @Generated + private final BinaryData unionProp; + + /** + * Creates an instance of NewModel class. + * + * @param newProp the newProp value to set. + * @param enumProp the enumProp value to set. + * @param unionProp the unionProp value to set. + */ + @Generated + public NewModel(String newProp, NewEnum enumProp, BinaryData unionProp) { + this.newProp = newProp; + this.enumProp = enumProp; + this.unionProp = unionProp; + } + + /** + * Get the newProp property: The newProp property. + * + * @return the newProp value. + */ + @Generated + public String getNewProp() { + return this.newProp; + } + + /** + * Get the enumProp property: The enumProp property. + * + * @return the enumProp value. + */ + @Generated + public NewEnum getEnumProp() { + return this.enumProp; + } + + /** + * Get the unionProp property: The unionProp property. + * + * @return the unionProp value. + */ + @Generated + public BinaryData getUnionProp() { + return this.unionProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("newProp", this.newProp); + jsonWriter.writeStringField("enumProp", this.enumProp == null ? null : this.enumProp.toString()); + jsonWriter.writeUntypedField("unionProp", this.unionProp.toObject(Object.class)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NewModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NewModel 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 NewModel. + */ + @Generated + public static NewModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String newProp = null; + NewEnum enumProp = null; + BinaryData unionProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("newProp".equals(fieldName)) { + newProp = reader.getString(); + } else if ("enumProp".equals(fieldName)) { + enumProp = NewEnum.fromString(reader.getString()); + } else if ("unionProp".equals(fieldName)) { + unionProp = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new NewModel(newProp, enumProp, unionProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/models/package-info.java new file mode 100644 index 000000000..4744b1fbb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/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 RenamedFrom. + * Test for the `@renamedFrom` decorator. + * + */ +package com.versioning.renamedfrom.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/package-info.java new file mode 100644 index 000000000..16547cf94 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/renamedfrom/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 RenamedFrom. + * Test for the `@renamedFrom` decorator. + * + */ +package com.versioning.renamedfrom; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/ReturnTypeChangedFromAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/ReturnTypeChangedFromAsyncClient.java new file mode 100644 index 000000000..b108e10f5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/ReturnTypeChangedFromAsyncClient.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 com.versioning.returntypechangedfrom; + +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 com.versioning.returntypechangedfrom.implementation.ReturnTypeChangedFromClientImpl; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous ReturnTypeChangedFromClient type. + */ +@ServiceClient(builder = ReturnTypeChangedFromClientBuilder.class, isAsync = true) +public final class ReturnTypeChangedFromAsyncClient { + @Generated + private final ReturnTypeChangedFromClientImpl serviceClient; + + /** + * Initializes an instance of ReturnTypeChangedFromAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ReturnTypeChangedFromAsyncClient(ReturnTypeChangedFromClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The test operation. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param body The body 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> testWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.testWithResponseAsync(body, requestOptions); + } + + /** + * The test operation. + * + * @param body The body 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 sequence of textual characters on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono test(String body) { + // Generated convenience method for testWithResponse + RequestOptions requestOptions = new RequestOptions(); + return testWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(String.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/ReturnTypeChangedFromClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/ReturnTypeChangedFromClient.java new file mode 100644 index 000000000..25d54923f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/ReturnTypeChangedFromClient.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 com.versioning.returntypechangedfrom; + +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.versioning.returntypechangedfrom.implementation.ReturnTypeChangedFromClientImpl; + +/** + * Initializes a new instance of the synchronous ReturnTypeChangedFromClient type. + */ +@ServiceClient(builder = ReturnTypeChangedFromClientBuilder.class) +public final class ReturnTypeChangedFromClient { + @Generated + private final ReturnTypeChangedFromClientImpl serviceClient; + + /** + * Initializes an instance of ReturnTypeChangedFromClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ReturnTypeChangedFromClient(ReturnTypeChangedFromClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The test operation. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param body The body 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 a sequence of textual characters along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response testWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.testWithResponse(body, requestOptions); + } + + /** + * The test operation. + * + * @param body The body 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 sequence of textual characters. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public String test(String body) { + // Generated convenience method for testWithResponse + RequestOptions requestOptions = new RequestOptions(); + return testWithResponse(BinaryData.fromObject(body), requestOptions).getValue().toObject(String.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/ReturnTypeChangedFromClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/ReturnTypeChangedFromClientBuilder.java new file mode 100644 index 000000000..b1e30111d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/ReturnTypeChangedFromClientBuilder.java @@ -0,0 +1,327 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.returntypechangedfrom; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.versioning.returntypechangedfrom.implementation.ReturnTypeChangedFromClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ReturnTypeChangedFromClient type. + */ +@ServiceClientBuilder(serviceClients = { ReturnTypeChangedFromClient.class, ReturnTypeChangedFromAsyncClient.class }) +public final class ReturnTypeChangedFromClientBuilder 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("versioning-returntypechangedfrom.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the ReturnTypeChangedFromClientBuilder. + */ + @Generated + public ReturnTypeChangedFromClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ReturnTypeChangedFromClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ReturnTypeChangedFromClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ReturnTypeChangedFromClientBuilder 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 ReturnTypeChangedFromClientBuilder 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 ReturnTypeChangedFromClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ReturnTypeChangedFromClientBuilder 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 ReturnTypeChangedFromClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public ReturnTypeChangedFromClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'v1' or 'v2' in client. + */ + @Generated + private String version; + + /** + * Sets Need to be set as 'v1' or 'v2' in client. + * + * @param version the version value. + * @return the ReturnTypeChangedFromClientBuilder. + */ + @Generated + public ReturnTypeChangedFromClientBuilder version(String version) { + this.version = version; + return this; + } + + /* + * Service version + */ + @Generated + private ReturnTypeChangedFromServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the ReturnTypeChangedFromClientBuilder. + */ + @Generated + public ReturnTypeChangedFromClientBuilder serviceVersion(ReturnTypeChangedFromServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 ReturnTypeChangedFromClientBuilder. + */ + @Generated + public ReturnTypeChangedFromClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of ReturnTypeChangedFromClientImpl with the provided parameters. + * + * @return an instance of ReturnTypeChangedFromClientImpl. + */ + @Generated + private ReturnTypeChangedFromClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ReturnTypeChangedFromServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ReturnTypeChangedFromServiceVersion.getLatest(); + ReturnTypeChangedFromClientImpl client = new ReturnTypeChangedFromClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, this.version, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(version, "'version' cannot be null."); + } + + @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 ReturnTypeChangedFromAsyncClient class. + * + * @return an instance of ReturnTypeChangedFromAsyncClient. + */ + @Generated + public ReturnTypeChangedFromAsyncClient buildAsyncClient() { + return new ReturnTypeChangedFromAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ReturnTypeChangedFromClient class. + * + * @return an instance of ReturnTypeChangedFromClient. + */ + @Generated + public ReturnTypeChangedFromClient buildClient() { + return new ReturnTypeChangedFromClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ReturnTypeChangedFromClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/ReturnTypeChangedFromServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/ReturnTypeChangedFromServiceVersion.java new file mode 100644 index 000000000..27650ab41 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/ReturnTypeChangedFromServiceVersion.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.returntypechangedfrom; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of ReturnTypeChangedFromClient. + */ +public enum ReturnTypeChangedFromServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + ReturnTypeChangedFromServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link ReturnTypeChangedFromServiceVersion}. + */ + public static ReturnTypeChangedFromServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/implementation/ReturnTypeChangedFromClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/implementation/ReturnTypeChangedFromClientImpl.java new file mode 100644 index 000000000..ac32c99f2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/implementation/ReturnTypeChangedFromClientImpl.java @@ -0,0 +1,248 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.returntypechangedfrom.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 com.versioning.returntypechangedfrom.ReturnTypeChangedFromServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the ReturnTypeChangedFromClient type. + */ +public final class ReturnTypeChangedFromClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ReturnTypeChangedFromClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'v1' or 'v2' in client. + */ + private final String version; + + /** + * Gets Need to be set as 'v1' or 'v2' in client. + * + * @return the version value. + */ + public String getVersion() { + return this.version; + } + + /** + * Service version. + */ + private final ReturnTypeChangedFromServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ReturnTypeChangedFromServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 ReturnTypeChangedFromClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public ReturnTypeChangedFromClientImpl(String endpoint, String version, + ReturnTypeChangedFromServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, version, serviceVersion); + } + + /** + * Initializes an instance of ReturnTypeChangedFromClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public ReturnTypeChangedFromClientImpl(HttpPipeline httpPipeline, String endpoint, String version, + ReturnTypeChangedFromServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, version, serviceVersion); + } + + /** + * Initializes an instance of ReturnTypeChangedFromClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public ReturnTypeChangedFromClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String version, ReturnTypeChangedFromServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.version = version; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(ReturnTypeChangedFromClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for ReturnTypeChangedFromClient to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}/versioning/return-type-changed-from/api-version:{version}") + @ServiceInterface(name = "ReturnTypeChangedFro") + public interface ReturnTypeChangedFromClientService { + @Post("/test") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> test(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/test") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response testSync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The test operation. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param body The body 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 a sequence of textual characters along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> testWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.test(this.getEndpoint(), this.getVersion(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The test operation. + *

Request Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * String
+     * }
+ * + * @param body The body 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 a sequence of textual characters along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response testWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.testSync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/implementation/package-info.java new file mode 100644 index 000000000..cf2193b23 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/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 ReturnTypeChangedFrom. + * Test for the `@returnTypeChangedFrom` decorator. + * + */ +package com.versioning.returntypechangedfrom.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/package-info.java new file mode 100644 index 000000000..c52b2190a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/returntypechangedfrom/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 ReturnTypeChangedFrom. + * Test for the `@returnTypeChangedFrom` decorator. + * + */ +package com.versioning.returntypechangedfrom; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/TypeChangedFromAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/TypeChangedFromAsyncClient.java new file mode 100644 index 000000000..254199b74 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/TypeChangedFromAsyncClient.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.typechangedfrom; + +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 com.versioning.typechangedfrom.implementation.TypeChangedFromClientImpl; +import com.versioning.typechangedfrom.models.TestModel; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous TypeChangedFromClient type. + */ +@ServiceClient(builder = TypeChangedFromClientBuilder.class, isAsync = true) +public final class TypeChangedFromAsyncClient { + @Generated + private final TypeChangedFromClientImpl serviceClient; + + /** + * Initializes an instance of TypeChangedFromAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + TypeChangedFromAsyncClient(TypeChangedFromClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The test operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Required)
+     * }
+     * }
+ * + * @param param The param parameter. + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> testWithResponse(String param, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.testWithResponseAsync(param, body, requestOptions); + } + + /** + * The test operation. + * + * @param param The param parameter. + * @param body The body 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono test(String param, TestModel body) { + // Generated convenience method for testWithResponse + RequestOptions requestOptions = new RequestOptions(); + return testWithResponse(param, BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TestModel.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/TypeChangedFromClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/TypeChangedFromClient.java new file mode 100644 index 000000000..2f85c234f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/TypeChangedFromClient.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.typechangedfrom; + +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.versioning.typechangedfrom.implementation.TypeChangedFromClientImpl; +import com.versioning.typechangedfrom.models.TestModel; + +/** + * Initializes a new instance of the synchronous TypeChangedFromClient type. + */ +@ServiceClient(builder = TypeChangedFromClientBuilder.class) +public final class TypeChangedFromClient { + @Generated + private final TypeChangedFromClientImpl serviceClient; + + /** + * Initializes an instance of TypeChangedFromClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + TypeChangedFromClient(TypeChangedFromClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The test operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Required)
+     * }
+     * }
+ * + * @param param The param parameter. + * @param body The body 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 response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response testWithResponse(String param, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.testWithResponse(param, body, requestOptions); + } + + /** + * The test operation. + * + * @param param The param parameter. + * @param body The body 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public TestModel test(String param, TestModel body) { + // Generated convenience method for testWithResponse + RequestOptions requestOptions = new RequestOptions(); + return testWithResponse(param, BinaryData.fromObject(body), requestOptions).getValue() + .toObject(TestModel.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/TypeChangedFromClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/TypeChangedFromClientBuilder.java new file mode 100644 index 000000000..fbd40fc38 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/TypeChangedFromClientBuilder.java @@ -0,0 +1,327 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.typechangedfrom; + +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.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +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 com.versioning.typechangedfrom.implementation.TypeChangedFromClientImpl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the TypeChangedFromClient type. + */ +@ServiceClientBuilder(serviceClients = { TypeChangedFromClient.class, TypeChangedFromAsyncClient.class }) +public final class TypeChangedFromClientBuilder 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("versioning-typechangedfrom.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the TypeChangedFromClientBuilder. + */ + @Generated + public TypeChangedFromClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TypeChangedFromClientBuilder 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 HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TypeChangedFromClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TypeChangedFromClientBuilder 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 TypeChangedFromClientBuilder 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 TypeChangedFromClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TypeChangedFromClientBuilder 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 TypeChangedFromClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public TypeChangedFromClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'v1' or 'v2' in client. + */ + @Generated + private String version; + + /** + * Sets Need to be set as 'v1' or 'v2' in client. + * + * @param version the version value. + * @return the TypeChangedFromClientBuilder. + */ + @Generated + public TypeChangedFromClientBuilder version(String version) { + this.version = version; + return this; + } + + /* + * Service version + */ + @Generated + private TypeChangedFromServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the TypeChangedFromClientBuilder. + */ + @Generated + public TypeChangedFromClientBuilder serviceVersion(TypeChangedFromServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + 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 TypeChangedFromClientBuilder. + */ + @Generated + public TypeChangedFromClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of TypeChangedFromClientImpl with the provided parameters. + * + * @return an instance of TypeChangedFromClientImpl. + */ + @Generated + private TypeChangedFromClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + TypeChangedFromServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : TypeChangedFromServiceVersion.getLatest(); + TypeChangedFromClientImpl client = new TypeChangedFromClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, this.version, localServiceVersion); + 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. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(version, "'version' cannot be null."); + } + + @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 TypeChangedFromAsyncClient class. + * + * @return an instance of TypeChangedFromAsyncClient. + */ + @Generated + public TypeChangedFromAsyncClient buildAsyncClient() { + return new TypeChangedFromAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of TypeChangedFromClient class. + * + * @return an instance of TypeChangedFromClient. + */ + @Generated + public TypeChangedFromClient buildClient() { + return new TypeChangedFromClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(TypeChangedFromClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/TypeChangedFromServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/TypeChangedFromServiceVersion.java new file mode 100644 index 000000000..be796248b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/TypeChangedFromServiceVersion.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.typechangedfrom; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of TypeChangedFromClient. + */ +public enum TypeChangedFromServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + TypeChangedFromServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link TypeChangedFromServiceVersion}. + */ + public static TypeChangedFromServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/implementation/TypeChangedFromClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/implementation/TypeChangedFromClientImpl.java new file mode 100644 index 000000000..76874be3a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/implementation/TypeChangedFromClientImpl.java @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.typechangedfrom.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.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.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 com.versioning.typechangedfrom.TypeChangedFromServiceVersion; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the TypeChangedFromClient type. + */ +public final class TypeChangedFromClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final TypeChangedFromClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'v1' or 'v2' in client. + */ + private final String version; + + /** + * Gets Need to be set as 'v1' or 'v2' in client. + * + * @return the version value. + */ + public String getVersion() { + return this.version; + } + + /** + * Service version. + */ + private final TypeChangedFromServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public TypeChangedFromServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 TypeChangedFromClient client. + * + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public TypeChangedFromClientImpl(String endpoint, String version, TypeChangedFromServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, version, serviceVersion); + } + + /** + * Initializes an instance of TypeChangedFromClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public TypeChangedFromClientImpl(HttpPipeline httpPipeline, String endpoint, String version, + TypeChangedFromServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, version, serviceVersion); + } + + /** + * Initializes an instance of TypeChangedFromClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public TypeChangedFromClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + String version, TypeChangedFromServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.version = version; + this.serviceVersion = serviceVersion; + this.service + = RestProxy.create(TypeChangedFromClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for TypeChangedFromClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}/versioning/type-changed-from/api-version:{version}") + @ServiceInterface(name = "TypeChangedFromClien") + public interface TypeChangedFromClientService { + @Post("/test") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> test(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @QueryParam("param") String param, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + + @Post("/test") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response testSync(@HostParam("endpoint") String endpoint, @HostParam("version") String version, + @QueryParam("param") String param, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The test operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Required)
+     * }
+     * }
+ * + * @param param The param parameter. + * @param body The body 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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> testWithResponseAsync(String param, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.test(this.getEndpoint(), this.getVersion(), param, contentType, + accept, body, requestOptions, context)); + } + + /** + * The test operation. + *

Request Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Required)
+     * }
+     * }
+ * + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Required)
+     * }
+     * }
+ * + * @param param The param parameter. + * @param body The body 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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response testWithResponse(String param, BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.testSync(this.getEndpoint(), this.getVersion(), param, contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/implementation/package-info.java new file mode 100644 index 000000000..f90beba11 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/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 TypeChangedFrom. + * Test for the `@typeChangedFrom` decorator. + * + */ +package com.versioning.typechangedfrom.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/models/TestModel.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/models/TestModel.java new file mode 100644 index 000000000..4f3e8f7c9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/models/TestModel.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.typechangedfrom.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; + +/** + * The TestModel model. + */ +@Immutable +public final class TestModel implements JsonSerializable { + /* + * The prop property. + */ + @Generated + private final String prop; + + /* + * The changedProp property. + */ + @Generated + private final String changedProp; + + /** + * Creates an instance of TestModel class. + * + * @param prop the prop value to set. + * @param changedProp the changedProp value to set. + */ + @Generated + public TestModel(String prop, String changedProp) { + this.prop = prop; + this.changedProp = changedProp; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Generated + public String getProp() { + return this.prop; + } + + /** + * Get the changedProp property: The changedProp property. + * + * @return the changedProp value. + */ + @Generated + public String getChangedProp() { + return this.changedProp; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop); + jsonWriter.writeStringField("changedProp", this.changedProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TestModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TestModel 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 TestModel. + */ + @Generated + public static TestModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prop = null; + String changedProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getString(); + } else if ("changedProp".equals(fieldName)) { + changedProp = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new TestModel(prop, changedProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/models/package-info.java new file mode 100644 index 000000000..968a826ed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/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 TypeChangedFrom. + * Test for the `@typeChangedFrom` decorator. + * + */ +package com.versioning.typechangedfrom.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/package-info.java new file mode 100644 index 000000000..b457b2d19 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/versioning/typechangedfrom/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 TypeChangedFrom. + * Test for the `@typeChangedFrom` decorator. + * + */ +package com.versioning.typechangedfrom; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-clientgenerator-core-access_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-clientgenerator-core-access_apiview_properties.json new file mode 100644 index 000000000..16bf4d221 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-clientgenerator-core-access_apiview_properties.json @@ -0,0 +1,61 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com._specs_.azure.clientgenerator.core.access.AccessClientBuilder": "_Specs_.Azure.ClientGenerator.Core.Access", + "com._specs_.azure.clientgenerator.core.access.InternalOperationAsyncClient": "null", + "com._specs_.azure.clientgenerator.core.access.InternalOperationAsyncClient.internalDecoratorInInternal": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.internalDecoratorInInternal", + "com._specs_.azure.clientgenerator.core.access.InternalOperationAsyncClient.internalDecoratorInInternalWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.internalDecoratorInInternal", + "com._specs_.azure.clientgenerator.core.access.InternalOperationAsyncClient.noDecoratorInInternal": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.noDecoratorInInternal", + "com._specs_.azure.clientgenerator.core.access.InternalOperationAsyncClient.noDecoratorInInternalWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.noDecoratorInInternal", + "com._specs_.azure.clientgenerator.core.access.InternalOperationAsyncClient.publicDecoratorInInternal": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.publicDecoratorInInternal", + "com._specs_.azure.clientgenerator.core.access.InternalOperationAsyncClient.publicDecoratorInInternalWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.publicDecoratorInInternal", + "com._specs_.azure.clientgenerator.core.access.InternalOperationClient": "null", + "com._specs_.azure.clientgenerator.core.access.InternalOperationClient.internalDecoratorInInternal": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.internalDecoratorInInternal", + "com._specs_.azure.clientgenerator.core.access.InternalOperationClient.internalDecoratorInInternalWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.internalDecoratorInInternal", + "com._specs_.azure.clientgenerator.core.access.InternalOperationClient.noDecoratorInInternal": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.noDecoratorInInternal", + "com._specs_.azure.clientgenerator.core.access.InternalOperationClient.noDecoratorInInternalWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.noDecoratorInInternal", + "com._specs_.azure.clientgenerator.core.access.InternalOperationClient.publicDecoratorInInternal": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.publicDecoratorInInternal", + "com._specs_.azure.clientgenerator.core.access.InternalOperationClient.publicDecoratorInInternalWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.publicDecoratorInInternal", + "com._specs_.azure.clientgenerator.core.access.PublicOperationAsyncClient": "null", + "com._specs_.azure.clientgenerator.core.access.PublicOperationAsyncClient.noDecoratorInPublic": "_Specs_.Azure.ClientGenerator.Core.Access.PublicOperation.noDecoratorInPublic", + "com._specs_.azure.clientgenerator.core.access.PublicOperationAsyncClient.noDecoratorInPublicWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.PublicOperation.noDecoratorInPublic", + "com._specs_.azure.clientgenerator.core.access.PublicOperationAsyncClient.publicDecoratorInPublic": "_Specs_.Azure.ClientGenerator.Core.Access.PublicOperation.publicDecoratorInPublic", + "com._specs_.azure.clientgenerator.core.access.PublicOperationAsyncClient.publicDecoratorInPublicWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.PublicOperation.publicDecoratorInPublic", + "com._specs_.azure.clientgenerator.core.access.PublicOperationClient": "null", + "com._specs_.azure.clientgenerator.core.access.PublicOperationClient.noDecoratorInPublic": "_Specs_.Azure.ClientGenerator.Core.Access.PublicOperation.noDecoratorInPublic", + "com._specs_.azure.clientgenerator.core.access.PublicOperationClient.noDecoratorInPublicWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.PublicOperation.noDecoratorInPublic", + "com._specs_.azure.clientgenerator.core.access.PublicOperationClient.publicDecoratorInPublic": "_Specs_.Azure.ClientGenerator.Core.Access.PublicOperation.publicDecoratorInPublic", + "com._specs_.azure.clientgenerator.core.access.PublicOperationClient.publicDecoratorInPublicWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.PublicOperation.publicDecoratorInPublic", + "com._specs_.azure.clientgenerator.core.access.RelativeModelInOperationAsyncClient": "null", + "com._specs_.azure.clientgenerator.core.access.RelativeModelInOperationAsyncClient.discriminator": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.discriminator", + "com._specs_.azure.clientgenerator.core.access.RelativeModelInOperationAsyncClient.discriminatorWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.discriminator", + "com._specs_.azure.clientgenerator.core.access.RelativeModelInOperationAsyncClient.operation": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.operation", + "com._specs_.azure.clientgenerator.core.access.RelativeModelInOperationAsyncClient.operationWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.operation", + "com._specs_.azure.clientgenerator.core.access.RelativeModelInOperationClient": "null", + "com._specs_.azure.clientgenerator.core.access.RelativeModelInOperationClient.discriminator": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.discriminator", + "com._specs_.azure.clientgenerator.core.access.RelativeModelInOperationClient.discriminatorWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.discriminator", + "com._specs_.azure.clientgenerator.core.access.RelativeModelInOperationClient.operation": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.operation", + "com._specs_.azure.clientgenerator.core.access.RelativeModelInOperationClient.operationWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.operation", + "com._specs_.azure.clientgenerator.core.access.SharedModelInOperationAsyncClient": "null", + "com._specs_.azure.clientgenerator.core.access.SharedModelInOperationAsyncClient.internal": "_Specs_.Azure.ClientGenerator.Core.Access.SharedModelInOperation.internal", + "com._specs_.azure.clientgenerator.core.access.SharedModelInOperationAsyncClient.internalWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.SharedModelInOperation.internal", + "com._specs_.azure.clientgenerator.core.access.SharedModelInOperationAsyncClient.publicMethod": "_Specs_.Azure.ClientGenerator.Core.Access.SharedModelInOperation.public", + "com._specs_.azure.clientgenerator.core.access.SharedModelInOperationAsyncClient.publicMethodWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.SharedModelInOperation.public", + "com._specs_.azure.clientgenerator.core.access.SharedModelInOperationClient": "null", + "com._specs_.azure.clientgenerator.core.access.SharedModelInOperationClient.internal": "_Specs_.Azure.ClientGenerator.Core.Access.SharedModelInOperation.internal", + "com._specs_.azure.clientgenerator.core.access.SharedModelInOperationClient.internalWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.SharedModelInOperation.internal", + "com._specs_.azure.clientgenerator.core.access.SharedModelInOperationClient.publicMethod": "_Specs_.Azure.ClientGenerator.Core.Access.SharedModelInOperation.public", + "com._specs_.azure.clientgenerator.core.access.SharedModelInOperationClient.publicMethodWithResponse": "_Specs_.Azure.ClientGenerator.Core.Access.SharedModelInOperation.public", + "com._specs_.azure.clientgenerator.core.access.implementation.models.AbstractModel": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.AbstractModel", + "com._specs_.azure.clientgenerator.core.access.implementation.models.BaseModel": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.BaseModel", + "com._specs_.azure.clientgenerator.core.access.implementation.models.InnerModel": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.InnerModel", + "com._specs_.azure.clientgenerator.core.access.implementation.models.InternalDecoratorModelInInternal": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.InternalDecoratorModelInInternal", + "com._specs_.azure.clientgenerator.core.access.implementation.models.NoDecoratorModelInInternal": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.NoDecoratorModelInInternal", + "com._specs_.azure.clientgenerator.core.access.implementation.models.OuterModel": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.OuterModel", + "com._specs_.azure.clientgenerator.core.access.implementation.models.RealModel": "_Specs_.Azure.ClientGenerator.Core.Access.RelativeModelInOperation.RealModel", + "com._specs_.azure.clientgenerator.core.access.models.NoDecoratorModelInPublic": "_Specs_.Azure.ClientGenerator.Core.Access.PublicOperation.NoDecoratorModelInPublic", + "com._specs_.azure.clientgenerator.core.access.models.PublicDecoratorModelInInternal": "_Specs_.Azure.ClientGenerator.Core.Access.InternalOperation.PublicDecoratorModelInInternal", + "com._specs_.azure.clientgenerator.core.access.models.PublicDecoratorModelInPublic": "_Specs_.Azure.ClientGenerator.Core.Access.PublicOperation.PublicDecoratorModelInPublic", + "com._specs_.azure.clientgenerator.core.access.models.SharedModel": "_Specs_.Azure.ClientGenerator.Core.Access.SharedModelInOperation.SharedModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-clientgenerator-core-usage_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-clientgenerator-core-usage_apiview_properties.json new file mode 100644 index 000000000..893888bad --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-clientgenerator-core-usage_apiview_properties.json @@ -0,0 +1,25 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com._specs_.azure.clientgenerator.core.usage.UsageAsyncClient": "null", + "com._specs_.azure.clientgenerator.core.usage.UsageAsyncClient.inputToInputOutput": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.inputToInputOutput", + "com._specs_.azure.clientgenerator.core.usage.UsageAsyncClient.inputToInputOutputWithResponse": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.inputToInputOutput", + "com._specs_.azure.clientgenerator.core.usage.UsageAsyncClient.modelInReadOnlyProperty": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.modelInReadOnlyProperty", + "com._specs_.azure.clientgenerator.core.usage.UsageAsyncClient.modelInReadOnlyPropertyWithResponse": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.modelInReadOnlyProperty", + "com._specs_.azure.clientgenerator.core.usage.UsageAsyncClient.outputToInputOutput": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.outputToInputOutput", + "com._specs_.azure.clientgenerator.core.usage.UsageAsyncClient.outputToInputOutputWithResponse": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.outputToInputOutput", + "com._specs_.azure.clientgenerator.core.usage.UsageClient": "null", + "com._specs_.azure.clientgenerator.core.usage.UsageClient.inputToInputOutput": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.inputToInputOutput", + "com._specs_.azure.clientgenerator.core.usage.UsageClient.inputToInputOutputWithResponse": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.inputToInputOutput", + "com._specs_.azure.clientgenerator.core.usage.UsageClient.modelInReadOnlyProperty": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.modelInReadOnlyProperty", + "com._specs_.azure.clientgenerator.core.usage.UsageClient.modelInReadOnlyPropertyWithResponse": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.modelInReadOnlyProperty", + "com._specs_.azure.clientgenerator.core.usage.UsageClient.outputToInputOutput": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.outputToInputOutput", + "com._specs_.azure.clientgenerator.core.usage.UsageClient.outputToInputOutputWithResponse": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.outputToInputOutput", + "com._specs_.azure.clientgenerator.core.usage.UsageClientBuilder": "_Specs_.Azure.ClientGenerator.Core.Usage", + "com._specs_.azure.clientgenerator.core.usage.models.InputModel": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.InputModel", + "com._specs_.azure.clientgenerator.core.usage.models.OrphanModel": "_Specs_.Azure.ClientGenerator.Core.Usage.OrphanModel", + "com._specs_.azure.clientgenerator.core.usage.models.OutputModel": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.OutputModel", + "com._specs_.azure.clientgenerator.core.usage.models.ResultModel": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.ResultModel", + "com._specs_.azure.clientgenerator.core.usage.models.RoundTripModel": "_Specs_.Azure.ClientGenerator.Core.Usage.ModelInOperation.RoundTripModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-basic_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-basic_apiview_properties.json new file mode 100644 index 000000000..6f3f2070f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-basic_apiview_properties.json @@ -0,0 +1,32 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com._specs_.azure.core.basic.BasicAsyncClient": "_Specs_.Azure.Core.Basic", + "com._specs_.azure.core.basic.BasicAsyncClient.createOrReplace": "_Specs_.Azure.Core.Basic.createOrReplace", + "com._specs_.azure.core.basic.BasicAsyncClient.createOrReplaceWithResponse": "_Specs_.Azure.Core.Basic.createOrReplace", + "com._specs_.azure.core.basic.BasicAsyncClient.createOrUpdate": "_Specs_.Azure.Core.Basic.createOrUpdate", + "com._specs_.azure.core.basic.BasicAsyncClient.createOrUpdateWithResponse": "_Specs_.Azure.Core.Basic.createOrUpdate", + "com._specs_.azure.core.basic.BasicAsyncClient.delete": "_Specs_.Azure.Core.Basic.delete", + "com._specs_.azure.core.basic.BasicAsyncClient.deleteWithResponse": "_Specs_.Azure.Core.Basic.delete", + "com._specs_.azure.core.basic.BasicAsyncClient.export": "_Specs_.Azure.Core.Basic.export", + "com._specs_.azure.core.basic.BasicAsyncClient.exportWithResponse": "_Specs_.Azure.Core.Basic.export", + "com._specs_.azure.core.basic.BasicAsyncClient.get": "_Specs_.Azure.Core.Basic.get", + "com._specs_.azure.core.basic.BasicAsyncClient.getWithResponse": "_Specs_.Azure.Core.Basic.get", + "com._specs_.azure.core.basic.BasicAsyncClient.list": "_Specs_.Azure.Core.Basic.list", + "com._specs_.azure.core.basic.BasicClient": "_Specs_.Azure.Core.Basic", + "com._specs_.azure.core.basic.BasicClient.createOrReplace": "_Specs_.Azure.Core.Basic.createOrReplace", + "com._specs_.azure.core.basic.BasicClient.createOrReplaceWithResponse": "_Specs_.Azure.Core.Basic.createOrReplace", + "com._specs_.azure.core.basic.BasicClient.createOrUpdate": "_Specs_.Azure.Core.Basic.createOrUpdate", + "com._specs_.azure.core.basic.BasicClient.createOrUpdateWithResponse": "_Specs_.Azure.Core.Basic.createOrUpdate", + "com._specs_.azure.core.basic.BasicClient.delete": "_Specs_.Azure.Core.Basic.delete", + "com._specs_.azure.core.basic.BasicClient.deleteWithResponse": "_Specs_.Azure.Core.Basic.delete", + "com._specs_.azure.core.basic.BasicClient.export": "_Specs_.Azure.Core.Basic.export", + "com._specs_.azure.core.basic.BasicClient.exportWithResponse": "_Specs_.Azure.Core.Basic.export", + "com._specs_.azure.core.basic.BasicClient.get": "_Specs_.Azure.Core.Basic.get", + "com._specs_.azure.core.basic.BasicClient.getWithResponse": "_Specs_.Azure.Core.Basic.get", + "com._specs_.azure.core.basic.BasicClient.list": "_Specs_.Azure.Core.Basic.list", + "com._specs_.azure.core.basic.BasicClientBuilder": "_Specs_.Azure.Core.Basic", + "com._specs_.azure.core.basic.models.User": "_Specs_.Azure.Core.Basic.User", + "com._specs_.azure.core.basic.models.UserOrder": "_Specs_.Azure.Core.Basic.UserOrder" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-rpc_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-rpc_apiview_properties.json new file mode 100644 index 000000000..b8ff6a75d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-rpc_apiview_properties.json @@ -0,0 +1,14 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com._specs_.azure.core.lro.rpc.RpcAsyncClient": "_Specs_.Azure.Core.Lro.Rpc", + "com._specs_.azure.core.lro.rpc.RpcAsyncClient.beginLongRunningRpc": "_Specs_.Azure.Core.Lro.Rpc.longRunningRpc", + "com._specs_.azure.core.lro.rpc.RpcAsyncClient.beginLongRunningRpcWithModel": "_Specs_.Azure.Core.Lro.Rpc.longRunningRpc", + "com._specs_.azure.core.lro.rpc.RpcClient": "_Specs_.Azure.Core.Lro.Rpc", + "com._specs_.azure.core.lro.rpc.RpcClient.beginLongRunningRpc": "_Specs_.Azure.Core.Lro.Rpc.longRunningRpc", + "com._specs_.azure.core.lro.rpc.RpcClient.beginLongRunningRpcWithModel": "_Specs_.Azure.Core.Lro.Rpc.longRunningRpc", + "com._specs_.azure.core.lro.rpc.RpcClientBuilder": "_Specs_.Azure.Core.Lro.Rpc", + "com._specs_.azure.core.lro.rpc.models.GenerationOptions": "_Specs_.Azure.Core.Lro.Rpc.GenerationOptions", + "com._specs_.azure.core.lro.rpc.models.GenerationResult": "_Specs_.Azure.Core.Lro.Rpc.GenerationResult" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-standard_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-standard_apiview_properties.json new file mode 100644 index 000000000..fd433fed6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-lro-standard_apiview_properties.json @@ -0,0 +1,22 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com._specs_.azure.core.lro.standard.StandardAsyncClient": "_Specs_.Azure.Core.Lro.Standard", + "com._specs_.azure.core.lro.standard.StandardAsyncClient.beginCreateOrReplace": "_Specs_.Azure.Core.Lro.Standard.createOrReplace", + "com._specs_.azure.core.lro.standard.StandardAsyncClient.beginCreateOrReplaceWithModel": "_Specs_.Azure.Core.Lro.Standard.createOrReplace", + "com._specs_.azure.core.lro.standard.StandardAsyncClient.beginDelete": "_Specs_.Azure.Core.Lro.Standard.delete", + "com._specs_.azure.core.lro.standard.StandardAsyncClient.beginDeleteWithModel": "_Specs_.Azure.Core.Lro.Standard.delete", + "com._specs_.azure.core.lro.standard.StandardAsyncClient.beginExport": "_Specs_.Azure.Core.Lro.Standard.export", + "com._specs_.azure.core.lro.standard.StandardAsyncClient.beginExportWithModel": "_Specs_.Azure.Core.Lro.Standard.export", + "com._specs_.azure.core.lro.standard.StandardClient": "_Specs_.Azure.Core.Lro.Standard", + "com._specs_.azure.core.lro.standard.StandardClient.beginCreateOrReplace": "_Specs_.Azure.Core.Lro.Standard.createOrReplace", + "com._specs_.azure.core.lro.standard.StandardClient.beginCreateOrReplaceWithModel": "_Specs_.Azure.Core.Lro.Standard.createOrReplace", + "com._specs_.azure.core.lro.standard.StandardClient.beginDelete": "_Specs_.Azure.Core.Lro.Standard.delete", + "com._specs_.azure.core.lro.standard.StandardClient.beginDeleteWithModel": "_Specs_.Azure.Core.Lro.Standard.delete", + "com._specs_.azure.core.lro.standard.StandardClient.beginExport": "_Specs_.Azure.Core.Lro.Standard.export", + "com._specs_.azure.core.lro.standard.StandardClient.beginExportWithModel": "_Specs_.Azure.Core.Lro.Standard.export", + "com._specs_.azure.core.lro.standard.StandardClientBuilder": "_Specs_.Azure.Core.Lro.Standard", + "com._specs_.azure.core.lro.standard.models.ExportedUser": "_Specs_.Azure.Core.Lro.Standard.ExportedUser", + "com._specs_.azure.core.lro.standard.models.User": "_Specs_.Azure.Core.Lro.Standard.User" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-model_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-model_apiview_properties.json new file mode 100644 index 000000000..0a09837be --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-model_apiview_properties.json @@ -0,0 +1,21 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com._specs_.azure.core.model.ModelAsyncClient": "null", + "com._specs_.azure.core.model.ModelAsyncClient.get": "_Specs_.Azure.Core.Model.AzureCoreEmbeddingVector.get", + "com._specs_.azure.core.model.ModelAsyncClient.getWithResponse": "_Specs_.Azure.Core.Model.AzureCoreEmbeddingVector.get", + "com._specs_.azure.core.model.ModelAsyncClient.post": "_Specs_.Azure.Core.Model.AzureCoreEmbeddingVector.post", + "com._specs_.azure.core.model.ModelAsyncClient.postWithResponse": "_Specs_.Azure.Core.Model.AzureCoreEmbeddingVector.post", + "com._specs_.azure.core.model.ModelAsyncClient.put": "_Specs_.Azure.Core.Model.AzureCoreEmbeddingVector.put", + "com._specs_.azure.core.model.ModelAsyncClient.putWithResponse": "_Specs_.Azure.Core.Model.AzureCoreEmbeddingVector.put", + "com._specs_.azure.core.model.ModelClient": "null", + "com._specs_.azure.core.model.ModelClient.get": "_Specs_.Azure.Core.Model.AzureCoreEmbeddingVector.get", + "com._specs_.azure.core.model.ModelClient.getWithResponse": "_Specs_.Azure.Core.Model.AzureCoreEmbeddingVector.get", + "com._specs_.azure.core.model.ModelClient.post": "_Specs_.Azure.Core.Model.AzureCoreEmbeddingVector.post", + "com._specs_.azure.core.model.ModelClient.postWithResponse": "_Specs_.Azure.Core.Model.AzureCoreEmbeddingVector.post", + "com._specs_.azure.core.model.ModelClient.put": "_Specs_.Azure.Core.Model.AzureCoreEmbeddingVector.put", + "com._specs_.azure.core.model.ModelClient.putWithResponse": "_Specs_.Azure.Core.Model.AzureCoreEmbeddingVector.put", + "com._specs_.azure.core.model.ModelClientBuilder": "_Specs_.Azure.Core.Model", + "com._specs_.azure.core.model.models.AzureEmbeddingModel": "_Specs_.Azure.Core.Model.AzureEmbeddingModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-page_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-page_apiview_properties.json new file mode 100644 index 000000000..64f328265 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-page_apiview_properties.json @@ -0,0 +1,26 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com._specs_.azure.core.page.PageAsyncClient": "_Specs_.Azure.Core.Page", + "com._specs_.azure.core.page.PageAsyncClient.listWithCustomPageModel": "_Specs_.Azure.Core.Page.listWithCustomPageModel", + "com._specs_.azure.core.page.PageAsyncClient.listWithPage": "_Specs_.Azure.Core.Page.listWithPage", + "com._specs_.azure.core.page.PageAsyncClient.listWithParameters": "_Specs_.Azure.Core.Page.listWithParameters", + "com._specs_.azure.core.page.PageClient": "_Specs_.Azure.Core.Page", + "com._specs_.azure.core.page.PageClient.listWithCustomPageModel": "_Specs_.Azure.Core.Page.listWithCustomPageModel", + "com._specs_.azure.core.page.PageClient.listWithPage": "_Specs_.Azure.Core.Page.listWithPage", + "com._specs_.azure.core.page.PageClient.listWithParameters": "_Specs_.Azure.Core.Page.listWithParameters", + "com._specs_.azure.core.page.PageClientBuilder": "_Specs_.Azure.Core.Page", + "com._specs_.azure.core.page.TwoModelsAsPageItemAsyncClient": "null", + "com._specs_.azure.core.page.TwoModelsAsPageItemAsyncClient.listFirstItem": "_Specs_.Azure.Core.Page.TwoModelsAsPageItem.listFirstItem", + "com._specs_.azure.core.page.TwoModelsAsPageItemAsyncClient.listSecondItem": "_Specs_.Azure.Core.Page.TwoModelsAsPageItem.listSecondItem", + "com._specs_.azure.core.page.TwoModelsAsPageItemClient": "null", + "com._specs_.azure.core.page.TwoModelsAsPageItemClient.listFirstItem": "_Specs_.Azure.Core.Page.TwoModelsAsPageItem.listFirstItem", + "com._specs_.azure.core.page.TwoModelsAsPageItemClient.listSecondItem": "_Specs_.Azure.Core.Page.TwoModelsAsPageItem.listSecondItem", + "com._specs_.azure.core.page.models.FirstItem": "_Specs_.Azure.Core.Page.FirstItem", + "com._specs_.azure.core.page.models.ListItemInputBody": "_Specs_.Azure.Core.Page.ListItemInputBody", + "com._specs_.azure.core.page.models.ListItemInputExtensibleEnum": "_Specs_.Azure.Core.Page.ListItemInputExtensibleEnum", + "com._specs_.azure.core.page.models.SecondItem": "_Specs_.Azure.Core.Page.SecondItem", + "com._specs_.azure.core.page.models.User": "_Specs_.Azure.Core.Page.User", + "com._specs_.azure.core.page.models.UserOrder": "_Specs_.Azure.Core.Page.UserOrder" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-scalar_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-scalar_apiview_properties.json new file mode 100644 index 000000000..6ada1fb83 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-scalar_apiview_properties.json @@ -0,0 +1,29 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com._specs_.azure.core.scalar.ScalarAsyncClient": "null", + "com._specs_.azure.core.scalar.ScalarAsyncClient.get": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.get", + "com._specs_.azure.core.scalar.ScalarAsyncClient.getWithResponse": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.get", + "com._specs_.azure.core.scalar.ScalarAsyncClient.headerMethod": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.header", + "com._specs_.azure.core.scalar.ScalarAsyncClient.headerMethodWithResponse": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.header", + "com._specs_.azure.core.scalar.ScalarAsyncClient.post": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.post", + "com._specs_.azure.core.scalar.ScalarAsyncClient.postWithResponse": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.post", + "com._specs_.azure.core.scalar.ScalarAsyncClient.put": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.put", + "com._specs_.azure.core.scalar.ScalarAsyncClient.putWithResponse": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.put", + "com._specs_.azure.core.scalar.ScalarAsyncClient.query": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.query", + "com._specs_.azure.core.scalar.ScalarAsyncClient.queryWithResponse": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.query", + "com._specs_.azure.core.scalar.ScalarClient": "null", + "com._specs_.azure.core.scalar.ScalarClient.get": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.get", + "com._specs_.azure.core.scalar.ScalarClient.getWithResponse": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.get", + "com._specs_.azure.core.scalar.ScalarClient.headerMethod": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.header", + "com._specs_.azure.core.scalar.ScalarClient.headerMethodWithResponse": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.header", + "com._specs_.azure.core.scalar.ScalarClient.post": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.post", + "com._specs_.azure.core.scalar.ScalarClient.postWithResponse": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.post", + "com._specs_.azure.core.scalar.ScalarClient.put": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.put", + "com._specs_.azure.core.scalar.ScalarClient.putWithResponse": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.put", + "com._specs_.azure.core.scalar.ScalarClient.query": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.query", + "com._specs_.azure.core.scalar.ScalarClient.queryWithResponse": "_Specs_.Azure.Core.Scalar.AzureLocationScalar.query", + "com._specs_.azure.core.scalar.ScalarClientBuilder": "_Specs_.Azure.Core.Scalar", + "com._specs_.azure.core.scalar.models.AzureLocationModel": "_Specs_.Azure.Core.Scalar.AzureLocationModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-traits_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-traits_apiview_properties.json new file mode 100644 index 000000000..772035cfc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-core-traits_apiview_properties.json @@ -0,0 +1,19 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com._specs_.azure.core.traits.TraitsAsyncClient": "_Specs_.Azure.Core.Traits", + "com._specs_.azure.core.traits.TraitsAsyncClient.repeatableAction": "_Specs_.Azure.Core.Traits.repeatableAction", + "com._specs_.azure.core.traits.TraitsAsyncClient.repeatableActionWithResponse": "_Specs_.Azure.Core.Traits.repeatableAction", + "com._specs_.azure.core.traits.TraitsAsyncClient.smokeTest": "_Specs_.Azure.Core.Traits.smokeTest", + "com._specs_.azure.core.traits.TraitsAsyncClient.smokeTestWithResponse": "_Specs_.Azure.Core.Traits.smokeTest", + "com._specs_.azure.core.traits.TraitsClient": "_Specs_.Azure.Core.Traits", + "com._specs_.azure.core.traits.TraitsClient.repeatableAction": "_Specs_.Azure.Core.Traits.repeatableAction", + "com._specs_.azure.core.traits.TraitsClient.repeatableActionWithResponse": "_Specs_.Azure.Core.Traits.repeatableAction", + "com._specs_.azure.core.traits.TraitsClient.smokeTest": "_Specs_.Azure.Core.Traits.smokeTest", + "com._specs_.azure.core.traits.TraitsClient.smokeTestWithResponse": "_Specs_.Azure.Core.Traits.smokeTest", + "com._specs_.azure.core.traits.TraitsClientBuilder": "_Specs_.Azure.Core.Traits", + "com._specs_.azure.core.traits.models.User": "_Specs_.Azure.Core.Traits.User", + "com._specs_.azure.core.traits.models.UserActionParam": "_Specs_.Azure.Core.Traits.UserActionParam", + "com._specs_.azure.core.traits.models.UserActionResponse": "_Specs_.Azure.Core.Traits.UserActionResponse" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-example-basic_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-example-basic_apiview_properties.json new file mode 100644 index 000000000..7b070dbfa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/_specs_-azure-example-basic_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com._specs_.azure.example.basic.AzureExampleAsyncClient": "Client.AzureExampleClient", + "com._specs_.azure.example.basic.AzureExampleAsyncClient.basicAction": "Client.AzureExampleClient.basicAction", + "com._specs_.azure.example.basic.AzureExampleAsyncClient.basicActionWithResponse": "Client.AzureExampleClient.basicAction", + "com._specs_.azure.example.basic.AzureExampleClient": "Client.AzureExampleClient", + "com._specs_.azure.example.basic.AzureExampleClient.basicAction": "Client.AzureExampleClient.basicAction", + "com._specs_.azure.example.basic.AzureExampleClient.basicActionWithResponse": "Client.AzureExampleClient.basicAction", + "com._specs_.azure.example.basic.AzureExampleClientBuilder": "Client.AzureExampleClient", + "com._specs_.azure.example.basic.models.ActionRequest": "_Specs_.Azure.Example.Basic.ActionRequest", + "com._specs_.azure.example.basic.models.ActionResponse": "_Specs_.Azure.Example.Basic.ActionResponse", + "com._specs_.azure.example.basic.models.Enum": "_Specs_.Azure.Example.Basic.Enum", + "com._specs_.azure.example.basic.models.Model": "_Specs_.Azure.Example.Basic.Model" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/authentication-apikey_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/authentication-apikey_apiview_properties.json new file mode 100644 index 000000000..08acf8b52 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/authentication-apikey_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.authentication.apikey.ApiKeyAsyncClient": "Authentication.ApiKey", + "com.authentication.apikey.ApiKeyAsyncClient.invalid": "Authentication.ApiKey.invalid", + "com.authentication.apikey.ApiKeyAsyncClient.invalidWithResponse": "Authentication.ApiKey.invalid", + "com.authentication.apikey.ApiKeyAsyncClient.valid": "Authentication.ApiKey.valid", + "com.authentication.apikey.ApiKeyAsyncClient.validWithResponse": "Authentication.ApiKey.valid", + "com.authentication.apikey.ApiKeyClient": "Authentication.ApiKey", + "com.authentication.apikey.ApiKeyClient.invalid": "Authentication.ApiKey.invalid", + "com.authentication.apikey.ApiKeyClient.invalidWithResponse": "Authentication.ApiKey.invalid", + "com.authentication.apikey.ApiKeyClient.valid": "Authentication.ApiKey.valid", + "com.authentication.apikey.ApiKeyClient.validWithResponse": "Authentication.ApiKey.valid", + "com.authentication.apikey.ApiKeyClientBuilder": "Authentication.ApiKey" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/authentication-http-custom_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/authentication-http-custom_apiview_properties.json new file mode 100644 index 000000000..511ff0fa4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/authentication-http-custom_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.authentication.http.custom.CustomAsyncClient": "Authentication.Http.Custom", + "com.authentication.http.custom.CustomAsyncClient.invalid": "Authentication.Http.Custom.invalid", + "com.authentication.http.custom.CustomAsyncClient.invalidWithResponse": "Authentication.Http.Custom.invalid", + "com.authentication.http.custom.CustomAsyncClient.valid": "Authentication.Http.Custom.valid", + "com.authentication.http.custom.CustomAsyncClient.validWithResponse": "Authentication.Http.Custom.valid", + "com.authentication.http.custom.CustomClient": "Authentication.Http.Custom", + "com.authentication.http.custom.CustomClient.invalid": "Authentication.Http.Custom.invalid", + "com.authentication.http.custom.CustomClient.invalidWithResponse": "Authentication.Http.Custom.invalid", + "com.authentication.http.custom.CustomClient.valid": "Authentication.Http.Custom.valid", + "com.authentication.http.custom.CustomClient.validWithResponse": "Authentication.Http.Custom.valid", + "com.authentication.http.custom.CustomClientBuilder": "Authentication.Http.Custom" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/authentication-oauth2_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/authentication-oauth2_apiview_properties.json new file mode 100644 index 000000000..c789cd984 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/authentication-oauth2_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.authentication.oauth2.OAuth2AsyncClient": "Authentication.OAuth2", + "com.authentication.oauth2.OAuth2AsyncClient.invalid": "Authentication.OAuth2.invalid", + "com.authentication.oauth2.OAuth2AsyncClient.invalidWithResponse": "Authentication.OAuth2.invalid", + "com.authentication.oauth2.OAuth2AsyncClient.valid": "Authentication.OAuth2.valid", + "com.authentication.oauth2.OAuth2AsyncClient.validWithResponse": "Authentication.OAuth2.valid", + "com.authentication.oauth2.OAuth2Client": "Authentication.OAuth2", + "com.authentication.oauth2.OAuth2Client.invalid": "Authentication.OAuth2.invalid", + "com.authentication.oauth2.OAuth2Client.invalidWithResponse": "Authentication.OAuth2.invalid", + "com.authentication.oauth2.OAuth2Client.valid": "Authentication.OAuth2.valid", + "com.authentication.oauth2.OAuth2Client.validWithResponse": "Authentication.OAuth2.valid", + "com.authentication.oauth2.OAuth2ClientBuilder": "Authentication.OAuth2" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/authentication-union_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/authentication-union_apiview_properties.json new file mode 100644 index 000000000..94b13df2e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/authentication-union_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.authentication.union.UnionAsyncClient": "Authentication.Union", + "com.authentication.union.UnionAsyncClient.validKey": "Authentication.Union.validKey", + "com.authentication.union.UnionAsyncClient.validKeyWithResponse": "Authentication.Union.validKey", + "com.authentication.union.UnionAsyncClient.validToken": "Authentication.Union.validToken", + "com.authentication.union.UnionAsyncClient.validTokenWithResponse": "Authentication.Union.validToken", + "com.authentication.union.UnionClient": "Authentication.Union", + "com.authentication.union.UnionClient.validKey": "Authentication.Union.validKey", + "com.authentication.union.UnionClient.validKeyWithResponse": "Authentication.Union.validKey", + "com.authentication.union.UnionClient.validToken": "Authentication.Union.validToken", + "com.authentication.union.UnionClient.validTokenWithResponse": "Authentication.Union.validToken", + "com.authentication.union.UnionClientBuilder": "Authentication.Union" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-specialheaders-xmsclientrequestid_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-specialheaders-xmsclientrequestid_apiview_properties.json new file mode 100644 index 000000000..12367f747 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-specialheaders-xmsclientrequestid_apiview_properties.json @@ -0,0 +1,12 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.azure.specialheaders.xmsclientrequestid.XmsClientRequestIdAsyncClient": "Azure.SpecialHeaders.XmsClientRequestId", + "com.azure.specialheaders.xmsclientrequestid.XmsClientRequestIdAsyncClient.get": "Azure.SpecialHeaders.XmsClientRequestId.get", + "com.azure.specialheaders.xmsclientrequestid.XmsClientRequestIdAsyncClient.getWithResponse": "Azure.SpecialHeaders.XmsClientRequestId.get", + "com.azure.specialheaders.xmsclientrequestid.XmsClientRequestIdClient": "Azure.SpecialHeaders.XmsClientRequestId", + "com.azure.specialheaders.xmsclientrequestid.XmsClientRequestIdClient.get": "Azure.SpecialHeaders.XmsClientRequestId.get", + "com.azure.specialheaders.xmsclientrequestid.XmsClientRequestIdClient.getWithResponse": "Azure.SpecialHeaders.XmsClientRequestId.get", + "com.azure.specialheaders.xmsclientrequestid.XmsClientRequestIdClientBuilder": "Azure.SpecialHeaders.XmsClientRequestId" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-builtin_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-builtin_apiview_properties.json new file mode 100644 index 000000000..e8050fdba --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-builtin_apiview_properties.json @@ -0,0 +1,14 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.builtin.BuiltinAsyncClient": "null", + "com.cadl.builtin.BuiltinAsyncClient.read": "Cadl.Builtin.BuiltinOp.read", + "com.cadl.builtin.BuiltinAsyncClient.readWithResponse": "Cadl.Builtin.BuiltinOp.read", + "com.cadl.builtin.BuiltinClient": "null", + "com.cadl.builtin.BuiltinClient.read": "Cadl.Builtin.BuiltinOp.read", + "com.cadl.builtin.BuiltinClient.readWithResponse": "Cadl.Builtin.BuiltinOp.read", + "com.cadl.builtin.BuiltinClientBuilder": "Cadl.Builtin", + "com.cadl.builtin.models.Builtin": "Cadl.Builtin.Builtin", + "com.cadl.builtin.models.Encoded": "Cadl.Builtin.Encoded" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-enumservice_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-enumservice_apiview_properties.json new file mode 100644 index 000000000..c1425196a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-enumservice_apiview_properties.json @@ -0,0 +1,76 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.enumservice.EnumServiceAsyncClient": "Cadl.EnumService.EnumOp", + "com.cadl.enumservice.EnumServiceAsyncClient.getColor": "Cadl.EnumService.EnumOp.getColor", + "com.cadl.enumservice.EnumServiceAsyncClient.getColorModel": "Cadl.EnumService.EnumOp.getColorModel", + "com.cadl.enumservice.EnumServiceAsyncClient.getColorModelWithResponse": "Cadl.EnumService.EnumOp.getColorModel", + "com.cadl.enumservice.EnumServiceAsyncClient.getColorWithResponse": "Cadl.EnumService.EnumOp.getColor", + "com.cadl.enumservice.EnumServiceAsyncClient.getOperation": "Cadl.EnumService.EnumOp.getOperation", + "com.cadl.enumservice.EnumServiceAsyncClient.getOperationWithResponse": "Cadl.EnumService.EnumOp.getOperation", + "com.cadl.enumservice.EnumServiceAsyncClient.getRunningOperation": "Cadl.EnumService.EnumOp.getRunningOperation", + "com.cadl.enumservice.EnumServiceAsyncClient.getRunningOperationWithResponse": "Cadl.EnumService.EnumOp.getRunningOperation", + "com.cadl.enumservice.EnumServiceAsyncClient.setColorModel": "Cadl.EnumService.EnumOp.setColorModel", + "com.cadl.enumservice.EnumServiceAsyncClient.setColorModelWithResponse": "Cadl.EnumService.EnumOp.setColorModel", + "com.cadl.enumservice.EnumServiceAsyncClient.setIntArray": "Cadl.EnumService.EnumOp.setIntArray", + "com.cadl.enumservice.EnumServiceAsyncClient.setIntArrayWithResponse": "Cadl.EnumService.EnumOp.setIntArray", + "com.cadl.enumservice.EnumServiceAsyncClient.setIntEnumArray": "Cadl.EnumService.EnumOp.setIntEnumArray", + "com.cadl.enumservice.EnumServiceAsyncClient.setIntEnumArrayWithResponse": "Cadl.EnumService.EnumOp.setIntEnumArray", + "com.cadl.enumservice.EnumServiceAsyncClient.setIntEnumMulti": "Cadl.EnumService.EnumOp.setIntEnumMulti", + "com.cadl.enumservice.EnumServiceAsyncClient.setIntEnumMultiWithResponse": "Cadl.EnumService.EnumOp.setIntEnumMulti", + "com.cadl.enumservice.EnumServiceAsyncClient.setIntMulti": "Cadl.EnumService.EnumOp.setIntMulti", + "com.cadl.enumservice.EnumServiceAsyncClient.setIntMultiWithResponse": "Cadl.EnumService.EnumOp.setIntMulti", + "com.cadl.enumservice.EnumServiceAsyncClient.setPriority": "Cadl.EnumService.EnumOp.setPriority", + "com.cadl.enumservice.EnumServiceAsyncClient.setPriorityWithResponse": "Cadl.EnumService.EnumOp.setPriority", + "com.cadl.enumservice.EnumServiceAsyncClient.setStringArray": "Cadl.EnumService.EnumOp.setStringArray", + "com.cadl.enumservice.EnumServiceAsyncClient.setStringArrayWithResponse": "Cadl.EnumService.EnumOp.setStringArray", + "com.cadl.enumservice.EnumServiceAsyncClient.setStringEnumArray": "Cadl.EnumService.EnumOp.setStringEnumArray", + "com.cadl.enumservice.EnumServiceAsyncClient.setStringEnumArrayHeader": "Cadl.EnumService.EnumOp.setStringEnumArrayHeader", + "com.cadl.enumservice.EnumServiceAsyncClient.setStringEnumArrayHeaderWithResponse": "Cadl.EnumService.EnumOp.setStringEnumArrayHeader", + "com.cadl.enumservice.EnumServiceAsyncClient.setStringEnumArrayWithResponse": "Cadl.EnumService.EnumOp.setStringEnumArray", + "com.cadl.enumservice.EnumServiceAsyncClient.setStringEnumMulti": "Cadl.EnumService.EnumOp.setStringEnumMulti", + "com.cadl.enumservice.EnumServiceAsyncClient.setStringEnumMultiWithResponse": "Cadl.EnumService.EnumOp.setStringEnumMulti", + "com.cadl.enumservice.EnumServiceAsyncClient.setStringMulti": "Cadl.EnumService.EnumOp.setStringMulti", + "com.cadl.enumservice.EnumServiceAsyncClient.setStringMultiWithResponse": "Cadl.EnumService.EnumOp.setStringMulti", + "com.cadl.enumservice.EnumServiceClient": "Cadl.EnumService.EnumOp", + "com.cadl.enumservice.EnumServiceClient.getColor": "Cadl.EnumService.EnumOp.getColor", + "com.cadl.enumservice.EnumServiceClient.getColorModel": "Cadl.EnumService.EnumOp.getColorModel", + "com.cadl.enumservice.EnumServiceClient.getColorModelWithResponse": "Cadl.EnumService.EnumOp.getColorModel", + "com.cadl.enumservice.EnumServiceClient.getColorWithResponse": "Cadl.EnumService.EnumOp.getColor", + "com.cadl.enumservice.EnumServiceClient.getOperation": "Cadl.EnumService.EnumOp.getOperation", + "com.cadl.enumservice.EnumServiceClient.getOperationWithResponse": "Cadl.EnumService.EnumOp.getOperation", + "com.cadl.enumservice.EnumServiceClient.getRunningOperation": "Cadl.EnumService.EnumOp.getRunningOperation", + "com.cadl.enumservice.EnumServiceClient.getRunningOperationWithResponse": "Cadl.EnumService.EnumOp.getRunningOperation", + "com.cadl.enumservice.EnumServiceClient.setColorModel": "Cadl.EnumService.EnumOp.setColorModel", + "com.cadl.enumservice.EnumServiceClient.setColorModelWithResponse": "Cadl.EnumService.EnumOp.setColorModel", + "com.cadl.enumservice.EnumServiceClient.setIntArray": "Cadl.EnumService.EnumOp.setIntArray", + "com.cadl.enumservice.EnumServiceClient.setIntArrayWithResponse": "Cadl.EnumService.EnumOp.setIntArray", + "com.cadl.enumservice.EnumServiceClient.setIntEnumArray": "Cadl.EnumService.EnumOp.setIntEnumArray", + "com.cadl.enumservice.EnumServiceClient.setIntEnumArrayWithResponse": "Cadl.EnumService.EnumOp.setIntEnumArray", + "com.cadl.enumservice.EnumServiceClient.setIntEnumMulti": "Cadl.EnumService.EnumOp.setIntEnumMulti", + "com.cadl.enumservice.EnumServiceClient.setIntEnumMultiWithResponse": "Cadl.EnumService.EnumOp.setIntEnumMulti", + "com.cadl.enumservice.EnumServiceClient.setIntMulti": "Cadl.EnumService.EnumOp.setIntMulti", + "com.cadl.enumservice.EnumServiceClient.setIntMultiWithResponse": "Cadl.EnumService.EnumOp.setIntMulti", + "com.cadl.enumservice.EnumServiceClient.setPriority": "Cadl.EnumService.EnumOp.setPriority", + "com.cadl.enumservice.EnumServiceClient.setPriorityWithResponse": "Cadl.EnumService.EnumOp.setPriority", + "com.cadl.enumservice.EnumServiceClient.setStringArray": "Cadl.EnumService.EnumOp.setStringArray", + "com.cadl.enumservice.EnumServiceClient.setStringArrayWithResponse": "Cadl.EnumService.EnumOp.setStringArray", + "com.cadl.enumservice.EnumServiceClient.setStringEnumArray": "Cadl.EnumService.EnumOp.setStringEnumArray", + "com.cadl.enumservice.EnumServiceClient.setStringEnumArrayHeader": "Cadl.EnumService.EnumOp.setStringEnumArrayHeader", + "com.cadl.enumservice.EnumServiceClient.setStringEnumArrayHeaderWithResponse": "Cadl.EnumService.EnumOp.setStringEnumArrayHeader", + "com.cadl.enumservice.EnumServiceClient.setStringEnumArrayWithResponse": "Cadl.EnumService.EnumOp.setStringEnumArray", + "com.cadl.enumservice.EnumServiceClient.setStringEnumMulti": "Cadl.EnumService.EnumOp.setStringEnumMulti", + "com.cadl.enumservice.EnumServiceClient.setStringEnumMultiWithResponse": "Cadl.EnumService.EnumOp.setStringEnumMulti", + "com.cadl.enumservice.EnumServiceClient.setStringMulti": "Cadl.EnumService.EnumOp.setStringMulti", + "com.cadl.enumservice.EnumServiceClient.setStringMultiWithResponse": "Cadl.EnumService.EnumOp.setStringMulti", + "com.cadl.enumservice.EnumServiceClientBuilder": "Cadl.EnumService.EnumOp", + "com.cadl.enumservice.models.Color": "Cadl.EnumService.Color", + "com.cadl.enumservice.models.ColorModel": "Cadl.EnumService.ColorModel", + "com.cadl.enumservice.models.Operation": "Cadl.EnumService.Operation", + "com.cadl.enumservice.models.OperationName": "Operation.name.anonymous", + "com.cadl.enumservice.models.OperationStateValues": "Cadl.EnumService.OperationStateValues", + "com.cadl.enumservice.models.Priority": "Cadl.EnumService.Priority", + "com.cadl.enumservice.models.PriorityModel": "Cadl.EnumService.PriorityModel", + "com.cadl.enumservice.models.Unit": "Cadl.EnumService.Unit" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-errormodel_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-errormodel_apiview_properties.json new file mode 100644 index 000000000..07f055687 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-errormodel_apiview_properties.json @@ -0,0 +1,13 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.errormodel.ErrorModelAsyncClient": "null", + "com.cadl.errormodel.ErrorModelAsyncClient.read": "Cadl.ErrorModel.ErrorOp.read", + "com.cadl.errormodel.ErrorModelAsyncClient.readWithResponse": "Cadl.ErrorModel.ErrorOp.read", + "com.cadl.errormodel.ErrorModelClient": "null", + "com.cadl.errormodel.ErrorModelClient.read": "Cadl.ErrorModel.ErrorOp.read", + "com.cadl.errormodel.ErrorModelClient.readWithResponse": "Cadl.ErrorModel.ErrorOp.read", + "com.cadl.errormodel.ErrorModelClientBuilder": "Cadl.ErrorModel", + "com.cadl.errormodel.models.Diagnostic": "Cadl.ErrorModel.Diagnostic" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-flatten_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-flatten_apiview_properties.json new file mode 100644 index 000000000..e7fdee04e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-flatten_apiview_properties.json @@ -0,0 +1,46 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.flatten.FlattenAsyncClient": "Cadl.Flatten.FlattenOp", + "com.cadl.flatten.FlattenAsyncClient.send": "Cadl.Flatten.FlattenOp.send", + "com.cadl.flatten.FlattenAsyncClient.sendLong": "Cadl.Flatten.FlattenOp.sendLong", + "com.cadl.flatten.FlattenAsyncClient.sendLongWithResponse": "Cadl.Flatten.FlattenOp.sendLong", + "com.cadl.flatten.FlattenAsyncClient.sendProjectedName": "Cadl.Flatten.FlattenOp.sendProjectedName", + "com.cadl.flatten.FlattenAsyncClient.sendProjectedNameWithResponse": "Cadl.Flatten.FlattenOp.sendProjectedName", + "com.cadl.flatten.FlattenAsyncClient.sendWithResponse": "Cadl.Flatten.FlattenOp.send", + "com.cadl.flatten.FlattenAsyncClient.update": "Cadl.Flatten.FlattenOp.update", + "com.cadl.flatten.FlattenAsyncClient.updateWithResponse": "Cadl.Flatten.FlattenOp.update", + "com.cadl.flatten.FlattenAsyncClient.uploadFile": "Cadl.Flatten.FlattenOp.uploadFile", + "com.cadl.flatten.FlattenAsyncClient.uploadFileWithResponse": "Cadl.Flatten.FlattenOp.uploadFile", + "com.cadl.flatten.FlattenAsyncClient.uploadTodo": "Cadl.Flatten.FlattenOp.uploadTodo", + "com.cadl.flatten.FlattenAsyncClient.uploadTodoWithResponse": "Cadl.Flatten.FlattenOp.uploadTodo", + "com.cadl.flatten.FlattenClient": "Cadl.Flatten.FlattenOp", + "com.cadl.flatten.FlattenClient.send": "Cadl.Flatten.FlattenOp.send", + "com.cadl.flatten.FlattenClient.sendLong": "Cadl.Flatten.FlattenOp.sendLong", + "com.cadl.flatten.FlattenClient.sendLongWithResponse": "Cadl.Flatten.FlattenOp.sendLong", + "com.cadl.flatten.FlattenClient.sendProjectedName": "Cadl.Flatten.FlattenOp.sendProjectedName", + "com.cadl.flatten.FlattenClient.sendProjectedNameWithResponse": "Cadl.Flatten.FlattenOp.sendProjectedName", + "com.cadl.flatten.FlattenClient.sendWithResponse": "Cadl.Flatten.FlattenOp.send", + "com.cadl.flatten.FlattenClient.update": "Cadl.Flatten.FlattenOp.update", + "com.cadl.flatten.FlattenClient.updateWithResponse": "Cadl.Flatten.FlattenOp.update", + "com.cadl.flatten.FlattenClient.uploadFile": "Cadl.Flatten.FlattenOp.uploadFile", + "com.cadl.flatten.FlattenClient.uploadFileWithResponse": "Cadl.Flatten.FlattenOp.uploadFile", + "com.cadl.flatten.FlattenClient.uploadTodo": "Cadl.Flatten.FlattenOp.uploadTodo", + "com.cadl.flatten.FlattenClient.uploadTodoWithResponse": "Cadl.Flatten.FlattenOp.uploadTodo", + "com.cadl.flatten.FlattenClientBuilder": "Cadl.Flatten.FlattenOp", + "com.cadl.flatten.implementation.models.SendLongRequest": "sendLong.Request.anonymous", + "com.cadl.flatten.implementation.models.SendProjectedNameRequest": "sendProjectedName.Request.anonymous", + "com.cadl.flatten.implementation.models.SendRequest": "send.Request.anonymous", + "com.cadl.flatten.implementation.models.UploadFileRequest": "uploadFile.Request.anonymous", + "com.cadl.flatten.implementation.models.UploadTodoRequest": "uploadTodo.Request.anonymous", + "com.cadl.flatten.models.FileDataFileDetails": "null", + "com.cadl.flatten.models.SendLongOptions": "null", + "com.cadl.flatten.models.SendLongRequestStatus": "sendLong.Request.status.anonymous", + "com.cadl.flatten.models.TodoItem": "Cadl.Flatten.TodoItem", + "com.cadl.flatten.models.TodoItemPatch": "Cadl.Flatten.TodoItemPatch", + "com.cadl.flatten.models.TodoItemPatchStatus": "TodoItemPatch.status.anonymous", + "com.cadl.flatten.models.UpdatePatchRequest": "update.Request.anonymous", + "com.cadl.flatten.models.UploadTodoOptions": "null", + "com.cadl.flatten.models.User": "Cadl.Flatten.User" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-internal_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-internal_apiview_properties.json new file mode 100644 index 000000000..9ce948473 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-internal_apiview_properties.json @@ -0,0 +1,26 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.internal.InternalAsyncClient": "null", + "com.cadl.internal.InternalAsyncClient.getInternal": "Cadl.Internal.InternalOp.getInternal", + "com.cadl.internal.InternalAsyncClient.getInternalWithResponse": "Cadl.Internal.InternalOp.getInternal", + "com.cadl.internal.InternalAsyncClient.postInternal": "Cadl.Internal.InternalOp.postInternal", + "com.cadl.internal.InternalAsyncClient.postInternalWithResponse": "Cadl.Internal.InternalOp.postInternal", + "com.cadl.internal.InternalClient": "null", + "com.cadl.internal.InternalClient.getInternal": "Cadl.Internal.InternalOp.getInternal", + "com.cadl.internal.InternalClient.getInternalWithResponse": "Cadl.Internal.InternalOp.getInternal", + "com.cadl.internal.InternalClient.postInternal": "Cadl.Internal.InternalOp.postInternal", + "com.cadl.internal.InternalClient.postInternalWithResponse": "Cadl.Internal.InternalOp.postInternal", + "com.cadl.internal.InternalClientBuilder": "Cadl.Internal", + "com.cadl.internal.implementation.models.Color": "Cadl.Internal.Color", + "com.cadl.internal.implementation.models.ColorModel": "Cadl.Internal.ColorModel", + "com.cadl.internal.models.ApiRequest": "Cadl.Internal.ApiRequest", + "com.cadl.internal.models.ApiResponse": "Cadl.Internal.ApiResponse", + "com.cadl.internal.models.RequestInner": "Cadl.Internal.RequestInner", + "com.cadl.internal.models.ResponseInternal": "Cadl.Internal.ResponseInternal", + "com.cadl.internal.models.ResponseInternalInner": "Cadl.Internal.ResponseInternalInner", + "com.cadl.internal.models.StandAloneData": "Cadl.Internal.StandAloneData", + "com.cadl.internal.models.StandAloneDataInner": "Cadl.Internal.StandAloneDataInner", + "com.cadl.internal.models.UnusedEnum": "Cadl.Internal.UnusedEnum" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-literalservice_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-literalservice_apiview_properties.json new file mode 100644 index 000000000..7a6e7e1f0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-literalservice_apiview_properties.json @@ -0,0 +1,15 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.literalservice.LiteralServiceAsyncClient": "null", + "com.cadl.literalservice.LiteralServiceAsyncClient.put": "Cadl.LiteralService.LiteralOp.put", + "com.cadl.literalservice.LiteralServiceAsyncClient.putWithResponse": "Cadl.LiteralService.LiteralOp.put", + "com.cadl.literalservice.LiteralServiceClient": "null", + "com.cadl.literalservice.LiteralServiceClient.put": "Cadl.LiteralService.LiteralOp.put", + "com.cadl.literalservice.LiteralServiceClient.putWithResponse": "Cadl.LiteralService.LiteralOp.put", + "com.cadl.literalservice.LiteralServiceClientBuilder": "Cadl.LiteralService", + "com.cadl.literalservice.models.Model": "Cadl.LiteralService.Model", + "com.cadl.literalservice.models.ModelOptionalLiteral": "null", + "com.cadl.literalservice.models.PutRequestOptionalLiteralParam": "null" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json new file mode 100644 index 000000000..26f9ae99a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-longrunning_apiview_properties.json @@ -0,0 +1,26 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.longrunning.LongRunningAsyncClient": "Cadl.LongRunning", + "com.cadl.longrunning.LongRunningAsyncClient.beginCreateJob": "Cadl.LongRunning.createJob", + "com.cadl.longrunning.LongRunningAsyncClient.beginCreateJobWithModel": "Cadl.LongRunning.createJob", + "com.cadl.longrunning.LongRunningAsyncClient.beginLongRunning": "Cadl.LongRunning.longRunning", + "com.cadl.longrunning.LongRunningAsyncClient.beginLongRunningWithModel": "Cadl.LongRunning.longRunning", + "com.cadl.longrunning.LongRunningAsyncClient.getJob": "Cadl.LongRunning.getJob", + "com.cadl.longrunning.LongRunningAsyncClient.getJobWithResponse": "Cadl.LongRunning.getJob", + "com.cadl.longrunning.LongRunningClient": "Cadl.LongRunning", + "com.cadl.longrunning.LongRunningClient.beginCreateJob": "Cadl.LongRunning.createJob", + "com.cadl.longrunning.LongRunningClient.beginCreateJobWithModel": "Cadl.LongRunning.createJob", + "com.cadl.longrunning.LongRunningClient.beginLongRunning": "Cadl.LongRunning.longRunning", + "com.cadl.longrunning.LongRunningClient.beginLongRunningWithModel": "Cadl.LongRunning.longRunning", + "com.cadl.longrunning.LongRunningClient.getJob": "Cadl.LongRunning.getJob", + "com.cadl.longrunning.LongRunningClient.getJobWithResponse": "Cadl.LongRunning.getJob", + "com.cadl.longrunning.LongRunningClientBuilder": "Cadl.LongRunning", + "com.cadl.longrunning.models.JobData": "Cadl.LongRunning.JobData", + "com.cadl.longrunning.models.JobResult": "Cadl.LongRunning.JobResult", + "com.cadl.longrunning.models.JobResultResult": "Cadl.LongRunning.JobResult.result.anonymous", + "com.cadl.longrunning.models.JobStatus": "Cadl.LongRunning.JobStatus", + "com.cadl.longrunning.models.OperationState": "Azure.Core.Foundations.OperationState", + "com.cadl.longrunning.models.PollResponse": "Cadl.LongRunning.PollResponse" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-model_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-model_apiview_properties.json new file mode 100644 index 000000000..e963d45e9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-model_apiview_properties.json @@ -0,0 +1,33 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.model.ModelAsyncClient": "null", + "com.cadl.model.ModelAsyncClient.get3": "Cadl.Model.ModelOp.get3", + "com.cadl.model.ModelAsyncClient.get3WithResponse": "Cadl.Model.ModelOp.get3", + "com.cadl.model.ModelAsyncClient.put1": "Cadl.Model.ModelOp.put1", + "com.cadl.model.ModelAsyncClient.put1WithResponse": "Cadl.Model.ModelOp.put1", + "com.cadl.model.ModelAsyncClient.put2": "Cadl.Model.ModelOp.put2", + "com.cadl.model.ModelAsyncClient.put2WithResponse": "Cadl.Model.ModelOp.put2", + "com.cadl.model.ModelAsyncClient.putNested": "Cadl.Model.ModelOp.putNested", + "com.cadl.model.ModelAsyncClient.putNestedWithResponse": "Cadl.Model.ModelOp.putNested", + "com.cadl.model.ModelClient": "null", + "com.cadl.model.ModelClient.get3": "Cadl.Model.ModelOp.get3", + "com.cadl.model.ModelClient.get3WithResponse": "Cadl.Model.ModelOp.get3", + "com.cadl.model.ModelClient.put1": "Cadl.Model.ModelOp.put1", + "com.cadl.model.ModelClient.put1WithResponse": "Cadl.Model.ModelOp.put1", + "com.cadl.model.ModelClient.put2": "Cadl.Model.ModelOp.put2", + "com.cadl.model.ModelClient.put2WithResponse": "Cadl.Model.ModelOp.put2", + "com.cadl.model.ModelClient.putNested": "Cadl.Model.ModelOp.putNested", + "com.cadl.model.ModelClient.putNestedWithResponse": "Cadl.Model.ModelOp.putNested", + "com.cadl.model.ModelClientBuilder": "Cadl.Model", + "com.cadl.model.models.InputOutputData2": "Cadl.Model.InputOutputData2", + "com.cadl.model.models.NestedModel": "Cadl.Model.NestedModel", + "com.cadl.model.models.NestedModel1": "Cadl.Model.NestedModel1", + "com.cadl.model.models.NestedModel2": "Cadl.Model.NestedModel2", + "com.cadl.model.models.OutputData": "Cadl.Model.OutputData", + "com.cadl.model.models.OutputData3": "Cadl.Model.OutputData3", + "com.cadl.model.models.Resource1": "Cadl.Model.Resource1", + "com.cadl.model.models.Resource2": "Cadl.Model.Resource2", + "com.cadl.model.models.Resource3": "Cadl.Model.Resource3" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json new file mode 100644 index 000000000..4577e1de5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multicontenttypes_apiview_properties.json @@ -0,0 +1,25 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.multicontenttypes.MultiContentTypesAsyncClient": "Cadl.MultiContentTypes", + "com.cadl.multicontenttypes.MultiContentTypesClient": "Cadl.MultiContentTypes", + "com.cadl.multicontenttypes.MultiContentTypesClientBuilder": "Cadl.MultiContentTypes", + "com.cadl.multicontenttypes.MultipleContentTypesOnRequestAsyncClient": "null", + "com.cadl.multicontenttypes.MultipleContentTypesOnRequestAsyncClient.uploadJsonWithMultiBodyTypesForMultiContentTypes": "Cadl.MultiContentTypes.MultipleContentTypesOnRequest.uploadJsonWithMultiBodyTypesForMultiContentTypes", + "com.cadl.multicontenttypes.MultipleContentTypesOnRequestAsyncClient.uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse": "Cadl.MultiContentTypes.MultipleContentTypesOnRequest.uploadJsonWithMultiBodyTypesForMultiContentTypes", + "com.cadl.multicontenttypes.MultipleContentTypesOnRequestClient": "null", + "com.cadl.multicontenttypes.MultipleContentTypesOnRequestClient.uploadJsonWithMultiBodyTypesForMultiContentTypes": "Cadl.MultiContentTypes.MultipleContentTypesOnRequest.uploadJsonWithMultiBodyTypesForMultiContentTypes", + "com.cadl.multicontenttypes.MultipleContentTypesOnRequestClient.uploadJsonWithMultiBodyTypesForMultiContentTypesWithResponse": "Cadl.MultiContentTypes.MultipleContentTypesOnRequest.uploadJsonWithMultiBodyTypesForMultiContentTypes", + "com.cadl.multicontenttypes.SingleContentTypeAsyncClient": "null", + "com.cadl.multicontenttypes.SingleContentTypeAsyncClient.downloadImageForSingleContentType": "Cadl.MultiContentTypes.SingleContentType.downloadImageForSingleContentType", + "com.cadl.multicontenttypes.SingleContentTypeAsyncClient.downloadImageForSingleContentTypeWithResponse": "Cadl.MultiContentTypes.SingleContentType.downloadImageForSingleContentType", + "com.cadl.multicontenttypes.SingleContentTypeAsyncClient.uploadImageForSingleContentType": "Cadl.MultiContentTypes.SingleContentType.uploadImageForSingleContentType", + "com.cadl.multicontenttypes.SingleContentTypeAsyncClient.uploadImageForSingleContentTypeWithResponse": "Cadl.MultiContentTypes.SingleContentType.uploadImageForSingleContentType", + "com.cadl.multicontenttypes.SingleContentTypeClient": "null", + "com.cadl.multicontenttypes.SingleContentTypeClient.downloadImageForSingleContentType": "Cadl.MultiContentTypes.SingleContentType.downloadImageForSingleContentType", + "com.cadl.multicontenttypes.SingleContentTypeClient.downloadImageForSingleContentTypeWithResponse": "Cadl.MultiContentTypes.SingleContentType.downloadImageForSingleContentType", + "com.cadl.multicontenttypes.SingleContentTypeClient.uploadImageForSingleContentType": "Cadl.MultiContentTypes.SingleContentType.uploadImageForSingleContentType", + "com.cadl.multicontenttypes.SingleContentTypeClient.uploadImageForSingleContentTypeWithResponse": "Cadl.MultiContentTypes.SingleContentType.uploadImageForSingleContentType", + "com.cadl.multicontenttypes.models.Resource": "Cadl.MultiContentTypes.Resource" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multipart_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multipart_apiview_properties.json new file mode 100644 index 000000000..7374df5a6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multipart_apiview_properties.json @@ -0,0 +1,24 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.multipart.MultipartAsyncClient": "Cadl.Multipart", + "com.cadl.multipart.MultipartAsyncClient.upload": "Cadl.Multipart.upload", + "com.cadl.multipart.MultipartAsyncClient.uploadHttpPart": "Cadl.Multipart.uploadHttpPart", + "com.cadl.multipart.MultipartAsyncClient.uploadHttpPartWithResponse": "Cadl.Multipart.uploadHttpPart", + "com.cadl.multipart.MultipartAsyncClient.uploadWithResponse": "Cadl.Multipart.upload", + "com.cadl.multipart.MultipartClient": "Cadl.Multipart", + "com.cadl.multipart.MultipartClient.upload": "Cadl.Multipart.upload", + "com.cadl.multipart.MultipartClient.uploadHttpPart": "Cadl.Multipart.uploadHttpPart", + "com.cadl.multipart.MultipartClient.uploadHttpPartWithResponse": "Cadl.Multipart.uploadHttpPart", + "com.cadl.multipart.MultipartClient.uploadWithResponse": "Cadl.Multipart.upload", + "com.cadl.multipart.MultipartClientBuilder": "Cadl.Multipart", + "com.cadl.multipart.models.FileDataFileDetails": "null", + "com.cadl.multipart.models.FileDetails": "TypeSpec.Http.File", + "com.cadl.multipart.models.FormData": "Cadl.Multipart.FormData", + "com.cadl.multipart.models.ImageFileDetails": "null", + "com.cadl.multipart.models.ImageType": "Cadl.Multipart.ImageType", + "com.cadl.multipart.models.InheritFileData": "Cadl.Multipart.Inherit2File", + "com.cadl.multipart.models.Size": "Cadl.Multipart.Size", + "com.cadl.multipart.models.UploadHttpPartRequest": "Cadl.Multipart.uploadHttpPart.Request.anonymous" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multipleapiversion_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multipleapiversion_apiview_properties.json new file mode 100644 index 000000000..8544e9bc6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-multipleapiversion_apiview_properties.json @@ -0,0 +1,28 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.multipleapiversion.FirstAsyncClient": "Cadl.MultipleApiVersion", + "com.cadl.multipleapiversion.FirstAsyncClient.get": "Cadl.MultipleApiVersion.Client.get", + "com.cadl.multipleapiversion.FirstAsyncClient.getWithResponse": "Cadl.MultipleApiVersion.Client.get", + "com.cadl.multipleapiversion.FirstClient": "Cadl.MultipleApiVersion", + "com.cadl.multipleapiversion.FirstClient.get": "Cadl.MultipleApiVersion.Client.get", + "com.cadl.multipleapiversion.FirstClient.getWithResponse": "Cadl.MultipleApiVersion.Client.get", + "com.cadl.multipleapiversion.FirstClientBuilder": "Cadl.MultipleApiVersion", + "com.cadl.multipleapiversion.NoApiVersionAsyncClient": "Cadl.MultipleApiVersion3", + "com.cadl.multipleapiversion.NoApiVersionAsyncClient.action": "Cadl.MultipleApiVersion3.Client.action", + "com.cadl.multipleapiversion.NoApiVersionAsyncClient.actionWithResponse": "Cadl.MultipleApiVersion3.Client.action", + "com.cadl.multipleapiversion.NoApiVersionClient": "Cadl.MultipleApiVersion3", + "com.cadl.multipleapiversion.NoApiVersionClient.action": "Cadl.MultipleApiVersion3.Client.action", + "com.cadl.multipleapiversion.NoApiVersionClient.actionWithResponse": "Cadl.MultipleApiVersion3.Client.action", + "com.cadl.multipleapiversion.NoApiVersionClientBuilder": "Cadl.MultipleApiVersion3", + "com.cadl.multipleapiversion.SecondAsyncClient": "Cadl.MultipleApiVersion2", + "com.cadl.multipleapiversion.SecondAsyncClient.get": "Cadl.MultipleApiVersion2.Client.get", + "com.cadl.multipleapiversion.SecondAsyncClient.getWithResponse": "Cadl.MultipleApiVersion2.Client.get", + "com.cadl.multipleapiversion.SecondClient": "Cadl.MultipleApiVersion2", + "com.cadl.multipleapiversion.SecondClient.get": "Cadl.MultipleApiVersion2.Client.get", + "com.cadl.multipleapiversion.SecondClient.getWithResponse": "Cadl.MultipleApiVersion2.Client.get", + "com.cadl.multipleapiversion.SecondClientBuilder": "Cadl.MultipleApiVersion2", + "com.cadl.multipleapiversion.models.Resource": "Cadl.MultipleApiVersion.Resource", + "com.cadl.multipleapiversion.models.Resource2": "Cadl.MultipleApiVersion2.Resource2" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-naming_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-naming_apiview_properties.json new file mode 100644 index 000000000..019e25088 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-naming_apiview_properties.json @@ -0,0 +1,29 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.naming.NamingAsyncClient": "null", + "com.cadl.naming.NamingAsyncClient.getAnonymous": "Cadl.Naming.NamingOp.getAnonymous", + "com.cadl.naming.NamingAsyncClient.getAnonymousWithResponse": "Cadl.Naming.NamingOp.getAnonymous", + "com.cadl.naming.NamingAsyncClient.post": "Cadl.Naming.NamingOp.post", + "com.cadl.naming.NamingAsyncClient.postWithResponse": "Cadl.Naming.NamingOp.post", + "com.cadl.naming.NamingClient": "null", + "com.cadl.naming.NamingClient.getAnonymous": "Cadl.Naming.NamingOp.getAnonymous", + "com.cadl.naming.NamingClient.getAnonymousWithResponse": "Cadl.Naming.NamingOp.getAnonymous", + "com.cadl.naming.NamingClient.post": "Cadl.Naming.NamingOp.post", + "com.cadl.naming.NamingClient.postWithResponse": "Cadl.Naming.NamingOp.post", + "com.cadl.naming.NamingClientBuilder": "Cadl.Naming", + "com.cadl.naming.models.BinaryData": "Cadl.Naming.DataModel", + "com.cadl.naming.models.BytesData": "Cadl.Naming.BytesData", + "com.cadl.naming.models.Data": "Cadl.Naming.Data", + "com.cadl.naming.models.DataRequest": "Cadl.Naming.Request", + "com.cadl.naming.models.DataResponse": "Cadl.Naming.Response", + "com.cadl.naming.models.DataStatus": "Cadl.Naming.StatusModel", + "com.cadl.naming.models.GetAnonymousResponse": "Cadl.Naming.getAnonymous.Response.anonymous", + "com.cadl.naming.models.RequestParameters": "Cadl.Naming.Request.parameters.anonymous", + "com.cadl.naming.models.RequestParametersType": "Request.parameters.type.anonymous", + "com.cadl.naming.models.RunObject": "Cadl.Naming.RunObject", + "com.cadl.naming.models.RunObjectLastError": "Cadl.Naming.RunObject.last_error.anonymous", + "com.cadl.naming.models.RunObjectLastErrorCode": "RunObject.last_error.code.anonymous", + "com.cadl.naming.models.TypesModel": "Cadl.Naming.TypesModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-optional_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-optional_apiview_properties.json new file mode 100644 index 000000000..fa016c9cd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-optional_apiview_properties.json @@ -0,0 +1,15 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.optional.OptionalAsyncClient": "null", + "com.cadl.optional.OptionalAsyncClient.put": "Cadl.Optional.OptionalOp.put", + "com.cadl.optional.OptionalAsyncClient.putWithResponse": "Cadl.Optional.OptionalOp.put", + "com.cadl.optional.OptionalClient": "null", + "com.cadl.optional.OptionalClient.put": "Cadl.Optional.OptionalOp.put", + "com.cadl.optional.OptionalClient.putWithResponse": "Cadl.Optional.OptionalOp.put", + "com.cadl.optional.OptionalClientBuilder": "Cadl.Optional", + "com.cadl.optional.models.AllPropertiesOptional": "Cadl.Optional.AllPropertiesOptional", + "com.cadl.optional.models.ImmutableModel": "Cadl.Optional.Immutable", + "com.cadl.optional.models.Optional": "Cadl.Optional.Optional" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-patch_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-patch_apiview_properties.json new file mode 100644 index 000000000..3c8bcd687 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-patch_apiview_properties.json @@ -0,0 +1,27 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.patch.PatchAsyncClient": "null", + "com.cadl.patch.PatchAsyncClient.createOrUpdateFish": "Cadl.Patch.Patch.createOrUpdateFish", + "com.cadl.patch.PatchAsyncClient.createOrUpdateFishWithResponse": "Cadl.Patch.Patch.createOrUpdateFish", + "com.cadl.patch.PatchAsyncClient.createOrUpdateOptionalResource": "Cadl.Patch.Patch.createOrUpdateOptionalResource", + "com.cadl.patch.PatchAsyncClient.createOrUpdateOptionalResourceWithResponse": "Cadl.Patch.Patch.createOrUpdateOptionalResource", + "com.cadl.patch.PatchAsyncClient.createOrUpdateResource": "Cadl.Patch.Patch.createOrUpdateResource", + "com.cadl.patch.PatchAsyncClient.createOrUpdateResourceWithResponse": "Cadl.Patch.Patch.createOrUpdateResource", + "com.cadl.patch.PatchClient": "null", + "com.cadl.patch.PatchClient.createOrUpdateFish": "Cadl.Patch.Patch.createOrUpdateFish", + "com.cadl.patch.PatchClient.createOrUpdateFishWithResponse": "Cadl.Patch.Patch.createOrUpdateFish", + "com.cadl.patch.PatchClient.createOrUpdateOptionalResource": "Cadl.Patch.Patch.createOrUpdateOptionalResource", + "com.cadl.patch.PatchClient.createOrUpdateOptionalResourceWithResponse": "Cadl.Patch.Patch.createOrUpdateOptionalResource", + "com.cadl.patch.PatchClient.createOrUpdateResource": "Cadl.Patch.Patch.createOrUpdateResource", + "com.cadl.patch.PatchClient.createOrUpdateResourceWithResponse": "Cadl.Patch.Patch.createOrUpdateResource", + "com.cadl.patch.PatchClientBuilder": "Cadl.Patch", + "com.cadl.patch.models.Fish": "Cadl.Patch.Fish", + "com.cadl.patch.models.InnerModel": "Cadl.Patch.InnerModel", + "com.cadl.patch.models.Resource": "Cadl.Patch.Resource", + "com.cadl.patch.models.ResourceEnumValue": "Resource.enumValue.anonymous", + "com.cadl.patch.models.Salmon": "Cadl.Patch.Salmon", + "com.cadl.patch.models.SawShark": "Cadl.Patch.SawShark", + "com.cadl.patch.models.Shark": "Cadl.Patch.Shark" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json new file mode 100644 index 000000000..f83ed0baa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-protocolandconvenient_apiview_properties.json @@ -0,0 +1,28 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient": "null", + "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.beginCreateOrReplace": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.createOrReplace", + "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.beginCreateOrReplaceWithModel": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.createOrReplace", + "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.bothConvenientAndProtocol": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.bothConvenientAndProtocol", + "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.bothConvenientAndProtocolWithResponse": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.bothConvenientAndProtocol", + "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.list": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.list", + "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.onlyConvenient": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.onlyConvenient", + "com.cadl.protocolandconvenient.ProtocolAndConvenientAsyncClient.onlyConvenientWithResponse": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.onlyConvenient", + "com.cadl.protocolandconvenient.ProtocolAndConvenientClient": "null", + "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.beginCreateOrReplace": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.createOrReplace", + "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.beginCreateOrReplaceWithModel": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.createOrReplace", + "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.bothConvenientAndProtocol": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.bothConvenientAndProtocol", + "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.bothConvenientAndProtocolWithResponse": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.bothConvenientAndProtocol", + "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.list": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.list", + "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.onlyConvenient": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.onlyConvenient", + "com.cadl.protocolandconvenient.ProtocolAndConvenientClient.onlyConvenientWithResponse": "Cadl.ProtocolAndConvenient.ProtocolAndConvenienceOp.onlyConvenient", + "com.cadl.protocolandconvenient.ProtocolAndConvenientClientBuilder": "Cadl.ProtocolAndConvenient", + "com.cadl.protocolandconvenient.models.ResourceA": "Cadl.ProtocolAndConvenient.ResourceA", + "com.cadl.protocolandconvenient.models.ResourceB": "Cadl.ProtocolAndConvenient.ResourceB", + "com.cadl.protocolandconvenient.models.ResourceE": "Cadl.ProtocolAndConvenient.ResourceE", + "com.cadl.protocolandconvenient.models.ResourceF": "Cadl.ProtocolAndConvenient.ResourceF", + "com.cadl.protocolandconvenient.models.ResourceI": "Cadl.ProtocolAndConvenient.ResourceI", + "com.cadl.protocolandconvenient.models.ResourceJ": "Cadl.ProtocolAndConvenient.ResourceJ" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-response_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-response_apiview_properties.json new file mode 100644 index 000000000..d6fdab21e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-response_apiview_properties.json @@ -0,0 +1,56 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.response.ResponseAsyncClient": "Cadl.Response.ResponseOp", + "com.cadl.response.ResponseAsyncClient.beginLroInvalidPollResponse": "Cadl.Response.ResponseOp.lroInvalidPollResponse", + "com.cadl.response.ResponseAsyncClient.beginLroInvalidPollResponseWithModel": "Cadl.Response.ResponseOp.lroInvalidPollResponse", + "com.cadl.response.ResponseAsyncClient.beginLroInvalidResult": "Cadl.Response.ResponseOp.lroInvalidResult", + "com.cadl.response.ResponseAsyncClient.beginLroInvalidResultWithModel": "Cadl.Response.ResponseOp.lroInvalidResult", + "com.cadl.response.ResponseAsyncClient.createWithHeaders": "Cadl.Response.ResponseOp.createWithHeaders", + "com.cadl.response.ResponseAsyncClient.createWithHeadersWithResponse": "Cadl.Response.ResponseOp.createWithHeaders", + "com.cadl.response.ResponseAsyncClient.deleteWithHeaders": "Cadl.Response.ResponseOp.deleteWithHeaders", + "com.cadl.response.ResponseAsyncClient.deleteWithHeadersWithResponse": "Cadl.Response.ResponseOp.deleteWithHeaders", + "com.cadl.response.ResponseAsyncClient.exists": "Cadl.Response.ResponseOp.exists", + "com.cadl.response.ResponseAsyncClient.existsWithResponse": "Cadl.Response.ResponseOp.exists", + "com.cadl.response.ResponseAsyncClient.getAnotherArray": "Cadl.Response.ResponseOp.getAnotherArray", + "com.cadl.response.ResponseAsyncClient.getAnotherArrayWithResponse": "Cadl.Response.ResponseOp.getAnotherArray", + "com.cadl.response.ResponseAsyncClient.getArray": "Cadl.Response.ResponseOp.getArray", + "com.cadl.response.ResponseAsyncClient.getArrayWithResponse": "Cadl.Response.ResponseOp.getArray", + "com.cadl.response.ResponseAsyncClient.getBinary": "Cadl.Response.ResponseOp.getBinary", + "com.cadl.response.ResponseAsyncClient.getBinaryWithResponse": "Cadl.Response.ResponseOp.getBinary", + "com.cadl.response.ResponseAsyncClient.getJsonUtf8Response": "Cadl.Response.ResponseOp.getJsonUtf8Response", + "com.cadl.response.ResponseAsyncClient.getJsonUtf8ResponseWithResponse": "Cadl.Response.ResponseOp.getJsonUtf8Response", + "com.cadl.response.ResponseAsyncClient.getPlusJsonResponse": "Cadl.Response.ResponseOp.getPlusJsonResponse", + "com.cadl.response.ResponseAsyncClient.getPlusJsonResponseWithResponse": "Cadl.Response.ResponseOp.getPlusJsonResponse", + "com.cadl.response.ResponseAsyncClient.listIntegers": "Cadl.Response.ResponseOp.listIntegers", + "com.cadl.response.ResponseAsyncClient.listStrings": "Cadl.Response.ResponseOp.listStrings", + "com.cadl.response.ResponseClient": "Cadl.Response.ResponseOp", + "com.cadl.response.ResponseClient.beginLroInvalidPollResponse": "Cadl.Response.ResponseOp.lroInvalidPollResponse", + "com.cadl.response.ResponseClient.beginLroInvalidPollResponseWithModel": "Cadl.Response.ResponseOp.lroInvalidPollResponse", + "com.cadl.response.ResponseClient.beginLroInvalidResult": "Cadl.Response.ResponseOp.lroInvalidResult", + "com.cadl.response.ResponseClient.beginLroInvalidResultWithModel": "Cadl.Response.ResponseOp.lroInvalidResult", + "com.cadl.response.ResponseClient.createWithHeaders": "Cadl.Response.ResponseOp.createWithHeaders", + "com.cadl.response.ResponseClient.createWithHeadersWithResponse": "Cadl.Response.ResponseOp.createWithHeaders", + "com.cadl.response.ResponseClient.deleteWithHeaders": "Cadl.Response.ResponseOp.deleteWithHeaders", + "com.cadl.response.ResponseClient.deleteWithHeadersWithResponse": "Cadl.Response.ResponseOp.deleteWithHeaders", + "com.cadl.response.ResponseClient.exists": "Cadl.Response.ResponseOp.exists", + "com.cadl.response.ResponseClient.existsWithResponse": "Cadl.Response.ResponseOp.exists", + "com.cadl.response.ResponseClient.getAnotherArray": "Cadl.Response.ResponseOp.getAnotherArray", + "com.cadl.response.ResponseClient.getAnotherArrayWithResponse": "Cadl.Response.ResponseOp.getAnotherArray", + "com.cadl.response.ResponseClient.getArray": "Cadl.Response.ResponseOp.getArray", + "com.cadl.response.ResponseClient.getArrayWithResponse": "Cadl.Response.ResponseOp.getArray", + "com.cadl.response.ResponseClient.getBinary": "Cadl.Response.ResponseOp.getBinary", + "com.cadl.response.ResponseClient.getBinaryWithResponse": "Cadl.Response.ResponseOp.getBinary", + "com.cadl.response.ResponseClient.getJsonUtf8Response": "Cadl.Response.ResponseOp.getJsonUtf8Response", + "com.cadl.response.ResponseClient.getJsonUtf8ResponseWithResponse": "Cadl.Response.ResponseOp.getJsonUtf8Response", + "com.cadl.response.ResponseClient.getPlusJsonResponse": "Cadl.Response.ResponseOp.getPlusJsonResponse", + "com.cadl.response.ResponseClient.getPlusJsonResponseWithResponse": "Cadl.Response.ResponseOp.getPlusJsonResponse", + "com.cadl.response.ResponseClient.listIntegers": "Cadl.Response.ResponseOp.listIntegers", + "com.cadl.response.ResponseClient.listStrings": "Cadl.Response.ResponseOp.listStrings", + "com.cadl.response.ResponseClientBuilder": "Cadl.Response.ResponseOp", + "com.cadl.response.models.OperationDetails1": "Cadl.Response.OperationDetails1", + "com.cadl.response.models.OperationDetails2": "Cadl.Response.OperationDetails2", + "com.cadl.response.models.OperationState": "Azure.Core.Foundations.OperationState", + "com.cadl.response.models.Resource": "Cadl.Response.Resource" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-server_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-server_apiview_properties.json new file mode 100644 index 000000000..6ed667c8a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-server_apiview_properties.json @@ -0,0 +1,19 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.server.HttpbinAsyncClient": "Cadl.Server.ServerOp", + "com.cadl.server.HttpbinAsyncClient.status": "Cadl.Server.ServerOp.status", + "com.cadl.server.HttpbinAsyncClient.statusWithResponse": "Cadl.Server.ServerOp.status", + "com.cadl.server.HttpbinClient": "Cadl.Server.ServerOp", + "com.cadl.server.HttpbinClient.status": "Cadl.Server.ServerOp.status", + "com.cadl.server.HttpbinClient.statusWithResponse": "Cadl.Server.ServerOp.status", + "com.cadl.server.HttpbinClientBuilder": "Cadl.Server.ServerOp", + "com.cadl.server.contoso.sub.ContosoAsyncClient": "Cadl.ContosoServer.ServerOp", + "com.cadl.server.contoso.sub.ContosoAsyncClient.get": "Cadl.ContosoServer.ServerOp.get", + "com.cadl.server.contoso.sub.ContosoAsyncClient.getWithResponse": "Cadl.ContosoServer.ServerOp.get", + "com.cadl.server.contoso.sub.ContosoClient": "Cadl.ContosoServer.ServerOp", + "com.cadl.server.contoso.sub.ContosoClient.get": "Cadl.ContosoServer.ServerOp.get", + "com.cadl.server.contoso.sub.ContosoClient.getWithResponse": "Cadl.ContosoServer.ServerOp.get", + "com.cadl.server.contoso.sub.ContosoClientBuilder": "Cadl.ContosoServer.ServerOp" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialchars_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialchars_apiview_properties.json new file mode 100644 index 000000000..334a42742 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialchars_apiview_properties.json @@ -0,0 +1,14 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.specialchars.SpecialCharsAsyncClient": "null", + "com.cadl.specialchars.SpecialCharsAsyncClient.read": "Cadl.SpecialChars.BuiltinOp.read", + "com.cadl.specialchars.SpecialCharsAsyncClient.readWithResponse": "Cadl.SpecialChars.BuiltinOp.read", + "com.cadl.specialchars.SpecialCharsClient": "null", + "com.cadl.specialchars.SpecialCharsClient.read": "Cadl.SpecialChars.BuiltinOp.read", + "com.cadl.specialchars.SpecialCharsClient.readWithResponse": "Cadl.SpecialChars.BuiltinOp.read", + "com.cadl.specialchars.SpecialCharsClientBuilder": "Cadl.SpecialChars", + "com.cadl.specialchars.implementation.models.ReadRequest": "Cadl.SpecialChars.read.Request.anonymous", + "com.cadl.specialchars.models.Resource": "Cadl.SpecialChars.Resource" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialheaders_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialheaders_apiview_properties.json new file mode 100644 index 000000000..58e3376a2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-specialheaders_apiview_properties.json @@ -0,0 +1,49 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.specialheaders.EtagHeadersAsyncClient": "null", + "com.cadl.specialheaders.EtagHeadersAsyncClient.listWithEtag": "Cadl.SpecialHeaders.EtagHeaders.listWithEtag", + "com.cadl.specialheaders.EtagHeadersAsyncClient.patchWithMatchHeaders": "Cadl.SpecialHeaders.EtagHeaders.patchWithMatchHeaders", + "com.cadl.specialheaders.EtagHeadersAsyncClient.patchWithMatchHeadersWithResponse": "Cadl.SpecialHeaders.EtagHeaders.patchWithMatchHeaders", + "com.cadl.specialheaders.EtagHeadersAsyncClient.putWithRequestHeaders": "Cadl.SpecialHeaders.EtagHeaders.putWithRequestHeaders", + "com.cadl.specialheaders.EtagHeadersAsyncClient.putWithRequestHeadersWithResponse": "Cadl.SpecialHeaders.EtagHeaders.putWithRequestHeaders", + "com.cadl.specialheaders.EtagHeadersClient": "null", + "com.cadl.specialheaders.EtagHeadersClient.listWithEtag": "Cadl.SpecialHeaders.EtagHeaders.listWithEtag", + "com.cadl.specialheaders.EtagHeadersClient.patchWithMatchHeaders": "Cadl.SpecialHeaders.EtagHeaders.patchWithMatchHeaders", + "com.cadl.specialheaders.EtagHeadersClient.patchWithMatchHeadersWithResponse": "Cadl.SpecialHeaders.EtagHeaders.patchWithMatchHeaders", + "com.cadl.specialheaders.EtagHeadersClient.putWithRequestHeaders": "Cadl.SpecialHeaders.EtagHeaders.putWithRequestHeaders", + "com.cadl.specialheaders.EtagHeadersClient.putWithRequestHeadersWithResponse": "Cadl.SpecialHeaders.EtagHeaders.putWithRequestHeaders", + "com.cadl.specialheaders.EtagHeadersOptionalBodyAsyncClient": "null", + "com.cadl.specialheaders.EtagHeadersOptionalBodyAsyncClient.putWithOptionalBody": "Cadl.SpecialHeaders.EtagHeadersOptionalBody.putWithOptionalBody", + "com.cadl.specialheaders.EtagHeadersOptionalBodyAsyncClient.putWithOptionalBodyWithResponse": "Cadl.SpecialHeaders.EtagHeadersOptionalBody.putWithOptionalBody", + "com.cadl.specialheaders.EtagHeadersOptionalBodyClient": "null", + "com.cadl.specialheaders.EtagHeadersOptionalBodyClient.putWithOptionalBody": "Cadl.SpecialHeaders.EtagHeadersOptionalBody.putWithOptionalBody", + "com.cadl.specialheaders.EtagHeadersOptionalBodyClient.putWithOptionalBodyWithResponse": "Cadl.SpecialHeaders.EtagHeadersOptionalBody.putWithOptionalBody", + "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient": "null", + "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.beginCreateLro": "Cadl.SpecialHeaders.RepeatabilityHeaders.createLro", + "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.beginCreateLroWithModel": "Cadl.SpecialHeaders.RepeatabilityHeaders.createLro", + "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.get": "Cadl.SpecialHeaders.RepeatabilityHeaders.get", + "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.getWithResponse": "Cadl.SpecialHeaders.RepeatabilityHeaders.get", + "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.post": "Cadl.SpecialHeaders.RepeatabilityHeaders.post", + "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.postWithResponse": "Cadl.SpecialHeaders.RepeatabilityHeaders.post", + "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.put": "Cadl.SpecialHeaders.RepeatabilityHeaders.put", + "com.cadl.specialheaders.RepeatabilityHeadersAsyncClient.putWithResponse": "Cadl.SpecialHeaders.RepeatabilityHeaders.put", + "com.cadl.specialheaders.RepeatabilityHeadersClient": "null", + "com.cadl.specialheaders.RepeatabilityHeadersClient.beginCreateLro": "Cadl.SpecialHeaders.RepeatabilityHeaders.createLro", + "com.cadl.specialheaders.RepeatabilityHeadersClient.beginCreateLroWithModel": "Cadl.SpecialHeaders.RepeatabilityHeaders.createLro", + "com.cadl.specialheaders.RepeatabilityHeadersClient.get": "Cadl.SpecialHeaders.RepeatabilityHeaders.get", + "com.cadl.specialheaders.RepeatabilityHeadersClient.getWithResponse": "Cadl.SpecialHeaders.RepeatabilityHeaders.get", + "com.cadl.specialheaders.RepeatabilityHeadersClient.post": "Cadl.SpecialHeaders.RepeatabilityHeaders.post", + "com.cadl.specialheaders.RepeatabilityHeadersClient.postWithResponse": "Cadl.SpecialHeaders.RepeatabilityHeaders.post", + "com.cadl.specialheaders.RepeatabilityHeadersClient.put": "Cadl.SpecialHeaders.RepeatabilityHeaders.put", + "com.cadl.specialheaders.RepeatabilityHeadersClient.putWithResponse": "Cadl.SpecialHeaders.RepeatabilityHeaders.put", + "com.cadl.specialheaders.SkipSpecialHeadersAsyncClient": "null", + "com.cadl.specialheaders.SkipSpecialHeadersAsyncClient.deleteWithSpecialHeaders": "Cadl.SpecialHeaders.SkipSpecialHeaders.deleteWithSpecialHeaders", + "com.cadl.specialheaders.SkipSpecialHeadersAsyncClient.deleteWithSpecialHeadersWithResponse": "Cadl.SpecialHeaders.SkipSpecialHeaders.deleteWithSpecialHeaders", + "com.cadl.specialheaders.SkipSpecialHeadersClient": "null", + "com.cadl.specialheaders.SkipSpecialHeadersClient.deleteWithSpecialHeaders": "Cadl.SpecialHeaders.SkipSpecialHeaders.deleteWithSpecialHeaders", + "com.cadl.specialheaders.SkipSpecialHeadersClient.deleteWithSpecialHeadersWithResponse": "Cadl.SpecialHeaders.SkipSpecialHeaders.deleteWithSpecialHeaders", + "com.cadl.specialheaders.SpecialHeadersClientBuilder": "Cadl.SpecialHeaders", + "com.cadl.specialheaders.models.Resource": "Cadl.SpecialHeaders.Resource" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-union_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-union_apiview_properties.json new file mode 100644 index 000000000..6c2e36840 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-union_apiview_properties.json @@ -0,0 +1,31 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.union.UnionAsyncClient": "null", + "com.cadl.union.UnionAsyncClient.beginGenerate": "Cadl.Union.UnionFlattenOp.generate", + "com.cadl.union.UnionAsyncClient.beginGenerateWithModel": "Cadl.Union.UnionFlattenOp.generate", + "com.cadl.union.UnionAsyncClient.get": "Cadl.Union.UnionFlattenOp.get", + "com.cadl.union.UnionAsyncClient.getWithResponse": "Cadl.Union.UnionFlattenOp.get", + "com.cadl.union.UnionAsyncClient.send": "Cadl.Union.UnionFlattenOp.send", + "com.cadl.union.UnionAsyncClient.sendLong": "Cadl.Union.UnionFlattenOp.sendLong", + "com.cadl.union.UnionAsyncClient.sendLongWithResponse": "Cadl.Union.UnionFlattenOp.sendLong", + "com.cadl.union.UnionAsyncClient.sendWithResponse": "Cadl.Union.UnionFlattenOp.send", + "com.cadl.union.UnionClient": "null", + "com.cadl.union.UnionClient.beginGenerate": "Cadl.Union.UnionFlattenOp.generate", + "com.cadl.union.UnionClient.beginGenerateWithModel": "Cadl.Union.UnionFlattenOp.generate", + "com.cadl.union.UnionClient.get": "Cadl.Union.UnionFlattenOp.get", + "com.cadl.union.UnionClient.getWithResponse": "Cadl.Union.UnionFlattenOp.get", + "com.cadl.union.UnionClient.send": "Cadl.Union.UnionFlattenOp.send", + "com.cadl.union.UnionClient.sendLong": "Cadl.Union.UnionFlattenOp.sendLong", + "com.cadl.union.UnionClient.sendLongWithResponse": "Cadl.Union.UnionFlattenOp.sendLong", + "com.cadl.union.UnionClient.sendWithResponse": "Cadl.Union.UnionFlattenOp.send", + "com.cadl.union.UnionClientBuilder": "Cadl.Union", + "com.cadl.union.implementation.models.SendLongRequest": "sendLong.Request.anonymous", + "com.cadl.union.implementation.models.SendRequest": "send.Request.anonymous", + "com.cadl.union.implementation.models.SubResult": "Cadl.Union.SubResult", + "com.cadl.union.models.ArrayData": "Cadl.Union.ArrayData", + "com.cadl.union.models.Result": "Cadl.Union.Result", + "com.cadl.union.models.SendLongOptions": "null", + "com.cadl.union.models.User": "Cadl.Union.User" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-versioning_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-versioning_apiview_properties.json new file mode 100644 index 000000000..90dbdda49 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-versioning_apiview_properties.json @@ -0,0 +1,20 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.versioning.VersioningAsyncClient": "null", + "com.cadl.versioning.VersioningAsyncClient.beginCreateLongRunning": "Cadl.Versioning.VersioningOp.createLongRunning", + "com.cadl.versioning.VersioningAsyncClient.beginCreateLongRunningWithModel": "Cadl.Versioning.VersioningOp.createLongRunning", + "com.cadl.versioning.VersioningAsyncClient.beginExport": "Cadl.Versioning.VersioningOp.export", + "com.cadl.versioning.VersioningAsyncClient.beginExportWithModel": "Cadl.Versioning.VersioningOp.export", + "com.cadl.versioning.VersioningAsyncClient.list": "Cadl.Versioning.VersioningOp.list", + "com.cadl.versioning.VersioningClient": "null", + "com.cadl.versioning.VersioningClient.beginCreateLongRunning": "Cadl.Versioning.VersioningOp.createLongRunning", + "com.cadl.versioning.VersioningClient.beginCreateLongRunningWithModel": "Cadl.Versioning.VersioningOp.createLongRunning", + "com.cadl.versioning.VersioningClient.beginExport": "Cadl.Versioning.VersioningOp.export", + "com.cadl.versioning.VersioningClient.beginExportWithModel": "Cadl.Versioning.VersioningOp.export", + "com.cadl.versioning.VersioningClient.list": "Cadl.Versioning.VersioningOp.list", + "com.cadl.versioning.VersioningClientBuilder": "Cadl.Versioning", + "com.cadl.versioning.models.ExportedResource": "Cadl.Versioning.ExportedResource", + "com.cadl.versioning.models.Resource": "Cadl.Versioning.Resource" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-visibility_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-visibility_apiview_properties.json new file mode 100644 index 000000000..4fd3d614c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-visibility_apiview_properties.json @@ -0,0 +1,40 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.visibility.VisibilityAsyncClient": "Cadl.Visibility", + "com.cadl.visibility.VisibilityAsyncClient.create": "Cadl.Visibility.VisibilityOp.create", + "com.cadl.visibility.VisibilityAsyncClient.createWithResponse": "Cadl.Visibility.VisibilityOp.create", + "com.cadl.visibility.VisibilityAsyncClient.get": "Cadl.Visibility.VisibilityOp.get", + "com.cadl.visibility.VisibilityAsyncClient.getWithResponse": "Cadl.Visibility.VisibilityOp.get", + "com.cadl.visibility.VisibilityAsyncClient.query": "Cadl.Visibility.VisibilityOp.query", + "com.cadl.visibility.VisibilityAsyncClient.queryWithResponse": "Cadl.Visibility.VisibilityOp.query", + "com.cadl.visibility.VisibilityAsyncClient.roundtrip": "Cadl.Visibility.VisibilityOp.roundtrip", + "com.cadl.visibility.VisibilityAsyncClient.roundtripWithResponse": "Cadl.Visibility.VisibilityOp.roundtrip", + "com.cadl.visibility.VisibilityClient": "Cadl.Visibility", + "com.cadl.visibility.VisibilityClient.create": "Cadl.Visibility.VisibilityOp.create", + "com.cadl.visibility.VisibilityClient.createWithResponse": "Cadl.Visibility.VisibilityOp.create", + "com.cadl.visibility.VisibilityClient.get": "Cadl.Visibility.VisibilityOp.get", + "com.cadl.visibility.VisibilityClient.getWithResponse": "Cadl.Visibility.VisibilityOp.get", + "com.cadl.visibility.VisibilityClient.query": "Cadl.Visibility.VisibilityOp.query", + "com.cadl.visibility.VisibilityClient.queryWithResponse": "Cadl.Visibility.VisibilityOp.query", + "com.cadl.visibility.VisibilityClient.roundtrip": "Cadl.Visibility.VisibilityOp.roundtrip", + "com.cadl.visibility.VisibilityClient.roundtripWithResponse": "Cadl.Visibility.VisibilityOp.roundtrip", + "com.cadl.visibility.VisibilityClientBuilder": "Cadl.Visibility", + "com.cadl.visibility.VisibilityReadAsyncClient": "null", + "com.cadl.visibility.VisibilityReadAsyncClient.get": "Cadl.Visibility.VisibilityRead.get", + "com.cadl.visibility.VisibilityReadAsyncClient.getWithResponse": "Cadl.Visibility.VisibilityRead.get", + "com.cadl.visibility.VisibilityReadClient": "null", + "com.cadl.visibility.VisibilityReadClient.get": "Cadl.Visibility.VisibilityRead.get", + "com.cadl.visibility.VisibilityReadClient.getWithResponse": "Cadl.Visibility.VisibilityRead.get", + "com.cadl.visibility.VisibilityWriteAsyncClient": "null", + "com.cadl.visibility.VisibilityWriteAsyncClient.create": "Cadl.Visibility.VisibilityWrite.create", + "com.cadl.visibility.VisibilityWriteAsyncClient.createWithResponse": "Cadl.Visibility.VisibilityWrite.create", + "com.cadl.visibility.VisibilityWriteClient": "null", + "com.cadl.visibility.VisibilityWriteClient.create": "Cadl.Visibility.VisibilityWrite.create", + "com.cadl.visibility.VisibilityWriteClient.createWithResponse": "Cadl.Visibility.VisibilityWrite.create", + "com.cadl.visibility.models.Dog": "Cadl.Visibility.Dog", + "com.cadl.visibility.models.ReadDog": "Cadl.Visibility.ReadDog", + "com.cadl.visibility.models.RoundTripModel": "Cadl.Visibility.RoundTripModel", + "com.cadl.visibility.models.WriteDog": "Cadl.Visibility.WriteDog" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-wiretype_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-wiretype_apiview_properties.json new file mode 100644 index 000000000..9ac2db13e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-wiretype_apiview_properties.json @@ -0,0 +1,25 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.wiretype.WireTypeAsyncClient": "null", + "com.cadl.wiretype.WireTypeAsyncClient.bothClassMismatch": "Cadl.WireType.WireTypeOp.bothClassMismatch", + "com.cadl.wiretype.WireTypeAsyncClient.bothClassMismatchWithResponse": "Cadl.WireType.WireTypeOp.bothClassMismatch", + "com.cadl.wiretype.WireTypeAsyncClient.subClassMismatch": "Cadl.WireType.WireTypeOp.subClassMismatch", + "com.cadl.wiretype.WireTypeAsyncClient.subClassMismatchWithResponse": "Cadl.WireType.WireTypeOp.subClassMismatch", + "com.cadl.wiretype.WireTypeAsyncClient.superClassMismatch": "Cadl.WireType.WireTypeOp.superClassMismatch", + "com.cadl.wiretype.WireTypeAsyncClient.superClassMismatchWithResponse": "Cadl.WireType.WireTypeOp.superClassMismatch", + "com.cadl.wiretype.WireTypeClient": "null", + "com.cadl.wiretype.WireTypeClient.bothClassMismatch": "Cadl.WireType.WireTypeOp.bothClassMismatch", + "com.cadl.wiretype.WireTypeClient.bothClassMismatchWithResponse": "Cadl.WireType.WireTypeOp.bothClassMismatch", + "com.cadl.wiretype.WireTypeClient.subClassMismatch": "Cadl.WireType.WireTypeOp.subClassMismatch", + "com.cadl.wiretype.WireTypeClient.subClassMismatchWithResponse": "Cadl.WireType.WireTypeOp.subClassMismatch", + "com.cadl.wiretype.WireTypeClient.superClassMismatch": "Cadl.WireType.WireTypeOp.superClassMismatch", + "com.cadl.wiretype.WireTypeClient.superClassMismatchWithResponse": "Cadl.WireType.WireTypeOp.superClassMismatch", + "com.cadl.wiretype.WireTypeClientBuilder": "Cadl.WireType", + "com.cadl.wiretype.models.SubClass": "Cadl.WireType.SubClass", + "com.cadl.wiretype.models.SubClassBothMismatch": "Cadl.WireType.SubClassBothMismatch", + "com.cadl.wiretype.models.SubClassMismatch": "Cadl.WireType.SubClassMismatch", + "com.cadl.wiretype.models.SuperClass": "Cadl.WireType.SuperClass", + "com.cadl.wiretype.models.SuperClassMismatch": "Cadl.WireType.SuperClassMismatch" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/client-naming_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/client-naming_apiview_properties.json new file mode 100644 index 000000000..7fc6c46c7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/client-naming_apiview_properties.json @@ -0,0 +1,63 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.client.naming.ClientModelAsyncClient": "null", + "com.client.naming.ClientModelAsyncClient.client": "Client.Naming.Model.client", + "com.client.naming.ClientModelAsyncClient.clientWithResponse": "Client.Naming.Model.client", + "com.client.naming.ClientModelAsyncClient.language": "Client.Naming.Model.language", + "com.client.naming.ClientModelAsyncClient.languageWithResponse": "Client.Naming.Model.language", + "com.client.naming.ClientModelClient": "null", + "com.client.naming.ClientModelClient.client": "Client.Naming.Model.client", + "com.client.naming.ClientModelClient.clientWithResponse": "Client.Naming.Model.client", + "com.client.naming.ClientModelClient.language": "Client.Naming.Model.language", + "com.client.naming.ClientModelClient.languageWithResponse": "Client.Naming.Model.language", + "com.client.naming.NamingAsyncClient": "Client.Naming", + "com.client.naming.NamingAsyncClient.client": "Client.Naming.Property.client", + "com.client.naming.NamingAsyncClient.clientName": "Client.Naming.operation", + "com.client.naming.NamingAsyncClient.clientNameWithResponse": "Client.Naming.operation", + "com.client.naming.NamingAsyncClient.clientWithResponse": "Client.Naming.Property.client", + "com.client.naming.NamingAsyncClient.compatibleWithEncodedName": "Client.Naming.Property.compatibleWithEncodedName", + "com.client.naming.NamingAsyncClient.compatibleWithEncodedNameWithResponse": "Client.Naming.Property.compatibleWithEncodedName", + "com.client.naming.NamingAsyncClient.language": "Client.Naming.Property.language", + "com.client.naming.NamingAsyncClient.languageWithResponse": "Client.Naming.Property.language", + "com.client.naming.NamingAsyncClient.parameter": "Client.Naming.parameter", + "com.client.naming.NamingAsyncClient.parameterWithResponse": "Client.Naming.parameter", + "com.client.naming.NamingAsyncClient.request": "Client.Naming.Header.request", + "com.client.naming.NamingAsyncClient.requestWithResponse": "Client.Naming.Header.request", + "com.client.naming.NamingAsyncClient.response": "Client.Naming.Header.response", + "com.client.naming.NamingAsyncClient.responseWithResponse": "Client.Naming.Header.response", + "com.client.naming.NamingClient": "Client.Naming", + "com.client.naming.NamingClient.client": "Client.Naming.Property.client", + "com.client.naming.NamingClient.clientName": "Client.Naming.operation", + "com.client.naming.NamingClient.clientNameWithResponse": "Client.Naming.operation", + "com.client.naming.NamingClient.clientWithResponse": "Client.Naming.Property.client", + "com.client.naming.NamingClient.compatibleWithEncodedName": "Client.Naming.Property.compatibleWithEncodedName", + "com.client.naming.NamingClient.compatibleWithEncodedNameWithResponse": "Client.Naming.Property.compatibleWithEncodedName", + "com.client.naming.NamingClient.language": "Client.Naming.Property.language", + "com.client.naming.NamingClient.languageWithResponse": "Client.Naming.Property.language", + "com.client.naming.NamingClient.parameter": "Client.Naming.parameter", + "com.client.naming.NamingClient.parameterWithResponse": "Client.Naming.parameter", + "com.client.naming.NamingClient.request": "Client.Naming.Header.request", + "com.client.naming.NamingClient.requestWithResponse": "Client.Naming.Header.request", + "com.client.naming.NamingClient.response": "Client.Naming.Header.response", + "com.client.naming.NamingClient.responseWithResponse": "Client.Naming.Header.response", + "com.client.naming.NamingClientBuilder": "Client.Naming", + "com.client.naming.UnionEnumAsyncClient": "null", + "com.client.naming.UnionEnumAsyncClient.unionEnumMemberName": "Client.Naming.UnionEnum.unionEnumMemberName", + "com.client.naming.UnionEnumAsyncClient.unionEnumMemberNameWithResponse": "Client.Naming.UnionEnum.unionEnumMemberName", + "com.client.naming.UnionEnumAsyncClient.unionEnumName": "Client.Naming.UnionEnum.unionEnumName", + "com.client.naming.UnionEnumAsyncClient.unionEnumNameWithResponse": "Client.Naming.UnionEnum.unionEnumName", + "com.client.naming.UnionEnumClient": "null", + "com.client.naming.UnionEnumClient.unionEnumMemberName": "Client.Naming.UnionEnum.unionEnumMemberName", + "com.client.naming.UnionEnumClient.unionEnumMemberNameWithResponse": "Client.Naming.UnionEnum.unionEnumMemberName", + "com.client.naming.UnionEnumClient.unionEnumName": "Client.Naming.UnionEnum.unionEnumName", + "com.client.naming.UnionEnumClient.unionEnumNameWithResponse": "Client.Naming.UnionEnum.unionEnumName", + "com.client.naming.models.ClientExtensibleEnum": "Client.Naming.UnionEnum.ServerExtensibleEnum", + "com.client.naming.models.ClientModel": "Client.Naming.Model.ModelWithClientClientName", + "com.client.naming.models.ClientNameAndJsonEncodedNameModel": "Client.Naming.Property.ClientNameAndJsonEncodedNameModel", + "com.client.naming.models.ClientNameModel": "Client.Naming.Property.ClientNameModel", + "com.client.naming.models.ExtensibleEnum": "Client.Naming.UnionEnum.ExtensibleEnum", + "com.client.naming.models.JavaModel": "Client.Naming.Model.ModelWithLanguageClientName", + "com.client.naming.models.LanguageClientNameModel": "Client.Naming.Property.LanguageClientNameModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/encode-bytes_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/encode-bytes_apiview_properties.json new file mode 100644 index 000000000..5d65e3b49 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/encode-bytes_apiview_properties.json @@ -0,0 +1,108 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.encode.bytes.BytesClientBuilder": "Encode.Bytes", + "com.encode.bytes.HeaderAsyncClient": "null", + "com.encode.bytes.HeaderAsyncClient.base64": "Encode.Bytes.Header.base64", + "com.encode.bytes.HeaderAsyncClient.base64WithResponse": "Encode.Bytes.Header.base64", + "com.encode.bytes.HeaderAsyncClient.base64url": "Encode.Bytes.Header.base64url", + "com.encode.bytes.HeaderAsyncClient.base64urlArray": "Encode.Bytes.Header.base64urlArray", + "com.encode.bytes.HeaderAsyncClient.base64urlArrayWithResponse": "Encode.Bytes.Header.base64urlArray", + "com.encode.bytes.HeaderAsyncClient.base64urlWithResponse": "Encode.Bytes.Header.base64url", + "com.encode.bytes.HeaderAsyncClient.defaultMethod": "Encode.Bytes.Header.default", + "com.encode.bytes.HeaderAsyncClient.defaultMethodWithResponse": "Encode.Bytes.Header.default", + "com.encode.bytes.HeaderClient": "null", + "com.encode.bytes.HeaderClient.base64": "Encode.Bytes.Header.base64", + "com.encode.bytes.HeaderClient.base64WithResponse": "Encode.Bytes.Header.base64", + "com.encode.bytes.HeaderClient.base64url": "Encode.Bytes.Header.base64url", + "com.encode.bytes.HeaderClient.base64urlArray": "Encode.Bytes.Header.base64urlArray", + "com.encode.bytes.HeaderClient.base64urlArrayWithResponse": "Encode.Bytes.Header.base64urlArray", + "com.encode.bytes.HeaderClient.base64urlWithResponse": "Encode.Bytes.Header.base64url", + "com.encode.bytes.HeaderClient.defaultMethod": "Encode.Bytes.Header.default", + "com.encode.bytes.HeaderClient.defaultMethodWithResponse": "Encode.Bytes.Header.default", + "com.encode.bytes.PropertyAsyncClient": "null", + "com.encode.bytes.PropertyAsyncClient.base64": "Encode.Bytes.Property.base64", + "com.encode.bytes.PropertyAsyncClient.base64WithResponse": "Encode.Bytes.Property.base64", + "com.encode.bytes.PropertyAsyncClient.base64url": "Encode.Bytes.Property.base64url", + "com.encode.bytes.PropertyAsyncClient.base64urlArray": "Encode.Bytes.Property.base64urlArray", + "com.encode.bytes.PropertyAsyncClient.base64urlArrayWithResponse": "Encode.Bytes.Property.base64urlArray", + "com.encode.bytes.PropertyAsyncClient.base64urlWithResponse": "Encode.Bytes.Property.base64url", + "com.encode.bytes.PropertyAsyncClient.defaultMethod": "Encode.Bytes.Property.default", + "com.encode.bytes.PropertyAsyncClient.defaultMethodWithResponse": "Encode.Bytes.Property.default", + "com.encode.bytes.PropertyClient": "null", + "com.encode.bytes.PropertyClient.base64": "Encode.Bytes.Property.base64", + "com.encode.bytes.PropertyClient.base64WithResponse": "Encode.Bytes.Property.base64", + "com.encode.bytes.PropertyClient.base64url": "Encode.Bytes.Property.base64url", + "com.encode.bytes.PropertyClient.base64urlArray": "Encode.Bytes.Property.base64urlArray", + "com.encode.bytes.PropertyClient.base64urlArrayWithResponse": "Encode.Bytes.Property.base64urlArray", + "com.encode.bytes.PropertyClient.base64urlWithResponse": "Encode.Bytes.Property.base64url", + "com.encode.bytes.PropertyClient.defaultMethod": "Encode.Bytes.Property.default", + "com.encode.bytes.PropertyClient.defaultMethodWithResponse": "Encode.Bytes.Property.default", + "com.encode.bytes.QueryAsyncClient": "null", + "com.encode.bytes.QueryAsyncClient.base64": "Encode.Bytes.Query.base64", + "com.encode.bytes.QueryAsyncClient.base64WithResponse": "Encode.Bytes.Query.base64", + "com.encode.bytes.QueryAsyncClient.base64url": "Encode.Bytes.Query.base64url", + "com.encode.bytes.QueryAsyncClient.base64urlArray": "Encode.Bytes.Query.base64urlArray", + "com.encode.bytes.QueryAsyncClient.base64urlArrayWithResponse": "Encode.Bytes.Query.base64urlArray", + "com.encode.bytes.QueryAsyncClient.base64urlWithResponse": "Encode.Bytes.Query.base64url", + "com.encode.bytes.QueryAsyncClient.defaultMethod": "Encode.Bytes.Query.default", + "com.encode.bytes.QueryAsyncClient.defaultMethodWithResponse": "Encode.Bytes.Query.default", + "com.encode.bytes.QueryClient": "null", + "com.encode.bytes.QueryClient.base64": "Encode.Bytes.Query.base64", + "com.encode.bytes.QueryClient.base64WithResponse": "Encode.Bytes.Query.base64", + "com.encode.bytes.QueryClient.base64url": "Encode.Bytes.Query.base64url", + "com.encode.bytes.QueryClient.base64urlArray": "Encode.Bytes.Query.base64urlArray", + "com.encode.bytes.QueryClient.base64urlArrayWithResponse": "Encode.Bytes.Query.base64urlArray", + "com.encode.bytes.QueryClient.base64urlWithResponse": "Encode.Bytes.Query.base64url", + "com.encode.bytes.QueryClient.defaultMethod": "Encode.Bytes.Query.default", + "com.encode.bytes.QueryClient.defaultMethodWithResponse": "Encode.Bytes.Query.default", + "com.encode.bytes.RequestBodyAsyncClient": "null", + "com.encode.bytes.RequestBodyAsyncClient.base64": "Encode.Bytes.RequestBody.base64", + "com.encode.bytes.RequestBodyAsyncClient.base64WithResponse": "Encode.Bytes.RequestBody.base64", + "com.encode.bytes.RequestBodyAsyncClient.base64url": "Encode.Bytes.RequestBody.base64url", + "com.encode.bytes.RequestBodyAsyncClient.base64urlWithResponse": "Encode.Bytes.RequestBody.base64url", + "com.encode.bytes.RequestBodyAsyncClient.customContentType": "Encode.Bytes.RequestBody.customContentType", + "com.encode.bytes.RequestBodyAsyncClient.customContentTypeWithResponse": "Encode.Bytes.RequestBody.customContentType", + "com.encode.bytes.RequestBodyAsyncClient.defaultMethod": "Encode.Bytes.RequestBody.default", + "com.encode.bytes.RequestBodyAsyncClient.defaultMethodWithResponse": "Encode.Bytes.RequestBody.default", + "com.encode.bytes.RequestBodyAsyncClient.octetStream": "Encode.Bytes.RequestBody.octetStream", + "com.encode.bytes.RequestBodyAsyncClient.octetStreamWithResponse": "Encode.Bytes.RequestBody.octetStream", + "com.encode.bytes.RequestBodyClient": "null", + "com.encode.bytes.RequestBodyClient.base64": "Encode.Bytes.RequestBody.base64", + "com.encode.bytes.RequestBodyClient.base64WithResponse": "Encode.Bytes.RequestBody.base64", + "com.encode.bytes.RequestBodyClient.base64url": "Encode.Bytes.RequestBody.base64url", + "com.encode.bytes.RequestBodyClient.base64urlWithResponse": "Encode.Bytes.RequestBody.base64url", + "com.encode.bytes.RequestBodyClient.customContentType": "Encode.Bytes.RequestBody.customContentType", + "com.encode.bytes.RequestBodyClient.customContentTypeWithResponse": "Encode.Bytes.RequestBody.customContentType", + "com.encode.bytes.RequestBodyClient.defaultMethod": "Encode.Bytes.RequestBody.default", + "com.encode.bytes.RequestBodyClient.defaultMethodWithResponse": "Encode.Bytes.RequestBody.default", + "com.encode.bytes.RequestBodyClient.octetStream": "Encode.Bytes.RequestBody.octetStream", + "com.encode.bytes.RequestBodyClient.octetStreamWithResponse": "Encode.Bytes.RequestBody.octetStream", + "com.encode.bytes.ResponseBodyAsyncClient": "null", + "com.encode.bytes.ResponseBodyAsyncClient.base64": "Encode.Bytes.ResponseBody.base64", + "com.encode.bytes.ResponseBodyAsyncClient.base64WithResponse": "Encode.Bytes.ResponseBody.base64", + "com.encode.bytes.ResponseBodyAsyncClient.base64url": "Encode.Bytes.ResponseBody.base64url", + "com.encode.bytes.ResponseBodyAsyncClient.base64urlWithResponse": "Encode.Bytes.ResponseBody.base64url", + "com.encode.bytes.ResponseBodyAsyncClient.customContentType": "Encode.Bytes.ResponseBody.customContentType", + "com.encode.bytes.ResponseBodyAsyncClient.customContentTypeWithResponse": "Encode.Bytes.ResponseBody.customContentType", + "com.encode.bytes.ResponseBodyAsyncClient.defaultMethod": "Encode.Bytes.ResponseBody.default", + "com.encode.bytes.ResponseBodyAsyncClient.defaultMethodWithResponse": "Encode.Bytes.ResponseBody.default", + "com.encode.bytes.ResponseBodyAsyncClient.octetStream": "Encode.Bytes.ResponseBody.octetStream", + "com.encode.bytes.ResponseBodyAsyncClient.octetStreamWithResponse": "Encode.Bytes.ResponseBody.octetStream", + "com.encode.bytes.ResponseBodyClient": "null", + "com.encode.bytes.ResponseBodyClient.base64": "Encode.Bytes.ResponseBody.base64", + "com.encode.bytes.ResponseBodyClient.base64WithResponse": "Encode.Bytes.ResponseBody.base64", + "com.encode.bytes.ResponseBodyClient.base64url": "Encode.Bytes.ResponseBody.base64url", + "com.encode.bytes.ResponseBodyClient.base64urlWithResponse": "Encode.Bytes.ResponseBody.base64url", + "com.encode.bytes.ResponseBodyClient.customContentType": "Encode.Bytes.ResponseBody.customContentType", + "com.encode.bytes.ResponseBodyClient.customContentTypeWithResponse": "Encode.Bytes.ResponseBody.customContentType", + "com.encode.bytes.ResponseBodyClient.defaultMethod": "Encode.Bytes.ResponseBody.default", + "com.encode.bytes.ResponseBodyClient.defaultMethodWithResponse": "Encode.Bytes.ResponseBody.default", + "com.encode.bytes.ResponseBodyClient.octetStream": "Encode.Bytes.ResponseBody.octetStream", + "com.encode.bytes.ResponseBodyClient.octetStreamWithResponse": "Encode.Bytes.ResponseBody.octetStream", + "com.encode.bytes.models.Base64BytesProperty": "Encode.Bytes.Base64BytesProperty", + "com.encode.bytes.models.Base64urlArrayBytesProperty": "Encode.Bytes.Base64urlArrayBytesProperty", + "com.encode.bytes.models.Base64urlBytesProperty": "Encode.Bytes.Base64urlBytesProperty", + "com.encode.bytes.models.DefaultBytesProperty": "Encode.Bytes.DefaultBytesProperty" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/encode-datetime_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/encode-datetime_apiview_properties.json new file mode 100644 index 000000000..a38ecf18d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/encode-datetime_apiview_properties.json @@ -0,0 +1,95 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.encode.datetime.DatetimeClientBuilder": "Encode.Datetime", + "com.encode.datetime.HeaderAsyncClient": "null", + "com.encode.datetime.HeaderAsyncClient.defaultMethod": "Encode.Datetime.Header.default", + "com.encode.datetime.HeaderAsyncClient.defaultMethodWithResponse": "Encode.Datetime.Header.default", + "com.encode.datetime.HeaderAsyncClient.rfc3339": "Encode.Datetime.Header.rfc3339", + "com.encode.datetime.HeaderAsyncClient.rfc3339WithResponse": "Encode.Datetime.Header.rfc3339", + "com.encode.datetime.HeaderAsyncClient.rfc7231": "Encode.Datetime.Header.rfc7231", + "com.encode.datetime.HeaderAsyncClient.rfc7231WithResponse": "Encode.Datetime.Header.rfc7231", + "com.encode.datetime.HeaderAsyncClient.unixTimestamp": "Encode.Datetime.Header.unixTimestamp", + "com.encode.datetime.HeaderAsyncClient.unixTimestampArray": "Encode.Datetime.Header.unixTimestampArray", + "com.encode.datetime.HeaderAsyncClient.unixTimestampArrayWithResponse": "Encode.Datetime.Header.unixTimestampArray", + "com.encode.datetime.HeaderAsyncClient.unixTimestampWithResponse": "Encode.Datetime.Header.unixTimestamp", + "com.encode.datetime.HeaderClient": "null", + "com.encode.datetime.HeaderClient.defaultMethod": "Encode.Datetime.Header.default", + "com.encode.datetime.HeaderClient.defaultMethodWithResponse": "Encode.Datetime.Header.default", + "com.encode.datetime.HeaderClient.rfc3339": "Encode.Datetime.Header.rfc3339", + "com.encode.datetime.HeaderClient.rfc3339WithResponse": "Encode.Datetime.Header.rfc3339", + "com.encode.datetime.HeaderClient.rfc7231": "Encode.Datetime.Header.rfc7231", + "com.encode.datetime.HeaderClient.rfc7231WithResponse": "Encode.Datetime.Header.rfc7231", + "com.encode.datetime.HeaderClient.unixTimestamp": "Encode.Datetime.Header.unixTimestamp", + "com.encode.datetime.HeaderClient.unixTimestampArray": "Encode.Datetime.Header.unixTimestampArray", + "com.encode.datetime.HeaderClient.unixTimestampArrayWithResponse": "Encode.Datetime.Header.unixTimestampArray", + "com.encode.datetime.HeaderClient.unixTimestampWithResponse": "Encode.Datetime.Header.unixTimestamp", + "com.encode.datetime.PropertyAsyncClient": "null", + "com.encode.datetime.PropertyAsyncClient.defaultMethod": "Encode.Datetime.Property.default", + "com.encode.datetime.PropertyAsyncClient.defaultMethodWithResponse": "Encode.Datetime.Property.default", + "com.encode.datetime.PropertyAsyncClient.rfc3339": "Encode.Datetime.Property.rfc3339", + "com.encode.datetime.PropertyAsyncClient.rfc3339WithResponse": "Encode.Datetime.Property.rfc3339", + "com.encode.datetime.PropertyAsyncClient.rfc7231": "Encode.Datetime.Property.rfc7231", + "com.encode.datetime.PropertyAsyncClient.rfc7231WithResponse": "Encode.Datetime.Property.rfc7231", + "com.encode.datetime.PropertyAsyncClient.unixTimestamp": "Encode.Datetime.Property.unixTimestamp", + "com.encode.datetime.PropertyAsyncClient.unixTimestampArray": "Encode.Datetime.Property.unixTimestampArray", + "com.encode.datetime.PropertyAsyncClient.unixTimestampArrayWithResponse": "Encode.Datetime.Property.unixTimestampArray", + "com.encode.datetime.PropertyAsyncClient.unixTimestampWithResponse": "Encode.Datetime.Property.unixTimestamp", + "com.encode.datetime.PropertyClient": "null", + "com.encode.datetime.PropertyClient.defaultMethod": "Encode.Datetime.Property.default", + "com.encode.datetime.PropertyClient.defaultMethodWithResponse": "Encode.Datetime.Property.default", + "com.encode.datetime.PropertyClient.rfc3339": "Encode.Datetime.Property.rfc3339", + "com.encode.datetime.PropertyClient.rfc3339WithResponse": "Encode.Datetime.Property.rfc3339", + "com.encode.datetime.PropertyClient.rfc7231": "Encode.Datetime.Property.rfc7231", + "com.encode.datetime.PropertyClient.rfc7231WithResponse": "Encode.Datetime.Property.rfc7231", + "com.encode.datetime.PropertyClient.unixTimestamp": "Encode.Datetime.Property.unixTimestamp", + "com.encode.datetime.PropertyClient.unixTimestampArray": "Encode.Datetime.Property.unixTimestampArray", + "com.encode.datetime.PropertyClient.unixTimestampArrayWithResponse": "Encode.Datetime.Property.unixTimestampArray", + "com.encode.datetime.PropertyClient.unixTimestampWithResponse": "Encode.Datetime.Property.unixTimestamp", + "com.encode.datetime.QueryAsyncClient": "null", + "com.encode.datetime.QueryAsyncClient.defaultMethod": "Encode.Datetime.Query.default", + "com.encode.datetime.QueryAsyncClient.defaultMethodWithResponse": "Encode.Datetime.Query.default", + "com.encode.datetime.QueryAsyncClient.rfc3339": "Encode.Datetime.Query.rfc3339", + "com.encode.datetime.QueryAsyncClient.rfc3339WithResponse": "Encode.Datetime.Query.rfc3339", + "com.encode.datetime.QueryAsyncClient.rfc7231": "Encode.Datetime.Query.rfc7231", + "com.encode.datetime.QueryAsyncClient.rfc7231WithResponse": "Encode.Datetime.Query.rfc7231", + "com.encode.datetime.QueryAsyncClient.unixTimestamp": "Encode.Datetime.Query.unixTimestamp", + "com.encode.datetime.QueryAsyncClient.unixTimestampArray": "Encode.Datetime.Query.unixTimestampArray", + "com.encode.datetime.QueryAsyncClient.unixTimestampArrayWithResponse": "Encode.Datetime.Query.unixTimestampArray", + "com.encode.datetime.QueryAsyncClient.unixTimestampWithResponse": "Encode.Datetime.Query.unixTimestamp", + "com.encode.datetime.QueryClient": "null", + "com.encode.datetime.QueryClient.defaultMethod": "Encode.Datetime.Query.default", + "com.encode.datetime.QueryClient.defaultMethodWithResponse": "Encode.Datetime.Query.default", + "com.encode.datetime.QueryClient.rfc3339": "Encode.Datetime.Query.rfc3339", + "com.encode.datetime.QueryClient.rfc3339WithResponse": "Encode.Datetime.Query.rfc3339", + "com.encode.datetime.QueryClient.rfc7231": "Encode.Datetime.Query.rfc7231", + "com.encode.datetime.QueryClient.rfc7231WithResponse": "Encode.Datetime.Query.rfc7231", + "com.encode.datetime.QueryClient.unixTimestamp": "Encode.Datetime.Query.unixTimestamp", + "com.encode.datetime.QueryClient.unixTimestampArray": "Encode.Datetime.Query.unixTimestampArray", + "com.encode.datetime.QueryClient.unixTimestampArrayWithResponse": "Encode.Datetime.Query.unixTimestampArray", + "com.encode.datetime.QueryClient.unixTimestampWithResponse": "Encode.Datetime.Query.unixTimestamp", + "com.encode.datetime.ResponseHeaderAsyncClient": "null", + "com.encode.datetime.ResponseHeaderAsyncClient.defaultMethod": "Encode.Datetime.ResponseHeader.default", + "com.encode.datetime.ResponseHeaderAsyncClient.defaultMethodWithResponse": "Encode.Datetime.ResponseHeader.default", + "com.encode.datetime.ResponseHeaderAsyncClient.rfc3339": "Encode.Datetime.ResponseHeader.rfc3339", + "com.encode.datetime.ResponseHeaderAsyncClient.rfc3339WithResponse": "Encode.Datetime.ResponseHeader.rfc3339", + "com.encode.datetime.ResponseHeaderAsyncClient.rfc7231": "Encode.Datetime.ResponseHeader.rfc7231", + "com.encode.datetime.ResponseHeaderAsyncClient.rfc7231WithResponse": "Encode.Datetime.ResponseHeader.rfc7231", + "com.encode.datetime.ResponseHeaderAsyncClient.unixTimestamp": "Encode.Datetime.ResponseHeader.unixTimestamp", + "com.encode.datetime.ResponseHeaderAsyncClient.unixTimestampWithResponse": "Encode.Datetime.ResponseHeader.unixTimestamp", + "com.encode.datetime.ResponseHeaderClient": "null", + "com.encode.datetime.ResponseHeaderClient.defaultMethod": "Encode.Datetime.ResponseHeader.default", + "com.encode.datetime.ResponseHeaderClient.defaultMethodWithResponse": "Encode.Datetime.ResponseHeader.default", + "com.encode.datetime.ResponseHeaderClient.rfc3339": "Encode.Datetime.ResponseHeader.rfc3339", + "com.encode.datetime.ResponseHeaderClient.rfc3339WithResponse": "Encode.Datetime.ResponseHeader.rfc3339", + "com.encode.datetime.ResponseHeaderClient.rfc7231": "Encode.Datetime.ResponseHeader.rfc7231", + "com.encode.datetime.ResponseHeaderClient.rfc7231WithResponse": "Encode.Datetime.ResponseHeader.rfc7231", + "com.encode.datetime.ResponseHeaderClient.unixTimestamp": "Encode.Datetime.ResponseHeader.unixTimestamp", + "com.encode.datetime.ResponseHeaderClient.unixTimestampWithResponse": "Encode.Datetime.ResponseHeader.unixTimestamp", + "com.encode.datetime.models.DefaultDatetimeProperty": "Encode.Datetime.DefaultDatetimeProperty", + "com.encode.datetime.models.Rfc3339DatetimeProperty": "Encode.Datetime.Rfc3339DatetimeProperty", + "com.encode.datetime.models.Rfc7231DatetimeProperty": "Encode.Datetime.Rfc7231DatetimeProperty", + "com.encode.datetime.models.UnixTimestampArrayDatetimeProperty": "Encode.Datetime.UnixTimestampArrayDatetimeProperty", + "com.encode.datetime.models.UnixTimestampDatetimeProperty": "Encode.Datetime.UnixTimestampDatetimeProperty" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/encode-duration_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/encode-duration_apiview_properties.json new file mode 100644 index 000000000..4cae693c7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/encode-duration_apiview_properties.json @@ -0,0 +1,90 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.encode.duration.DurationClientBuilder": "Encode.Duration", + "com.encode.duration.HeaderAsyncClient": "null", + "com.encode.duration.HeaderAsyncClient.defaultMethod": "Encode.Duration.Header.default", + "com.encode.duration.HeaderAsyncClient.defaultMethodWithResponse": "Encode.Duration.Header.default", + "com.encode.duration.HeaderAsyncClient.float64Seconds": "Encode.Duration.Header.float64Seconds", + "com.encode.duration.HeaderAsyncClient.float64SecondsWithResponse": "Encode.Duration.Header.float64Seconds", + "com.encode.duration.HeaderAsyncClient.floatSeconds": "Encode.Duration.Header.floatSeconds", + "com.encode.duration.HeaderAsyncClient.floatSecondsWithResponse": "Encode.Duration.Header.floatSeconds", + "com.encode.duration.HeaderAsyncClient.int32Seconds": "Encode.Duration.Header.int32Seconds", + "com.encode.duration.HeaderAsyncClient.int32SecondsWithResponse": "Encode.Duration.Header.int32Seconds", + "com.encode.duration.HeaderAsyncClient.iso8601": "Encode.Duration.Header.iso8601", + "com.encode.duration.HeaderAsyncClient.iso8601Array": "Encode.Duration.Header.iso8601Array", + "com.encode.duration.HeaderAsyncClient.iso8601ArrayWithResponse": "Encode.Duration.Header.iso8601Array", + "com.encode.duration.HeaderAsyncClient.iso8601WithResponse": "Encode.Duration.Header.iso8601", + "com.encode.duration.HeaderClient": "null", + "com.encode.duration.HeaderClient.defaultMethod": "Encode.Duration.Header.default", + "com.encode.duration.HeaderClient.defaultMethodWithResponse": "Encode.Duration.Header.default", + "com.encode.duration.HeaderClient.float64Seconds": "Encode.Duration.Header.float64Seconds", + "com.encode.duration.HeaderClient.float64SecondsWithResponse": "Encode.Duration.Header.float64Seconds", + "com.encode.duration.HeaderClient.floatSeconds": "Encode.Duration.Header.floatSeconds", + "com.encode.duration.HeaderClient.floatSecondsWithResponse": "Encode.Duration.Header.floatSeconds", + "com.encode.duration.HeaderClient.int32Seconds": "Encode.Duration.Header.int32Seconds", + "com.encode.duration.HeaderClient.int32SecondsWithResponse": "Encode.Duration.Header.int32Seconds", + "com.encode.duration.HeaderClient.iso8601": "Encode.Duration.Header.iso8601", + "com.encode.duration.HeaderClient.iso8601Array": "Encode.Duration.Header.iso8601Array", + "com.encode.duration.HeaderClient.iso8601ArrayWithResponse": "Encode.Duration.Header.iso8601Array", + "com.encode.duration.HeaderClient.iso8601WithResponse": "Encode.Duration.Header.iso8601", + "com.encode.duration.PropertyAsyncClient": "null", + "com.encode.duration.PropertyAsyncClient.defaultMethod": "Encode.Duration.Property.default", + "com.encode.duration.PropertyAsyncClient.defaultMethodWithResponse": "Encode.Duration.Property.default", + "com.encode.duration.PropertyAsyncClient.float64Seconds": "Encode.Duration.Property.float64Seconds", + "com.encode.duration.PropertyAsyncClient.float64SecondsWithResponse": "Encode.Duration.Property.float64Seconds", + "com.encode.duration.PropertyAsyncClient.floatSeconds": "Encode.Duration.Property.floatSeconds", + "com.encode.duration.PropertyAsyncClient.floatSecondsArray": "Encode.Duration.Property.floatSecondsArray", + "com.encode.duration.PropertyAsyncClient.floatSecondsArrayWithResponse": "Encode.Duration.Property.floatSecondsArray", + "com.encode.duration.PropertyAsyncClient.floatSecondsWithResponse": "Encode.Duration.Property.floatSeconds", + "com.encode.duration.PropertyAsyncClient.int32Seconds": "Encode.Duration.Property.int32Seconds", + "com.encode.duration.PropertyAsyncClient.int32SecondsWithResponse": "Encode.Duration.Property.int32Seconds", + "com.encode.duration.PropertyAsyncClient.iso8601": "Encode.Duration.Property.iso8601", + "com.encode.duration.PropertyAsyncClient.iso8601WithResponse": "Encode.Duration.Property.iso8601", + "com.encode.duration.PropertyClient": "null", + "com.encode.duration.PropertyClient.defaultMethod": "Encode.Duration.Property.default", + "com.encode.duration.PropertyClient.defaultMethodWithResponse": "Encode.Duration.Property.default", + "com.encode.duration.PropertyClient.float64Seconds": "Encode.Duration.Property.float64Seconds", + "com.encode.duration.PropertyClient.float64SecondsWithResponse": "Encode.Duration.Property.float64Seconds", + "com.encode.duration.PropertyClient.floatSeconds": "Encode.Duration.Property.floatSeconds", + "com.encode.duration.PropertyClient.floatSecondsArray": "Encode.Duration.Property.floatSecondsArray", + "com.encode.duration.PropertyClient.floatSecondsArrayWithResponse": "Encode.Duration.Property.floatSecondsArray", + "com.encode.duration.PropertyClient.floatSecondsWithResponse": "Encode.Duration.Property.floatSeconds", + "com.encode.duration.PropertyClient.int32Seconds": "Encode.Duration.Property.int32Seconds", + "com.encode.duration.PropertyClient.int32SecondsWithResponse": "Encode.Duration.Property.int32Seconds", + "com.encode.duration.PropertyClient.iso8601": "Encode.Duration.Property.iso8601", + "com.encode.duration.PropertyClient.iso8601WithResponse": "Encode.Duration.Property.iso8601", + "com.encode.duration.QueryAsyncClient": "null", + "com.encode.duration.QueryAsyncClient.defaultMethod": "Encode.Duration.Query.default", + "com.encode.duration.QueryAsyncClient.defaultMethodWithResponse": "Encode.Duration.Query.default", + "com.encode.duration.QueryAsyncClient.float64Seconds": "Encode.Duration.Query.float64Seconds", + "com.encode.duration.QueryAsyncClient.float64SecondsWithResponse": "Encode.Duration.Query.float64Seconds", + "com.encode.duration.QueryAsyncClient.floatSeconds": "Encode.Duration.Query.floatSeconds", + "com.encode.duration.QueryAsyncClient.floatSecondsWithResponse": "Encode.Duration.Query.floatSeconds", + "com.encode.duration.QueryAsyncClient.int32Seconds": "Encode.Duration.Query.int32Seconds", + "com.encode.duration.QueryAsyncClient.int32SecondsArray": "Encode.Duration.Query.int32SecondsArray", + "com.encode.duration.QueryAsyncClient.int32SecondsArrayWithResponse": "Encode.Duration.Query.int32SecondsArray", + "com.encode.duration.QueryAsyncClient.int32SecondsWithResponse": "Encode.Duration.Query.int32Seconds", + "com.encode.duration.QueryAsyncClient.iso8601": "Encode.Duration.Query.iso8601", + "com.encode.duration.QueryAsyncClient.iso8601WithResponse": "Encode.Duration.Query.iso8601", + "com.encode.duration.QueryClient": "null", + "com.encode.duration.QueryClient.defaultMethod": "Encode.Duration.Query.default", + "com.encode.duration.QueryClient.defaultMethodWithResponse": "Encode.Duration.Query.default", + "com.encode.duration.QueryClient.float64Seconds": "Encode.Duration.Query.float64Seconds", + "com.encode.duration.QueryClient.float64SecondsWithResponse": "Encode.Duration.Query.float64Seconds", + "com.encode.duration.QueryClient.floatSeconds": "Encode.Duration.Query.floatSeconds", + "com.encode.duration.QueryClient.floatSecondsWithResponse": "Encode.Duration.Query.floatSeconds", + "com.encode.duration.QueryClient.int32Seconds": "Encode.Duration.Query.int32Seconds", + "com.encode.duration.QueryClient.int32SecondsArray": "Encode.Duration.Query.int32SecondsArray", + "com.encode.duration.QueryClient.int32SecondsArrayWithResponse": "Encode.Duration.Query.int32SecondsArray", + "com.encode.duration.QueryClient.int32SecondsWithResponse": "Encode.Duration.Query.int32Seconds", + "com.encode.duration.QueryClient.iso8601": "Encode.Duration.Query.iso8601", + "com.encode.duration.QueryClient.iso8601WithResponse": "Encode.Duration.Query.iso8601", + "com.encode.duration.models.DefaultDurationProperty": "Encode.Duration.Property.DefaultDurationProperty", + "com.encode.duration.models.Float64SecondsDurationProperty": "Encode.Duration.Property.Float64SecondsDurationProperty", + "com.encode.duration.models.FloatSecondsDurationArrayProperty": "Encode.Duration.Property.FloatSecondsDurationArrayProperty", + "com.encode.duration.models.FloatSecondsDurationProperty": "Encode.Duration.Property.FloatSecondsDurationProperty", + "com.encode.duration.models.ISO8601DurationProperty": "Encode.Duration.Property.ISO8601DurationProperty", + "com.encode.duration.models.Int32SecondsDurationProperty": "Encode.Duration.Property.Int32SecondsDurationProperty" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armresourceprovider-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-armresourceprovider-generated/proxy-config.json new file mode 100644 index 000000000..e73aab709 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armresourceprovider-generated/proxy-config.json @@ -0,0 +1 @@ +[["com.cadl.armresourceprovider.implementation.ChildExtensionResourceInterfacesClientImpl$ChildExtensionResourceInterfacesService"],["com.cadl.armresourceprovider.implementation.ChildResourcesInterfacesClientImpl$ChildResourcesInterfacesService"],["com.cadl.armresourceprovider.implementation.CustomTemplateResourceInterfacesClientImpl$CustomTemplateResourceInterfacesService"],["com.cadl.armresourceprovider.implementation.OperationsClientImpl$OperationsService"],["com.cadl.armresourceprovider.implementation.TopLevelArmResourceInterfacesClientImpl$TopLevelArmResourceInterfacesService"]] \ 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-armresourceprovider-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-armresourceprovider-generated/reflect-config.json new file mode 100644 index 000000000..95474aab0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armresourceprovider-generated/reflect-config.json @@ -0,0 +1 @@ +[{"name":"com.cadl.armresourceprovider.fluent.models.ChildExtensionResourceInner","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.fluent.models.ChildResourceInner","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.fluent.models.ChildResourceProperties","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.fluent.models.CustomTemplateResourceInner","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.fluent.models.CustomTemplateResourceProperties","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.fluent.models.OperationInner","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.fluent.models.ResultInner","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceInner","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceProperties","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceUpdateProperties","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.implementation.models.ChildExtensionResourceListResult","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.implementation.models.ChildResourceListResult","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.implementation.models.OperationListResult","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.implementation.models.TopLevelArmResourceListResult","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.ActionType","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.ChildExtensionResourceProperties","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.ChildExtensionResourceUpdate","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.ChildResourceUpdate","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.CustomTemplateResourcePatch","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.CustomTemplateResourcePropertiesAnonymousEmptyModel","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.Dog","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.DogKind","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.EmptyModel","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.Golden","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.ManagedServiceIdentity","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.ManagedServiceIdentityType","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.OperationDisplay","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.Origin","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.ProvisioningState","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.TopLevelArmResourceUpdate","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armresourceprovider.models.UserAssignedIdentity","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true}] \ 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-armstreamstyleserialization-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-armstreamstyleserialization-generated/proxy-config.json new file mode 100644 index 000000000..79305dc22 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armstreamstyleserialization-generated/proxy-config.json @@ -0,0 +1 @@ +[["com.cadl.armstreamstyleserialization.implementation.FishesClientImpl$FishesService"],["com.cadl.armstreamstyleserialization.implementation.TopLevelArmResourcesClientImpl$TopLevelArmResourcesService"]] \ 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-armstreamstyleserialization-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-armstreamstyleserialization-generated/reflect-config.json new file mode 100644 index 000000000..70035a0a9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armstreamstyleserialization-generated/reflect-config.json @@ -0,0 +1 @@ +[{"name":"com.cadl.armstreamstyleserialization.models.Error","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armstreamstyleserialization.models.ErrorException","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armstreamstyleserialization.models.ErrorMin","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true},{"name":"com.cadl.armstreamstyleserialization.models.ErrorMinException","allDeclaredConstructors":true,"allDeclaredFields":true,"allDeclaredMethods":true}] \ 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-models-commontypes-managedidentity/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-models-commontypes-managedidentity/proxy-config.json new file mode 100644 index 000000000..f5b57f490 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-models-commontypes-managedidentity/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.models.commontypes.managedidentity.implementation.ManagedIdentityTrackedResourcesClientImpl$ManagedIdentityTrackedResourcesService"]] \ 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-models-commontypes-managedidentity/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-models-commontypes-managedidentity/reflect-config.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-models-commontypes-managedidentity/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/native-image/com.azure.resourcemanager/azure-resourcemanager-models-resources/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-models-resources/proxy-config.json new file mode 100644 index 000000000..39fb0b001 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-models-resources/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.models.resources.implementation.NestedProxyResourcesClientImpl$NestedProxyResourcesService"],["com.azure.resourcemanager.models.resources.implementation.TopLevelTrackedResourcesClientImpl$TopLevelTrackedResourcesService"]] \ 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-models-resources/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-models-resources/reflect-config.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-models-resources/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-basic_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-basic_apiview_properties.json new file mode 100644 index 000000000..40df5fb5a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-basic_apiview_properties.json @@ -0,0 +1,20 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.parameters.basic.BasicClientBuilder": "Parameters.Basic", + "com.parameters.basic.ExplicitBodyAsyncClient": "null", + "com.parameters.basic.ExplicitBodyAsyncClient.simple": "Parameters.Basic.ExplicitBody.simple", + "com.parameters.basic.ExplicitBodyAsyncClient.simpleWithResponse": "Parameters.Basic.ExplicitBody.simple", + "com.parameters.basic.ExplicitBodyClient": "null", + "com.parameters.basic.ExplicitBodyClient.simple": "Parameters.Basic.ExplicitBody.simple", + "com.parameters.basic.ExplicitBodyClient.simpleWithResponse": "Parameters.Basic.ExplicitBody.simple", + "com.parameters.basic.ImplicitBodyAsyncClient": "null", + "com.parameters.basic.ImplicitBodyAsyncClient.simple": "Parameters.Basic.ImplicitBody.simple", + "com.parameters.basic.ImplicitBodyAsyncClient.simpleWithResponse": "Parameters.Basic.ImplicitBody.simple", + "com.parameters.basic.ImplicitBodyClient": "null", + "com.parameters.basic.ImplicitBodyClient.simple": "Parameters.Basic.ImplicitBody.simple", + "com.parameters.basic.ImplicitBodyClient.simpleWithResponse": "Parameters.Basic.ImplicitBody.simple", + "com.parameters.basic.implementation.models.SimpleRequest": "Parameters.Basic.ImplicitBody.simple.Request.anonymous", + "com.parameters.basic.models.User": "Parameters.Basic.ExplicitBody.User" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-bodyoptionality_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-bodyoptionality_apiview_properties.json new file mode 100644 index 000000000..62b92b815 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-bodyoptionality_apiview_properties.json @@ -0,0 +1,28 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.parameters.bodyoptionality.BodyOptionalityAsyncClient": "Parameters.BodyOptionality", + "com.parameters.bodyoptionality.BodyOptionalityAsyncClient.requiredExplicit": "Parameters.BodyOptionality.requiredExplicit", + "com.parameters.bodyoptionality.BodyOptionalityAsyncClient.requiredExplicitWithResponse": "Parameters.BodyOptionality.requiredExplicit", + "com.parameters.bodyoptionality.BodyOptionalityAsyncClient.requiredImplicit": "Parameters.BodyOptionality.requiredImplicit", + "com.parameters.bodyoptionality.BodyOptionalityAsyncClient.requiredImplicitWithResponse": "Parameters.BodyOptionality.requiredImplicit", + "com.parameters.bodyoptionality.BodyOptionalityClient": "Parameters.BodyOptionality", + "com.parameters.bodyoptionality.BodyOptionalityClient.requiredExplicit": "Parameters.BodyOptionality.requiredExplicit", + "com.parameters.bodyoptionality.BodyOptionalityClient.requiredExplicitWithResponse": "Parameters.BodyOptionality.requiredExplicit", + "com.parameters.bodyoptionality.BodyOptionalityClient.requiredImplicit": "Parameters.BodyOptionality.requiredImplicit", + "com.parameters.bodyoptionality.BodyOptionalityClient.requiredImplicitWithResponse": "Parameters.BodyOptionality.requiredImplicit", + "com.parameters.bodyoptionality.BodyOptionalityClientBuilder": "Parameters.BodyOptionality", + "com.parameters.bodyoptionality.OptionalExplicitAsyncClient": "null", + "com.parameters.bodyoptionality.OptionalExplicitAsyncClient.omit": "Parameters.BodyOptionality.OptionalExplicit.omit", + "com.parameters.bodyoptionality.OptionalExplicitAsyncClient.omitWithResponse": "Parameters.BodyOptionality.OptionalExplicit.omit", + "com.parameters.bodyoptionality.OptionalExplicitAsyncClient.set": "Parameters.BodyOptionality.OptionalExplicit.set", + "com.parameters.bodyoptionality.OptionalExplicitAsyncClient.setWithResponse": "Parameters.BodyOptionality.OptionalExplicit.set", + "com.parameters.bodyoptionality.OptionalExplicitClient": "null", + "com.parameters.bodyoptionality.OptionalExplicitClient.omit": "Parameters.BodyOptionality.OptionalExplicit.omit", + "com.parameters.bodyoptionality.OptionalExplicitClient.omitWithResponse": "Parameters.BodyOptionality.OptionalExplicit.omit", + "com.parameters.bodyoptionality.OptionalExplicitClient.set": "Parameters.BodyOptionality.OptionalExplicit.set", + "com.parameters.bodyoptionality.OptionalExplicitClient.setWithResponse": "Parameters.BodyOptionality.OptionalExplicit.set", + "com.parameters.bodyoptionality.implementation.models.RequiredImplicitRequest": "Parameters.BodyOptionality.requiredImplicit.Request.anonymous", + "com.parameters.bodyoptionality.models.BodyModel": "Parameters.BodyOptionality.BodyModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-collectionformat_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-collectionformat_apiview_properties.json new file mode 100644 index 000000000..252acb167 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-collectionformat_apiview_properties.json @@ -0,0 +1,34 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.parameters.collectionformat.CollectionFormatClientBuilder": "Parameters.CollectionFormat", + "com.parameters.collectionformat.HeaderAsyncClient": "null", + "com.parameters.collectionformat.HeaderAsyncClient.csv": "Parameters.CollectionFormat.Header.csv", + "com.parameters.collectionformat.HeaderAsyncClient.csvWithResponse": "Parameters.CollectionFormat.Header.csv", + "com.parameters.collectionformat.HeaderClient": "null", + "com.parameters.collectionformat.HeaderClient.csv": "Parameters.CollectionFormat.Header.csv", + "com.parameters.collectionformat.HeaderClient.csvWithResponse": "Parameters.CollectionFormat.Header.csv", + "com.parameters.collectionformat.QueryAsyncClient": "null", + "com.parameters.collectionformat.QueryAsyncClient.csv": "Parameters.CollectionFormat.Query.csv", + "com.parameters.collectionformat.QueryAsyncClient.csvWithResponse": "Parameters.CollectionFormat.Query.csv", + "com.parameters.collectionformat.QueryAsyncClient.multi": "Parameters.CollectionFormat.Query.multi", + "com.parameters.collectionformat.QueryAsyncClient.multiWithResponse": "Parameters.CollectionFormat.Query.multi", + "com.parameters.collectionformat.QueryAsyncClient.pipes": "Parameters.CollectionFormat.Query.pipes", + "com.parameters.collectionformat.QueryAsyncClient.pipesWithResponse": "Parameters.CollectionFormat.Query.pipes", + "com.parameters.collectionformat.QueryAsyncClient.ssv": "Parameters.CollectionFormat.Query.ssv", + "com.parameters.collectionformat.QueryAsyncClient.ssvWithResponse": "Parameters.CollectionFormat.Query.ssv", + "com.parameters.collectionformat.QueryAsyncClient.tsv": "Parameters.CollectionFormat.Query.tsv", + "com.parameters.collectionformat.QueryAsyncClient.tsvWithResponse": "Parameters.CollectionFormat.Query.tsv", + "com.parameters.collectionformat.QueryClient": "null", + "com.parameters.collectionformat.QueryClient.csv": "Parameters.CollectionFormat.Query.csv", + "com.parameters.collectionformat.QueryClient.csvWithResponse": "Parameters.CollectionFormat.Query.csv", + "com.parameters.collectionformat.QueryClient.multi": "Parameters.CollectionFormat.Query.multi", + "com.parameters.collectionformat.QueryClient.multiWithResponse": "Parameters.CollectionFormat.Query.multi", + "com.parameters.collectionformat.QueryClient.pipes": "Parameters.CollectionFormat.Query.pipes", + "com.parameters.collectionformat.QueryClient.pipesWithResponse": "Parameters.CollectionFormat.Query.pipes", + "com.parameters.collectionformat.QueryClient.ssv": "Parameters.CollectionFormat.Query.ssv", + "com.parameters.collectionformat.QueryClient.ssvWithResponse": "Parameters.CollectionFormat.Query.ssv", + "com.parameters.collectionformat.QueryClient.tsv": "Parameters.CollectionFormat.Query.tsv", + "com.parameters.collectionformat.QueryClient.tsvWithResponse": "Parameters.CollectionFormat.Query.tsv" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-spread_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-spread_apiview_properties.json new file mode 100644 index 000000000..80c6eab50 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/parameters-spread_apiview_properties.json @@ -0,0 +1,58 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.parameters.spread.AliasAsyncClient": "null", + "com.parameters.spread.AliasAsyncClient.spreadAsRequestBody": "Parameters.Spread.Alias.spreadAsRequestBody", + "com.parameters.spread.AliasAsyncClient.spreadAsRequestBodyWithResponse": "Parameters.Spread.Alias.spreadAsRequestBody", + "com.parameters.spread.AliasAsyncClient.spreadAsRequestParameter": "Parameters.Spread.Alias.spreadAsRequestParameter", + "com.parameters.spread.AliasAsyncClient.spreadAsRequestParameterWithResponse": "Parameters.Spread.Alias.spreadAsRequestParameter", + "com.parameters.spread.AliasAsyncClient.spreadParameterWithInnerAlias": "Parameters.Spread.Alias.spreadParameterWithInnerAlias", + "com.parameters.spread.AliasAsyncClient.spreadParameterWithInnerAliasWithResponse": "Parameters.Spread.Alias.spreadParameterWithInnerAlias", + "com.parameters.spread.AliasAsyncClient.spreadParameterWithInnerModel": "Parameters.Spread.Alias.spreadParameterWithInnerModel", + "com.parameters.spread.AliasAsyncClient.spreadParameterWithInnerModelWithResponse": "Parameters.Spread.Alias.spreadParameterWithInnerModel", + "com.parameters.spread.AliasAsyncClient.spreadWithMultipleParameters": "Parameters.Spread.Alias.spreadWithMultipleParameters", + "com.parameters.spread.AliasAsyncClient.spreadWithMultipleParametersWithResponse": "Parameters.Spread.Alias.spreadWithMultipleParameters", + "com.parameters.spread.AliasClient": "null", + "com.parameters.spread.AliasClient.spreadAsRequestBody": "Parameters.Spread.Alias.spreadAsRequestBody", + "com.parameters.spread.AliasClient.spreadAsRequestBodyWithResponse": "Parameters.Spread.Alias.spreadAsRequestBody", + "com.parameters.spread.AliasClient.spreadAsRequestParameter": "Parameters.Spread.Alias.spreadAsRequestParameter", + "com.parameters.spread.AliasClient.spreadAsRequestParameterWithResponse": "Parameters.Spread.Alias.spreadAsRequestParameter", + "com.parameters.spread.AliasClient.spreadParameterWithInnerAlias": "Parameters.Spread.Alias.spreadParameterWithInnerAlias", + "com.parameters.spread.AliasClient.spreadParameterWithInnerAliasWithResponse": "Parameters.Spread.Alias.spreadParameterWithInnerAlias", + "com.parameters.spread.AliasClient.spreadParameterWithInnerModel": "Parameters.Spread.Alias.spreadParameterWithInnerModel", + "com.parameters.spread.AliasClient.spreadParameterWithInnerModelWithResponse": "Parameters.Spread.Alias.spreadParameterWithInnerModel", + "com.parameters.spread.AliasClient.spreadWithMultipleParameters": "Parameters.Spread.Alias.spreadWithMultipleParameters", + "com.parameters.spread.AliasClient.spreadWithMultipleParametersWithResponse": "Parameters.Spread.Alias.spreadWithMultipleParameters", + "com.parameters.spread.ModelAsyncClient": "null", + "com.parameters.spread.ModelAsyncClient.spreadAsRequestBody": "Parameters.Spread.Model.spreadAsRequestBody", + "com.parameters.spread.ModelAsyncClient.spreadAsRequestBodyWithResponse": "Parameters.Spread.Model.spreadAsRequestBody", + "com.parameters.spread.ModelAsyncClient.spreadCompositeRequest": "Parameters.Spread.Model.spreadCompositeRequest", + "com.parameters.spread.ModelAsyncClient.spreadCompositeRequestMix": "Parameters.Spread.Model.spreadCompositeRequestMix", + "com.parameters.spread.ModelAsyncClient.spreadCompositeRequestMixWithResponse": "Parameters.Spread.Model.spreadCompositeRequestMix", + "com.parameters.spread.ModelAsyncClient.spreadCompositeRequestOnlyWithBody": "Parameters.Spread.Model.spreadCompositeRequestOnlyWithBody", + "com.parameters.spread.ModelAsyncClient.spreadCompositeRequestOnlyWithBodyWithResponse": "Parameters.Spread.Model.spreadCompositeRequestOnlyWithBody", + "com.parameters.spread.ModelAsyncClient.spreadCompositeRequestWithResponse": "Parameters.Spread.Model.spreadCompositeRequest", + "com.parameters.spread.ModelAsyncClient.spreadCompositeRequestWithoutBody": "Parameters.Spread.Model.spreadCompositeRequestWithoutBody", + "com.parameters.spread.ModelAsyncClient.spreadCompositeRequestWithoutBodyWithResponse": "Parameters.Spread.Model.spreadCompositeRequestWithoutBody", + "com.parameters.spread.ModelClient": "null", + "com.parameters.spread.ModelClient.spreadAsRequestBody": "Parameters.Spread.Model.spreadAsRequestBody", + "com.parameters.spread.ModelClient.spreadAsRequestBodyWithResponse": "Parameters.Spread.Model.spreadAsRequestBody", + "com.parameters.spread.ModelClient.spreadCompositeRequest": "Parameters.Spread.Model.spreadCompositeRequest", + "com.parameters.spread.ModelClient.spreadCompositeRequestMix": "Parameters.Spread.Model.spreadCompositeRequestMix", + "com.parameters.spread.ModelClient.spreadCompositeRequestMixWithResponse": "Parameters.Spread.Model.spreadCompositeRequestMix", + "com.parameters.spread.ModelClient.spreadCompositeRequestOnlyWithBody": "Parameters.Spread.Model.spreadCompositeRequestOnlyWithBody", + "com.parameters.spread.ModelClient.spreadCompositeRequestOnlyWithBodyWithResponse": "Parameters.Spread.Model.spreadCompositeRequestOnlyWithBody", + "com.parameters.spread.ModelClient.spreadCompositeRequestWithResponse": "Parameters.Spread.Model.spreadCompositeRequest", + "com.parameters.spread.ModelClient.spreadCompositeRequestWithoutBody": "Parameters.Spread.Model.spreadCompositeRequestWithoutBody", + "com.parameters.spread.ModelClient.spreadCompositeRequestWithoutBodyWithResponse": "Parameters.Spread.Model.spreadCompositeRequestWithoutBody", + "com.parameters.spread.SpreadClientBuilder": "Parameters.Spread", + "com.parameters.spread.implementation.models.SpreadAsRequestBodyRequest": "Parameters.Spread.Model.spreadAsRequestBody.Request.anonymous", + "com.parameters.spread.implementation.models.SpreadAsRequestBodyRequest1": "Parameters.Spread.Alias.spreadAsRequestBody.Request.anonymous", + "com.parameters.spread.implementation.models.SpreadAsRequestParameterRequest": "spreadAsRequestParameter.Request.anonymous", + "com.parameters.spread.implementation.models.SpreadCompositeRequestMixRequest": "spreadCompositeRequestMix.Request.anonymous", + "com.parameters.spread.implementation.models.SpreadParameterWithInnerAliasRequest": "spreadParameterWithInnerAlias.Request.anonymous", + "com.parameters.spread.implementation.models.SpreadParameterWithInnerModelRequest": "spreadParameterWithInnerModel.Request.anonymous", + "com.parameters.spread.implementation.models.SpreadWithMultipleParametersRequest": "spreadWithMultipleParameters.Request.anonymous", + "com.parameters.spread.models.BodyParameter": "Parameters.Spread.Model.BodyParameter" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-contentnegotiation_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-contentnegotiation_apiview_properties.json new file mode 100644 index 000000000..982b2f6b2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-contentnegotiation_apiview_properties.json @@ -0,0 +1,27 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.payload.contentnegotiation.ContentNegotiationClientBuilder": "Payload.ContentNegotiation", + "com.payload.contentnegotiation.DifferentBodyAsyncClient": "null", + "com.payload.contentnegotiation.DifferentBodyAsyncClient.getAvatarAsJson": "Payload.ContentNegotiation.DifferentBody.getAvatarAsJson", + "com.payload.contentnegotiation.DifferentBodyAsyncClient.getAvatarAsJsonWithResponse": "Payload.ContentNegotiation.DifferentBody.getAvatarAsJson", + "com.payload.contentnegotiation.DifferentBodyAsyncClient.getAvatarAsPng": "Payload.ContentNegotiation.DifferentBody.getAvatarAsPng", + "com.payload.contentnegotiation.DifferentBodyAsyncClient.getAvatarAsPngWithResponse": "Payload.ContentNegotiation.DifferentBody.getAvatarAsPng", + "com.payload.contentnegotiation.DifferentBodyClient": "null", + "com.payload.contentnegotiation.DifferentBodyClient.getAvatarAsJson": "Payload.ContentNegotiation.DifferentBody.getAvatarAsJson", + "com.payload.contentnegotiation.DifferentBodyClient.getAvatarAsJsonWithResponse": "Payload.ContentNegotiation.DifferentBody.getAvatarAsJson", + "com.payload.contentnegotiation.DifferentBodyClient.getAvatarAsPng": "Payload.ContentNegotiation.DifferentBody.getAvatarAsPng", + "com.payload.contentnegotiation.DifferentBodyClient.getAvatarAsPngWithResponse": "Payload.ContentNegotiation.DifferentBody.getAvatarAsPng", + "com.payload.contentnegotiation.SameBodyAsyncClient": "null", + "com.payload.contentnegotiation.SameBodyAsyncClient.getAvatarAsJpeg": "Payload.ContentNegotiation.SameBody.getAvatarAsJpeg", + "com.payload.contentnegotiation.SameBodyAsyncClient.getAvatarAsJpegWithResponse": "Payload.ContentNegotiation.SameBody.getAvatarAsJpeg", + "com.payload.contentnegotiation.SameBodyAsyncClient.getAvatarAsPng": "Payload.ContentNegotiation.SameBody.getAvatarAsPng", + "com.payload.contentnegotiation.SameBodyAsyncClient.getAvatarAsPngWithResponse": "Payload.ContentNegotiation.SameBody.getAvatarAsPng", + "com.payload.contentnegotiation.SameBodyClient": "null", + "com.payload.contentnegotiation.SameBodyClient.getAvatarAsJpeg": "Payload.ContentNegotiation.SameBody.getAvatarAsJpeg", + "com.payload.contentnegotiation.SameBodyClient.getAvatarAsJpegWithResponse": "Payload.ContentNegotiation.SameBody.getAvatarAsJpeg", + "com.payload.contentnegotiation.SameBodyClient.getAvatarAsPng": "Payload.ContentNegotiation.SameBody.getAvatarAsPng", + "com.payload.contentnegotiation.SameBodyClient.getAvatarAsPngWithResponse": "Payload.ContentNegotiation.SameBody.getAvatarAsPng", + "com.payload.contentnegotiation.models.PngImageAsJson": "Payload.ContentNegotiation.DifferentBody.PngImageAsJson" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-jsonmergepatch_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-jsonmergepatch_apiview_properties.json new file mode 100644 index 000000000..bb48476f0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-jsonmergepatch_apiview_properties.json @@ -0,0 +1,23 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.payload.jsonmergepatch.JsonMergePatchAsyncClient": "Payload.JsonMergePatch", + "com.payload.jsonmergepatch.JsonMergePatchAsyncClient.createResource": "Payload.JsonMergePatch.createResource", + "com.payload.jsonmergepatch.JsonMergePatchAsyncClient.createResourceWithResponse": "Payload.JsonMergePatch.createResource", + "com.payload.jsonmergepatch.JsonMergePatchAsyncClient.updateOptionalResource": "Payload.JsonMergePatch.updateOptionalResource", + "com.payload.jsonmergepatch.JsonMergePatchAsyncClient.updateOptionalResourceWithResponse": "Payload.JsonMergePatch.updateOptionalResource", + "com.payload.jsonmergepatch.JsonMergePatchAsyncClient.updateResource": "Payload.JsonMergePatch.updateResource", + "com.payload.jsonmergepatch.JsonMergePatchAsyncClient.updateResourceWithResponse": "Payload.JsonMergePatch.updateResource", + "com.payload.jsonmergepatch.JsonMergePatchClient": "Payload.JsonMergePatch", + "com.payload.jsonmergepatch.JsonMergePatchClient.createResource": "Payload.JsonMergePatch.createResource", + "com.payload.jsonmergepatch.JsonMergePatchClient.createResourceWithResponse": "Payload.JsonMergePatch.createResource", + "com.payload.jsonmergepatch.JsonMergePatchClient.updateOptionalResource": "Payload.JsonMergePatch.updateOptionalResource", + "com.payload.jsonmergepatch.JsonMergePatchClient.updateOptionalResourceWithResponse": "Payload.JsonMergePatch.updateOptionalResource", + "com.payload.jsonmergepatch.JsonMergePatchClient.updateResource": "Payload.JsonMergePatch.updateResource", + "com.payload.jsonmergepatch.JsonMergePatchClient.updateResourceWithResponse": "Payload.JsonMergePatch.updateResource", + "com.payload.jsonmergepatch.JsonMergePatchClientBuilder": "Payload.JsonMergePatch", + "com.payload.jsonmergepatch.models.InnerModel": "Payload.JsonMergePatch.InnerModel", + "com.payload.jsonmergepatch.models.Resource": "Payload.JsonMergePatch.Resource", + "com.payload.jsonmergepatch.models.ResourcePatch": "Payload.JsonMergePatch.ResourcePatch" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-mediatype_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-mediatype_apiview_properties.json new file mode 100644 index 000000000..d61d35483 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-mediatype_apiview_properties.json @@ -0,0 +1,24 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.payload.mediatype.MediaTypeAsyncClient": "null", + "com.payload.mediatype.MediaTypeAsyncClient.getAsJson": "Payload.MediaType.StringBody.getAsJson", + "com.payload.mediatype.MediaTypeAsyncClient.getAsJsonWithResponse": "Payload.MediaType.StringBody.getAsJson", + "com.payload.mediatype.MediaTypeAsyncClient.getAsText": "Payload.MediaType.StringBody.getAsText", + "com.payload.mediatype.MediaTypeAsyncClient.getAsTextWithResponse": "Payload.MediaType.StringBody.getAsText", + "com.payload.mediatype.MediaTypeAsyncClient.sendAsJson": "Payload.MediaType.StringBody.sendAsJson", + "com.payload.mediatype.MediaTypeAsyncClient.sendAsJsonWithResponse": "Payload.MediaType.StringBody.sendAsJson", + "com.payload.mediatype.MediaTypeAsyncClient.sendAsText": "Payload.MediaType.StringBody.sendAsText", + "com.payload.mediatype.MediaTypeAsyncClient.sendAsTextWithResponse": "Payload.MediaType.StringBody.sendAsText", + "com.payload.mediatype.MediaTypeClient": "null", + "com.payload.mediatype.MediaTypeClient.getAsJson": "Payload.MediaType.StringBody.getAsJson", + "com.payload.mediatype.MediaTypeClient.getAsJsonWithResponse": "Payload.MediaType.StringBody.getAsJson", + "com.payload.mediatype.MediaTypeClient.getAsText": "Payload.MediaType.StringBody.getAsText", + "com.payload.mediatype.MediaTypeClient.getAsTextWithResponse": "Payload.MediaType.StringBody.getAsText", + "com.payload.mediatype.MediaTypeClient.sendAsJson": "Payload.MediaType.StringBody.sendAsJson", + "com.payload.mediatype.MediaTypeClient.sendAsJsonWithResponse": "Payload.MediaType.StringBody.sendAsJson", + "com.payload.mediatype.MediaTypeClient.sendAsText": "Payload.MediaType.StringBody.sendAsText", + "com.payload.mediatype.MediaTypeClient.sendAsTextWithResponse": "Payload.MediaType.StringBody.sendAsText", + "com.payload.mediatype.MediaTypeClientBuilder": "Payload.MediaType" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-multipart_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-multipart_apiview_properties.json new file mode 100644 index 000000000..086bd0358 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-multipart_apiview_properties.json @@ -0,0 +1,51 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.payload.multipart.MultiPartAsyncClient": "null", + "com.payload.multipart.MultiPartAsyncClient.anonymousModel": "Payload.MultiPart.FormData.anonymousModel", + "com.payload.multipart.MultiPartAsyncClient.anonymousModelWithResponse": "Payload.MultiPart.FormData.anonymousModel", + "com.payload.multipart.MultiPartAsyncClient.basic": "Payload.MultiPart.FormData.basic", + "com.payload.multipart.MultiPartAsyncClient.basicWithResponse": "Payload.MultiPart.FormData.basic", + "com.payload.multipart.MultiPartAsyncClient.binaryArrayParts": "Payload.MultiPart.FormData.binaryArrayParts", + "com.payload.multipart.MultiPartAsyncClient.binaryArrayPartsWithResponse": "Payload.MultiPart.FormData.binaryArrayParts", + "com.payload.multipart.MultiPartAsyncClient.checkFileNameAndContentType": "Payload.MultiPart.FormData.checkFileNameAndContentType", + "com.payload.multipart.MultiPartAsyncClient.checkFileNameAndContentTypeWithResponse": "Payload.MultiPart.FormData.checkFileNameAndContentType", + "com.payload.multipart.MultiPartAsyncClient.complex": "Payload.MultiPart.FormData.complex", + "com.payload.multipart.MultiPartAsyncClient.complexWithResponse": "Payload.MultiPart.FormData.complex", + "com.payload.multipart.MultiPartAsyncClient.jsonArrayParts": "Payload.MultiPart.FormData.jsonArrayParts", + "com.payload.multipart.MultiPartAsyncClient.jsonArrayPartsWithResponse": "Payload.MultiPart.FormData.jsonArrayParts", + "com.payload.multipart.MultiPartAsyncClient.jsonPart": "Payload.MultiPart.FormData.jsonPart", + "com.payload.multipart.MultiPartAsyncClient.jsonPartWithResponse": "Payload.MultiPart.FormData.jsonPart", + "com.payload.multipart.MultiPartAsyncClient.multiBinaryParts": "Payload.MultiPart.FormData.multiBinaryParts", + "com.payload.multipart.MultiPartAsyncClient.multiBinaryPartsWithResponse": "Payload.MultiPart.FormData.multiBinaryParts", + "com.payload.multipart.MultiPartClient": "null", + "com.payload.multipart.MultiPartClient.anonymousModel": "Payload.MultiPart.FormData.anonymousModel", + "com.payload.multipart.MultiPartClient.anonymousModelWithResponse": "Payload.MultiPart.FormData.anonymousModel", + "com.payload.multipart.MultiPartClient.basic": "Payload.MultiPart.FormData.basic", + "com.payload.multipart.MultiPartClient.basicWithResponse": "Payload.MultiPart.FormData.basic", + "com.payload.multipart.MultiPartClient.binaryArrayParts": "Payload.MultiPart.FormData.binaryArrayParts", + "com.payload.multipart.MultiPartClient.binaryArrayPartsWithResponse": "Payload.MultiPart.FormData.binaryArrayParts", + "com.payload.multipart.MultiPartClient.checkFileNameAndContentType": "Payload.MultiPart.FormData.checkFileNameAndContentType", + "com.payload.multipart.MultiPartClient.checkFileNameAndContentTypeWithResponse": "Payload.MultiPart.FormData.checkFileNameAndContentType", + "com.payload.multipart.MultiPartClient.complex": "Payload.MultiPart.FormData.complex", + "com.payload.multipart.MultiPartClient.complexWithResponse": "Payload.MultiPart.FormData.complex", + "com.payload.multipart.MultiPartClient.jsonArrayParts": "Payload.MultiPart.FormData.jsonArrayParts", + "com.payload.multipart.MultiPartClient.jsonArrayPartsWithResponse": "Payload.MultiPart.FormData.jsonArrayParts", + "com.payload.multipart.MultiPartClient.jsonPart": "Payload.MultiPart.FormData.jsonPart", + "com.payload.multipart.MultiPartClient.jsonPartWithResponse": "Payload.MultiPart.FormData.jsonPart", + "com.payload.multipart.MultiPartClient.multiBinaryParts": "Payload.MultiPart.FormData.multiBinaryParts", + "com.payload.multipart.MultiPartClient.multiBinaryPartsWithResponse": "Payload.MultiPart.FormData.multiBinaryParts", + "com.payload.multipart.MultiPartClientBuilder": "Payload.MultiPart", + "com.payload.multipart.implementation.models.AnonymousModelRequest": "anonymousModel.Request.anonymous", + "com.payload.multipart.models.Address": "Payload.MultiPart.Address", + "com.payload.multipart.models.BinaryArrayPartsRequest": "Payload.MultiPart.BinaryArrayPartsRequest", + "com.payload.multipart.models.ComplexPartsRequest": "Payload.MultiPart.ComplexPartsRequest", + "com.payload.multipart.models.JsonArrayPartsRequest": "Payload.MultiPart.JsonArrayPartsRequest", + "com.payload.multipart.models.JsonPartRequest": "Payload.MultiPart.JsonPartRequest", + "com.payload.multipart.models.MultiBinaryPartsRequest": "Payload.MultiPart.MultiBinaryPartsRequest", + "com.payload.multipart.models.MultiPartRequest": "Payload.MultiPart.MultiPartRequest", + "com.payload.multipart.models.PictureFileDetails": "null", + "com.payload.multipart.models.PicturesFileDetails": "null", + "com.payload.multipart.models.ProfileImageFileDetails": "null" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-pageable_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-pageable_apiview_properties.json new file mode 100644 index 000000000..76a291f1c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/payload-pageable_apiview_properties.json @@ -0,0 +1,11 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.payload.pageable.PageableAsyncClient": "Payload.Pageable", + "com.payload.pageable.PageableAsyncClient.list": "Payload.Pageable.list", + "com.payload.pageable.PageableClient": "Payload.Pageable", + "com.payload.pageable.PageableClient.list": "Payload.Pageable.list", + "com.payload.pageable.PageableClientBuilder": "Payload.Pageable", + "com.payload.pageable.models.User": "Payload.Pageable.User" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/resiliency-servicedriven-v1_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/resiliency-servicedriven-v1_apiview_properties.json new file mode 100644 index 000000000..54efb6f01 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/resiliency-servicedriven-v1_apiview_properties.json @@ -0,0 +1,20 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenAsyncClient": "Resiliency.ServiceDriven", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenAsyncClient.fromNone": "Resiliency.ServiceDriven.AddOptionalParam.fromNone", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenAsyncClient.fromNoneWithResponse": "Resiliency.ServiceDriven.AddOptionalParam.fromNone", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenAsyncClient.fromOneOptional": "Resiliency.ServiceDriven.AddOptionalParam.fromOneOptional", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenAsyncClient.fromOneOptionalWithResponse": "Resiliency.ServiceDriven.AddOptionalParam.fromOneOptional", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenAsyncClient.fromOneRequired": "Resiliency.ServiceDriven.AddOptionalParam.fromOneRequired", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenAsyncClient.fromOneRequiredWithResponse": "Resiliency.ServiceDriven.AddOptionalParam.fromOneRequired", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenClient": "Resiliency.ServiceDriven", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenClient.fromNone": "Resiliency.ServiceDriven.AddOptionalParam.fromNone", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenClient.fromNoneWithResponse": "Resiliency.ServiceDriven.AddOptionalParam.fromNone", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenClient.fromOneOptional": "Resiliency.ServiceDriven.AddOptionalParam.fromOneOptional", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenClient.fromOneOptionalWithResponse": "Resiliency.ServiceDriven.AddOptionalParam.fromOneOptional", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenClient.fromOneRequired": "Resiliency.ServiceDriven.AddOptionalParam.fromOneRequired", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenClient.fromOneRequiredWithResponse": "Resiliency.ServiceDriven.AddOptionalParam.fromOneRequired", + "com.resiliency.servicedriven.v1.ResiliencyServiceDrivenClientBuilder": "Resiliency.ServiceDriven" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/resiliency-servicedriven_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/resiliency-servicedriven_apiview_properties.json new file mode 100644 index 000000000..5a35d3220 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/resiliency-servicedriven_apiview_properties.json @@ -0,0 +1,24 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.resiliency.servicedriven.ResiliencyServiceDrivenAsyncClient": "Resiliency.ServiceDriven", + "com.resiliency.servicedriven.ResiliencyServiceDrivenAsyncClient.addOperation": "Resiliency.ServiceDriven.addOperation", + "com.resiliency.servicedriven.ResiliencyServiceDrivenAsyncClient.addOperationWithResponse": "Resiliency.ServiceDriven.addOperation", + "com.resiliency.servicedriven.ResiliencyServiceDrivenAsyncClient.fromNone": "Resiliency.ServiceDriven.AddOptionalParam.fromNone", + "com.resiliency.servicedriven.ResiliencyServiceDrivenAsyncClient.fromNoneWithResponse": "Resiliency.ServiceDriven.AddOptionalParam.fromNone", + "com.resiliency.servicedriven.ResiliencyServiceDrivenAsyncClient.fromOneOptional": "Resiliency.ServiceDriven.AddOptionalParam.fromOneOptional", + "com.resiliency.servicedriven.ResiliencyServiceDrivenAsyncClient.fromOneOptionalWithResponse": "Resiliency.ServiceDriven.AddOptionalParam.fromOneOptional", + "com.resiliency.servicedriven.ResiliencyServiceDrivenAsyncClient.fromOneRequired": "Resiliency.ServiceDriven.AddOptionalParam.fromOneRequired", + "com.resiliency.servicedriven.ResiliencyServiceDrivenAsyncClient.fromOneRequiredWithResponse": "Resiliency.ServiceDriven.AddOptionalParam.fromOneRequired", + "com.resiliency.servicedriven.ResiliencyServiceDrivenClient": "Resiliency.ServiceDriven", + "com.resiliency.servicedriven.ResiliencyServiceDrivenClient.addOperation": "Resiliency.ServiceDriven.addOperation", + "com.resiliency.servicedriven.ResiliencyServiceDrivenClient.addOperationWithResponse": "Resiliency.ServiceDriven.addOperation", + "com.resiliency.servicedriven.ResiliencyServiceDrivenClient.fromNone": "Resiliency.ServiceDriven.AddOptionalParam.fromNone", + "com.resiliency.servicedriven.ResiliencyServiceDrivenClient.fromNoneWithResponse": "Resiliency.ServiceDriven.AddOptionalParam.fromNone", + "com.resiliency.servicedriven.ResiliencyServiceDrivenClient.fromOneOptional": "Resiliency.ServiceDriven.AddOptionalParam.fromOneOptional", + "com.resiliency.servicedriven.ResiliencyServiceDrivenClient.fromOneOptionalWithResponse": "Resiliency.ServiceDriven.AddOptionalParam.fromOneOptional", + "com.resiliency.servicedriven.ResiliencyServiceDrivenClient.fromOneRequired": "Resiliency.ServiceDriven.AddOptionalParam.fromOneRequired", + "com.resiliency.servicedriven.ResiliencyServiceDrivenClient.fromOneRequiredWithResponse": "Resiliency.ServiceDriven.AddOptionalParam.fromOneRequired", + "com.resiliency.servicedriven.ResiliencyServiceDrivenClientBuilder": "Resiliency.ServiceDriven" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/serialization-encodedname-json_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/serialization-encodedname-json_apiview_properties.json new file mode 100644 index 000000000..682589461 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/serialization-encodedname-json_apiview_properties.json @@ -0,0 +1,17 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.serialization.encodedname.json.JsonAsyncClient": "null", + "com.serialization.encodedname.json.JsonAsyncClient.get": "Serialization.EncodedName.Json.Property.get", + "com.serialization.encodedname.json.JsonAsyncClient.getWithResponse": "Serialization.EncodedName.Json.Property.get", + "com.serialization.encodedname.json.JsonAsyncClient.send": "Serialization.EncodedName.Json.Property.send", + "com.serialization.encodedname.json.JsonAsyncClient.sendWithResponse": "Serialization.EncodedName.Json.Property.send", + "com.serialization.encodedname.json.JsonClient": "null", + "com.serialization.encodedname.json.JsonClient.get": "Serialization.EncodedName.Json.Property.get", + "com.serialization.encodedname.json.JsonClient.getWithResponse": "Serialization.EncodedName.Json.Property.get", + "com.serialization.encodedname.json.JsonClient.send": "Serialization.EncodedName.Json.Property.send", + "com.serialization.encodedname.json.JsonClient.sendWithResponse": "Serialization.EncodedName.Json.Property.send", + "com.serialization.encodedname.json.JsonClientBuilder": "Serialization.EncodedName.Json", + "com.serialization.encodedname.json.models.JsonEncodedNameModel": "Serialization.EncodedName.Json.Property.JsonEncodedNameModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-endpoint-notdefined_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-endpoint-notdefined_apiview_properties.json new file mode 100644 index 000000000..6f863265a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-endpoint-notdefined_apiview_properties.json @@ -0,0 +1,12 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.server.endpoint.notdefined.NotDefinedAsyncClient": "Server.Endpoint.NotDefined", + "com.server.endpoint.notdefined.NotDefinedAsyncClient.valid": "Server.Endpoint.NotDefined.valid", + "com.server.endpoint.notdefined.NotDefinedAsyncClient.validWithResponse": "Server.Endpoint.NotDefined.valid", + "com.server.endpoint.notdefined.NotDefinedClient": "Server.Endpoint.NotDefined", + "com.server.endpoint.notdefined.NotDefinedClient.valid": "Server.Endpoint.NotDefined.valid", + "com.server.endpoint.notdefined.NotDefinedClient.validWithResponse": "Server.Endpoint.NotDefined.valid", + "com.server.endpoint.notdefined.NotDefinedClientBuilder": "Server.Endpoint.NotDefined" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-path-multiple_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-path-multiple_apiview_properties.json new file mode 100644 index 000000000..8d6dd0bda --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-path-multiple_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.server.path.multiple.MultipleAsyncClient": "Server.Path.Multiple", + "com.server.path.multiple.MultipleAsyncClient.noOperationParams": "Server.Path.Multiple.noOperationParams", + "com.server.path.multiple.MultipleAsyncClient.noOperationParamsWithResponse": "Server.Path.Multiple.noOperationParams", + "com.server.path.multiple.MultipleAsyncClient.withOperationPathParam": "Server.Path.Multiple.withOperationPathParam", + "com.server.path.multiple.MultipleAsyncClient.withOperationPathParamWithResponse": "Server.Path.Multiple.withOperationPathParam", + "com.server.path.multiple.MultipleClient": "Server.Path.Multiple", + "com.server.path.multiple.MultipleClient.noOperationParams": "Server.Path.Multiple.noOperationParams", + "com.server.path.multiple.MultipleClient.noOperationParamsWithResponse": "Server.Path.Multiple.noOperationParams", + "com.server.path.multiple.MultipleClient.withOperationPathParam": "Server.Path.Multiple.withOperationPathParam", + "com.server.path.multiple.MultipleClient.withOperationPathParamWithResponse": "Server.Path.Multiple.withOperationPathParam", + "com.server.path.multiple.MultipleClientBuilder": "Server.Path.Multiple" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-path-single_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-path-single_apiview_properties.json new file mode 100644 index 000000000..8fe7533c4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-path-single_apiview_properties.json @@ -0,0 +1,12 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.server.path.single.SingleAsyncClient": "Server.Path.Single", + "com.server.path.single.SingleAsyncClient.myOp": "Server.Path.Single.myOp", + "com.server.path.single.SingleAsyncClient.myOpWithResponse": "Server.Path.Single.myOp", + "com.server.path.single.SingleClient": "Server.Path.Single", + "com.server.path.single.SingleClient.myOp": "Server.Path.Single.myOp", + "com.server.path.single.SingleClient.myOpWithResponse": "Server.Path.Single.myOp", + "com.server.path.single.SingleClientBuilder": "Server.Path.Single" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-versions-notversioned_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-versions-notversioned_apiview_properties.json new file mode 100644 index 000000000..01edbe1af --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-versions-notversioned_apiview_properties.json @@ -0,0 +1,20 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.server.versions.notversioned.NotVersionedAsyncClient": "Server.Versions.NotVersioned", + "com.server.versions.notversioned.NotVersionedAsyncClient.withPathApiVersion": "Server.Versions.NotVersioned.withPathApiVersion", + "com.server.versions.notversioned.NotVersionedAsyncClient.withPathApiVersionWithResponse": "Server.Versions.NotVersioned.withPathApiVersion", + "com.server.versions.notversioned.NotVersionedAsyncClient.withQueryApiVersion": "Server.Versions.NotVersioned.withQueryApiVersion", + "com.server.versions.notversioned.NotVersionedAsyncClient.withQueryApiVersionWithResponse": "Server.Versions.NotVersioned.withQueryApiVersion", + "com.server.versions.notversioned.NotVersionedAsyncClient.withoutApiVersion": "Server.Versions.NotVersioned.withoutApiVersion", + "com.server.versions.notversioned.NotVersionedAsyncClient.withoutApiVersionWithResponse": "Server.Versions.NotVersioned.withoutApiVersion", + "com.server.versions.notversioned.NotVersionedClient": "Server.Versions.NotVersioned", + "com.server.versions.notversioned.NotVersionedClient.withPathApiVersion": "Server.Versions.NotVersioned.withPathApiVersion", + "com.server.versions.notversioned.NotVersionedClient.withPathApiVersionWithResponse": "Server.Versions.NotVersioned.withPathApiVersion", + "com.server.versions.notversioned.NotVersionedClient.withQueryApiVersion": "Server.Versions.NotVersioned.withQueryApiVersion", + "com.server.versions.notversioned.NotVersionedClient.withQueryApiVersionWithResponse": "Server.Versions.NotVersioned.withQueryApiVersion", + "com.server.versions.notversioned.NotVersionedClient.withoutApiVersion": "Server.Versions.NotVersioned.withoutApiVersion", + "com.server.versions.notversioned.NotVersionedClient.withoutApiVersionWithResponse": "Server.Versions.NotVersioned.withoutApiVersion", + "com.server.versions.notversioned.NotVersionedClientBuilder": "Server.Versions.NotVersioned" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-versions-versioned_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-versions-versioned_apiview_properties.json new file mode 100644 index 000000000..d2c1be380 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/server-versions-versioned_apiview_properties.json @@ -0,0 +1,24 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.server.versions.versioned.VersionedAsyncClient": "Server.Versions.Versioned", + "com.server.versions.versioned.VersionedAsyncClient.withPathApiVersion": "Server.Versions.Versioned.withPathApiVersion", + "com.server.versions.versioned.VersionedAsyncClient.withPathApiVersionWithResponse": "Server.Versions.Versioned.withPathApiVersion", + "com.server.versions.versioned.VersionedAsyncClient.withQueryApiVersion": "Server.Versions.Versioned.withQueryApiVersion", + "com.server.versions.versioned.VersionedAsyncClient.withQueryApiVersionWithResponse": "Server.Versions.Versioned.withQueryApiVersion", + "com.server.versions.versioned.VersionedAsyncClient.withQueryOldApiVersion": "Server.Versions.Versioned.withQueryOldApiVersion", + "com.server.versions.versioned.VersionedAsyncClient.withQueryOldApiVersionWithResponse": "Server.Versions.Versioned.withQueryOldApiVersion", + "com.server.versions.versioned.VersionedAsyncClient.withoutApiVersion": "Server.Versions.Versioned.withoutApiVersion", + "com.server.versions.versioned.VersionedAsyncClient.withoutApiVersionWithResponse": "Server.Versions.Versioned.withoutApiVersion", + "com.server.versions.versioned.VersionedClient": "Server.Versions.Versioned", + "com.server.versions.versioned.VersionedClient.withPathApiVersion": "Server.Versions.Versioned.withPathApiVersion", + "com.server.versions.versioned.VersionedClient.withPathApiVersionWithResponse": "Server.Versions.Versioned.withPathApiVersion", + "com.server.versions.versioned.VersionedClient.withQueryApiVersion": "Server.Versions.Versioned.withQueryApiVersion", + "com.server.versions.versioned.VersionedClient.withQueryApiVersionWithResponse": "Server.Versions.Versioned.withQueryApiVersion", + "com.server.versions.versioned.VersionedClient.withQueryOldApiVersion": "Server.Versions.Versioned.withQueryOldApiVersion", + "com.server.versions.versioned.VersionedClient.withQueryOldApiVersionWithResponse": "Server.Versions.Versioned.withQueryOldApiVersion", + "com.server.versions.versioned.VersionedClient.withoutApiVersion": "Server.Versions.Versioned.withoutApiVersion", + "com.server.versions.versioned.VersionedClient.withoutApiVersionWithResponse": "Server.Versions.Versioned.withoutApiVersion", + "com.server.versions.versioned.VersionedClientBuilder": "Server.Versions.Versioned" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-conditionalrequest_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-conditionalrequest_apiview_properties.json new file mode 100644 index 000000000..a5a0f5062 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-conditionalrequest_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.specialheaders.conditionalrequest.ConditionalRequestAsyncClient": "SpecialHeaders.ConditionalRequest", + "com.specialheaders.conditionalrequest.ConditionalRequestAsyncClient.postIfMatch": "SpecialHeaders.ConditionalRequest.postIfMatch", + "com.specialheaders.conditionalrequest.ConditionalRequestAsyncClient.postIfMatchWithResponse": "SpecialHeaders.ConditionalRequest.postIfMatch", + "com.specialheaders.conditionalrequest.ConditionalRequestAsyncClient.postIfNoneMatch": "SpecialHeaders.ConditionalRequest.postIfNoneMatch", + "com.specialheaders.conditionalrequest.ConditionalRequestAsyncClient.postIfNoneMatchWithResponse": "SpecialHeaders.ConditionalRequest.postIfNoneMatch", + "com.specialheaders.conditionalrequest.ConditionalRequestClient": "SpecialHeaders.ConditionalRequest", + "com.specialheaders.conditionalrequest.ConditionalRequestClient.postIfMatch": "SpecialHeaders.ConditionalRequest.postIfMatch", + "com.specialheaders.conditionalrequest.ConditionalRequestClient.postIfMatchWithResponse": "SpecialHeaders.ConditionalRequest.postIfMatch", + "com.specialheaders.conditionalrequest.ConditionalRequestClient.postIfNoneMatch": "SpecialHeaders.ConditionalRequest.postIfNoneMatch", + "com.specialheaders.conditionalrequest.ConditionalRequestClient.postIfNoneMatchWithResponse": "SpecialHeaders.ConditionalRequest.postIfNoneMatch", + "com.specialheaders.conditionalrequest.ConditionalRequestClientBuilder": "SpecialHeaders.ConditionalRequest" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-repeatability_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-repeatability_apiview_properties.json new file mode 100644 index 000000000..734dbfc57 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialheaders-repeatability_apiview_properties.json @@ -0,0 +1,12 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.specialheaders.repeatability.RepeatabilityAsyncClient": "SpecialHeaders.Repeatability", + "com.specialheaders.repeatability.RepeatabilityAsyncClient.immediateSuccess": "SpecialHeaders.Repeatability.immediateSuccess", + "com.specialheaders.repeatability.RepeatabilityAsyncClient.immediateSuccessWithResponse": "SpecialHeaders.Repeatability.immediateSuccess", + "com.specialheaders.repeatability.RepeatabilityClient": "SpecialHeaders.Repeatability", + "com.specialheaders.repeatability.RepeatabilityClient.immediateSuccess": "SpecialHeaders.Repeatability.immediateSuccess", + "com.specialheaders.repeatability.RepeatabilityClient.immediateSuccessWithResponse": "SpecialHeaders.Repeatability.immediateSuccess", + "com.specialheaders.repeatability.RepeatabilityClientBuilder": "SpecialHeaders.Repeatability" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialwords_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialwords_apiview_properties.json new file mode 100644 index 000000000..5d98692ee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/specialwords_apiview_properties.json @@ -0,0 +1,448 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.specialwords.ModelPropertiesAsyncClient": "null", + "com.specialwords.ModelPropertiesAsyncClient.sameAsModel": "SpecialWords.ModelProperties.sameAsModel", + "com.specialwords.ModelPropertiesAsyncClient.sameAsModelWithResponse": "SpecialWords.ModelProperties.sameAsModel", + "com.specialwords.ModelPropertiesClient": "null", + "com.specialwords.ModelPropertiesClient.sameAsModel": "SpecialWords.ModelProperties.sameAsModel", + "com.specialwords.ModelPropertiesClient.sameAsModelWithResponse": "SpecialWords.ModelProperties.sameAsModel", + "com.specialwords.ModelsAsyncClient": "null", + "com.specialwords.ModelsAsyncClient.withAnd": "SpecialWords.Models.withAnd", + "com.specialwords.ModelsAsyncClient.withAndWithResponse": "SpecialWords.Models.withAnd", + "com.specialwords.ModelsAsyncClient.withAs": "SpecialWords.Models.withAs", + "com.specialwords.ModelsAsyncClient.withAsWithResponse": "SpecialWords.Models.withAs", + "com.specialwords.ModelsAsyncClient.withAssert": "SpecialWords.Models.withAssert", + "com.specialwords.ModelsAsyncClient.withAssertWithResponse": "SpecialWords.Models.withAssert", + "com.specialwords.ModelsAsyncClient.withAsyncWithResponse": "SpecialWords.Models.withAsync", + "com.specialwords.ModelsAsyncClient.withAwait": "SpecialWords.Models.withAwait", + "com.specialwords.ModelsAsyncClient.withAwaitWithResponse": "SpecialWords.Models.withAwait", + "com.specialwords.ModelsAsyncClient.withBreak": "SpecialWords.Models.withBreak", + "com.specialwords.ModelsAsyncClient.withBreakWithResponse": "SpecialWords.Models.withBreak", + "com.specialwords.ModelsAsyncClient.withClass": "SpecialWords.Models.withClass", + "com.specialwords.ModelsAsyncClient.withClassWithResponse": "SpecialWords.Models.withClass", + "com.specialwords.ModelsAsyncClient.withConstructor": "SpecialWords.Models.withConstructor", + "com.specialwords.ModelsAsyncClient.withConstructorWithResponse": "SpecialWords.Models.withConstructor", + "com.specialwords.ModelsAsyncClient.withContinue": "SpecialWords.Models.withContinue", + "com.specialwords.ModelsAsyncClient.withContinueWithResponse": "SpecialWords.Models.withContinue", + "com.specialwords.ModelsAsyncClient.withDef": "SpecialWords.Models.withDef", + "com.specialwords.ModelsAsyncClient.withDefWithResponse": "SpecialWords.Models.withDef", + "com.specialwords.ModelsAsyncClient.withDel": "SpecialWords.Models.withDel", + "com.specialwords.ModelsAsyncClient.withDelWithResponse": "SpecialWords.Models.withDel", + "com.specialwords.ModelsAsyncClient.withElif": "SpecialWords.Models.withElif", + "com.specialwords.ModelsAsyncClient.withElifWithResponse": "SpecialWords.Models.withElif", + "com.specialwords.ModelsAsyncClient.withElse": "SpecialWords.Models.withElse", + "com.specialwords.ModelsAsyncClient.withElseWithResponse": "SpecialWords.Models.withElse", + "com.specialwords.ModelsAsyncClient.withExcept": "SpecialWords.Models.withExcept", + "com.specialwords.ModelsAsyncClient.withExceptWithResponse": "SpecialWords.Models.withExcept", + "com.specialwords.ModelsAsyncClient.withExec": "SpecialWords.Models.withExec", + "com.specialwords.ModelsAsyncClient.withExecWithResponse": "SpecialWords.Models.withExec", + "com.specialwords.ModelsAsyncClient.withFinally": "SpecialWords.Models.withFinally", + "com.specialwords.ModelsAsyncClient.withFinallyWithResponse": "SpecialWords.Models.withFinally", + "com.specialwords.ModelsAsyncClient.withFor": "SpecialWords.Models.withFor", + "com.specialwords.ModelsAsyncClient.withForWithResponse": "SpecialWords.Models.withFor", + "com.specialwords.ModelsAsyncClient.withFrom": "SpecialWords.Models.withFrom", + "com.specialwords.ModelsAsyncClient.withFromWithResponse": "SpecialWords.Models.withFrom", + "com.specialwords.ModelsAsyncClient.withGlobal": "SpecialWords.Models.withGlobal", + "com.specialwords.ModelsAsyncClient.withGlobalWithResponse": "SpecialWords.Models.withGlobal", + "com.specialwords.ModelsAsyncClient.withIf": "SpecialWords.Models.withIf", + "com.specialwords.ModelsAsyncClient.withIfWithResponse": "SpecialWords.Models.withIf", + "com.specialwords.ModelsAsyncClient.withImport": "SpecialWords.Models.withImport", + "com.specialwords.ModelsAsyncClient.withImportWithResponse": "SpecialWords.Models.withImport", + "com.specialwords.ModelsAsyncClient.withIn": "SpecialWords.Models.withIn", + "com.specialwords.ModelsAsyncClient.withInWithResponse": "SpecialWords.Models.withIn", + "com.specialwords.ModelsAsyncClient.withIs": "SpecialWords.Models.withIs", + "com.specialwords.ModelsAsyncClient.withIsWithResponse": "SpecialWords.Models.withIs", + "com.specialwords.ModelsAsyncClient.withLambda": "SpecialWords.Models.withLambda", + "com.specialwords.ModelsAsyncClient.withLambdaWithResponse": "SpecialWords.Models.withLambda", + "com.specialwords.ModelsAsyncClient.withNot": "SpecialWords.Models.withNot", + "com.specialwords.ModelsAsyncClient.withNotWithResponse": "SpecialWords.Models.withNot", + "com.specialwords.ModelsAsyncClient.withOr": "SpecialWords.Models.withOr", + "com.specialwords.ModelsAsyncClient.withOrWithResponse": "SpecialWords.Models.withOr", + "com.specialwords.ModelsAsyncClient.withPass": "SpecialWords.Models.withPass", + "com.specialwords.ModelsAsyncClient.withPassWithResponse": "SpecialWords.Models.withPass", + "com.specialwords.ModelsAsyncClient.withRaise": "SpecialWords.Models.withRaise", + "com.specialwords.ModelsAsyncClient.withRaiseWithResponse": "SpecialWords.Models.withRaise", + "com.specialwords.ModelsAsyncClient.withReturn": "SpecialWords.Models.withReturn", + "com.specialwords.ModelsAsyncClient.withReturnWithResponse": "SpecialWords.Models.withReturn", + "com.specialwords.ModelsAsyncClient.withTry": "SpecialWords.Models.withTry", + "com.specialwords.ModelsAsyncClient.withTryWithResponse": "SpecialWords.Models.withTry", + "com.specialwords.ModelsAsyncClient.withWhile": "SpecialWords.Models.withWhile", + "com.specialwords.ModelsAsyncClient.withWhileWithResponse": "SpecialWords.Models.withWhile", + "com.specialwords.ModelsAsyncClient.withWith": "SpecialWords.Models.withWith", + "com.specialwords.ModelsAsyncClient.withWithWithResponse": "SpecialWords.Models.withWith", + "com.specialwords.ModelsAsyncClient.withYield": "SpecialWords.Models.withYield", + "com.specialwords.ModelsAsyncClient.withYieldWithResponse": "SpecialWords.Models.withYield", + "com.specialwords.ModelsClient": "null", + "com.specialwords.ModelsClient.withAnd": "SpecialWords.Models.withAnd", + "com.specialwords.ModelsClient.withAndWithResponse": "SpecialWords.Models.withAnd", + "com.specialwords.ModelsClient.withAs": "SpecialWords.Models.withAs", + "com.specialwords.ModelsClient.withAsWithResponse": "SpecialWords.Models.withAs", + "com.specialwords.ModelsClient.withAssert": "SpecialWords.Models.withAssert", + "com.specialwords.ModelsClient.withAssertWithResponse": "SpecialWords.Models.withAssert", + "com.specialwords.ModelsClient.withAsyncWithResponse": "SpecialWords.Models.withAsync", + "com.specialwords.ModelsClient.withAwait": "SpecialWords.Models.withAwait", + "com.specialwords.ModelsClient.withAwaitWithResponse": "SpecialWords.Models.withAwait", + "com.specialwords.ModelsClient.withBreak": "SpecialWords.Models.withBreak", + "com.specialwords.ModelsClient.withBreakWithResponse": "SpecialWords.Models.withBreak", + "com.specialwords.ModelsClient.withClass": "SpecialWords.Models.withClass", + "com.specialwords.ModelsClient.withClassWithResponse": "SpecialWords.Models.withClass", + "com.specialwords.ModelsClient.withConstructor": "SpecialWords.Models.withConstructor", + "com.specialwords.ModelsClient.withConstructorWithResponse": "SpecialWords.Models.withConstructor", + "com.specialwords.ModelsClient.withContinue": "SpecialWords.Models.withContinue", + "com.specialwords.ModelsClient.withContinueWithResponse": "SpecialWords.Models.withContinue", + "com.specialwords.ModelsClient.withDef": "SpecialWords.Models.withDef", + "com.specialwords.ModelsClient.withDefWithResponse": "SpecialWords.Models.withDef", + "com.specialwords.ModelsClient.withDel": "SpecialWords.Models.withDel", + "com.specialwords.ModelsClient.withDelWithResponse": "SpecialWords.Models.withDel", + "com.specialwords.ModelsClient.withElif": "SpecialWords.Models.withElif", + "com.specialwords.ModelsClient.withElifWithResponse": "SpecialWords.Models.withElif", + "com.specialwords.ModelsClient.withElse": "SpecialWords.Models.withElse", + "com.specialwords.ModelsClient.withElseWithResponse": "SpecialWords.Models.withElse", + "com.specialwords.ModelsClient.withExcept": "SpecialWords.Models.withExcept", + "com.specialwords.ModelsClient.withExceptWithResponse": "SpecialWords.Models.withExcept", + "com.specialwords.ModelsClient.withExec": "SpecialWords.Models.withExec", + "com.specialwords.ModelsClient.withExecWithResponse": "SpecialWords.Models.withExec", + "com.specialwords.ModelsClient.withFinally": "SpecialWords.Models.withFinally", + "com.specialwords.ModelsClient.withFinallyWithResponse": "SpecialWords.Models.withFinally", + "com.specialwords.ModelsClient.withFor": "SpecialWords.Models.withFor", + "com.specialwords.ModelsClient.withForWithResponse": "SpecialWords.Models.withFor", + "com.specialwords.ModelsClient.withFrom": "SpecialWords.Models.withFrom", + "com.specialwords.ModelsClient.withFromWithResponse": "SpecialWords.Models.withFrom", + "com.specialwords.ModelsClient.withGlobal": "SpecialWords.Models.withGlobal", + "com.specialwords.ModelsClient.withGlobalWithResponse": "SpecialWords.Models.withGlobal", + "com.specialwords.ModelsClient.withIf": "SpecialWords.Models.withIf", + "com.specialwords.ModelsClient.withIfWithResponse": "SpecialWords.Models.withIf", + "com.specialwords.ModelsClient.withImport": "SpecialWords.Models.withImport", + "com.specialwords.ModelsClient.withImportWithResponse": "SpecialWords.Models.withImport", + "com.specialwords.ModelsClient.withIn": "SpecialWords.Models.withIn", + "com.specialwords.ModelsClient.withInWithResponse": "SpecialWords.Models.withIn", + "com.specialwords.ModelsClient.withIs": "SpecialWords.Models.withIs", + "com.specialwords.ModelsClient.withIsWithResponse": "SpecialWords.Models.withIs", + "com.specialwords.ModelsClient.withLambda": "SpecialWords.Models.withLambda", + "com.specialwords.ModelsClient.withLambdaWithResponse": "SpecialWords.Models.withLambda", + "com.specialwords.ModelsClient.withNot": "SpecialWords.Models.withNot", + "com.specialwords.ModelsClient.withNotWithResponse": "SpecialWords.Models.withNot", + "com.specialwords.ModelsClient.withOr": "SpecialWords.Models.withOr", + "com.specialwords.ModelsClient.withOrWithResponse": "SpecialWords.Models.withOr", + "com.specialwords.ModelsClient.withPass": "SpecialWords.Models.withPass", + "com.specialwords.ModelsClient.withPassWithResponse": "SpecialWords.Models.withPass", + "com.specialwords.ModelsClient.withRaise": "SpecialWords.Models.withRaise", + "com.specialwords.ModelsClient.withRaiseWithResponse": "SpecialWords.Models.withRaise", + "com.specialwords.ModelsClient.withReturn": "SpecialWords.Models.withReturn", + "com.specialwords.ModelsClient.withReturnWithResponse": "SpecialWords.Models.withReturn", + "com.specialwords.ModelsClient.withTry": "SpecialWords.Models.withTry", + "com.specialwords.ModelsClient.withTryWithResponse": "SpecialWords.Models.withTry", + "com.specialwords.ModelsClient.withWhile": "SpecialWords.Models.withWhile", + "com.specialwords.ModelsClient.withWhileWithResponse": "SpecialWords.Models.withWhile", + "com.specialwords.ModelsClient.withWith": "SpecialWords.Models.withWith", + "com.specialwords.ModelsClient.withWithWithResponse": "SpecialWords.Models.withWith", + "com.specialwords.ModelsClient.withYield": "SpecialWords.Models.withYield", + "com.specialwords.ModelsClient.withYieldWithResponse": "SpecialWords.Models.withYield", + "com.specialwords.OperationsAsyncClient": "null", + "com.specialwords.OperationsAsyncClient.and": "SpecialWords.Operations.and", + "com.specialwords.OperationsAsyncClient.andWithResponse": "SpecialWords.Operations.and", + "com.specialwords.OperationsAsyncClient.as": "SpecialWords.Operations.as", + "com.specialwords.OperationsAsyncClient.asWithResponse": "SpecialWords.Operations.as", + "com.specialwords.OperationsAsyncClient.assertMethod": "SpecialWords.Operations.assert", + "com.specialwords.OperationsAsyncClient.assertMethodWithResponse": "SpecialWords.Operations.assert", + "com.specialwords.OperationsAsyncClient.async": "SpecialWords.Operations.async", + "com.specialwords.OperationsAsyncClient.asyncWithResponse": "SpecialWords.Operations.async", + "com.specialwords.OperationsAsyncClient.await": "SpecialWords.Operations.await", + "com.specialwords.OperationsAsyncClient.awaitWithResponse": "SpecialWords.Operations.await", + "com.specialwords.OperationsAsyncClient.breakMethod": "SpecialWords.Operations.break", + "com.specialwords.OperationsAsyncClient.breakMethodWithResponse": "SpecialWords.Operations.break", + "com.specialwords.OperationsAsyncClient.classMethod": "SpecialWords.Operations.class", + "com.specialwords.OperationsAsyncClient.classMethodWithResponse": "SpecialWords.Operations.class", + "com.specialwords.OperationsAsyncClient.constructor": "SpecialWords.Operations.constructor", + "com.specialwords.OperationsAsyncClient.constructorWithResponse": "SpecialWords.Operations.constructor", + "com.specialwords.OperationsAsyncClient.continueMethod": "SpecialWords.Operations.continue", + "com.specialwords.OperationsAsyncClient.continueMethodWithResponse": "SpecialWords.Operations.continue", + "com.specialwords.OperationsAsyncClient.def": "SpecialWords.Operations.def", + "com.specialwords.OperationsAsyncClient.defWithResponse": "SpecialWords.Operations.def", + "com.specialwords.OperationsAsyncClient.del": "SpecialWords.Operations.del", + "com.specialwords.OperationsAsyncClient.delWithResponse": "SpecialWords.Operations.del", + "com.specialwords.OperationsAsyncClient.elif": "SpecialWords.Operations.elif", + "com.specialwords.OperationsAsyncClient.elifWithResponse": "SpecialWords.Operations.elif", + "com.specialwords.OperationsAsyncClient.elseMethod": "SpecialWords.Operations.else", + "com.specialwords.OperationsAsyncClient.elseMethodWithResponse": "SpecialWords.Operations.else", + "com.specialwords.OperationsAsyncClient.except": "SpecialWords.Operations.except", + "com.specialwords.OperationsAsyncClient.exceptWithResponse": "SpecialWords.Operations.except", + "com.specialwords.OperationsAsyncClient.exec": "SpecialWords.Operations.exec", + "com.specialwords.OperationsAsyncClient.execWithResponse": "SpecialWords.Operations.exec", + "com.specialwords.OperationsAsyncClient.finallyMethod": "SpecialWords.Operations.finally", + "com.specialwords.OperationsAsyncClient.finallyMethodWithResponse": "SpecialWords.Operations.finally", + "com.specialwords.OperationsAsyncClient.forMethod": "SpecialWords.Operations.for", + "com.specialwords.OperationsAsyncClient.forMethodWithResponse": "SpecialWords.Operations.for", + "com.specialwords.OperationsAsyncClient.from": "SpecialWords.Operations.from", + "com.specialwords.OperationsAsyncClient.fromWithResponse": "SpecialWords.Operations.from", + "com.specialwords.OperationsAsyncClient.global": "SpecialWords.Operations.global", + "com.specialwords.OperationsAsyncClient.globalWithResponse": "SpecialWords.Operations.global", + "com.specialwords.OperationsAsyncClient.ifMethod": "SpecialWords.Operations.if", + "com.specialwords.OperationsAsyncClient.ifMethodWithResponse": "SpecialWords.Operations.if", + "com.specialwords.OperationsAsyncClient.importMethod": "SpecialWords.Operations.import", + "com.specialwords.OperationsAsyncClient.importMethodWithResponse": "SpecialWords.Operations.import", + "com.specialwords.OperationsAsyncClient.in": "SpecialWords.Operations.in", + "com.specialwords.OperationsAsyncClient.inWithResponse": "SpecialWords.Operations.in", + "com.specialwords.OperationsAsyncClient.is": "SpecialWords.Operations.is", + "com.specialwords.OperationsAsyncClient.isWithResponse": "SpecialWords.Operations.is", + "com.specialwords.OperationsAsyncClient.lambda": "SpecialWords.Operations.lambda", + "com.specialwords.OperationsAsyncClient.lambdaWithResponse": "SpecialWords.Operations.lambda", + "com.specialwords.OperationsAsyncClient.not": "SpecialWords.Operations.not", + "com.specialwords.OperationsAsyncClient.notWithResponse": "SpecialWords.Operations.not", + "com.specialwords.OperationsAsyncClient.or": "SpecialWords.Operations.or", + "com.specialwords.OperationsAsyncClient.orWithResponse": "SpecialWords.Operations.or", + "com.specialwords.OperationsAsyncClient.pass": "SpecialWords.Operations.pass", + "com.specialwords.OperationsAsyncClient.passWithResponse": "SpecialWords.Operations.pass", + "com.specialwords.OperationsAsyncClient.raise": "SpecialWords.Operations.raise", + "com.specialwords.OperationsAsyncClient.raiseWithResponse": "SpecialWords.Operations.raise", + "com.specialwords.OperationsAsyncClient.returnMethod": "SpecialWords.Operations.return", + "com.specialwords.OperationsAsyncClient.returnMethodWithResponse": "SpecialWords.Operations.return", + "com.specialwords.OperationsAsyncClient.tryMethod": "SpecialWords.Operations.try", + "com.specialwords.OperationsAsyncClient.tryMethodWithResponse": "SpecialWords.Operations.try", + "com.specialwords.OperationsAsyncClient.whileMethod": "SpecialWords.Operations.while", + "com.specialwords.OperationsAsyncClient.whileMethodWithResponse": "SpecialWords.Operations.while", + "com.specialwords.OperationsAsyncClient.with": "SpecialWords.Operations.with", + "com.specialwords.OperationsAsyncClient.withWithResponse": "SpecialWords.Operations.with", + "com.specialwords.OperationsAsyncClient.yield": "SpecialWords.Operations.yield", + "com.specialwords.OperationsAsyncClient.yieldWithResponse": "SpecialWords.Operations.yield", + "com.specialwords.OperationsClient": "null", + "com.specialwords.OperationsClient.and": "SpecialWords.Operations.and", + "com.specialwords.OperationsClient.andWithResponse": "SpecialWords.Operations.and", + "com.specialwords.OperationsClient.as": "SpecialWords.Operations.as", + "com.specialwords.OperationsClient.asWithResponse": "SpecialWords.Operations.as", + "com.specialwords.OperationsClient.assertMethod": "SpecialWords.Operations.assert", + "com.specialwords.OperationsClient.assertMethodWithResponse": "SpecialWords.Operations.assert", + "com.specialwords.OperationsClient.async": "SpecialWords.Operations.async", + "com.specialwords.OperationsClient.asyncWithResponse": "SpecialWords.Operations.async", + "com.specialwords.OperationsClient.await": "SpecialWords.Operations.await", + "com.specialwords.OperationsClient.awaitWithResponse": "SpecialWords.Operations.await", + "com.specialwords.OperationsClient.breakMethod": "SpecialWords.Operations.break", + "com.specialwords.OperationsClient.breakMethodWithResponse": "SpecialWords.Operations.break", + "com.specialwords.OperationsClient.classMethod": "SpecialWords.Operations.class", + "com.specialwords.OperationsClient.classMethodWithResponse": "SpecialWords.Operations.class", + "com.specialwords.OperationsClient.constructor": "SpecialWords.Operations.constructor", + "com.specialwords.OperationsClient.constructorWithResponse": "SpecialWords.Operations.constructor", + "com.specialwords.OperationsClient.continueMethod": "SpecialWords.Operations.continue", + "com.specialwords.OperationsClient.continueMethodWithResponse": "SpecialWords.Operations.continue", + "com.specialwords.OperationsClient.def": "SpecialWords.Operations.def", + "com.specialwords.OperationsClient.defWithResponse": "SpecialWords.Operations.def", + "com.specialwords.OperationsClient.del": "SpecialWords.Operations.del", + "com.specialwords.OperationsClient.delWithResponse": "SpecialWords.Operations.del", + "com.specialwords.OperationsClient.elif": "SpecialWords.Operations.elif", + "com.specialwords.OperationsClient.elifWithResponse": "SpecialWords.Operations.elif", + "com.specialwords.OperationsClient.elseMethod": "SpecialWords.Operations.else", + "com.specialwords.OperationsClient.elseMethodWithResponse": "SpecialWords.Operations.else", + "com.specialwords.OperationsClient.except": "SpecialWords.Operations.except", + "com.specialwords.OperationsClient.exceptWithResponse": "SpecialWords.Operations.except", + "com.specialwords.OperationsClient.exec": "SpecialWords.Operations.exec", + "com.specialwords.OperationsClient.execWithResponse": "SpecialWords.Operations.exec", + "com.specialwords.OperationsClient.finallyMethod": "SpecialWords.Operations.finally", + "com.specialwords.OperationsClient.finallyMethodWithResponse": "SpecialWords.Operations.finally", + "com.specialwords.OperationsClient.forMethod": "SpecialWords.Operations.for", + "com.specialwords.OperationsClient.forMethodWithResponse": "SpecialWords.Operations.for", + "com.specialwords.OperationsClient.from": "SpecialWords.Operations.from", + "com.specialwords.OperationsClient.fromWithResponse": "SpecialWords.Operations.from", + "com.specialwords.OperationsClient.global": "SpecialWords.Operations.global", + "com.specialwords.OperationsClient.globalWithResponse": "SpecialWords.Operations.global", + "com.specialwords.OperationsClient.ifMethod": "SpecialWords.Operations.if", + "com.specialwords.OperationsClient.ifMethodWithResponse": "SpecialWords.Operations.if", + "com.specialwords.OperationsClient.importMethod": "SpecialWords.Operations.import", + "com.specialwords.OperationsClient.importMethodWithResponse": "SpecialWords.Operations.import", + "com.specialwords.OperationsClient.in": "SpecialWords.Operations.in", + "com.specialwords.OperationsClient.inWithResponse": "SpecialWords.Operations.in", + "com.specialwords.OperationsClient.is": "SpecialWords.Operations.is", + "com.specialwords.OperationsClient.isWithResponse": "SpecialWords.Operations.is", + "com.specialwords.OperationsClient.lambda": "SpecialWords.Operations.lambda", + "com.specialwords.OperationsClient.lambdaWithResponse": "SpecialWords.Operations.lambda", + "com.specialwords.OperationsClient.not": "SpecialWords.Operations.not", + "com.specialwords.OperationsClient.notWithResponse": "SpecialWords.Operations.not", + "com.specialwords.OperationsClient.or": "SpecialWords.Operations.or", + "com.specialwords.OperationsClient.orWithResponse": "SpecialWords.Operations.or", + "com.specialwords.OperationsClient.pass": "SpecialWords.Operations.pass", + "com.specialwords.OperationsClient.passWithResponse": "SpecialWords.Operations.pass", + "com.specialwords.OperationsClient.raise": "SpecialWords.Operations.raise", + "com.specialwords.OperationsClient.raiseWithResponse": "SpecialWords.Operations.raise", + "com.specialwords.OperationsClient.returnMethod": "SpecialWords.Operations.return", + "com.specialwords.OperationsClient.returnMethodWithResponse": "SpecialWords.Operations.return", + "com.specialwords.OperationsClient.tryMethod": "SpecialWords.Operations.try", + "com.specialwords.OperationsClient.tryMethodWithResponse": "SpecialWords.Operations.try", + "com.specialwords.OperationsClient.whileMethod": "SpecialWords.Operations.while", + "com.specialwords.OperationsClient.whileMethodWithResponse": "SpecialWords.Operations.while", + "com.specialwords.OperationsClient.with": "SpecialWords.Operations.with", + "com.specialwords.OperationsClient.withWithResponse": "SpecialWords.Operations.with", + "com.specialwords.OperationsClient.yield": "SpecialWords.Operations.yield", + "com.specialwords.OperationsClient.yieldWithResponse": "SpecialWords.Operations.yield", + "com.specialwords.ParametersAsyncClient": "null", + "com.specialwords.ParametersAsyncClient.withAnd": "SpecialWords.Parameters.withAnd", + "com.specialwords.ParametersAsyncClient.withAndWithResponse": "SpecialWords.Parameters.withAnd", + "com.specialwords.ParametersAsyncClient.withAs": "SpecialWords.Parameters.withAs", + "com.specialwords.ParametersAsyncClient.withAsWithResponse": "SpecialWords.Parameters.withAs", + "com.specialwords.ParametersAsyncClient.withAssert": "SpecialWords.Parameters.withAssert", + "com.specialwords.ParametersAsyncClient.withAssertWithResponse": "SpecialWords.Parameters.withAssert", + "com.specialwords.ParametersAsyncClient.withAsyncWithResponse": "SpecialWords.Parameters.withAsync", + "com.specialwords.ParametersAsyncClient.withAwait": "SpecialWords.Parameters.withAwait", + "com.specialwords.ParametersAsyncClient.withAwaitWithResponse": "SpecialWords.Parameters.withAwait", + "com.specialwords.ParametersAsyncClient.withBreak": "SpecialWords.Parameters.withBreak", + "com.specialwords.ParametersAsyncClient.withBreakWithResponse": "SpecialWords.Parameters.withBreak", + "com.specialwords.ParametersAsyncClient.withCancellationToken": "SpecialWords.Parameters.withCancellationToken", + "com.specialwords.ParametersAsyncClient.withCancellationTokenWithResponse": "SpecialWords.Parameters.withCancellationToken", + "com.specialwords.ParametersAsyncClient.withClass": "SpecialWords.Parameters.withClass", + "com.specialwords.ParametersAsyncClient.withClassWithResponse": "SpecialWords.Parameters.withClass", + "com.specialwords.ParametersAsyncClient.withConstructor": "SpecialWords.Parameters.withConstructor", + "com.specialwords.ParametersAsyncClient.withConstructorWithResponse": "SpecialWords.Parameters.withConstructor", + "com.specialwords.ParametersAsyncClient.withContinue": "SpecialWords.Parameters.withContinue", + "com.specialwords.ParametersAsyncClient.withContinueWithResponse": "SpecialWords.Parameters.withContinue", + "com.specialwords.ParametersAsyncClient.withDef": "SpecialWords.Parameters.withDef", + "com.specialwords.ParametersAsyncClient.withDefWithResponse": "SpecialWords.Parameters.withDef", + "com.specialwords.ParametersAsyncClient.withDel": "SpecialWords.Parameters.withDel", + "com.specialwords.ParametersAsyncClient.withDelWithResponse": "SpecialWords.Parameters.withDel", + "com.specialwords.ParametersAsyncClient.withElif": "SpecialWords.Parameters.withElif", + "com.specialwords.ParametersAsyncClient.withElifWithResponse": "SpecialWords.Parameters.withElif", + "com.specialwords.ParametersAsyncClient.withElse": "SpecialWords.Parameters.withElse", + "com.specialwords.ParametersAsyncClient.withElseWithResponse": "SpecialWords.Parameters.withElse", + "com.specialwords.ParametersAsyncClient.withExcept": "SpecialWords.Parameters.withExcept", + "com.specialwords.ParametersAsyncClient.withExceptWithResponse": "SpecialWords.Parameters.withExcept", + "com.specialwords.ParametersAsyncClient.withExec": "SpecialWords.Parameters.withExec", + "com.specialwords.ParametersAsyncClient.withExecWithResponse": "SpecialWords.Parameters.withExec", + "com.specialwords.ParametersAsyncClient.withFinally": "SpecialWords.Parameters.withFinally", + "com.specialwords.ParametersAsyncClient.withFinallyWithResponse": "SpecialWords.Parameters.withFinally", + "com.specialwords.ParametersAsyncClient.withFor": "SpecialWords.Parameters.withFor", + "com.specialwords.ParametersAsyncClient.withForWithResponse": "SpecialWords.Parameters.withFor", + "com.specialwords.ParametersAsyncClient.withFrom": "SpecialWords.Parameters.withFrom", + "com.specialwords.ParametersAsyncClient.withFromWithResponse": "SpecialWords.Parameters.withFrom", + "com.specialwords.ParametersAsyncClient.withGlobal": "SpecialWords.Parameters.withGlobal", + "com.specialwords.ParametersAsyncClient.withGlobalWithResponse": "SpecialWords.Parameters.withGlobal", + "com.specialwords.ParametersAsyncClient.withIf": "SpecialWords.Parameters.withIf", + "com.specialwords.ParametersAsyncClient.withIfWithResponse": "SpecialWords.Parameters.withIf", + "com.specialwords.ParametersAsyncClient.withImport": "SpecialWords.Parameters.withImport", + "com.specialwords.ParametersAsyncClient.withImportWithResponse": "SpecialWords.Parameters.withImport", + "com.specialwords.ParametersAsyncClient.withIn": "SpecialWords.Parameters.withIn", + "com.specialwords.ParametersAsyncClient.withInWithResponse": "SpecialWords.Parameters.withIn", + "com.specialwords.ParametersAsyncClient.withIs": "SpecialWords.Parameters.withIs", + "com.specialwords.ParametersAsyncClient.withIsWithResponse": "SpecialWords.Parameters.withIs", + "com.specialwords.ParametersAsyncClient.withLambda": "SpecialWords.Parameters.withLambda", + "com.specialwords.ParametersAsyncClient.withLambdaWithResponse": "SpecialWords.Parameters.withLambda", + "com.specialwords.ParametersAsyncClient.withNot": "SpecialWords.Parameters.withNot", + "com.specialwords.ParametersAsyncClient.withNotWithResponse": "SpecialWords.Parameters.withNot", + "com.specialwords.ParametersAsyncClient.withOr": "SpecialWords.Parameters.withOr", + "com.specialwords.ParametersAsyncClient.withOrWithResponse": "SpecialWords.Parameters.withOr", + "com.specialwords.ParametersAsyncClient.withPass": "SpecialWords.Parameters.withPass", + "com.specialwords.ParametersAsyncClient.withPassWithResponse": "SpecialWords.Parameters.withPass", + "com.specialwords.ParametersAsyncClient.withRaise": "SpecialWords.Parameters.withRaise", + "com.specialwords.ParametersAsyncClient.withRaiseWithResponse": "SpecialWords.Parameters.withRaise", + "com.specialwords.ParametersAsyncClient.withReturn": "SpecialWords.Parameters.withReturn", + "com.specialwords.ParametersAsyncClient.withReturnWithResponse": "SpecialWords.Parameters.withReturn", + "com.specialwords.ParametersAsyncClient.withTry": "SpecialWords.Parameters.withTry", + "com.specialwords.ParametersAsyncClient.withTryWithResponse": "SpecialWords.Parameters.withTry", + "com.specialwords.ParametersAsyncClient.withWhile": "SpecialWords.Parameters.withWhile", + "com.specialwords.ParametersAsyncClient.withWhileWithResponse": "SpecialWords.Parameters.withWhile", + "com.specialwords.ParametersAsyncClient.withWith": "SpecialWords.Parameters.withWith", + "com.specialwords.ParametersAsyncClient.withWithWithResponse": "SpecialWords.Parameters.withWith", + "com.specialwords.ParametersAsyncClient.withYield": "SpecialWords.Parameters.withYield", + "com.specialwords.ParametersAsyncClient.withYieldWithResponse": "SpecialWords.Parameters.withYield", + "com.specialwords.ParametersClient": "null", + "com.specialwords.ParametersClient.withAnd": "SpecialWords.Parameters.withAnd", + "com.specialwords.ParametersClient.withAndWithResponse": "SpecialWords.Parameters.withAnd", + "com.specialwords.ParametersClient.withAs": "SpecialWords.Parameters.withAs", + "com.specialwords.ParametersClient.withAsWithResponse": "SpecialWords.Parameters.withAs", + "com.specialwords.ParametersClient.withAssert": "SpecialWords.Parameters.withAssert", + "com.specialwords.ParametersClient.withAssertWithResponse": "SpecialWords.Parameters.withAssert", + "com.specialwords.ParametersClient.withAsyncWithResponse": "SpecialWords.Parameters.withAsync", + "com.specialwords.ParametersClient.withAwait": "SpecialWords.Parameters.withAwait", + "com.specialwords.ParametersClient.withAwaitWithResponse": "SpecialWords.Parameters.withAwait", + "com.specialwords.ParametersClient.withBreak": "SpecialWords.Parameters.withBreak", + "com.specialwords.ParametersClient.withBreakWithResponse": "SpecialWords.Parameters.withBreak", + "com.specialwords.ParametersClient.withCancellationToken": "SpecialWords.Parameters.withCancellationToken", + "com.specialwords.ParametersClient.withCancellationTokenWithResponse": "SpecialWords.Parameters.withCancellationToken", + "com.specialwords.ParametersClient.withClass": "SpecialWords.Parameters.withClass", + "com.specialwords.ParametersClient.withClassWithResponse": "SpecialWords.Parameters.withClass", + "com.specialwords.ParametersClient.withConstructor": "SpecialWords.Parameters.withConstructor", + "com.specialwords.ParametersClient.withConstructorWithResponse": "SpecialWords.Parameters.withConstructor", + "com.specialwords.ParametersClient.withContinue": "SpecialWords.Parameters.withContinue", + "com.specialwords.ParametersClient.withContinueWithResponse": "SpecialWords.Parameters.withContinue", + "com.specialwords.ParametersClient.withDef": "SpecialWords.Parameters.withDef", + "com.specialwords.ParametersClient.withDefWithResponse": "SpecialWords.Parameters.withDef", + "com.specialwords.ParametersClient.withDel": "SpecialWords.Parameters.withDel", + "com.specialwords.ParametersClient.withDelWithResponse": "SpecialWords.Parameters.withDel", + "com.specialwords.ParametersClient.withElif": "SpecialWords.Parameters.withElif", + "com.specialwords.ParametersClient.withElifWithResponse": "SpecialWords.Parameters.withElif", + "com.specialwords.ParametersClient.withElse": "SpecialWords.Parameters.withElse", + "com.specialwords.ParametersClient.withElseWithResponse": "SpecialWords.Parameters.withElse", + "com.specialwords.ParametersClient.withExcept": "SpecialWords.Parameters.withExcept", + "com.specialwords.ParametersClient.withExceptWithResponse": "SpecialWords.Parameters.withExcept", + "com.specialwords.ParametersClient.withExec": "SpecialWords.Parameters.withExec", + "com.specialwords.ParametersClient.withExecWithResponse": "SpecialWords.Parameters.withExec", + "com.specialwords.ParametersClient.withFinally": "SpecialWords.Parameters.withFinally", + "com.specialwords.ParametersClient.withFinallyWithResponse": "SpecialWords.Parameters.withFinally", + "com.specialwords.ParametersClient.withFor": "SpecialWords.Parameters.withFor", + "com.specialwords.ParametersClient.withForWithResponse": "SpecialWords.Parameters.withFor", + "com.specialwords.ParametersClient.withFrom": "SpecialWords.Parameters.withFrom", + "com.specialwords.ParametersClient.withFromWithResponse": "SpecialWords.Parameters.withFrom", + "com.specialwords.ParametersClient.withGlobal": "SpecialWords.Parameters.withGlobal", + "com.specialwords.ParametersClient.withGlobalWithResponse": "SpecialWords.Parameters.withGlobal", + "com.specialwords.ParametersClient.withIf": "SpecialWords.Parameters.withIf", + "com.specialwords.ParametersClient.withIfWithResponse": "SpecialWords.Parameters.withIf", + "com.specialwords.ParametersClient.withImport": "SpecialWords.Parameters.withImport", + "com.specialwords.ParametersClient.withImportWithResponse": "SpecialWords.Parameters.withImport", + "com.specialwords.ParametersClient.withIn": "SpecialWords.Parameters.withIn", + "com.specialwords.ParametersClient.withInWithResponse": "SpecialWords.Parameters.withIn", + "com.specialwords.ParametersClient.withIs": "SpecialWords.Parameters.withIs", + "com.specialwords.ParametersClient.withIsWithResponse": "SpecialWords.Parameters.withIs", + "com.specialwords.ParametersClient.withLambda": "SpecialWords.Parameters.withLambda", + "com.specialwords.ParametersClient.withLambdaWithResponse": "SpecialWords.Parameters.withLambda", + "com.specialwords.ParametersClient.withNot": "SpecialWords.Parameters.withNot", + "com.specialwords.ParametersClient.withNotWithResponse": "SpecialWords.Parameters.withNot", + "com.specialwords.ParametersClient.withOr": "SpecialWords.Parameters.withOr", + "com.specialwords.ParametersClient.withOrWithResponse": "SpecialWords.Parameters.withOr", + "com.specialwords.ParametersClient.withPass": "SpecialWords.Parameters.withPass", + "com.specialwords.ParametersClient.withPassWithResponse": "SpecialWords.Parameters.withPass", + "com.specialwords.ParametersClient.withRaise": "SpecialWords.Parameters.withRaise", + "com.specialwords.ParametersClient.withRaiseWithResponse": "SpecialWords.Parameters.withRaise", + "com.specialwords.ParametersClient.withReturn": "SpecialWords.Parameters.withReturn", + "com.specialwords.ParametersClient.withReturnWithResponse": "SpecialWords.Parameters.withReturn", + "com.specialwords.ParametersClient.withTry": "SpecialWords.Parameters.withTry", + "com.specialwords.ParametersClient.withTryWithResponse": "SpecialWords.Parameters.withTry", + "com.specialwords.ParametersClient.withWhile": "SpecialWords.Parameters.withWhile", + "com.specialwords.ParametersClient.withWhileWithResponse": "SpecialWords.Parameters.withWhile", + "com.specialwords.ParametersClient.withWith": "SpecialWords.Parameters.withWith", + "com.specialwords.ParametersClient.withWithWithResponse": "SpecialWords.Parameters.withWith", + "com.specialwords.ParametersClient.withYield": "SpecialWords.Parameters.withYield", + "com.specialwords.ParametersClient.withYieldWithResponse": "SpecialWords.Parameters.withYield", + "com.specialwords.SpecialWordsClientBuilder": "SpecialWords", + "com.specialwords.models.And": "SpecialWords.Models.and", + "com.specialwords.models.As": "SpecialWords.Models.as", + "com.specialwords.models.Assert": "SpecialWords.Models.assert", + "com.specialwords.models.Async": "SpecialWords.Models.async", + "com.specialwords.models.Await": "SpecialWords.Models.await", + "com.specialwords.models.Break": "SpecialWords.Models.break", + "com.specialwords.models.ClassModel": "SpecialWords.Models.class", + "com.specialwords.models.Constructor": "SpecialWords.Models.constructor", + "com.specialwords.models.Continue": "SpecialWords.Models.continue", + "com.specialwords.models.Def": "SpecialWords.Models.def", + "com.specialwords.models.Del": "SpecialWords.Models.del", + "com.specialwords.models.Elif": "SpecialWords.Models.elif", + "com.specialwords.models.Else": "SpecialWords.Models.else", + "com.specialwords.models.Except": "SpecialWords.Models.except", + "com.specialwords.models.Exec": "SpecialWords.Models.exec", + "com.specialwords.models.Finally": "SpecialWords.Models.finally", + "com.specialwords.models.For": "SpecialWords.Models.for", + "com.specialwords.models.From": "SpecialWords.Models.from", + "com.specialwords.models.Global": "SpecialWords.Models.global", + "com.specialwords.models.If": "SpecialWords.Models.if", + "com.specialwords.models.Import": "SpecialWords.Models.import", + "com.specialwords.models.In": "SpecialWords.Models.in", + "com.specialwords.models.Is": "SpecialWords.Models.is", + "com.specialwords.models.Lambda": "SpecialWords.Models.lambda", + "com.specialwords.models.Not": "SpecialWords.Models.not", + "com.specialwords.models.Or": "SpecialWords.Models.or", + "com.specialwords.models.Pass": "SpecialWords.Models.pass", + "com.specialwords.models.Raise": "SpecialWords.Models.raise", + "com.specialwords.models.Return": "SpecialWords.Models.return", + "com.specialwords.models.SameAsModel": "SpecialWords.ModelProperties.SameAsModel", + "com.specialwords.models.Try": "SpecialWords.Models.try", + "com.specialwords.models.While": "SpecialWords.Models.while", + "com.specialwords.models.With": "SpecialWords.Models.with", + "com.specialwords.models.Yield": "SpecialWords.Models.yield" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-array_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-array_apiview_properties.json new file mode 100644 index 000000000..903ca2739 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-array_apiview_properties.json @@ -0,0 +1,147 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.array.ArrayClientBuilder": "Type.Array", + "com.type.array.BooleanValueAsyncClient": "null", + "com.type.array.BooleanValueAsyncClient.get": "Type.Array.BooleanValue.get", + "com.type.array.BooleanValueAsyncClient.getWithResponse": "Type.Array.BooleanValue.get", + "com.type.array.BooleanValueAsyncClient.put": "Type.Array.BooleanValue.put", + "com.type.array.BooleanValueAsyncClient.putWithResponse": "Type.Array.BooleanValue.put", + "com.type.array.BooleanValueClient": "null", + "com.type.array.BooleanValueClient.get": "Type.Array.BooleanValue.get", + "com.type.array.BooleanValueClient.getWithResponse": "Type.Array.BooleanValue.get", + "com.type.array.BooleanValueClient.put": "Type.Array.BooleanValue.put", + "com.type.array.BooleanValueClient.putWithResponse": "Type.Array.BooleanValue.put", + "com.type.array.DatetimeValueAsyncClient": "null", + "com.type.array.DatetimeValueAsyncClient.get": "Type.Array.DatetimeValue.get", + "com.type.array.DatetimeValueAsyncClient.getWithResponse": "Type.Array.DatetimeValue.get", + "com.type.array.DatetimeValueAsyncClient.put": "Type.Array.DatetimeValue.put", + "com.type.array.DatetimeValueAsyncClient.putWithResponse": "Type.Array.DatetimeValue.put", + "com.type.array.DatetimeValueClient": "null", + "com.type.array.DatetimeValueClient.get": "Type.Array.DatetimeValue.get", + "com.type.array.DatetimeValueClient.getWithResponse": "Type.Array.DatetimeValue.get", + "com.type.array.DatetimeValueClient.put": "Type.Array.DatetimeValue.put", + "com.type.array.DatetimeValueClient.putWithResponse": "Type.Array.DatetimeValue.put", + "com.type.array.DurationValueAsyncClient": "null", + "com.type.array.DurationValueAsyncClient.get": "Type.Array.DurationValue.get", + "com.type.array.DurationValueAsyncClient.getWithResponse": "Type.Array.DurationValue.get", + "com.type.array.DurationValueAsyncClient.put": "Type.Array.DurationValue.put", + "com.type.array.DurationValueAsyncClient.putWithResponse": "Type.Array.DurationValue.put", + "com.type.array.DurationValueClient": "null", + "com.type.array.DurationValueClient.get": "Type.Array.DurationValue.get", + "com.type.array.DurationValueClient.getWithResponse": "Type.Array.DurationValue.get", + "com.type.array.DurationValueClient.put": "Type.Array.DurationValue.put", + "com.type.array.DurationValueClient.putWithResponse": "Type.Array.DurationValue.put", + "com.type.array.Float32ValueAsyncClient": "null", + "com.type.array.Float32ValueAsyncClient.get": "Type.Array.Float32Value.get", + "com.type.array.Float32ValueAsyncClient.getWithResponse": "Type.Array.Float32Value.get", + "com.type.array.Float32ValueAsyncClient.put": "Type.Array.Float32Value.put", + "com.type.array.Float32ValueAsyncClient.putWithResponse": "Type.Array.Float32Value.put", + "com.type.array.Float32ValueClient": "null", + "com.type.array.Float32ValueClient.get": "Type.Array.Float32Value.get", + "com.type.array.Float32ValueClient.getWithResponse": "Type.Array.Float32Value.get", + "com.type.array.Float32ValueClient.put": "Type.Array.Float32Value.put", + "com.type.array.Float32ValueClient.putWithResponse": "Type.Array.Float32Value.put", + "com.type.array.Int32ValueAsyncClient": "null", + "com.type.array.Int32ValueAsyncClient.get": "Type.Array.Int32Value.get", + "com.type.array.Int32ValueAsyncClient.getWithResponse": "Type.Array.Int32Value.get", + "com.type.array.Int32ValueAsyncClient.put": "Type.Array.Int32Value.put", + "com.type.array.Int32ValueAsyncClient.putWithResponse": "Type.Array.Int32Value.put", + "com.type.array.Int32ValueClient": "null", + "com.type.array.Int32ValueClient.get": "Type.Array.Int32Value.get", + "com.type.array.Int32ValueClient.getWithResponse": "Type.Array.Int32Value.get", + "com.type.array.Int32ValueClient.put": "Type.Array.Int32Value.put", + "com.type.array.Int32ValueClient.putWithResponse": "Type.Array.Int32Value.put", + "com.type.array.Int64ValueAsyncClient": "null", + "com.type.array.Int64ValueAsyncClient.get": "Type.Array.Int64Value.get", + "com.type.array.Int64ValueAsyncClient.getWithResponse": "Type.Array.Int64Value.get", + "com.type.array.Int64ValueAsyncClient.put": "Type.Array.Int64Value.put", + "com.type.array.Int64ValueAsyncClient.putWithResponse": "Type.Array.Int64Value.put", + "com.type.array.Int64ValueClient": "null", + "com.type.array.Int64ValueClient.get": "Type.Array.Int64Value.get", + "com.type.array.Int64ValueClient.getWithResponse": "Type.Array.Int64Value.get", + "com.type.array.Int64ValueClient.put": "Type.Array.Int64Value.put", + "com.type.array.Int64ValueClient.putWithResponse": "Type.Array.Int64Value.put", + "com.type.array.ModelValueAsyncClient": "null", + "com.type.array.ModelValueAsyncClient.get": "Type.Array.ModelValue.get", + "com.type.array.ModelValueAsyncClient.getWithResponse": "Type.Array.ModelValue.get", + "com.type.array.ModelValueAsyncClient.put": "Type.Array.ModelValue.put", + "com.type.array.ModelValueAsyncClient.putWithResponse": "Type.Array.ModelValue.put", + "com.type.array.ModelValueClient": "null", + "com.type.array.ModelValueClient.get": "Type.Array.ModelValue.get", + "com.type.array.ModelValueClient.getWithResponse": "Type.Array.ModelValue.get", + "com.type.array.ModelValueClient.put": "Type.Array.ModelValue.put", + "com.type.array.ModelValueClient.putWithResponse": "Type.Array.ModelValue.put", + "com.type.array.NullableBooleanValueAsyncClient": "null", + "com.type.array.NullableBooleanValueAsyncClient.get": "Type.Array.NullableBooleanValue.get", + "com.type.array.NullableBooleanValueAsyncClient.getWithResponse": "Type.Array.NullableBooleanValue.get", + "com.type.array.NullableBooleanValueAsyncClient.put": "Type.Array.NullableBooleanValue.put", + "com.type.array.NullableBooleanValueAsyncClient.putWithResponse": "Type.Array.NullableBooleanValue.put", + "com.type.array.NullableBooleanValueClient": "null", + "com.type.array.NullableBooleanValueClient.get": "Type.Array.NullableBooleanValue.get", + "com.type.array.NullableBooleanValueClient.getWithResponse": "Type.Array.NullableBooleanValue.get", + "com.type.array.NullableBooleanValueClient.put": "Type.Array.NullableBooleanValue.put", + "com.type.array.NullableBooleanValueClient.putWithResponse": "Type.Array.NullableBooleanValue.put", + "com.type.array.NullableFloatValueAsyncClient": "null", + "com.type.array.NullableFloatValueAsyncClient.get": "Type.Array.NullableFloatValue.get", + "com.type.array.NullableFloatValueAsyncClient.getWithResponse": "Type.Array.NullableFloatValue.get", + "com.type.array.NullableFloatValueAsyncClient.put": "Type.Array.NullableFloatValue.put", + "com.type.array.NullableFloatValueAsyncClient.putWithResponse": "Type.Array.NullableFloatValue.put", + "com.type.array.NullableFloatValueClient": "null", + "com.type.array.NullableFloatValueClient.get": "Type.Array.NullableFloatValue.get", + "com.type.array.NullableFloatValueClient.getWithResponse": "Type.Array.NullableFloatValue.get", + "com.type.array.NullableFloatValueClient.put": "Type.Array.NullableFloatValue.put", + "com.type.array.NullableFloatValueClient.putWithResponse": "Type.Array.NullableFloatValue.put", + "com.type.array.NullableInt32ValueAsyncClient": "null", + "com.type.array.NullableInt32ValueAsyncClient.get": "Type.Array.NullableInt32Value.get", + "com.type.array.NullableInt32ValueAsyncClient.getWithResponse": "Type.Array.NullableInt32Value.get", + "com.type.array.NullableInt32ValueAsyncClient.put": "Type.Array.NullableInt32Value.put", + "com.type.array.NullableInt32ValueAsyncClient.putWithResponse": "Type.Array.NullableInt32Value.put", + "com.type.array.NullableInt32ValueClient": "null", + "com.type.array.NullableInt32ValueClient.get": "Type.Array.NullableInt32Value.get", + "com.type.array.NullableInt32ValueClient.getWithResponse": "Type.Array.NullableInt32Value.get", + "com.type.array.NullableInt32ValueClient.put": "Type.Array.NullableInt32Value.put", + "com.type.array.NullableInt32ValueClient.putWithResponse": "Type.Array.NullableInt32Value.put", + "com.type.array.NullableModelValueAsyncClient": "null", + "com.type.array.NullableModelValueAsyncClient.get": "Type.Array.NullableModelValue.get", + "com.type.array.NullableModelValueAsyncClient.getWithResponse": "Type.Array.NullableModelValue.get", + "com.type.array.NullableModelValueAsyncClient.put": "Type.Array.NullableModelValue.put", + "com.type.array.NullableModelValueAsyncClient.putWithResponse": "Type.Array.NullableModelValue.put", + "com.type.array.NullableModelValueClient": "null", + "com.type.array.NullableModelValueClient.get": "Type.Array.NullableModelValue.get", + "com.type.array.NullableModelValueClient.getWithResponse": "Type.Array.NullableModelValue.get", + "com.type.array.NullableModelValueClient.put": "Type.Array.NullableModelValue.put", + "com.type.array.NullableModelValueClient.putWithResponse": "Type.Array.NullableModelValue.put", + "com.type.array.NullableStringValueAsyncClient": "null", + "com.type.array.NullableStringValueAsyncClient.get": "Type.Array.NullableStringValue.get", + "com.type.array.NullableStringValueAsyncClient.getWithResponse": "Type.Array.NullableStringValue.get", + "com.type.array.NullableStringValueAsyncClient.put": "Type.Array.NullableStringValue.put", + "com.type.array.NullableStringValueAsyncClient.putWithResponse": "Type.Array.NullableStringValue.put", + "com.type.array.NullableStringValueClient": "null", + "com.type.array.NullableStringValueClient.get": "Type.Array.NullableStringValue.get", + "com.type.array.NullableStringValueClient.getWithResponse": "Type.Array.NullableStringValue.get", + "com.type.array.NullableStringValueClient.put": "Type.Array.NullableStringValue.put", + "com.type.array.NullableStringValueClient.putWithResponse": "Type.Array.NullableStringValue.put", + "com.type.array.StringValueAsyncClient": "null", + "com.type.array.StringValueAsyncClient.get": "Type.Array.StringValue.get", + "com.type.array.StringValueAsyncClient.getWithResponse": "Type.Array.StringValue.get", + "com.type.array.StringValueAsyncClient.put": "Type.Array.StringValue.put", + "com.type.array.StringValueAsyncClient.putWithResponse": "Type.Array.StringValue.put", + "com.type.array.StringValueClient": "null", + "com.type.array.StringValueClient.get": "Type.Array.StringValue.get", + "com.type.array.StringValueClient.getWithResponse": "Type.Array.StringValue.get", + "com.type.array.StringValueClient.put": "Type.Array.StringValue.put", + "com.type.array.StringValueClient.putWithResponse": "Type.Array.StringValue.put", + "com.type.array.UnknownValueAsyncClient": "null", + "com.type.array.UnknownValueAsyncClient.get": "Type.Array.UnknownValue.get", + "com.type.array.UnknownValueAsyncClient.getWithResponse": "Type.Array.UnknownValue.get", + "com.type.array.UnknownValueAsyncClient.put": "Type.Array.UnknownValue.put", + "com.type.array.UnknownValueAsyncClient.putWithResponse": "Type.Array.UnknownValue.put", + "com.type.array.UnknownValueClient": "null", + "com.type.array.UnknownValueClient.get": "Type.Array.UnknownValue.get", + "com.type.array.UnknownValueClient.getWithResponse": "Type.Array.UnknownValue.get", + "com.type.array.UnknownValueClient.put": "Type.Array.UnknownValue.put", + "com.type.array.UnknownValueClient.putWithResponse": "Type.Array.UnknownValue.put", + "com.type.array.models.InnerModel": "Type.Array.InnerModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-dictionary_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-dictionary_apiview_properties.json new file mode 100644 index 000000000..d898fd594 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-dictionary_apiview_properties.json @@ -0,0 +1,117 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.dictionary.BooleanValueAsyncClient": "null", + "com.type.dictionary.BooleanValueAsyncClient.get": "Type.Dictionary.BooleanValue.get", + "com.type.dictionary.BooleanValueAsyncClient.getWithResponse": "Type.Dictionary.BooleanValue.get", + "com.type.dictionary.BooleanValueAsyncClient.put": "Type.Dictionary.BooleanValue.put", + "com.type.dictionary.BooleanValueAsyncClient.putWithResponse": "Type.Dictionary.BooleanValue.put", + "com.type.dictionary.BooleanValueClient": "null", + "com.type.dictionary.BooleanValueClient.get": "Type.Dictionary.BooleanValue.get", + "com.type.dictionary.BooleanValueClient.getWithResponse": "Type.Dictionary.BooleanValue.get", + "com.type.dictionary.BooleanValueClient.put": "Type.Dictionary.BooleanValue.put", + "com.type.dictionary.BooleanValueClient.putWithResponse": "Type.Dictionary.BooleanValue.put", + "com.type.dictionary.DatetimeValueAsyncClient": "null", + "com.type.dictionary.DatetimeValueAsyncClient.get": "Type.Dictionary.DatetimeValue.get", + "com.type.dictionary.DatetimeValueAsyncClient.getWithResponse": "Type.Dictionary.DatetimeValue.get", + "com.type.dictionary.DatetimeValueAsyncClient.put": "Type.Dictionary.DatetimeValue.put", + "com.type.dictionary.DatetimeValueAsyncClient.putWithResponse": "Type.Dictionary.DatetimeValue.put", + "com.type.dictionary.DatetimeValueClient": "null", + "com.type.dictionary.DatetimeValueClient.get": "Type.Dictionary.DatetimeValue.get", + "com.type.dictionary.DatetimeValueClient.getWithResponse": "Type.Dictionary.DatetimeValue.get", + "com.type.dictionary.DatetimeValueClient.put": "Type.Dictionary.DatetimeValue.put", + "com.type.dictionary.DatetimeValueClient.putWithResponse": "Type.Dictionary.DatetimeValue.put", + "com.type.dictionary.DictionaryClientBuilder": "Type.Dictionary", + "com.type.dictionary.DurationValueAsyncClient": "null", + "com.type.dictionary.DurationValueAsyncClient.get": "Type.Dictionary.DurationValue.get", + "com.type.dictionary.DurationValueAsyncClient.getWithResponse": "Type.Dictionary.DurationValue.get", + "com.type.dictionary.DurationValueAsyncClient.put": "Type.Dictionary.DurationValue.put", + "com.type.dictionary.DurationValueAsyncClient.putWithResponse": "Type.Dictionary.DurationValue.put", + "com.type.dictionary.DurationValueClient": "null", + "com.type.dictionary.DurationValueClient.get": "Type.Dictionary.DurationValue.get", + "com.type.dictionary.DurationValueClient.getWithResponse": "Type.Dictionary.DurationValue.get", + "com.type.dictionary.DurationValueClient.put": "Type.Dictionary.DurationValue.put", + "com.type.dictionary.DurationValueClient.putWithResponse": "Type.Dictionary.DurationValue.put", + "com.type.dictionary.Float32ValueAsyncClient": "null", + "com.type.dictionary.Float32ValueAsyncClient.get": "Type.Dictionary.Float32Value.get", + "com.type.dictionary.Float32ValueAsyncClient.getWithResponse": "Type.Dictionary.Float32Value.get", + "com.type.dictionary.Float32ValueAsyncClient.put": "Type.Dictionary.Float32Value.put", + "com.type.dictionary.Float32ValueAsyncClient.putWithResponse": "Type.Dictionary.Float32Value.put", + "com.type.dictionary.Float32ValueClient": "null", + "com.type.dictionary.Float32ValueClient.get": "Type.Dictionary.Float32Value.get", + "com.type.dictionary.Float32ValueClient.getWithResponse": "Type.Dictionary.Float32Value.get", + "com.type.dictionary.Float32ValueClient.put": "Type.Dictionary.Float32Value.put", + "com.type.dictionary.Float32ValueClient.putWithResponse": "Type.Dictionary.Float32Value.put", + "com.type.dictionary.Int32ValueAsyncClient": "null", + "com.type.dictionary.Int32ValueAsyncClient.get": "Type.Dictionary.Int32Value.get", + "com.type.dictionary.Int32ValueAsyncClient.getWithResponse": "Type.Dictionary.Int32Value.get", + "com.type.dictionary.Int32ValueAsyncClient.put": "Type.Dictionary.Int32Value.put", + "com.type.dictionary.Int32ValueAsyncClient.putWithResponse": "Type.Dictionary.Int32Value.put", + "com.type.dictionary.Int32ValueClient": "null", + "com.type.dictionary.Int32ValueClient.get": "Type.Dictionary.Int32Value.get", + "com.type.dictionary.Int32ValueClient.getWithResponse": "Type.Dictionary.Int32Value.get", + "com.type.dictionary.Int32ValueClient.put": "Type.Dictionary.Int32Value.put", + "com.type.dictionary.Int32ValueClient.putWithResponse": "Type.Dictionary.Int32Value.put", + "com.type.dictionary.Int64ValueAsyncClient": "null", + "com.type.dictionary.Int64ValueAsyncClient.get": "Type.Dictionary.Int64Value.get", + "com.type.dictionary.Int64ValueAsyncClient.getWithResponse": "Type.Dictionary.Int64Value.get", + "com.type.dictionary.Int64ValueAsyncClient.put": "Type.Dictionary.Int64Value.put", + "com.type.dictionary.Int64ValueAsyncClient.putWithResponse": "Type.Dictionary.Int64Value.put", + "com.type.dictionary.Int64ValueClient": "null", + "com.type.dictionary.Int64ValueClient.get": "Type.Dictionary.Int64Value.get", + "com.type.dictionary.Int64ValueClient.getWithResponse": "Type.Dictionary.Int64Value.get", + "com.type.dictionary.Int64ValueClient.put": "Type.Dictionary.Int64Value.put", + "com.type.dictionary.Int64ValueClient.putWithResponse": "Type.Dictionary.Int64Value.put", + "com.type.dictionary.ModelValueAsyncClient": "null", + "com.type.dictionary.ModelValueAsyncClient.get": "Type.Dictionary.ModelValue.get", + "com.type.dictionary.ModelValueAsyncClient.getWithResponse": "Type.Dictionary.ModelValue.get", + "com.type.dictionary.ModelValueAsyncClient.put": "Type.Dictionary.ModelValue.put", + "com.type.dictionary.ModelValueAsyncClient.putWithResponse": "Type.Dictionary.ModelValue.put", + "com.type.dictionary.ModelValueClient": "null", + "com.type.dictionary.ModelValueClient.get": "Type.Dictionary.ModelValue.get", + "com.type.dictionary.ModelValueClient.getWithResponse": "Type.Dictionary.ModelValue.get", + "com.type.dictionary.ModelValueClient.put": "Type.Dictionary.ModelValue.put", + "com.type.dictionary.ModelValueClient.putWithResponse": "Type.Dictionary.ModelValue.put", + "com.type.dictionary.NullableFloatValueAsyncClient": "null", + "com.type.dictionary.NullableFloatValueAsyncClient.get": "Type.Dictionary.NullableFloatValue.get", + "com.type.dictionary.NullableFloatValueAsyncClient.getWithResponse": "Type.Dictionary.NullableFloatValue.get", + "com.type.dictionary.NullableFloatValueAsyncClient.put": "Type.Dictionary.NullableFloatValue.put", + "com.type.dictionary.NullableFloatValueAsyncClient.putWithResponse": "Type.Dictionary.NullableFloatValue.put", + "com.type.dictionary.NullableFloatValueClient": "null", + "com.type.dictionary.NullableFloatValueClient.get": "Type.Dictionary.NullableFloatValue.get", + "com.type.dictionary.NullableFloatValueClient.getWithResponse": "Type.Dictionary.NullableFloatValue.get", + "com.type.dictionary.NullableFloatValueClient.put": "Type.Dictionary.NullableFloatValue.put", + "com.type.dictionary.NullableFloatValueClient.putWithResponse": "Type.Dictionary.NullableFloatValue.put", + "com.type.dictionary.RecursiveModelValueAsyncClient": "null", + "com.type.dictionary.RecursiveModelValueAsyncClient.get": "Type.Dictionary.RecursiveModelValue.get", + "com.type.dictionary.RecursiveModelValueAsyncClient.getWithResponse": "Type.Dictionary.RecursiveModelValue.get", + "com.type.dictionary.RecursiveModelValueAsyncClient.put": "Type.Dictionary.RecursiveModelValue.put", + "com.type.dictionary.RecursiveModelValueAsyncClient.putWithResponse": "Type.Dictionary.RecursiveModelValue.put", + "com.type.dictionary.RecursiveModelValueClient": "null", + "com.type.dictionary.RecursiveModelValueClient.get": "Type.Dictionary.RecursiveModelValue.get", + "com.type.dictionary.RecursiveModelValueClient.getWithResponse": "Type.Dictionary.RecursiveModelValue.get", + "com.type.dictionary.RecursiveModelValueClient.put": "Type.Dictionary.RecursiveModelValue.put", + "com.type.dictionary.RecursiveModelValueClient.putWithResponse": "Type.Dictionary.RecursiveModelValue.put", + "com.type.dictionary.StringValueAsyncClient": "null", + "com.type.dictionary.StringValueAsyncClient.get": "Type.Dictionary.StringValue.get", + "com.type.dictionary.StringValueAsyncClient.getWithResponse": "Type.Dictionary.StringValue.get", + "com.type.dictionary.StringValueAsyncClient.put": "Type.Dictionary.StringValue.put", + "com.type.dictionary.StringValueAsyncClient.putWithResponse": "Type.Dictionary.StringValue.put", + "com.type.dictionary.StringValueClient": "null", + "com.type.dictionary.StringValueClient.get": "Type.Dictionary.StringValue.get", + "com.type.dictionary.StringValueClient.getWithResponse": "Type.Dictionary.StringValue.get", + "com.type.dictionary.StringValueClient.put": "Type.Dictionary.StringValue.put", + "com.type.dictionary.StringValueClient.putWithResponse": "Type.Dictionary.StringValue.put", + "com.type.dictionary.UnknownValueAsyncClient": "null", + "com.type.dictionary.UnknownValueAsyncClient.get": "Type.Dictionary.UnknownValue.get", + "com.type.dictionary.UnknownValueAsyncClient.getWithResponse": "Type.Dictionary.UnknownValue.get", + "com.type.dictionary.UnknownValueAsyncClient.put": "Type.Dictionary.UnknownValue.put", + "com.type.dictionary.UnknownValueAsyncClient.putWithResponse": "Type.Dictionary.UnknownValue.put", + "com.type.dictionary.UnknownValueClient": "null", + "com.type.dictionary.UnknownValueClient.get": "Type.Dictionary.UnknownValue.get", + "com.type.dictionary.UnknownValueClient.getWithResponse": "Type.Dictionary.UnknownValue.get", + "com.type.dictionary.UnknownValueClient.put": "Type.Dictionary.UnknownValue.put", + "com.type.dictionary.UnknownValueClient.putWithResponse": "Type.Dictionary.UnknownValue.put", + "com.type.dictionary.models.InnerModel": "Type.Dictionary.InnerModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-enums-extensible_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-enums-extensible_apiview_properties.json new file mode 100644 index 000000000..8fd69ffb3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-enums-extensible_apiview_properties.json @@ -0,0 +1,25 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.enums.extensible.ExtensibleAsyncClient": "null", + "com.type.enums.extensible.ExtensibleAsyncClient.getKnownValue": "Type.Enum.Extensible.String.getKnownValue", + "com.type.enums.extensible.ExtensibleAsyncClient.getKnownValueWithResponse": "Type.Enum.Extensible.String.getKnownValue", + "com.type.enums.extensible.ExtensibleAsyncClient.getUnknownValue": "Type.Enum.Extensible.String.getUnknownValue", + "com.type.enums.extensible.ExtensibleAsyncClient.getUnknownValueWithResponse": "Type.Enum.Extensible.String.getUnknownValue", + "com.type.enums.extensible.ExtensibleAsyncClient.putKnownValue": "Type.Enum.Extensible.String.putKnownValue", + "com.type.enums.extensible.ExtensibleAsyncClient.putKnownValueWithResponse": "Type.Enum.Extensible.String.putKnownValue", + "com.type.enums.extensible.ExtensibleAsyncClient.putUnknownValue": "Type.Enum.Extensible.String.putUnknownValue", + "com.type.enums.extensible.ExtensibleAsyncClient.putUnknownValueWithResponse": "Type.Enum.Extensible.String.putUnknownValue", + "com.type.enums.extensible.ExtensibleClient": "null", + "com.type.enums.extensible.ExtensibleClient.getKnownValue": "Type.Enum.Extensible.String.getKnownValue", + "com.type.enums.extensible.ExtensibleClient.getKnownValueWithResponse": "Type.Enum.Extensible.String.getKnownValue", + "com.type.enums.extensible.ExtensibleClient.getUnknownValue": "Type.Enum.Extensible.String.getUnknownValue", + "com.type.enums.extensible.ExtensibleClient.getUnknownValueWithResponse": "Type.Enum.Extensible.String.getUnknownValue", + "com.type.enums.extensible.ExtensibleClient.putKnownValue": "Type.Enum.Extensible.String.putKnownValue", + "com.type.enums.extensible.ExtensibleClient.putKnownValueWithResponse": "Type.Enum.Extensible.String.putKnownValue", + "com.type.enums.extensible.ExtensibleClient.putUnknownValue": "Type.Enum.Extensible.String.putUnknownValue", + "com.type.enums.extensible.ExtensibleClient.putUnknownValueWithResponse": "Type.Enum.Extensible.String.putUnknownValue", + "com.type.enums.extensible.ExtensibleClientBuilder": "Type.Enum.Extensible", + "com.type.enums.extensible.models.DaysOfWeekExtensibleEnum": "Type.Enum.Extensible.DaysOfWeekExtensibleEnum" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-enums-fixed_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-enums-fixed_apiview_properties.json new file mode 100644 index 000000000..d92c0b930 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-enums-fixed_apiview_properties.json @@ -0,0 +1,21 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.enums.fixed.FixedAsyncClient": "null", + "com.type.enums.fixed.FixedAsyncClient.getKnownValue": "Type.Enum.Fixed.String.getKnownValue", + "com.type.enums.fixed.FixedAsyncClient.getKnownValueWithResponse": "Type.Enum.Fixed.String.getKnownValue", + "com.type.enums.fixed.FixedAsyncClient.putKnownValue": "Type.Enum.Fixed.String.putKnownValue", + "com.type.enums.fixed.FixedAsyncClient.putKnownValueWithResponse": "Type.Enum.Fixed.String.putKnownValue", + "com.type.enums.fixed.FixedAsyncClient.putUnknownValue": "Type.Enum.Fixed.String.putUnknownValue", + "com.type.enums.fixed.FixedAsyncClient.putUnknownValueWithResponse": "Type.Enum.Fixed.String.putUnknownValue", + "com.type.enums.fixed.FixedClient": "null", + "com.type.enums.fixed.FixedClient.getKnownValue": "Type.Enum.Fixed.String.getKnownValue", + "com.type.enums.fixed.FixedClient.getKnownValueWithResponse": "Type.Enum.Fixed.String.getKnownValue", + "com.type.enums.fixed.FixedClient.putKnownValue": "Type.Enum.Fixed.String.putKnownValue", + "com.type.enums.fixed.FixedClient.putKnownValueWithResponse": "Type.Enum.Fixed.String.putKnownValue", + "com.type.enums.fixed.FixedClient.putUnknownValue": "Type.Enum.Fixed.String.putUnknownValue", + "com.type.enums.fixed.FixedClient.putUnknownValueWithResponse": "Type.Enum.Fixed.String.putUnknownValue", + "com.type.enums.fixed.FixedClientBuilder": "Type.Enum.Fixed", + "com.type.enums.fixed.models.DaysOfWeekEnum": "Type.Enum.Fixed.DaysOfWeekEnum" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-empty_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-empty_apiview_properties.json new file mode 100644 index 000000000..8a4151a88 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-empty_apiview_properties.json @@ -0,0 +1,23 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.model.empty.EmptyAsyncClient": "Type.Model.Empty", + "com.type.model.empty.EmptyAsyncClient.getEmpty": "Type.Model.Empty.getEmpty", + "com.type.model.empty.EmptyAsyncClient.getEmptyWithResponse": "Type.Model.Empty.getEmpty", + "com.type.model.empty.EmptyAsyncClient.postRoundTripEmpty": "Type.Model.Empty.postRoundTripEmpty", + "com.type.model.empty.EmptyAsyncClient.postRoundTripEmptyWithResponse": "Type.Model.Empty.postRoundTripEmpty", + "com.type.model.empty.EmptyAsyncClient.putEmpty": "Type.Model.Empty.putEmpty", + "com.type.model.empty.EmptyAsyncClient.putEmptyWithResponse": "Type.Model.Empty.putEmpty", + "com.type.model.empty.EmptyClient": "Type.Model.Empty", + "com.type.model.empty.EmptyClient.getEmpty": "Type.Model.Empty.getEmpty", + "com.type.model.empty.EmptyClient.getEmptyWithResponse": "Type.Model.Empty.getEmpty", + "com.type.model.empty.EmptyClient.postRoundTripEmpty": "Type.Model.Empty.postRoundTripEmpty", + "com.type.model.empty.EmptyClient.postRoundTripEmptyWithResponse": "Type.Model.Empty.postRoundTripEmpty", + "com.type.model.empty.EmptyClient.putEmpty": "Type.Model.Empty.putEmpty", + "com.type.model.empty.EmptyClient.putEmptyWithResponse": "Type.Model.Empty.putEmpty", + "com.type.model.empty.EmptyClientBuilder": "Type.Model.Empty", + "com.type.model.empty.models.EmptyInput": "Type.Model.Empty.EmptyInput", + "com.type.model.empty.models.EmptyInputOutput": "Type.Model.Empty.EmptyInputOutput", + "com.type.model.empty.models.EmptyOutput": "Type.Model.Empty.EmptyOutput" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-flatten_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-flatten_apiview_properties.json new file mode 100644 index 000000000..e43086ffd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-flatten_apiview_properties.json @@ -0,0 +1,20 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.model.flatten.FlattenAsyncClient": "Type.Model.Flatten", + "com.type.model.flatten.FlattenAsyncClient.putFlattenModel": "Type.Model.Flatten.putFlattenModel", + "com.type.model.flatten.FlattenAsyncClient.putFlattenModelWithResponse": "Type.Model.Flatten.putFlattenModel", + "com.type.model.flatten.FlattenAsyncClient.putNestedFlattenModel": "Type.Model.Flatten.putNestedFlattenModel", + "com.type.model.flatten.FlattenAsyncClient.putNestedFlattenModelWithResponse": "Type.Model.Flatten.putNestedFlattenModel", + "com.type.model.flatten.FlattenClient": "Type.Model.Flatten", + "com.type.model.flatten.FlattenClient.putFlattenModel": "Type.Model.Flatten.putFlattenModel", + "com.type.model.flatten.FlattenClient.putFlattenModelWithResponse": "Type.Model.Flatten.putFlattenModel", + "com.type.model.flatten.FlattenClient.putNestedFlattenModel": "Type.Model.Flatten.putNestedFlattenModel", + "com.type.model.flatten.FlattenClient.putNestedFlattenModelWithResponse": "Type.Model.Flatten.putNestedFlattenModel", + "com.type.model.flatten.FlattenClientBuilder": "Type.Model.Flatten", + "com.type.model.flatten.models.ChildFlattenModel": "Type.Model.Flatten.ChildFlattenModel", + "com.type.model.flatten.models.ChildModel": "Type.Model.Flatten.ChildModel", + "com.type.model.flatten.models.FlattenModel": "Type.Model.Flatten.FlattenModel", + "com.type.model.flatten.models.NestedFlattenModel": "Type.Model.Flatten.NestedFlattenModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-enumdiscriminator_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-enumdiscriminator_apiview_properties.json new file mode 100644 index 000000000..44265a2de --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-enumdiscriminator_apiview_properties.json @@ -0,0 +1,46 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient": "Type.Model.Inheritance.EnumDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.getExtensibleModel": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.getExtensibleModelMissingDiscriminator": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModelMissingDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.getExtensibleModelMissingDiscriminatorWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModelMissingDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.getExtensibleModelWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.getExtensibleModelWrongDiscriminator": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModelWrongDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.getExtensibleModelWrongDiscriminatorWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModelWrongDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.getFixedModel": "Type.Model.Inheritance.EnumDiscriminator.getFixedModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.getFixedModelMissingDiscriminator": "Type.Model.Inheritance.EnumDiscriminator.getFixedModelMissingDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.getFixedModelMissingDiscriminatorWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getFixedModelMissingDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.getFixedModelWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getFixedModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.getFixedModelWrongDiscriminator": "Type.Model.Inheritance.EnumDiscriminator.getFixedModelWrongDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.getFixedModelWrongDiscriminatorWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getFixedModelWrongDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.putExtensibleModel": "Type.Model.Inheritance.EnumDiscriminator.putExtensibleModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.putExtensibleModelWithResponse": "Type.Model.Inheritance.EnumDiscriminator.putExtensibleModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.putFixedModel": "Type.Model.Inheritance.EnumDiscriminator.putFixedModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorAsyncClient.putFixedModelWithResponse": "Type.Model.Inheritance.EnumDiscriminator.putFixedModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient": "Type.Model.Inheritance.EnumDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getExtensibleModel": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getExtensibleModelMissingDiscriminator": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModelMissingDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getExtensibleModelMissingDiscriminatorWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModelMissingDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getExtensibleModelWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getExtensibleModelWrongDiscriminator": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModelWrongDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getExtensibleModelWrongDiscriminatorWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModelWrongDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getFixedModel": "Type.Model.Inheritance.EnumDiscriminator.getFixedModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getFixedModelMissingDiscriminator": "Type.Model.Inheritance.EnumDiscriminator.getFixedModelMissingDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getFixedModelMissingDiscriminatorWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getFixedModelMissingDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getFixedModelWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getFixedModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getFixedModelWrongDiscriminator": "Type.Model.Inheritance.EnumDiscriminator.getFixedModelWrongDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getFixedModelWrongDiscriminatorWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getFixedModelWrongDiscriminator", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.putExtensibleModel": "Type.Model.Inheritance.EnumDiscriminator.putExtensibleModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.putExtensibleModelWithResponse": "Type.Model.Inheritance.EnumDiscriminator.putExtensibleModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.putFixedModel": "Type.Model.Inheritance.EnumDiscriminator.putFixedModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.putFixedModelWithResponse": "Type.Model.Inheritance.EnumDiscriminator.putFixedModel", + "com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClientBuilder": "Type.Model.Inheritance.EnumDiscriminator", + "com.type.model.inheritance.enumdiscriminator.models.Cobra": "Type.Model.Inheritance.EnumDiscriminator.Cobra", + "com.type.model.inheritance.enumdiscriminator.models.Dog": "Type.Model.Inheritance.EnumDiscriminator.Dog", + "com.type.model.inheritance.enumdiscriminator.models.DogKind": "Type.Model.Inheritance.EnumDiscriminator.DogKind", + "com.type.model.inheritance.enumdiscriminator.models.Golden": "Type.Model.Inheritance.EnumDiscriminator.Golden", + "com.type.model.inheritance.enumdiscriminator.models.Snake": "Type.Model.Inheritance.EnumDiscriminator.Snake", + "com.type.model.inheritance.enumdiscriminator.models.SnakeKind": "Type.Model.Inheritance.EnumDiscriminator.SnakeKind" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-enumnesteddiscriminator_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-enumnesteddiscriminator_apiview_properties.json new file mode 100644 index 000000000..e3bccbd43 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-enumnesteddiscriminator_apiview_properties.json @@ -0,0 +1,39 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient": "Type.Model.Inheritance.EnumNestedDiscriminator", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient.getMissingDiscriminator": "Type.Model.Inheritance.EnumNestedDiscriminator.getMissingDiscriminator", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient.getMissingDiscriminatorWithResponse": "Type.Model.Inheritance.EnumNestedDiscriminator.getMissingDiscriminator", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient.getModel": "Type.Model.Inheritance.EnumNestedDiscriminator.getModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient.getModelWithResponse": "Type.Model.Inheritance.EnumNestedDiscriminator.getModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient.getRecursiveModel": "Type.Model.Inheritance.EnumNestedDiscriminator.getRecursiveModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient.getRecursiveModelWithResponse": "Type.Model.Inheritance.EnumNestedDiscriminator.getRecursiveModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient.getWrongDiscriminator": "Type.Model.Inheritance.EnumNestedDiscriminator.getWrongDiscriminator", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient.getWrongDiscriminatorWithResponse": "Type.Model.Inheritance.EnumNestedDiscriminator.getWrongDiscriminator", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient.putModel": "Type.Model.Inheritance.EnumNestedDiscriminator.putModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient.putModelWithResponse": "Type.Model.Inheritance.EnumNestedDiscriminator.putModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient.putRecursiveModel": "Type.Model.Inheritance.EnumNestedDiscriminator.putRecursiveModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorAsyncClient.putRecursiveModelWithResponse": "Type.Model.Inheritance.EnumNestedDiscriminator.putRecursiveModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient": "Type.Model.Inheritance.EnumNestedDiscriminator", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient.getMissingDiscriminator": "Type.Model.Inheritance.EnumNestedDiscriminator.getMissingDiscriminator", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient.getMissingDiscriminatorWithResponse": "Type.Model.Inheritance.EnumNestedDiscriminator.getMissingDiscriminator", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient.getModel": "Type.Model.Inheritance.EnumNestedDiscriminator.getModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient.getModelWithResponse": "Type.Model.Inheritance.EnumNestedDiscriminator.getModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient.getRecursiveModel": "Type.Model.Inheritance.EnumNestedDiscriminator.getRecursiveModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient.getRecursiveModelWithResponse": "Type.Model.Inheritance.EnumNestedDiscriminator.getRecursiveModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient.getWrongDiscriminator": "Type.Model.Inheritance.EnumNestedDiscriminator.getWrongDiscriminator", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient.getWrongDiscriminatorWithResponse": "Type.Model.Inheritance.EnumNestedDiscriminator.getWrongDiscriminator", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient.putModel": "Type.Model.Inheritance.EnumNestedDiscriminator.putModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient.putModelWithResponse": "Type.Model.Inheritance.EnumNestedDiscriminator.putModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient.putRecursiveModel": "Type.Model.Inheritance.EnumNestedDiscriminator.putRecursiveModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient.putRecursiveModelWithResponse": "Type.Model.Inheritance.EnumNestedDiscriminator.putRecursiveModel", + "com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClientBuilder": "Type.Model.Inheritance.EnumNestedDiscriminator", + "com.type.model.inheritance.enumnesteddiscriminator.models.Fish": "Type.Model.Inheritance.EnumNestedDiscriminator.Fish", + "com.type.model.inheritance.enumnesteddiscriminator.models.FishKind": "Type.Model.Inheritance.EnumNestedDiscriminator.FishKind", + "com.type.model.inheritance.enumnesteddiscriminator.models.GoblinShark": "Type.Model.Inheritance.EnumNestedDiscriminator.GoblinShark", + "com.type.model.inheritance.enumnesteddiscriminator.models.Salmon": "Type.Model.Inheritance.EnumNestedDiscriminator.Salmon", + "com.type.model.inheritance.enumnesteddiscriminator.models.SawShark": "Type.Model.Inheritance.EnumNestedDiscriminator.SawShark", + "com.type.model.inheritance.enumnesteddiscriminator.models.Shark": "Type.Model.Inheritance.EnumNestedDiscriminator.Shark", + "com.type.model.inheritance.enumnesteddiscriminator.models.SharkKind": "Type.Model.Inheritance.EnumNestedDiscriminator.SharkKind" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-nesteddiscriminator_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-nesteddiscriminator_apiview_properties.json new file mode 100644 index 000000000..a34f9379a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-nesteddiscriminator_apiview_properties.json @@ -0,0 +1,37 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient": "Type.Model.Inheritance.NestedDiscriminator", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient.getMissingDiscriminator": "Type.Model.Inheritance.NestedDiscriminator.getMissingDiscriminator", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient.getMissingDiscriminatorWithResponse": "Type.Model.Inheritance.NestedDiscriminator.getMissingDiscriminator", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient.getModel": "Type.Model.Inheritance.NestedDiscriminator.getModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient.getModelWithResponse": "Type.Model.Inheritance.NestedDiscriminator.getModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient.getRecursiveModel": "Type.Model.Inheritance.NestedDiscriminator.getRecursiveModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient.getRecursiveModelWithResponse": "Type.Model.Inheritance.NestedDiscriminator.getRecursiveModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient.getWrongDiscriminator": "Type.Model.Inheritance.NestedDiscriminator.getWrongDiscriminator", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient.getWrongDiscriminatorWithResponse": "Type.Model.Inheritance.NestedDiscriminator.getWrongDiscriminator", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient.putModel": "Type.Model.Inheritance.NestedDiscriminator.putModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient.putModelWithResponse": "Type.Model.Inheritance.NestedDiscriminator.putModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient.putRecursiveModel": "Type.Model.Inheritance.NestedDiscriminator.putRecursiveModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorAsyncClient.putRecursiveModelWithResponse": "Type.Model.Inheritance.NestedDiscriminator.putRecursiveModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient": "Type.Model.Inheritance.NestedDiscriminator", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getMissingDiscriminator": "Type.Model.Inheritance.NestedDiscriminator.getMissingDiscriminator", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getMissingDiscriminatorWithResponse": "Type.Model.Inheritance.NestedDiscriminator.getMissingDiscriminator", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getModel": "Type.Model.Inheritance.NestedDiscriminator.getModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getModelWithResponse": "Type.Model.Inheritance.NestedDiscriminator.getModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getRecursiveModel": "Type.Model.Inheritance.NestedDiscriminator.getRecursiveModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getRecursiveModelWithResponse": "Type.Model.Inheritance.NestedDiscriminator.getRecursiveModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getWrongDiscriminator": "Type.Model.Inheritance.NestedDiscriminator.getWrongDiscriminator", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getWrongDiscriminatorWithResponse": "Type.Model.Inheritance.NestedDiscriminator.getWrongDiscriminator", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.putModel": "Type.Model.Inheritance.NestedDiscriminator.putModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.putModelWithResponse": "Type.Model.Inheritance.NestedDiscriminator.putModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.putRecursiveModel": "Type.Model.Inheritance.NestedDiscriminator.putRecursiveModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.putRecursiveModelWithResponse": "Type.Model.Inheritance.NestedDiscriminator.putRecursiveModel", + "com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClientBuilder": "Type.Model.Inheritance.NestedDiscriminator", + "com.type.model.inheritance.nesteddiscriminator.models.Fish": "Type.Model.Inheritance.NestedDiscriminator.Fish", + "com.type.model.inheritance.nesteddiscriminator.models.GoblinShark": "Type.Model.Inheritance.NestedDiscriminator.GoblinShark", + "com.type.model.inheritance.nesteddiscriminator.models.Salmon": "Type.Model.Inheritance.NestedDiscriminator.Salmon", + "com.type.model.inheritance.nesteddiscriminator.models.SawShark": "Type.Model.Inheritance.NestedDiscriminator.SawShark", + "com.type.model.inheritance.nesteddiscriminator.models.Shark": "Type.Model.Inheritance.NestedDiscriminator.Shark" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-notdiscriminated_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-notdiscriminated_apiview_properties.json new file mode 100644 index 000000000..9c27676c5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-notdiscriminated_apiview_properties.json @@ -0,0 +1,23 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedAsyncClient": "Type.Model.Inheritance.NotDiscriminated", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedAsyncClient.getValid": "Type.Model.Inheritance.NotDiscriminated.getValid", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedAsyncClient.getValidWithResponse": "Type.Model.Inheritance.NotDiscriminated.getValid", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedAsyncClient.postValid": "Type.Model.Inheritance.NotDiscriminated.postValid", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedAsyncClient.postValidWithResponse": "Type.Model.Inheritance.NotDiscriminated.postValid", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedAsyncClient.putValid": "Type.Model.Inheritance.NotDiscriminated.putValid", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedAsyncClient.putValidWithResponse": "Type.Model.Inheritance.NotDiscriminated.putValid", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedClient": "Type.Model.Inheritance.NotDiscriminated", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedClient.getValid": "Type.Model.Inheritance.NotDiscriminated.getValid", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedClient.getValidWithResponse": "Type.Model.Inheritance.NotDiscriminated.getValid", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedClient.postValid": "Type.Model.Inheritance.NotDiscriminated.postValid", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedClient.postValidWithResponse": "Type.Model.Inheritance.NotDiscriminated.postValid", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedClient.putValid": "Type.Model.Inheritance.NotDiscriminated.putValid", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedClient.putValidWithResponse": "Type.Model.Inheritance.NotDiscriminated.putValid", + "com.type.model.inheritance.notdiscriminated.NotDiscriminatedClientBuilder": "Type.Model.Inheritance.NotDiscriminated", + "com.type.model.inheritance.notdiscriminated.models.Cat": "Type.Model.Inheritance.NotDiscriminated.Cat", + "com.type.model.inheritance.notdiscriminated.models.Pet": "Type.Model.Inheritance.NotDiscriminated.Pet", + "com.type.model.inheritance.notdiscriminated.models.Siamese": "Type.Model.Inheritance.NotDiscriminated.Siamese" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-recursive_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-recursive_apiview_properties.json new file mode 100644 index 000000000..ab907a2f8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-recursive_apiview_properties.json @@ -0,0 +1,18 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.model.inheritance.recursive.RecursiveAsyncClient": "Type.Model.Inheritance.Recursive", + "com.type.model.inheritance.recursive.RecursiveAsyncClient.get": "Type.Model.Inheritance.Recursive.get", + "com.type.model.inheritance.recursive.RecursiveAsyncClient.getWithResponse": "Type.Model.Inheritance.Recursive.get", + "com.type.model.inheritance.recursive.RecursiveAsyncClient.put": "Type.Model.Inheritance.Recursive.put", + "com.type.model.inheritance.recursive.RecursiveAsyncClient.putWithResponse": "Type.Model.Inheritance.Recursive.put", + "com.type.model.inheritance.recursive.RecursiveClient": "Type.Model.Inheritance.Recursive", + "com.type.model.inheritance.recursive.RecursiveClient.get": "Type.Model.Inheritance.Recursive.get", + "com.type.model.inheritance.recursive.RecursiveClient.getWithResponse": "Type.Model.Inheritance.Recursive.get", + "com.type.model.inheritance.recursive.RecursiveClient.put": "Type.Model.Inheritance.Recursive.put", + "com.type.model.inheritance.recursive.RecursiveClient.putWithResponse": "Type.Model.Inheritance.Recursive.put", + "com.type.model.inheritance.recursive.RecursiveClientBuilder": "Type.Model.Inheritance.Recursive", + "com.type.model.inheritance.recursive.models.Element": "Type.Model.Inheritance.Recursive.Element", + "com.type.model.inheritance.recursive.models.Extension": "Type.Model.Inheritance.Recursive.Extension" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_apiview_properties.json new file mode 100644 index 000000000..c4fc88f77 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_apiview_properties.json @@ -0,0 +1,43 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient": "Type.Model.Inheritance.SingleDiscriminator", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getLegacyModel": "Type.Model.Inheritance.SingleDiscriminator.getLegacyModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getLegacyModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getLegacyModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getMissingDiscriminator": "Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getMissingDiscriminatorWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getModel": "Type.Model.Inheritance.SingleDiscriminator.getModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getRecursiveModel": "Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getRecursiveModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getWrongDiscriminator": "Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.getWrongDiscriminatorWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putModel": "Type.Model.Inheritance.SingleDiscriminator.putModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.putModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putRecursiveModel": "Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorAsyncClient.putRecursiveModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient": "Type.Model.Inheritance.SingleDiscriminator", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getLegacyModel": "Type.Model.Inheritance.SingleDiscriminator.getLegacyModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getLegacyModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getLegacyModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getMissingDiscriminator": "Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getMissingDiscriminatorWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getModel": "Type.Model.Inheritance.SingleDiscriminator.getModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getRecursiveModel": "Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getRecursiveModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getWrongDiscriminator": "Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getWrongDiscriminatorWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putModel": "Type.Model.Inheritance.SingleDiscriminator.putModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.putModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putRecursiveModel": "Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putRecursiveModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel", + "com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder": "Type.Model.Inheritance.SingleDiscriminator", + "com.type.model.inheritance.singlediscriminator.models.Bird": "Type.Model.Inheritance.SingleDiscriminator.Bird", + "com.type.model.inheritance.singlediscriminator.models.Dinosaur": "Type.Model.Inheritance.SingleDiscriminator.Dinosaur", + "com.type.model.inheritance.singlediscriminator.models.Eagle": "Type.Model.Inheritance.SingleDiscriminator.Eagle", + "com.type.model.inheritance.singlediscriminator.models.Goose": "Type.Model.Inheritance.SingleDiscriminator.Goose", + "com.type.model.inheritance.singlediscriminator.models.SeaGull": "Type.Model.Inheritance.SingleDiscriminator.SeaGull", + "com.type.model.inheritance.singlediscriminator.models.Sparrow": "Type.Model.Inheritance.SingleDiscriminator.Sparrow", + "com.type.model.inheritance.singlediscriminator.models.TRex": "Type.Model.Inheritance.SingleDiscriminator.TRex" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-usage_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-usage_apiview_properties.json new file mode 100644 index 000000000..e8224320b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-usage_apiview_properties.json @@ -0,0 +1,23 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.model.usage.UsageAsyncClient": "Type.Model.Usage", + "com.type.model.usage.UsageAsyncClient.input": "Type.Model.Usage.input", + "com.type.model.usage.UsageAsyncClient.inputAndOutput": "Type.Model.Usage.inputAndOutput", + "com.type.model.usage.UsageAsyncClient.inputAndOutputWithResponse": "Type.Model.Usage.inputAndOutput", + "com.type.model.usage.UsageAsyncClient.inputWithResponse": "Type.Model.Usage.input", + "com.type.model.usage.UsageAsyncClient.output": "Type.Model.Usage.output", + "com.type.model.usage.UsageAsyncClient.outputWithResponse": "Type.Model.Usage.output", + "com.type.model.usage.UsageClient": "Type.Model.Usage", + "com.type.model.usage.UsageClient.input": "Type.Model.Usage.input", + "com.type.model.usage.UsageClient.inputAndOutput": "Type.Model.Usage.inputAndOutput", + "com.type.model.usage.UsageClient.inputAndOutputWithResponse": "Type.Model.Usage.inputAndOutput", + "com.type.model.usage.UsageClient.inputWithResponse": "Type.Model.Usage.input", + "com.type.model.usage.UsageClient.output": "Type.Model.Usage.output", + "com.type.model.usage.UsageClient.outputWithResponse": "Type.Model.Usage.output", + "com.type.model.usage.UsageClientBuilder": "Type.Model.Usage", + "com.type.model.usage.models.InputOutputRecord": "Type.Model.Usage.InputOutputRecord", + "com.type.model.usage.models.InputRecord": "Type.Model.Usage.InputRecord", + "com.type.model.usage.models.OutputRecord": "Type.Model.Usage.OutputRecord" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-visibility_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-visibility_apiview_properties.json new file mode 100644 index 000000000..557d9a0bd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-model-visibility_apiview_properties.json @@ -0,0 +1,38 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.model.visibility.VisibilityAsyncClient": "Type.Model.Visibility", + "com.type.model.visibility.VisibilityAsyncClient.deleteModel": "Type.Model.Visibility.deleteModel", + "com.type.model.visibility.VisibilityAsyncClient.deleteModelWithResponse": "Type.Model.Visibility.deleteModel", + "com.type.model.visibility.VisibilityAsyncClient.getModel": "Type.Model.Visibility.getModel", + "com.type.model.visibility.VisibilityAsyncClient.getModelWithResponse": "Type.Model.Visibility.getModel", + "com.type.model.visibility.VisibilityAsyncClient.headModel": "Type.Model.Visibility.headModel", + "com.type.model.visibility.VisibilityAsyncClient.headModelWithResponse": "Type.Model.Visibility.headModel", + "com.type.model.visibility.VisibilityAsyncClient.patchModel": "Type.Model.Visibility.patchModel", + "com.type.model.visibility.VisibilityAsyncClient.patchModelWithResponse": "Type.Model.Visibility.patchModel", + "com.type.model.visibility.VisibilityAsyncClient.postModel": "Type.Model.Visibility.postModel", + "com.type.model.visibility.VisibilityAsyncClient.postModelWithResponse": "Type.Model.Visibility.postModel", + "com.type.model.visibility.VisibilityAsyncClient.putModel": "Type.Model.Visibility.putModel", + "com.type.model.visibility.VisibilityAsyncClient.putModelWithResponse": "Type.Model.Visibility.putModel", + "com.type.model.visibility.VisibilityAsyncClient.putReadOnlyModel": "Type.Model.Visibility.putReadOnlyModel", + "com.type.model.visibility.VisibilityAsyncClient.putReadOnlyModelWithResponse": "Type.Model.Visibility.putReadOnlyModel", + "com.type.model.visibility.VisibilityClient": "Type.Model.Visibility", + "com.type.model.visibility.VisibilityClient.deleteModel": "Type.Model.Visibility.deleteModel", + "com.type.model.visibility.VisibilityClient.deleteModelWithResponse": "Type.Model.Visibility.deleteModel", + "com.type.model.visibility.VisibilityClient.getModel": "Type.Model.Visibility.getModel", + "com.type.model.visibility.VisibilityClient.getModelWithResponse": "Type.Model.Visibility.getModel", + "com.type.model.visibility.VisibilityClient.headModel": "Type.Model.Visibility.headModel", + "com.type.model.visibility.VisibilityClient.headModelWithResponse": "Type.Model.Visibility.headModel", + "com.type.model.visibility.VisibilityClient.patchModel": "Type.Model.Visibility.patchModel", + "com.type.model.visibility.VisibilityClient.patchModelWithResponse": "Type.Model.Visibility.patchModel", + "com.type.model.visibility.VisibilityClient.postModel": "Type.Model.Visibility.postModel", + "com.type.model.visibility.VisibilityClient.postModelWithResponse": "Type.Model.Visibility.postModel", + "com.type.model.visibility.VisibilityClient.putModel": "Type.Model.Visibility.putModel", + "com.type.model.visibility.VisibilityClient.putModelWithResponse": "Type.Model.Visibility.putModel", + "com.type.model.visibility.VisibilityClient.putReadOnlyModel": "Type.Model.Visibility.putReadOnlyModel", + "com.type.model.visibility.VisibilityClient.putReadOnlyModelWithResponse": "Type.Model.Visibility.putReadOnlyModel", + "com.type.model.visibility.VisibilityClientBuilder": "Type.Model.Visibility", + "com.type.model.visibility.models.ReadOnlyModel": "Type.Model.Visibility.ReadOnlyModel", + "com.type.model.visibility.models.VisibilityModel": "Type.Model.Visibility.VisibilityModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-additionalproperties_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-additionalproperties_apiview_properties.json new file mode 100644 index 000000000..f67c6e5f3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-additionalproperties_apiview_properties.json @@ -0,0 +1,364 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.property.additionalproperties.AdditionalPropertiesClientBuilder": "Type.Property.AdditionalProperties", + "com.type.property.additionalproperties.ExtendsDifferentSpreadFloatAsyncClient": "null", + "com.type.property.additionalproperties.ExtendsDifferentSpreadFloatAsyncClient.get": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadFloatAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadFloatAsyncClient.put": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadFloatAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadFloatClient": "null", + "com.type.property.additionalproperties.ExtendsDifferentSpreadFloatClient.get": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadFloatClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadFloatClient.put": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadFloatClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelArrayAsyncClient": "null", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelArrayAsyncClient.get": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelArrayAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelArrayAsyncClient.put": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelArrayAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelArrayClient": "null", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelArrayClient.get": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelArrayClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelArrayClient.put": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelArrayClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelAsyncClient": "null", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelAsyncClient.get": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelAsyncClient.put": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelClient": "null", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelClient.get": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelClient.put": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadModelClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadStringAsyncClient": "null", + "com.type.property.additionalproperties.ExtendsDifferentSpreadStringAsyncClient.get": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadStringAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadStringAsyncClient.put": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadStringAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadStringClient": "null", + "com.type.property.additionalproperties.ExtendsDifferentSpreadStringClient.get": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadStringClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString.get", + "com.type.property.additionalproperties.ExtendsDifferentSpreadStringClient.put": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString.put", + "com.type.property.additionalproperties.ExtendsDifferentSpreadStringClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString.put", + "com.type.property.additionalproperties.ExtendsFloatAsyncClient": "null", + "com.type.property.additionalproperties.ExtendsFloatAsyncClient.get": "Type.Property.AdditionalProperties.ExtendsFloat.get", + "com.type.property.additionalproperties.ExtendsFloatAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsFloat.get", + "com.type.property.additionalproperties.ExtendsFloatAsyncClient.put": "Type.Property.AdditionalProperties.ExtendsFloat.put", + "com.type.property.additionalproperties.ExtendsFloatAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsFloat.put", + "com.type.property.additionalproperties.ExtendsFloatClient": "null", + "com.type.property.additionalproperties.ExtendsFloatClient.get": "Type.Property.AdditionalProperties.ExtendsFloat.get", + "com.type.property.additionalproperties.ExtendsFloatClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsFloat.get", + "com.type.property.additionalproperties.ExtendsFloatClient.put": "Type.Property.AdditionalProperties.ExtendsFloat.put", + "com.type.property.additionalproperties.ExtendsFloatClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsFloat.put", + "com.type.property.additionalproperties.ExtendsModelArrayAsyncClient": "null", + "com.type.property.additionalproperties.ExtendsModelArrayAsyncClient.get": "Type.Property.AdditionalProperties.ExtendsModelArray.get", + "com.type.property.additionalproperties.ExtendsModelArrayAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsModelArray.get", + "com.type.property.additionalproperties.ExtendsModelArrayAsyncClient.put": "Type.Property.AdditionalProperties.ExtendsModelArray.put", + "com.type.property.additionalproperties.ExtendsModelArrayAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsModelArray.put", + "com.type.property.additionalproperties.ExtendsModelArrayClient": "null", + "com.type.property.additionalproperties.ExtendsModelArrayClient.get": "Type.Property.AdditionalProperties.ExtendsModelArray.get", + "com.type.property.additionalproperties.ExtendsModelArrayClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsModelArray.get", + "com.type.property.additionalproperties.ExtendsModelArrayClient.put": "Type.Property.AdditionalProperties.ExtendsModelArray.put", + "com.type.property.additionalproperties.ExtendsModelArrayClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsModelArray.put", + "com.type.property.additionalproperties.ExtendsModelAsyncClient": "null", + "com.type.property.additionalproperties.ExtendsModelAsyncClient.get": "Type.Property.AdditionalProperties.ExtendsModel.get", + "com.type.property.additionalproperties.ExtendsModelAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsModel.get", + "com.type.property.additionalproperties.ExtendsModelAsyncClient.put": "Type.Property.AdditionalProperties.ExtendsModel.put", + "com.type.property.additionalproperties.ExtendsModelAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsModel.put", + "com.type.property.additionalproperties.ExtendsModelClient": "null", + "com.type.property.additionalproperties.ExtendsModelClient.get": "Type.Property.AdditionalProperties.ExtendsModel.get", + "com.type.property.additionalproperties.ExtendsModelClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsModel.get", + "com.type.property.additionalproperties.ExtendsModelClient.put": "Type.Property.AdditionalProperties.ExtendsModel.put", + "com.type.property.additionalproperties.ExtendsModelClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsModel.put", + "com.type.property.additionalproperties.ExtendsStringAsyncClient": "null", + "com.type.property.additionalproperties.ExtendsStringAsyncClient.get": "Type.Property.AdditionalProperties.ExtendsString.get", + "com.type.property.additionalproperties.ExtendsStringAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsString.get", + "com.type.property.additionalproperties.ExtendsStringAsyncClient.put": "Type.Property.AdditionalProperties.ExtendsString.put", + "com.type.property.additionalproperties.ExtendsStringAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsString.put", + "com.type.property.additionalproperties.ExtendsStringClient": "null", + "com.type.property.additionalproperties.ExtendsStringClient.get": "Type.Property.AdditionalProperties.ExtendsString.get", + "com.type.property.additionalproperties.ExtendsStringClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsString.get", + "com.type.property.additionalproperties.ExtendsStringClient.put": "Type.Property.AdditionalProperties.ExtendsString.put", + "com.type.property.additionalproperties.ExtendsStringClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsString.put", + "com.type.property.additionalproperties.ExtendsUnknownAsyncClient": "null", + "com.type.property.additionalproperties.ExtendsUnknownAsyncClient.get": "Type.Property.AdditionalProperties.ExtendsUnknown.get", + "com.type.property.additionalproperties.ExtendsUnknownAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknown.get", + "com.type.property.additionalproperties.ExtendsUnknownAsyncClient.put": "Type.Property.AdditionalProperties.ExtendsUnknown.put", + "com.type.property.additionalproperties.ExtendsUnknownAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknown.put", + "com.type.property.additionalproperties.ExtendsUnknownClient": "null", + "com.type.property.additionalproperties.ExtendsUnknownClient.get": "Type.Property.AdditionalProperties.ExtendsUnknown.get", + "com.type.property.additionalproperties.ExtendsUnknownClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknown.get", + "com.type.property.additionalproperties.ExtendsUnknownClient.put": "Type.Property.AdditionalProperties.ExtendsUnknown.put", + "com.type.property.additionalproperties.ExtendsUnknownClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknown.put", + "com.type.property.additionalproperties.ExtendsUnknownDerivedAsyncClient": "null", + "com.type.property.additionalproperties.ExtendsUnknownDerivedAsyncClient.get": "Type.Property.AdditionalProperties.ExtendsUnknownDerived.get", + "com.type.property.additionalproperties.ExtendsUnknownDerivedAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknownDerived.get", + "com.type.property.additionalproperties.ExtendsUnknownDerivedAsyncClient.put": "Type.Property.AdditionalProperties.ExtendsUnknownDerived.put", + "com.type.property.additionalproperties.ExtendsUnknownDerivedAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknownDerived.put", + "com.type.property.additionalproperties.ExtendsUnknownDerivedClient": "null", + "com.type.property.additionalproperties.ExtendsUnknownDerivedClient.get": "Type.Property.AdditionalProperties.ExtendsUnknownDerived.get", + "com.type.property.additionalproperties.ExtendsUnknownDerivedClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknownDerived.get", + "com.type.property.additionalproperties.ExtendsUnknownDerivedClient.put": "Type.Property.AdditionalProperties.ExtendsUnknownDerived.put", + "com.type.property.additionalproperties.ExtendsUnknownDerivedClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknownDerived.put", + "com.type.property.additionalproperties.ExtendsUnknownDiscriminatedAsyncClient": "null", + "com.type.property.additionalproperties.ExtendsUnknownDiscriminatedAsyncClient.get": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated.get", + "com.type.property.additionalproperties.ExtendsUnknownDiscriminatedAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated.get", + "com.type.property.additionalproperties.ExtendsUnknownDiscriminatedAsyncClient.put": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated.put", + "com.type.property.additionalproperties.ExtendsUnknownDiscriminatedAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated.put", + "com.type.property.additionalproperties.ExtendsUnknownDiscriminatedClient": "null", + "com.type.property.additionalproperties.ExtendsUnknownDiscriminatedClient.get": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated.get", + "com.type.property.additionalproperties.ExtendsUnknownDiscriminatedClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated.get", + "com.type.property.additionalproperties.ExtendsUnknownDiscriminatedClient.put": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated.put", + "com.type.property.additionalproperties.ExtendsUnknownDiscriminatedClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated.put", + "com.type.property.additionalproperties.IsFloatAsyncClient": "null", + "com.type.property.additionalproperties.IsFloatAsyncClient.get": "Type.Property.AdditionalProperties.IsFloat.get", + "com.type.property.additionalproperties.IsFloatAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.IsFloat.get", + "com.type.property.additionalproperties.IsFloatAsyncClient.put": "Type.Property.AdditionalProperties.IsFloat.put", + "com.type.property.additionalproperties.IsFloatAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.IsFloat.put", + "com.type.property.additionalproperties.IsFloatClient": "null", + "com.type.property.additionalproperties.IsFloatClient.get": "Type.Property.AdditionalProperties.IsFloat.get", + "com.type.property.additionalproperties.IsFloatClient.getWithResponse": "Type.Property.AdditionalProperties.IsFloat.get", + "com.type.property.additionalproperties.IsFloatClient.put": "Type.Property.AdditionalProperties.IsFloat.put", + "com.type.property.additionalproperties.IsFloatClient.putWithResponse": "Type.Property.AdditionalProperties.IsFloat.put", + "com.type.property.additionalproperties.IsModelArrayAsyncClient": "null", + "com.type.property.additionalproperties.IsModelArrayAsyncClient.get": "Type.Property.AdditionalProperties.IsModelArray.get", + "com.type.property.additionalproperties.IsModelArrayAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.IsModelArray.get", + "com.type.property.additionalproperties.IsModelArrayAsyncClient.put": "Type.Property.AdditionalProperties.IsModelArray.put", + "com.type.property.additionalproperties.IsModelArrayAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.IsModelArray.put", + "com.type.property.additionalproperties.IsModelArrayClient": "null", + "com.type.property.additionalproperties.IsModelArrayClient.get": "Type.Property.AdditionalProperties.IsModelArray.get", + "com.type.property.additionalproperties.IsModelArrayClient.getWithResponse": "Type.Property.AdditionalProperties.IsModelArray.get", + "com.type.property.additionalproperties.IsModelArrayClient.put": "Type.Property.AdditionalProperties.IsModelArray.put", + "com.type.property.additionalproperties.IsModelArrayClient.putWithResponse": "Type.Property.AdditionalProperties.IsModelArray.put", + "com.type.property.additionalproperties.IsModelAsyncClient": "null", + "com.type.property.additionalproperties.IsModelAsyncClient.get": "Type.Property.AdditionalProperties.IsModel.get", + "com.type.property.additionalproperties.IsModelAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.IsModel.get", + "com.type.property.additionalproperties.IsModelAsyncClient.put": "Type.Property.AdditionalProperties.IsModel.put", + "com.type.property.additionalproperties.IsModelAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.IsModel.put", + "com.type.property.additionalproperties.IsModelClient": "null", + "com.type.property.additionalproperties.IsModelClient.get": "Type.Property.AdditionalProperties.IsModel.get", + "com.type.property.additionalproperties.IsModelClient.getWithResponse": "Type.Property.AdditionalProperties.IsModel.get", + "com.type.property.additionalproperties.IsModelClient.put": "Type.Property.AdditionalProperties.IsModel.put", + "com.type.property.additionalproperties.IsModelClient.putWithResponse": "Type.Property.AdditionalProperties.IsModel.put", + "com.type.property.additionalproperties.IsStringAsyncClient": "null", + "com.type.property.additionalproperties.IsStringAsyncClient.get": "Type.Property.AdditionalProperties.IsString.get", + "com.type.property.additionalproperties.IsStringAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.IsString.get", + "com.type.property.additionalproperties.IsStringAsyncClient.put": "Type.Property.AdditionalProperties.IsString.put", + "com.type.property.additionalproperties.IsStringAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.IsString.put", + "com.type.property.additionalproperties.IsStringClient": "null", + "com.type.property.additionalproperties.IsStringClient.get": "Type.Property.AdditionalProperties.IsString.get", + "com.type.property.additionalproperties.IsStringClient.getWithResponse": "Type.Property.AdditionalProperties.IsString.get", + "com.type.property.additionalproperties.IsStringClient.put": "Type.Property.AdditionalProperties.IsString.put", + "com.type.property.additionalproperties.IsStringClient.putWithResponse": "Type.Property.AdditionalProperties.IsString.put", + "com.type.property.additionalproperties.IsUnknownAsyncClient": "null", + "com.type.property.additionalproperties.IsUnknownAsyncClient.get": "Type.Property.AdditionalProperties.IsUnknown.get", + "com.type.property.additionalproperties.IsUnknownAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.IsUnknown.get", + "com.type.property.additionalproperties.IsUnknownAsyncClient.put": "Type.Property.AdditionalProperties.IsUnknown.put", + "com.type.property.additionalproperties.IsUnknownAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.IsUnknown.put", + "com.type.property.additionalproperties.IsUnknownClient": "null", + "com.type.property.additionalproperties.IsUnknownClient.get": "Type.Property.AdditionalProperties.IsUnknown.get", + "com.type.property.additionalproperties.IsUnknownClient.getWithResponse": "Type.Property.AdditionalProperties.IsUnknown.get", + "com.type.property.additionalproperties.IsUnknownClient.put": "Type.Property.AdditionalProperties.IsUnknown.put", + "com.type.property.additionalproperties.IsUnknownClient.putWithResponse": "Type.Property.AdditionalProperties.IsUnknown.put", + "com.type.property.additionalproperties.IsUnknownDerivedAsyncClient": "null", + "com.type.property.additionalproperties.IsUnknownDerivedAsyncClient.get": "Type.Property.AdditionalProperties.IsUnknownDerived.get", + "com.type.property.additionalproperties.IsUnknownDerivedAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.IsUnknownDerived.get", + "com.type.property.additionalproperties.IsUnknownDerivedAsyncClient.put": "Type.Property.AdditionalProperties.IsUnknownDerived.put", + "com.type.property.additionalproperties.IsUnknownDerivedAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.IsUnknownDerived.put", + "com.type.property.additionalproperties.IsUnknownDerivedClient": "null", + "com.type.property.additionalproperties.IsUnknownDerivedClient.get": "Type.Property.AdditionalProperties.IsUnknownDerived.get", + "com.type.property.additionalproperties.IsUnknownDerivedClient.getWithResponse": "Type.Property.AdditionalProperties.IsUnknownDerived.get", + "com.type.property.additionalproperties.IsUnknownDerivedClient.put": "Type.Property.AdditionalProperties.IsUnknownDerived.put", + "com.type.property.additionalproperties.IsUnknownDerivedClient.putWithResponse": "Type.Property.AdditionalProperties.IsUnknownDerived.put", + "com.type.property.additionalproperties.IsUnknownDiscriminatedAsyncClient": "null", + "com.type.property.additionalproperties.IsUnknownDiscriminatedAsyncClient.get": "Type.Property.AdditionalProperties.IsUnknownDiscriminated.get", + "com.type.property.additionalproperties.IsUnknownDiscriminatedAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.IsUnknownDiscriminated.get", + "com.type.property.additionalproperties.IsUnknownDiscriminatedAsyncClient.put": "Type.Property.AdditionalProperties.IsUnknownDiscriminated.put", + "com.type.property.additionalproperties.IsUnknownDiscriminatedAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.IsUnknownDiscriminated.put", + "com.type.property.additionalproperties.IsUnknownDiscriminatedClient": "null", + "com.type.property.additionalproperties.IsUnknownDiscriminatedClient.get": "Type.Property.AdditionalProperties.IsUnknownDiscriminated.get", + "com.type.property.additionalproperties.IsUnknownDiscriminatedClient.getWithResponse": "Type.Property.AdditionalProperties.IsUnknownDiscriminated.get", + "com.type.property.additionalproperties.IsUnknownDiscriminatedClient.put": "Type.Property.AdditionalProperties.IsUnknownDiscriminated.put", + "com.type.property.additionalproperties.IsUnknownDiscriminatedClient.putWithResponse": "Type.Property.AdditionalProperties.IsUnknownDiscriminated.put", + "com.type.property.additionalproperties.MultipleSpreadAsyncClient": "null", + "com.type.property.additionalproperties.MultipleSpreadAsyncClient.get": "Type.Property.AdditionalProperties.MultipleSpread.get", + "com.type.property.additionalproperties.MultipleSpreadAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.MultipleSpread.get", + "com.type.property.additionalproperties.MultipleSpreadAsyncClient.put": "Type.Property.AdditionalProperties.MultipleSpread.put", + "com.type.property.additionalproperties.MultipleSpreadAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.MultipleSpread.put", + "com.type.property.additionalproperties.MultipleSpreadClient": "null", + "com.type.property.additionalproperties.MultipleSpreadClient.get": "Type.Property.AdditionalProperties.MultipleSpread.get", + "com.type.property.additionalproperties.MultipleSpreadClient.getWithResponse": "Type.Property.AdditionalProperties.MultipleSpread.get", + "com.type.property.additionalproperties.MultipleSpreadClient.put": "Type.Property.AdditionalProperties.MultipleSpread.put", + "com.type.property.additionalproperties.MultipleSpreadClient.putWithResponse": "Type.Property.AdditionalProperties.MultipleSpread.put", + "com.type.property.additionalproperties.SpreadDifferentFloatAsyncClient": "null", + "com.type.property.additionalproperties.SpreadDifferentFloatAsyncClient.get": "Type.Property.AdditionalProperties.SpreadDifferentFloat.get", + "com.type.property.additionalproperties.SpreadDifferentFloatAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentFloat.get", + "com.type.property.additionalproperties.SpreadDifferentFloatAsyncClient.put": "Type.Property.AdditionalProperties.SpreadDifferentFloat.put", + "com.type.property.additionalproperties.SpreadDifferentFloatAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentFloat.put", + "com.type.property.additionalproperties.SpreadDifferentFloatClient": "null", + "com.type.property.additionalproperties.SpreadDifferentFloatClient.get": "Type.Property.AdditionalProperties.SpreadDifferentFloat.get", + "com.type.property.additionalproperties.SpreadDifferentFloatClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentFloat.get", + "com.type.property.additionalproperties.SpreadDifferentFloatClient.put": "Type.Property.AdditionalProperties.SpreadDifferentFloat.put", + "com.type.property.additionalproperties.SpreadDifferentFloatClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentFloat.put", + "com.type.property.additionalproperties.SpreadDifferentModelArrayAsyncClient": "null", + "com.type.property.additionalproperties.SpreadDifferentModelArrayAsyncClient.get": "Type.Property.AdditionalProperties.SpreadDifferentModelArray.get", + "com.type.property.additionalproperties.SpreadDifferentModelArrayAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentModelArray.get", + "com.type.property.additionalproperties.SpreadDifferentModelArrayAsyncClient.put": "Type.Property.AdditionalProperties.SpreadDifferentModelArray.put", + "com.type.property.additionalproperties.SpreadDifferentModelArrayAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentModelArray.put", + "com.type.property.additionalproperties.SpreadDifferentModelArrayClient": "null", + "com.type.property.additionalproperties.SpreadDifferentModelArrayClient.get": "Type.Property.AdditionalProperties.SpreadDifferentModelArray.get", + "com.type.property.additionalproperties.SpreadDifferentModelArrayClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentModelArray.get", + "com.type.property.additionalproperties.SpreadDifferentModelArrayClient.put": "Type.Property.AdditionalProperties.SpreadDifferentModelArray.put", + "com.type.property.additionalproperties.SpreadDifferentModelArrayClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentModelArray.put", + "com.type.property.additionalproperties.SpreadDifferentModelAsyncClient": "null", + "com.type.property.additionalproperties.SpreadDifferentModelAsyncClient.get": "Type.Property.AdditionalProperties.SpreadDifferentModel.get", + "com.type.property.additionalproperties.SpreadDifferentModelAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentModel.get", + "com.type.property.additionalproperties.SpreadDifferentModelAsyncClient.put": "Type.Property.AdditionalProperties.SpreadDifferentModel.put", + "com.type.property.additionalproperties.SpreadDifferentModelAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentModel.put", + "com.type.property.additionalproperties.SpreadDifferentModelClient": "null", + "com.type.property.additionalproperties.SpreadDifferentModelClient.get": "Type.Property.AdditionalProperties.SpreadDifferentModel.get", + "com.type.property.additionalproperties.SpreadDifferentModelClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentModel.get", + "com.type.property.additionalproperties.SpreadDifferentModelClient.put": "Type.Property.AdditionalProperties.SpreadDifferentModel.put", + "com.type.property.additionalproperties.SpreadDifferentModelClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentModel.put", + "com.type.property.additionalproperties.SpreadDifferentStringAsyncClient": "null", + "com.type.property.additionalproperties.SpreadDifferentStringAsyncClient.get": "Type.Property.AdditionalProperties.SpreadDifferentString.get", + "com.type.property.additionalproperties.SpreadDifferentStringAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentString.get", + "com.type.property.additionalproperties.SpreadDifferentStringAsyncClient.put": "Type.Property.AdditionalProperties.SpreadDifferentString.put", + "com.type.property.additionalproperties.SpreadDifferentStringAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentString.put", + "com.type.property.additionalproperties.SpreadDifferentStringClient": "null", + "com.type.property.additionalproperties.SpreadDifferentStringClient.get": "Type.Property.AdditionalProperties.SpreadDifferentString.get", + "com.type.property.additionalproperties.SpreadDifferentStringClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentString.get", + "com.type.property.additionalproperties.SpreadDifferentStringClient.put": "Type.Property.AdditionalProperties.SpreadDifferentString.put", + "com.type.property.additionalproperties.SpreadDifferentStringClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentString.put", + "com.type.property.additionalproperties.SpreadFloatAsyncClient": "null", + "com.type.property.additionalproperties.SpreadFloatAsyncClient.get": "Type.Property.AdditionalProperties.SpreadFloat.get", + "com.type.property.additionalproperties.SpreadFloatAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadFloat.get", + "com.type.property.additionalproperties.SpreadFloatAsyncClient.put": "Type.Property.AdditionalProperties.SpreadFloat.put", + "com.type.property.additionalproperties.SpreadFloatAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadFloat.put", + "com.type.property.additionalproperties.SpreadFloatClient": "null", + "com.type.property.additionalproperties.SpreadFloatClient.get": "Type.Property.AdditionalProperties.SpreadFloat.get", + "com.type.property.additionalproperties.SpreadFloatClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadFloat.get", + "com.type.property.additionalproperties.SpreadFloatClient.put": "Type.Property.AdditionalProperties.SpreadFloat.put", + "com.type.property.additionalproperties.SpreadFloatClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadFloat.put", + "com.type.property.additionalproperties.SpreadModelArrayAsyncClient": "null", + "com.type.property.additionalproperties.SpreadModelArrayAsyncClient.get": "Type.Property.AdditionalProperties.SpreadModelArray.get", + "com.type.property.additionalproperties.SpreadModelArrayAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadModelArray.get", + "com.type.property.additionalproperties.SpreadModelArrayAsyncClient.put": "Type.Property.AdditionalProperties.SpreadModelArray.put", + "com.type.property.additionalproperties.SpreadModelArrayAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadModelArray.put", + "com.type.property.additionalproperties.SpreadModelArrayClient": "null", + "com.type.property.additionalproperties.SpreadModelArrayClient.get": "Type.Property.AdditionalProperties.SpreadModelArray.get", + "com.type.property.additionalproperties.SpreadModelArrayClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadModelArray.get", + "com.type.property.additionalproperties.SpreadModelArrayClient.put": "Type.Property.AdditionalProperties.SpreadModelArray.put", + "com.type.property.additionalproperties.SpreadModelArrayClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadModelArray.put", + "com.type.property.additionalproperties.SpreadModelAsyncClient": "null", + "com.type.property.additionalproperties.SpreadModelAsyncClient.get": "Type.Property.AdditionalProperties.SpreadModel.get", + "com.type.property.additionalproperties.SpreadModelAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadModel.get", + "com.type.property.additionalproperties.SpreadModelAsyncClient.put": "Type.Property.AdditionalProperties.SpreadModel.put", + "com.type.property.additionalproperties.SpreadModelAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadModel.put", + "com.type.property.additionalproperties.SpreadModelClient": "null", + "com.type.property.additionalproperties.SpreadModelClient.get": "Type.Property.AdditionalProperties.SpreadModel.get", + "com.type.property.additionalproperties.SpreadModelClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadModel.get", + "com.type.property.additionalproperties.SpreadModelClient.put": "Type.Property.AdditionalProperties.SpreadModel.put", + "com.type.property.additionalproperties.SpreadModelClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadModel.put", + "com.type.property.additionalproperties.SpreadRecordDiscriminatedUnionAsyncClient": "null", + "com.type.property.additionalproperties.SpreadRecordDiscriminatedUnionAsyncClient.get": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.get", + "com.type.property.additionalproperties.SpreadRecordDiscriminatedUnionAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.get", + "com.type.property.additionalproperties.SpreadRecordDiscriminatedUnionAsyncClient.put": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.put", + "com.type.property.additionalproperties.SpreadRecordDiscriminatedUnionAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.put", + "com.type.property.additionalproperties.SpreadRecordDiscriminatedUnionClient": "null", + "com.type.property.additionalproperties.SpreadRecordDiscriminatedUnionClient.get": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.get", + "com.type.property.additionalproperties.SpreadRecordDiscriminatedUnionClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.get", + "com.type.property.additionalproperties.SpreadRecordDiscriminatedUnionClient.put": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.put", + "com.type.property.additionalproperties.SpreadRecordDiscriminatedUnionClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.put", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2AsyncClient": "null", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2AsyncClient.get": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.get", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2AsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.get", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2AsyncClient.put": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.put", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2AsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.put", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2Client": "null", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2Client.get": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.get", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2Client.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.get", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2Client.put": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.put", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2Client.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.put", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3AsyncClient": "null", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3AsyncClient.get": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3.get", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3AsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3.get", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3AsyncClient.put": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3.put", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3AsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3.put", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3Client": "null", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3Client.get": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3.get", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3Client.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3.get", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3Client.put": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3.put", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3Client.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3.put", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionAsyncClient": "null", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionAsyncClient.get": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.get", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.get", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionAsyncClient.put": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.put", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.put", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionClient": "null", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionClient.get": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.get", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.get", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionClient.put": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.put", + "com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.put", + "com.type.property.additionalproperties.SpreadRecordUnionAsyncClient": "null", + "com.type.property.additionalproperties.SpreadRecordUnionAsyncClient.get": "Type.Property.AdditionalProperties.SpreadRecordUnion.get", + "com.type.property.additionalproperties.SpreadRecordUnionAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordUnion.get", + "com.type.property.additionalproperties.SpreadRecordUnionAsyncClient.put": "Type.Property.AdditionalProperties.SpreadRecordUnion.put", + "com.type.property.additionalproperties.SpreadRecordUnionAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordUnion.put", + "com.type.property.additionalproperties.SpreadRecordUnionClient": "null", + "com.type.property.additionalproperties.SpreadRecordUnionClient.get": "Type.Property.AdditionalProperties.SpreadRecordUnion.get", + "com.type.property.additionalproperties.SpreadRecordUnionClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordUnion.get", + "com.type.property.additionalproperties.SpreadRecordUnionClient.put": "Type.Property.AdditionalProperties.SpreadRecordUnion.put", + "com.type.property.additionalproperties.SpreadRecordUnionClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordUnion.put", + "com.type.property.additionalproperties.SpreadStringAsyncClient": "null", + "com.type.property.additionalproperties.SpreadStringAsyncClient.get": "Type.Property.AdditionalProperties.SpreadString.get", + "com.type.property.additionalproperties.SpreadStringAsyncClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadString.get", + "com.type.property.additionalproperties.SpreadStringAsyncClient.put": "Type.Property.AdditionalProperties.SpreadString.put", + "com.type.property.additionalproperties.SpreadStringAsyncClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadString.put", + "com.type.property.additionalproperties.SpreadStringClient": "null", + "com.type.property.additionalproperties.SpreadStringClient.get": "Type.Property.AdditionalProperties.SpreadString.get", + "com.type.property.additionalproperties.SpreadStringClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadString.get", + "com.type.property.additionalproperties.SpreadStringClient.put": "Type.Property.AdditionalProperties.SpreadString.put", + "com.type.property.additionalproperties.SpreadStringClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadString.put", + "com.type.property.additionalproperties.models.DifferentSpreadFloatDerived": "Type.Property.AdditionalProperties.DifferentSpreadFloatDerived", + "com.type.property.additionalproperties.models.DifferentSpreadFloatRecord": "Type.Property.AdditionalProperties.DifferentSpreadFloatRecord", + "com.type.property.additionalproperties.models.DifferentSpreadModelArrayDerived": "Type.Property.AdditionalProperties.DifferentSpreadModelArrayDerived", + "com.type.property.additionalproperties.models.DifferentSpreadModelArrayRecord": "Type.Property.AdditionalProperties.DifferentSpreadModelArrayRecord", + "com.type.property.additionalproperties.models.DifferentSpreadModelDerived": "Type.Property.AdditionalProperties.DifferentSpreadModelDerived", + "com.type.property.additionalproperties.models.DifferentSpreadModelRecord": "Type.Property.AdditionalProperties.DifferentSpreadModelRecord", + "com.type.property.additionalproperties.models.DifferentSpreadStringDerived": "Type.Property.AdditionalProperties.DifferentSpreadStringDerived", + "com.type.property.additionalproperties.models.DifferentSpreadStringRecord": "Type.Property.AdditionalProperties.DifferentSpreadStringRecord", + "com.type.property.additionalproperties.models.ExtendsFloatAdditionalProperties": "Type.Property.AdditionalProperties.ExtendsFloatAdditionalProperties", + "com.type.property.additionalproperties.models.ExtendsModelAdditionalProperties": "Type.Property.AdditionalProperties.ExtendsModelAdditionalProperties", + "com.type.property.additionalproperties.models.ExtendsModelArrayAdditionalProperties": "Type.Property.AdditionalProperties.ExtendsModelArrayAdditionalProperties", + "com.type.property.additionalproperties.models.ExtendsStringAdditionalProperties": "Type.Property.AdditionalProperties.ExtendsStringAdditionalProperties", + "com.type.property.additionalproperties.models.ExtendsUnknownAdditionalProperties": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalProperties", + "com.type.property.additionalproperties.models.ExtendsUnknownAdditionalPropertiesDerived": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDerived", + "com.type.property.additionalproperties.models.ExtendsUnknownAdditionalPropertiesDiscriminated": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDiscriminated", + "com.type.property.additionalproperties.models.ExtendsUnknownAdditionalPropertiesDiscriminatedDerived": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDiscriminatedDerived", + "com.type.property.additionalproperties.models.IsFloatAdditionalProperties": "Type.Property.AdditionalProperties.IsFloatAdditionalProperties", + "com.type.property.additionalproperties.models.IsModelAdditionalProperties": "Type.Property.AdditionalProperties.IsModelAdditionalProperties", + "com.type.property.additionalproperties.models.IsModelArrayAdditionalProperties": "Type.Property.AdditionalProperties.IsModelArrayAdditionalProperties", + "com.type.property.additionalproperties.models.IsStringAdditionalProperties": "Type.Property.AdditionalProperties.IsStringAdditionalProperties", + "com.type.property.additionalproperties.models.IsUnknownAdditionalProperties": "Type.Property.AdditionalProperties.IsUnknownAdditionalProperties", + "com.type.property.additionalproperties.models.IsUnknownAdditionalPropertiesDerived": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDerived", + "com.type.property.additionalproperties.models.IsUnknownAdditionalPropertiesDiscriminated": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDiscriminated", + "com.type.property.additionalproperties.models.IsUnknownAdditionalPropertiesDiscriminatedDerived": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDiscriminatedDerived", + "com.type.property.additionalproperties.models.ModelForRecord": "Type.Property.AdditionalProperties.ModelForRecord", + "com.type.property.additionalproperties.models.MultipleSpreadRecord": "Type.Property.AdditionalProperties.MultipleSpreadRecord", + "com.type.property.additionalproperties.models.SpreadFloatRecord": "Type.Property.AdditionalProperties.SpreadFloatRecord", + "com.type.property.additionalproperties.models.SpreadModelArrayRecord": "Type.Property.AdditionalProperties.SpreadModelArrayRecord", + "com.type.property.additionalproperties.models.SpreadModelRecord": "Type.Property.AdditionalProperties.SpreadModelRecord", + "com.type.property.additionalproperties.models.SpreadRecordForDiscriminatedUnion": "Type.Property.AdditionalProperties.SpreadRecordForDiscriminatedUnion", + "com.type.property.additionalproperties.models.SpreadRecordForNonDiscriminatedUnion": "Type.Property.AdditionalProperties.SpreadRecordForNonDiscriminatedUnion", + "com.type.property.additionalproperties.models.SpreadRecordForNonDiscriminatedUnion2": "Type.Property.AdditionalProperties.SpreadRecordForNonDiscriminatedUnion2", + "com.type.property.additionalproperties.models.SpreadRecordForNonDiscriminatedUnion3": "Type.Property.AdditionalProperties.SpreadRecordForNonDiscriminatedUnion3", + "com.type.property.additionalproperties.models.SpreadRecordForUnion": "Type.Property.AdditionalProperties.SpreadRecordForUnion", + "com.type.property.additionalproperties.models.SpreadStringRecord": "Type.Property.AdditionalProperties.SpreadStringRecord", + "com.type.property.additionalproperties.models.WidgetData0": "Type.Property.AdditionalProperties.WidgetData0", + "com.type.property.additionalproperties.models.WidgetData1": "Type.Property.AdditionalProperties.WidgetData1", + "com.type.property.additionalproperties.models.WidgetData2": "Type.Property.AdditionalProperties.WidgetData2" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-nullable_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-nullable_apiview_properties.json new file mode 100644 index 000000000..cdcf52aa0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-nullable_apiview_properties.json @@ -0,0 +1,140 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.property.nullable.BytesAsyncClient": "null", + "com.type.property.nullable.BytesAsyncClient.getNonNull": "Type.Property.Nullable.Bytes.getNonNull", + "com.type.property.nullable.BytesAsyncClient.getNonNullWithResponse": "Type.Property.Nullable.Bytes.getNonNull", + "com.type.property.nullable.BytesAsyncClient.getNull": "Type.Property.Nullable.Bytes.getNull", + "com.type.property.nullable.BytesAsyncClient.getNullWithResponse": "Type.Property.Nullable.Bytes.getNull", + "com.type.property.nullable.BytesAsyncClient.patchNonNull": "Type.Property.Nullable.Bytes.patchNonNull", + "com.type.property.nullable.BytesAsyncClient.patchNonNullWithResponse": "Type.Property.Nullable.Bytes.patchNonNull", + "com.type.property.nullable.BytesAsyncClient.patchNull": "Type.Property.Nullable.Bytes.patchNull", + "com.type.property.nullable.BytesAsyncClient.patchNullWithResponse": "Type.Property.Nullable.Bytes.patchNull", + "com.type.property.nullable.BytesClient": "null", + "com.type.property.nullable.BytesClient.getNonNull": "Type.Property.Nullable.Bytes.getNonNull", + "com.type.property.nullable.BytesClient.getNonNullWithResponse": "Type.Property.Nullable.Bytes.getNonNull", + "com.type.property.nullable.BytesClient.getNull": "Type.Property.Nullable.Bytes.getNull", + "com.type.property.nullable.BytesClient.getNullWithResponse": "Type.Property.Nullable.Bytes.getNull", + "com.type.property.nullable.BytesClient.patchNonNull": "Type.Property.Nullable.Bytes.patchNonNull", + "com.type.property.nullable.BytesClient.patchNonNullWithResponse": "Type.Property.Nullable.Bytes.patchNonNull", + "com.type.property.nullable.BytesClient.patchNull": "Type.Property.Nullable.Bytes.patchNull", + "com.type.property.nullable.BytesClient.patchNullWithResponse": "Type.Property.Nullable.Bytes.patchNull", + "com.type.property.nullable.CollectionsByteAsyncClient": "null", + "com.type.property.nullable.CollectionsByteAsyncClient.getNonNull": "Type.Property.Nullable.CollectionsByte.getNonNull", + "com.type.property.nullable.CollectionsByteAsyncClient.getNonNullWithResponse": "Type.Property.Nullable.CollectionsByte.getNonNull", + "com.type.property.nullable.CollectionsByteAsyncClient.getNull": "Type.Property.Nullable.CollectionsByte.getNull", + "com.type.property.nullable.CollectionsByteAsyncClient.getNullWithResponse": "Type.Property.Nullable.CollectionsByte.getNull", + "com.type.property.nullable.CollectionsByteAsyncClient.patchNonNull": "Type.Property.Nullable.CollectionsByte.patchNonNull", + "com.type.property.nullable.CollectionsByteAsyncClient.patchNonNullWithResponse": "Type.Property.Nullable.CollectionsByte.patchNonNull", + "com.type.property.nullable.CollectionsByteAsyncClient.patchNull": "Type.Property.Nullable.CollectionsByte.patchNull", + "com.type.property.nullable.CollectionsByteAsyncClient.patchNullWithResponse": "Type.Property.Nullable.CollectionsByte.patchNull", + "com.type.property.nullable.CollectionsByteClient": "null", + "com.type.property.nullable.CollectionsByteClient.getNonNull": "Type.Property.Nullable.CollectionsByte.getNonNull", + "com.type.property.nullable.CollectionsByteClient.getNonNullWithResponse": "Type.Property.Nullable.CollectionsByte.getNonNull", + "com.type.property.nullable.CollectionsByteClient.getNull": "Type.Property.Nullable.CollectionsByte.getNull", + "com.type.property.nullable.CollectionsByteClient.getNullWithResponse": "Type.Property.Nullable.CollectionsByte.getNull", + "com.type.property.nullable.CollectionsByteClient.patchNonNull": "Type.Property.Nullable.CollectionsByte.patchNonNull", + "com.type.property.nullable.CollectionsByteClient.patchNonNullWithResponse": "Type.Property.Nullable.CollectionsByte.patchNonNull", + "com.type.property.nullable.CollectionsByteClient.patchNull": "Type.Property.Nullable.CollectionsByte.patchNull", + "com.type.property.nullable.CollectionsByteClient.patchNullWithResponse": "Type.Property.Nullable.CollectionsByte.patchNull", + "com.type.property.nullable.CollectionsModelAsyncClient": "null", + "com.type.property.nullable.CollectionsModelAsyncClient.getNonNull": "Type.Property.Nullable.CollectionsModel.getNonNull", + "com.type.property.nullable.CollectionsModelAsyncClient.getNonNullWithResponse": "Type.Property.Nullable.CollectionsModel.getNonNull", + "com.type.property.nullable.CollectionsModelAsyncClient.getNull": "Type.Property.Nullable.CollectionsModel.getNull", + "com.type.property.nullable.CollectionsModelAsyncClient.getNullWithResponse": "Type.Property.Nullable.CollectionsModel.getNull", + "com.type.property.nullable.CollectionsModelAsyncClient.patchNonNull": "Type.Property.Nullable.CollectionsModel.patchNonNull", + "com.type.property.nullable.CollectionsModelAsyncClient.patchNonNullWithResponse": "Type.Property.Nullable.CollectionsModel.patchNonNull", + "com.type.property.nullable.CollectionsModelAsyncClient.patchNull": "Type.Property.Nullable.CollectionsModel.patchNull", + "com.type.property.nullable.CollectionsModelAsyncClient.patchNullWithResponse": "Type.Property.Nullable.CollectionsModel.patchNull", + "com.type.property.nullable.CollectionsModelClient": "null", + "com.type.property.nullable.CollectionsModelClient.getNonNull": "Type.Property.Nullable.CollectionsModel.getNonNull", + "com.type.property.nullable.CollectionsModelClient.getNonNullWithResponse": "Type.Property.Nullable.CollectionsModel.getNonNull", + "com.type.property.nullable.CollectionsModelClient.getNull": "Type.Property.Nullable.CollectionsModel.getNull", + "com.type.property.nullable.CollectionsModelClient.getNullWithResponse": "Type.Property.Nullable.CollectionsModel.getNull", + "com.type.property.nullable.CollectionsModelClient.patchNonNull": "Type.Property.Nullable.CollectionsModel.patchNonNull", + "com.type.property.nullable.CollectionsModelClient.patchNonNullWithResponse": "Type.Property.Nullable.CollectionsModel.patchNonNull", + "com.type.property.nullable.CollectionsModelClient.patchNull": "Type.Property.Nullable.CollectionsModel.patchNull", + "com.type.property.nullable.CollectionsModelClient.patchNullWithResponse": "Type.Property.Nullable.CollectionsModel.patchNull", + "com.type.property.nullable.CollectionsStringAsyncClient": "null", + "com.type.property.nullable.CollectionsStringAsyncClient.getNonNull": "Type.Property.Nullable.CollectionsString.getNonNull", + "com.type.property.nullable.CollectionsStringAsyncClient.getNonNullWithResponse": "Type.Property.Nullable.CollectionsString.getNonNull", + "com.type.property.nullable.CollectionsStringAsyncClient.getNull": "Type.Property.Nullable.CollectionsString.getNull", + "com.type.property.nullable.CollectionsStringAsyncClient.getNullWithResponse": "Type.Property.Nullable.CollectionsString.getNull", + "com.type.property.nullable.CollectionsStringAsyncClient.patchNonNull": "Type.Property.Nullable.CollectionsString.patchNonNull", + "com.type.property.nullable.CollectionsStringAsyncClient.patchNonNullWithResponse": "Type.Property.Nullable.CollectionsString.patchNonNull", + "com.type.property.nullable.CollectionsStringAsyncClient.patchNull": "Type.Property.Nullable.CollectionsString.patchNull", + "com.type.property.nullable.CollectionsStringAsyncClient.patchNullWithResponse": "Type.Property.Nullable.CollectionsString.patchNull", + "com.type.property.nullable.CollectionsStringClient": "null", + "com.type.property.nullable.CollectionsStringClient.getNonNull": "Type.Property.Nullable.CollectionsString.getNonNull", + "com.type.property.nullable.CollectionsStringClient.getNonNullWithResponse": "Type.Property.Nullable.CollectionsString.getNonNull", + "com.type.property.nullable.CollectionsStringClient.getNull": "Type.Property.Nullable.CollectionsString.getNull", + "com.type.property.nullable.CollectionsStringClient.getNullWithResponse": "Type.Property.Nullable.CollectionsString.getNull", + "com.type.property.nullable.CollectionsStringClient.patchNonNull": "Type.Property.Nullable.CollectionsString.patchNonNull", + "com.type.property.nullable.CollectionsStringClient.patchNonNullWithResponse": "Type.Property.Nullable.CollectionsString.patchNonNull", + "com.type.property.nullable.CollectionsStringClient.patchNull": "Type.Property.Nullable.CollectionsString.patchNull", + "com.type.property.nullable.CollectionsStringClient.patchNullWithResponse": "Type.Property.Nullable.CollectionsString.patchNull", + "com.type.property.nullable.DatetimeOperationAsyncClient": "null", + "com.type.property.nullable.DatetimeOperationAsyncClient.getNonNull": "Type.Property.Nullable.Datetime.getNonNull", + "com.type.property.nullable.DatetimeOperationAsyncClient.getNonNullWithResponse": "Type.Property.Nullable.Datetime.getNonNull", + "com.type.property.nullable.DatetimeOperationAsyncClient.getNull": "Type.Property.Nullable.Datetime.getNull", + "com.type.property.nullable.DatetimeOperationAsyncClient.getNullWithResponse": "Type.Property.Nullable.Datetime.getNull", + "com.type.property.nullable.DatetimeOperationAsyncClient.patchNonNull": "Type.Property.Nullable.Datetime.patchNonNull", + "com.type.property.nullable.DatetimeOperationAsyncClient.patchNonNullWithResponse": "Type.Property.Nullable.Datetime.patchNonNull", + "com.type.property.nullable.DatetimeOperationAsyncClient.patchNull": "Type.Property.Nullable.Datetime.patchNull", + "com.type.property.nullable.DatetimeOperationAsyncClient.patchNullWithResponse": "Type.Property.Nullable.Datetime.patchNull", + "com.type.property.nullable.DatetimeOperationClient": "null", + "com.type.property.nullable.DatetimeOperationClient.getNonNull": "Type.Property.Nullable.Datetime.getNonNull", + "com.type.property.nullable.DatetimeOperationClient.getNonNullWithResponse": "Type.Property.Nullable.Datetime.getNonNull", + "com.type.property.nullable.DatetimeOperationClient.getNull": "Type.Property.Nullable.Datetime.getNull", + "com.type.property.nullable.DatetimeOperationClient.getNullWithResponse": "Type.Property.Nullable.Datetime.getNull", + "com.type.property.nullable.DatetimeOperationClient.patchNonNull": "Type.Property.Nullable.Datetime.patchNonNull", + "com.type.property.nullable.DatetimeOperationClient.patchNonNullWithResponse": "Type.Property.Nullable.Datetime.patchNonNull", + "com.type.property.nullable.DatetimeOperationClient.patchNull": "Type.Property.Nullable.Datetime.patchNull", + "com.type.property.nullable.DatetimeOperationClient.patchNullWithResponse": "Type.Property.Nullable.Datetime.patchNull", + "com.type.property.nullable.DurationOperationAsyncClient": "null", + "com.type.property.nullable.DurationOperationAsyncClient.getNonNull": "Type.Property.Nullable.Duration.getNonNull", + "com.type.property.nullable.DurationOperationAsyncClient.getNonNullWithResponse": "Type.Property.Nullable.Duration.getNonNull", + "com.type.property.nullable.DurationOperationAsyncClient.getNull": "Type.Property.Nullable.Duration.getNull", + "com.type.property.nullable.DurationOperationAsyncClient.getNullWithResponse": "Type.Property.Nullable.Duration.getNull", + "com.type.property.nullable.DurationOperationAsyncClient.patchNonNull": "Type.Property.Nullable.Duration.patchNonNull", + "com.type.property.nullable.DurationOperationAsyncClient.patchNonNullWithResponse": "Type.Property.Nullable.Duration.patchNonNull", + "com.type.property.nullable.DurationOperationAsyncClient.patchNull": "Type.Property.Nullable.Duration.patchNull", + "com.type.property.nullable.DurationOperationAsyncClient.patchNullWithResponse": "Type.Property.Nullable.Duration.patchNull", + "com.type.property.nullable.DurationOperationClient": "null", + "com.type.property.nullable.DurationOperationClient.getNonNull": "Type.Property.Nullable.Duration.getNonNull", + "com.type.property.nullable.DurationOperationClient.getNonNullWithResponse": "Type.Property.Nullable.Duration.getNonNull", + "com.type.property.nullable.DurationOperationClient.getNull": "Type.Property.Nullable.Duration.getNull", + "com.type.property.nullable.DurationOperationClient.getNullWithResponse": "Type.Property.Nullable.Duration.getNull", + "com.type.property.nullable.DurationOperationClient.patchNonNull": "Type.Property.Nullable.Duration.patchNonNull", + "com.type.property.nullable.DurationOperationClient.patchNonNullWithResponse": "Type.Property.Nullable.Duration.patchNonNull", + "com.type.property.nullable.DurationOperationClient.patchNull": "Type.Property.Nullable.Duration.patchNull", + "com.type.property.nullable.DurationOperationClient.patchNullWithResponse": "Type.Property.Nullable.Duration.patchNull", + "com.type.property.nullable.NullableClientBuilder": "Type.Property.Nullable", + "com.type.property.nullable.StringOperationAsyncClient": "null", + "com.type.property.nullable.StringOperationAsyncClient.getNonNull": "Type.Property.Nullable.String.getNonNull", + "com.type.property.nullable.StringOperationAsyncClient.getNonNullWithResponse": "Type.Property.Nullable.String.getNonNull", + "com.type.property.nullable.StringOperationAsyncClient.getNull": "Type.Property.Nullable.String.getNull", + "com.type.property.nullable.StringOperationAsyncClient.getNullWithResponse": "Type.Property.Nullable.String.getNull", + "com.type.property.nullable.StringOperationAsyncClient.patchNonNull": "Type.Property.Nullable.String.patchNonNull", + "com.type.property.nullable.StringOperationAsyncClient.patchNonNullWithResponse": "Type.Property.Nullable.String.patchNonNull", + "com.type.property.nullable.StringOperationAsyncClient.patchNull": "Type.Property.Nullable.String.patchNull", + "com.type.property.nullable.StringOperationAsyncClient.patchNullWithResponse": "Type.Property.Nullable.String.patchNull", + "com.type.property.nullable.StringOperationClient": "null", + "com.type.property.nullable.StringOperationClient.getNonNull": "Type.Property.Nullable.String.getNonNull", + "com.type.property.nullable.StringOperationClient.getNonNullWithResponse": "Type.Property.Nullable.String.getNonNull", + "com.type.property.nullable.StringOperationClient.getNull": "Type.Property.Nullable.String.getNull", + "com.type.property.nullable.StringOperationClient.getNullWithResponse": "Type.Property.Nullable.String.getNull", + "com.type.property.nullable.StringOperationClient.patchNonNull": "Type.Property.Nullable.String.patchNonNull", + "com.type.property.nullable.StringOperationClient.patchNonNullWithResponse": "Type.Property.Nullable.String.patchNonNull", + "com.type.property.nullable.StringOperationClient.patchNull": "Type.Property.Nullable.String.patchNull", + "com.type.property.nullable.StringOperationClient.patchNullWithResponse": "Type.Property.Nullable.String.patchNull", + "com.type.property.nullable.models.BytesProperty": "Type.Property.Nullable.BytesProperty", + "com.type.property.nullable.models.CollectionsByteProperty": "Type.Property.Nullable.CollectionsByteProperty", + "com.type.property.nullable.models.CollectionsModelProperty": "Type.Property.Nullable.CollectionsModelProperty", + "com.type.property.nullable.models.CollectionsStringProperty": "Type.Property.Nullable.CollectionsStringProperty", + "com.type.property.nullable.models.DatetimeProperty": "Type.Property.Nullable.DatetimeProperty", + "com.type.property.nullable.models.DurationProperty": "Type.Property.Nullable.DurationProperty", + "com.type.property.nullable.models.InnerModel": "Type.Property.Nullable.InnerModel", + "com.type.property.nullable.models.StringProperty": "Type.Property.Nullable.StringProperty" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json new file mode 100644 index 000000000..7e62e36cc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json @@ -0,0 +1,317 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.property.optional.BooleanLiteralAsyncClient": "null", + "com.type.property.optional.BooleanLiteralAsyncClient.getAll": "Type.Property.Optional.BooleanLiteral.getAll", + "com.type.property.optional.BooleanLiteralAsyncClient.getAllWithResponse": "Type.Property.Optional.BooleanLiteral.getAll", + "com.type.property.optional.BooleanLiteralAsyncClient.getDefault": "Type.Property.Optional.BooleanLiteral.getDefault", + "com.type.property.optional.BooleanLiteralAsyncClient.getDefaultWithResponse": "Type.Property.Optional.BooleanLiteral.getDefault", + "com.type.property.optional.BooleanLiteralAsyncClient.putAll": "Type.Property.Optional.BooleanLiteral.putAll", + "com.type.property.optional.BooleanLiteralAsyncClient.putAllWithResponse": "Type.Property.Optional.BooleanLiteral.putAll", + "com.type.property.optional.BooleanLiteralAsyncClient.putDefault": "Type.Property.Optional.BooleanLiteral.putDefault", + "com.type.property.optional.BooleanLiteralAsyncClient.putDefaultWithResponse": "Type.Property.Optional.BooleanLiteral.putDefault", + "com.type.property.optional.BooleanLiteralClient": "null", + "com.type.property.optional.BooleanLiteralClient.getAll": "Type.Property.Optional.BooleanLiteral.getAll", + "com.type.property.optional.BooleanLiteralClient.getAllWithResponse": "Type.Property.Optional.BooleanLiteral.getAll", + "com.type.property.optional.BooleanLiteralClient.getDefault": "Type.Property.Optional.BooleanLiteral.getDefault", + "com.type.property.optional.BooleanLiteralClient.getDefaultWithResponse": "Type.Property.Optional.BooleanLiteral.getDefault", + "com.type.property.optional.BooleanLiteralClient.putAll": "Type.Property.Optional.BooleanLiteral.putAll", + "com.type.property.optional.BooleanLiteralClient.putAllWithResponse": "Type.Property.Optional.BooleanLiteral.putAll", + "com.type.property.optional.BooleanLiteralClient.putDefault": "Type.Property.Optional.BooleanLiteral.putDefault", + "com.type.property.optional.BooleanLiteralClient.putDefaultWithResponse": "Type.Property.Optional.BooleanLiteral.putDefault", + "com.type.property.optional.BytesAsyncClient": "null", + "com.type.property.optional.BytesAsyncClient.getAll": "Type.Property.Optional.Bytes.getAll", + "com.type.property.optional.BytesAsyncClient.getAllWithResponse": "Type.Property.Optional.Bytes.getAll", + "com.type.property.optional.BytesAsyncClient.getDefault": "Type.Property.Optional.Bytes.getDefault", + "com.type.property.optional.BytesAsyncClient.getDefaultWithResponse": "Type.Property.Optional.Bytes.getDefault", + "com.type.property.optional.BytesAsyncClient.putAll": "Type.Property.Optional.Bytes.putAll", + "com.type.property.optional.BytesAsyncClient.putAllWithResponse": "Type.Property.Optional.Bytes.putAll", + "com.type.property.optional.BytesAsyncClient.putDefault": "Type.Property.Optional.Bytes.putDefault", + "com.type.property.optional.BytesAsyncClient.putDefaultWithResponse": "Type.Property.Optional.Bytes.putDefault", + "com.type.property.optional.BytesClient": "null", + "com.type.property.optional.BytesClient.getAll": "Type.Property.Optional.Bytes.getAll", + "com.type.property.optional.BytesClient.getAllWithResponse": "Type.Property.Optional.Bytes.getAll", + "com.type.property.optional.BytesClient.getDefault": "Type.Property.Optional.Bytes.getDefault", + "com.type.property.optional.BytesClient.getDefaultWithResponse": "Type.Property.Optional.Bytes.getDefault", + "com.type.property.optional.BytesClient.putAll": "Type.Property.Optional.Bytes.putAll", + "com.type.property.optional.BytesClient.putAllWithResponse": "Type.Property.Optional.Bytes.putAll", + "com.type.property.optional.BytesClient.putDefault": "Type.Property.Optional.Bytes.putDefault", + "com.type.property.optional.BytesClient.putDefaultWithResponse": "Type.Property.Optional.Bytes.putDefault", + "com.type.property.optional.CollectionsByteAsyncClient": "null", + "com.type.property.optional.CollectionsByteAsyncClient.getAll": "Type.Property.Optional.CollectionsByte.getAll", + "com.type.property.optional.CollectionsByteAsyncClient.getAllWithResponse": "Type.Property.Optional.CollectionsByte.getAll", + "com.type.property.optional.CollectionsByteAsyncClient.getDefault": "Type.Property.Optional.CollectionsByte.getDefault", + "com.type.property.optional.CollectionsByteAsyncClient.getDefaultWithResponse": "Type.Property.Optional.CollectionsByte.getDefault", + "com.type.property.optional.CollectionsByteAsyncClient.putAll": "Type.Property.Optional.CollectionsByte.putAll", + "com.type.property.optional.CollectionsByteAsyncClient.putAllWithResponse": "Type.Property.Optional.CollectionsByte.putAll", + "com.type.property.optional.CollectionsByteAsyncClient.putDefault": "Type.Property.Optional.CollectionsByte.putDefault", + "com.type.property.optional.CollectionsByteAsyncClient.putDefaultWithResponse": "Type.Property.Optional.CollectionsByte.putDefault", + "com.type.property.optional.CollectionsByteClient": "null", + "com.type.property.optional.CollectionsByteClient.getAll": "Type.Property.Optional.CollectionsByte.getAll", + "com.type.property.optional.CollectionsByteClient.getAllWithResponse": "Type.Property.Optional.CollectionsByte.getAll", + "com.type.property.optional.CollectionsByteClient.getDefault": "Type.Property.Optional.CollectionsByte.getDefault", + "com.type.property.optional.CollectionsByteClient.getDefaultWithResponse": "Type.Property.Optional.CollectionsByte.getDefault", + "com.type.property.optional.CollectionsByteClient.putAll": "Type.Property.Optional.CollectionsByte.putAll", + "com.type.property.optional.CollectionsByteClient.putAllWithResponse": "Type.Property.Optional.CollectionsByte.putAll", + "com.type.property.optional.CollectionsByteClient.putDefault": "Type.Property.Optional.CollectionsByte.putDefault", + "com.type.property.optional.CollectionsByteClient.putDefaultWithResponse": "Type.Property.Optional.CollectionsByte.putDefault", + "com.type.property.optional.CollectionsModelAsyncClient": "null", + "com.type.property.optional.CollectionsModelAsyncClient.getAll": "Type.Property.Optional.CollectionsModel.getAll", + "com.type.property.optional.CollectionsModelAsyncClient.getAllWithResponse": "Type.Property.Optional.CollectionsModel.getAll", + "com.type.property.optional.CollectionsModelAsyncClient.getDefault": "Type.Property.Optional.CollectionsModel.getDefault", + "com.type.property.optional.CollectionsModelAsyncClient.getDefaultWithResponse": "Type.Property.Optional.CollectionsModel.getDefault", + "com.type.property.optional.CollectionsModelAsyncClient.putAll": "Type.Property.Optional.CollectionsModel.putAll", + "com.type.property.optional.CollectionsModelAsyncClient.putAllWithResponse": "Type.Property.Optional.CollectionsModel.putAll", + "com.type.property.optional.CollectionsModelAsyncClient.putDefault": "Type.Property.Optional.CollectionsModel.putDefault", + "com.type.property.optional.CollectionsModelAsyncClient.putDefaultWithResponse": "Type.Property.Optional.CollectionsModel.putDefault", + "com.type.property.optional.CollectionsModelClient": "null", + "com.type.property.optional.CollectionsModelClient.getAll": "Type.Property.Optional.CollectionsModel.getAll", + "com.type.property.optional.CollectionsModelClient.getAllWithResponse": "Type.Property.Optional.CollectionsModel.getAll", + "com.type.property.optional.CollectionsModelClient.getDefault": "Type.Property.Optional.CollectionsModel.getDefault", + "com.type.property.optional.CollectionsModelClient.getDefaultWithResponse": "Type.Property.Optional.CollectionsModel.getDefault", + "com.type.property.optional.CollectionsModelClient.putAll": "Type.Property.Optional.CollectionsModel.putAll", + "com.type.property.optional.CollectionsModelClient.putAllWithResponse": "Type.Property.Optional.CollectionsModel.putAll", + "com.type.property.optional.CollectionsModelClient.putDefault": "Type.Property.Optional.CollectionsModel.putDefault", + "com.type.property.optional.CollectionsModelClient.putDefaultWithResponse": "Type.Property.Optional.CollectionsModel.putDefault", + "com.type.property.optional.DatetimeOperationAsyncClient": "null", + "com.type.property.optional.DatetimeOperationAsyncClient.getAll": "Type.Property.Optional.Datetime.getAll", + "com.type.property.optional.DatetimeOperationAsyncClient.getAllWithResponse": "Type.Property.Optional.Datetime.getAll", + "com.type.property.optional.DatetimeOperationAsyncClient.getDefault": "Type.Property.Optional.Datetime.getDefault", + "com.type.property.optional.DatetimeOperationAsyncClient.getDefaultWithResponse": "Type.Property.Optional.Datetime.getDefault", + "com.type.property.optional.DatetimeOperationAsyncClient.putAll": "Type.Property.Optional.Datetime.putAll", + "com.type.property.optional.DatetimeOperationAsyncClient.putAllWithResponse": "Type.Property.Optional.Datetime.putAll", + "com.type.property.optional.DatetimeOperationAsyncClient.putDefault": "Type.Property.Optional.Datetime.putDefault", + "com.type.property.optional.DatetimeOperationAsyncClient.putDefaultWithResponse": "Type.Property.Optional.Datetime.putDefault", + "com.type.property.optional.DatetimeOperationClient": "null", + "com.type.property.optional.DatetimeOperationClient.getAll": "Type.Property.Optional.Datetime.getAll", + "com.type.property.optional.DatetimeOperationClient.getAllWithResponse": "Type.Property.Optional.Datetime.getAll", + "com.type.property.optional.DatetimeOperationClient.getDefault": "Type.Property.Optional.Datetime.getDefault", + "com.type.property.optional.DatetimeOperationClient.getDefaultWithResponse": "Type.Property.Optional.Datetime.getDefault", + "com.type.property.optional.DatetimeOperationClient.putAll": "Type.Property.Optional.Datetime.putAll", + "com.type.property.optional.DatetimeOperationClient.putAllWithResponse": "Type.Property.Optional.Datetime.putAll", + "com.type.property.optional.DatetimeOperationClient.putDefault": "Type.Property.Optional.Datetime.putDefault", + "com.type.property.optional.DatetimeOperationClient.putDefaultWithResponse": "Type.Property.Optional.Datetime.putDefault", + "com.type.property.optional.DurationOperationAsyncClient": "null", + "com.type.property.optional.DurationOperationAsyncClient.getAll": "Type.Property.Optional.Duration.getAll", + "com.type.property.optional.DurationOperationAsyncClient.getAllWithResponse": "Type.Property.Optional.Duration.getAll", + "com.type.property.optional.DurationOperationAsyncClient.getDefault": "Type.Property.Optional.Duration.getDefault", + "com.type.property.optional.DurationOperationAsyncClient.getDefaultWithResponse": "Type.Property.Optional.Duration.getDefault", + "com.type.property.optional.DurationOperationAsyncClient.putAll": "Type.Property.Optional.Duration.putAll", + "com.type.property.optional.DurationOperationAsyncClient.putAllWithResponse": "Type.Property.Optional.Duration.putAll", + "com.type.property.optional.DurationOperationAsyncClient.putDefault": "Type.Property.Optional.Duration.putDefault", + "com.type.property.optional.DurationOperationAsyncClient.putDefaultWithResponse": "Type.Property.Optional.Duration.putDefault", + "com.type.property.optional.DurationOperationClient": "null", + "com.type.property.optional.DurationOperationClient.getAll": "Type.Property.Optional.Duration.getAll", + "com.type.property.optional.DurationOperationClient.getAllWithResponse": "Type.Property.Optional.Duration.getAll", + "com.type.property.optional.DurationOperationClient.getDefault": "Type.Property.Optional.Duration.getDefault", + "com.type.property.optional.DurationOperationClient.getDefaultWithResponse": "Type.Property.Optional.Duration.getDefault", + "com.type.property.optional.DurationOperationClient.putAll": "Type.Property.Optional.Duration.putAll", + "com.type.property.optional.DurationOperationClient.putAllWithResponse": "Type.Property.Optional.Duration.putAll", + "com.type.property.optional.DurationOperationClient.putDefault": "Type.Property.Optional.Duration.putDefault", + "com.type.property.optional.DurationOperationClient.putDefaultWithResponse": "Type.Property.Optional.Duration.putDefault", + "com.type.property.optional.FloatLiteralAsyncClient": "null", + "com.type.property.optional.FloatLiteralAsyncClient.getAll": "Type.Property.Optional.FloatLiteral.getAll", + "com.type.property.optional.FloatLiteralAsyncClient.getAllWithResponse": "Type.Property.Optional.FloatLiteral.getAll", + "com.type.property.optional.FloatLiteralAsyncClient.getDefault": "Type.Property.Optional.FloatLiteral.getDefault", + "com.type.property.optional.FloatLiteralAsyncClient.getDefaultWithResponse": "Type.Property.Optional.FloatLiteral.getDefault", + "com.type.property.optional.FloatLiteralAsyncClient.putAll": "Type.Property.Optional.FloatLiteral.putAll", + "com.type.property.optional.FloatLiteralAsyncClient.putAllWithResponse": "Type.Property.Optional.FloatLiteral.putAll", + "com.type.property.optional.FloatLiteralAsyncClient.putDefault": "Type.Property.Optional.FloatLiteral.putDefault", + "com.type.property.optional.FloatLiteralAsyncClient.putDefaultWithResponse": "Type.Property.Optional.FloatLiteral.putDefault", + "com.type.property.optional.FloatLiteralClient": "null", + "com.type.property.optional.FloatLiteralClient.getAll": "Type.Property.Optional.FloatLiteral.getAll", + "com.type.property.optional.FloatLiteralClient.getAllWithResponse": "Type.Property.Optional.FloatLiteral.getAll", + "com.type.property.optional.FloatLiteralClient.getDefault": "Type.Property.Optional.FloatLiteral.getDefault", + "com.type.property.optional.FloatLiteralClient.getDefaultWithResponse": "Type.Property.Optional.FloatLiteral.getDefault", + "com.type.property.optional.FloatLiteralClient.putAll": "Type.Property.Optional.FloatLiteral.putAll", + "com.type.property.optional.FloatLiteralClient.putAllWithResponse": "Type.Property.Optional.FloatLiteral.putAll", + "com.type.property.optional.FloatLiteralClient.putDefault": "Type.Property.Optional.FloatLiteral.putDefault", + "com.type.property.optional.FloatLiteralClient.putDefaultWithResponse": "Type.Property.Optional.FloatLiteral.putDefault", + "com.type.property.optional.IntLiteralAsyncClient": "null", + "com.type.property.optional.IntLiteralAsyncClient.getAll": "Type.Property.Optional.IntLiteral.getAll", + "com.type.property.optional.IntLiteralAsyncClient.getAllWithResponse": "Type.Property.Optional.IntLiteral.getAll", + "com.type.property.optional.IntLiteralAsyncClient.getDefault": "Type.Property.Optional.IntLiteral.getDefault", + "com.type.property.optional.IntLiteralAsyncClient.getDefaultWithResponse": "Type.Property.Optional.IntLiteral.getDefault", + "com.type.property.optional.IntLiteralAsyncClient.putAll": "Type.Property.Optional.IntLiteral.putAll", + "com.type.property.optional.IntLiteralAsyncClient.putAllWithResponse": "Type.Property.Optional.IntLiteral.putAll", + "com.type.property.optional.IntLiteralAsyncClient.putDefault": "Type.Property.Optional.IntLiteral.putDefault", + "com.type.property.optional.IntLiteralAsyncClient.putDefaultWithResponse": "Type.Property.Optional.IntLiteral.putDefault", + "com.type.property.optional.IntLiteralClient": "null", + "com.type.property.optional.IntLiteralClient.getAll": "Type.Property.Optional.IntLiteral.getAll", + "com.type.property.optional.IntLiteralClient.getAllWithResponse": "Type.Property.Optional.IntLiteral.getAll", + "com.type.property.optional.IntLiteralClient.getDefault": "Type.Property.Optional.IntLiteral.getDefault", + "com.type.property.optional.IntLiteralClient.getDefaultWithResponse": "Type.Property.Optional.IntLiteral.getDefault", + "com.type.property.optional.IntLiteralClient.putAll": "Type.Property.Optional.IntLiteral.putAll", + "com.type.property.optional.IntLiteralClient.putAllWithResponse": "Type.Property.Optional.IntLiteral.putAll", + "com.type.property.optional.IntLiteralClient.putDefault": "Type.Property.Optional.IntLiteral.putDefault", + "com.type.property.optional.IntLiteralClient.putDefaultWithResponse": "Type.Property.Optional.IntLiteral.putDefault", + "com.type.property.optional.OptionalClientBuilder": "Type.Property.Optional", + "com.type.property.optional.PlainDateAsyncClient": "null", + "com.type.property.optional.PlainDateAsyncClient.getAll": "Type.Property.Optional.PlainDate.getAll", + "com.type.property.optional.PlainDateAsyncClient.getAllWithResponse": "Type.Property.Optional.PlainDate.getAll", + "com.type.property.optional.PlainDateAsyncClient.getDefault": "Type.Property.Optional.PlainDate.getDefault", + "com.type.property.optional.PlainDateAsyncClient.getDefaultWithResponse": "Type.Property.Optional.PlainDate.getDefault", + "com.type.property.optional.PlainDateAsyncClient.putAll": "Type.Property.Optional.PlainDate.putAll", + "com.type.property.optional.PlainDateAsyncClient.putAllWithResponse": "Type.Property.Optional.PlainDate.putAll", + "com.type.property.optional.PlainDateAsyncClient.putDefault": "Type.Property.Optional.PlainDate.putDefault", + "com.type.property.optional.PlainDateAsyncClient.putDefaultWithResponse": "Type.Property.Optional.PlainDate.putDefault", + "com.type.property.optional.PlainDateClient": "null", + "com.type.property.optional.PlainDateClient.getAll": "Type.Property.Optional.PlainDate.getAll", + "com.type.property.optional.PlainDateClient.getAllWithResponse": "Type.Property.Optional.PlainDate.getAll", + "com.type.property.optional.PlainDateClient.getDefault": "Type.Property.Optional.PlainDate.getDefault", + "com.type.property.optional.PlainDateClient.getDefaultWithResponse": "Type.Property.Optional.PlainDate.getDefault", + "com.type.property.optional.PlainDateClient.putAll": "Type.Property.Optional.PlainDate.putAll", + "com.type.property.optional.PlainDateClient.putAllWithResponse": "Type.Property.Optional.PlainDate.putAll", + "com.type.property.optional.PlainDateClient.putDefault": "Type.Property.Optional.PlainDate.putDefault", + "com.type.property.optional.PlainDateClient.putDefaultWithResponse": "Type.Property.Optional.PlainDate.putDefault", + "com.type.property.optional.PlainTimeAsyncClient": "null", + "com.type.property.optional.PlainTimeAsyncClient.getAll": "Type.Property.Optional.PlainTime.getAll", + "com.type.property.optional.PlainTimeAsyncClient.getAllWithResponse": "Type.Property.Optional.PlainTime.getAll", + "com.type.property.optional.PlainTimeAsyncClient.getDefault": "Type.Property.Optional.PlainTime.getDefault", + "com.type.property.optional.PlainTimeAsyncClient.getDefaultWithResponse": "Type.Property.Optional.PlainTime.getDefault", + "com.type.property.optional.PlainTimeAsyncClient.putAll": "Type.Property.Optional.PlainTime.putAll", + "com.type.property.optional.PlainTimeAsyncClient.putAllWithResponse": "Type.Property.Optional.PlainTime.putAll", + "com.type.property.optional.PlainTimeAsyncClient.putDefault": "Type.Property.Optional.PlainTime.putDefault", + "com.type.property.optional.PlainTimeAsyncClient.putDefaultWithResponse": "Type.Property.Optional.PlainTime.putDefault", + "com.type.property.optional.PlainTimeClient": "null", + "com.type.property.optional.PlainTimeClient.getAll": "Type.Property.Optional.PlainTime.getAll", + "com.type.property.optional.PlainTimeClient.getAllWithResponse": "Type.Property.Optional.PlainTime.getAll", + "com.type.property.optional.PlainTimeClient.getDefault": "Type.Property.Optional.PlainTime.getDefault", + "com.type.property.optional.PlainTimeClient.getDefaultWithResponse": "Type.Property.Optional.PlainTime.getDefault", + "com.type.property.optional.PlainTimeClient.putAll": "Type.Property.Optional.PlainTime.putAll", + "com.type.property.optional.PlainTimeClient.putAllWithResponse": "Type.Property.Optional.PlainTime.putAll", + "com.type.property.optional.PlainTimeClient.putDefault": "Type.Property.Optional.PlainTime.putDefault", + "com.type.property.optional.PlainTimeClient.putDefaultWithResponse": "Type.Property.Optional.PlainTime.putDefault", + "com.type.property.optional.RequiredAndOptionalAsyncClient": "null", + "com.type.property.optional.RequiredAndOptionalAsyncClient.getAll": "Type.Property.Optional.RequiredAndOptional.getAll", + "com.type.property.optional.RequiredAndOptionalAsyncClient.getAllWithResponse": "Type.Property.Optional.RequiredAndOptional.getAll", + "com.type.property.optional.RequiredAndOptionalAsyncClient.getRequiredOnly": "Type.Property.Optional.RequiredAndOptional.getRequiredOnly", + "com.type.property.optional.RequiredAndOptionalAsyncClient.getRequiredOnlyWithResponse": "Type.Property.Optional.RequiredAndOptional.getRequiredOnly", + "com.type.property.optional.RequiredAndOptionalAsyncClient.putAll": "Type.Property.Optional.RequiredAndOptional.putAll", + "com.type.property.optional.RequiredAndOptionalAsyncClient.putAllWithResponse": "Type.Property.Optional.RequiredAndOptional.putAll", + "com.type.property.optional.RequiredAndOptionalAsyncClient.putRequiredOnly": "Type.Property.Optional.RequiredAndOptional.putRequiredOnly", + "com.type.property.optional.RequiredAndOptionalAsyncClient.putRequiredOnlyWithResponse": "Type.Property.Optional.RequiredAndOptional.putRequiredOnly", + "com.type.property.optional.RequiredAndOptionalClient": "null", + "com.type.property.optional.RequiredAndOptionalClient.getAll": "Type.Property.Optional.RequiredAndOptional.getAll", + "com.type.property.optional.RequiredAndOptionalClient.getAllWithResponse": "Type.Property.Optional.RequiredAndOptional.getAll", + "com.type.property.optional.RequiredAndOptionalClient.getRequiredOnly": "Type.Property.Optional.RequiredAndOptional.getRequiredOnly", + "com.type.property.optional.RequiredAndOptionalClient.getRequiredOnlyWithResponse": "Type.Property.Optional.RequiredAndOptional.getRequiredOnly", + "com.type.property.optional.RequiredAndOptionalClient.putAll": "Type.Property.Optional.RequiredAndOptional.putAll", + "com.type.property.optional.RequiredAndOptionalClient.putAllWithResponse": "Type.Property.Optional.RequiredAndOptional.putAll", + "com.type.property.optional.RequiredAndOptionalClient.putRequiredOnly": "Type.Property.Optional.RequiredAndOptional.putRequiredOnly", + "com.type.property.optional.RequiredAndOptionalClient.putRequiredOnlyWithResponse": "Type.Property.Optional.RequiredAndOptional.putRequiredOnly", + "com.type.property.optional.StringLiteralAsyncClient": "null", + "com.type.property.optional.StringLiteralAsyncClient.getAll": "Type.Property.Optional.StringLiteral.getAll", + "com.type.property.optional.StringLiteralAsyncClient.getAllWithResponse": "Type.Property.Optional.StringLiteral.getAll", + "com.type.property.optional.StringLiteralAsyncClient.getDefault": "Type.Property.Optional.StringLiteral.getDefault", + "com.type.property.optional.StringLiteralAsyncClient.getDefaultWithResponse": "Type.Property.Optional.StringLiteral.getDefault", + "com.type.property.optional.StringLiteralAsyncClient.putAll": "Type.Property.Optional.StringLiteral.putAll", + "com.type.property.optional.StringLiteralAsyncClient.putAllWithResponse": "Type.Property.Optional.StringLiteral.putAll", + "com.type.property.optional.StringLiteralAsyncClient.putDefault": "Type.Property.Optional.StringLiteral.putDefault", + "com.type.property.optional.StringLiteralAsyncClient.putDefaultWithResponse": "Type.Property.Optional.StringLiteral.putDefault", + "com.type.property.optional.StringLiteralClient": "null", + "com.type.property.optional.StringLiteralClient.getAll": "Type.Property.Optional.StringLiteral.getAll", + "com.type.property.optional.StringLiteralClient.getAllWithResponse": "Type.Property.Optional.StringLiteral.getAll", + "com.type.property.optional.StringLiteralClient.getDefault": "Type.Property.Optional.StringLiteral.getDefault", + "com.type.property.optional.StringLiteralClient.getDefaultWithResponse": "Type.Property.Optional.StringLiteral.getDefault", + "com.type.property.optional.StringLiteralClient.putAll": "Type.Property.Optional.StringLiteral.putAll", + "com.type.property.optional.StringLiteralClient.putAllWithResponse": "Type.Property.Optional.StringLiteral.putAll", + "com.type.property.optional.StringLiteralClient.putDefault": "Type.Property.Optional.StringLiteral.putDefault", + "com.type.property.optional.StringLiteralClient.putDefaultWithResponse": "Type.Property.Optional.StringLiteral.putDefault", + "com.type.property.optional.StringOperationAsyncClient": "null", + "com.type.property.optional.StringOperationAsyncClient.getAll": "Type.Property.Optional.String.getAll", + "com.type.property.optional.StringOperationAsyncClient.getAllWithResponse": "Type.Property.Optional.String.getAll", + "com.type.property.optional.StringOperationAsyncClient.getDefault": "Type.Property.Optional.String.getDefault", + "com.type.property.optional.StringOperationAsyncClient.getDefaultWithResponse": "Type.Property.Optional.String.getDefault", + "com.type.property.optional.StringOperationAsyncClient.putAll": "Type.Property.Optional.String.putAll", + "com.type.property.optional.StringOperationAsyncClient.putAllWithResponse": "Type.Property.Optional.String.putAll", + "com.type.property.optional.StringOperationAsyncClient.putDefault": "Type.Property.Optional.String.putDefault", + "com.type.property.optional.StringOperationAsyncClient.putDefaultWithResponse": "Type.Property.Optional.String.putDefault", + "com.type.property.optional.StringOperationClient": "null", + "com.type.property.optional.StringOperationClient.getAll": "Type.Property.Optional.String.getAll", + "com.type.property.optional.StringOperationClient.getAllWithResponse": "Type.Property.Optional.String.getAll", + "com.type.property.optional.StringOperationClient.getDefault": "Type.Property.Optional.String.getDefault", + "com.type.property.optional.StringOperationClient.getDefaultWithResponse": "Type.Property.Optional.String.getDefault", + "com.type.property.optional.StringOperationClient.putAll": "Type.Property.Optional.String.putAll", + "com.type.property.optional.StringOperationClient.putAllWithResponse": "Type.Property.Optional.String.putAll", + "com.type.property.optional.StringOperationClient.putDefault": "Type.Property.Optional.String.putDefault", + "com.type.property.optional.StringOperationClient.putDefaultWithResponse": "Type.Property.Optional.String.putDefault", + "com.type.property.optional.UnionFloatLiteralAsyncClient": "null", + "com.type.property.optional.UnionFloatLiteralAsyncClient.getAll": "Type.Property.Optional.UnionFloatLiteral.getAll", + "com.type.property.optional.UnionFloatLiteralAsyncClient.getAllWithResponse": "Type.Property.Optional.UnionFloatLiteral.getAll", + "com.type.property.optional.UnionFloatLiteralAsyncClient.getDefault": "Type.Property.Optional.UnionFloatLiteral.getDefault", + "com.type.property.optional.UnionFloatLiteralAsyncClient.getDefaultWithResponse": "Type.Property.Optional.UnionFloatLiteral.getDefault", + "com.type.property.optional.UnionFloatLiteralAsyncClient.putAll": "Type.Property.Optional.UnionFloatLiteral.putAll", + "com.type.property.optional.UnionFloatLiteralAsyncClient.putAllWithResponse": "Type.Property.Optional.UnionFloatLiteral.putAll", + "com.type.property.optional.UnionFloatLiteralAsyncClient.putDefault": "Type.Property.Optional.UnionFloatLiteral.putDefault", + "com.type.property.optional.UnionFloatLiteralAsyncClient.putDefaultWithResponse": "Type.Property.Optional.UnionFloatLiteral.putDefault", + "com.type.property.optional.UnionFloatLiteralClient": "null", + "com.type.property.optional.UnionFloatLiteralClient.getAll": "Type.Property.Optional.UnionFloatLiteral.getAll", + "com.type.property.optional.UnionFloatLiteralClient.getAllWithResponse": "Type.Property.Optional.UnionFloatLiteral.getAll", + "com.type.property.optional.UnionFloatLiteralClient.getDefault": "Type.Property.Optional.UnionFloatLiteral.getDefault", + "com.type.property.optional.UnionFloatLiteralClient.getDefaultWithResponse": "Type.Property.Optional.UnionFloatLiteral.getDefault", + "com.type.property.optional.UnionFloatLiteralClient.putAll": "Type.Property.Optional.UnionFloatLiteral.putAll", + "com.type.property.optional.UnionFloatLiteralClient.putAllWithResponse": "Type.Property.Optional.UnionFloatLiteral.putAll", + "com.type.property.optional.UnionFloatLiteralClient.putDefault": "Type.Property.Optional.UnionFloatLiteral.putDefault", + "com.type.property.optional.UnionFloatLiteralClient.putDefaultWithResponse": "Type.Property.Optional.UnionFloatLiteral.putDefault", + "com.type.property.optional.UnionIntLiteralAsyncClient": "null", + "com.type.property.optional.UnionIntLiteralAsyncClient.getAll": "Type.Property.Optional.UnionIntLiteral.getAll", + "com.type.property.optional.UnionIntLiteralAsyncClient.getAllWithResponse": "Type.Property.Optional.UnionIntLiteral.getAll", + "com.type.property.optional.UnionIntLiteralAsyncClient.getDefault": "Type.Property.Optional.UnionIntLiteral.getDefault", + "com.type.property.optional.UnionIntLiteralAsyncClient.getDefaultWithResponse": "Type.Property.Optional.UnionIntLiteral.getDefault", + "com.type.property.optional.UnionIntLiteralAsyncClient.putAll": "Type.Property.Optional.UnionIntLiteral.putAll", + "com.type.property.optional.UnionIntLiteralAsyncClient.putAllWithResponse": "Type.Property.Optional.UnionIntLiteral.putAll", + "com.type.property.optional.UnionIntLiteralAsyncClient.putDefault": "Type.Property.Optional.UnionIntLiteral.putDefault", + "com.type.property.optional.UnionIntLiteralAsyncClient.putDefaultWithResponse": "Type.Property.Optional.UnionIntLiteral.putDefault", + "com.type.property.optional.UnionIntLiteralClient": "null", + "com.type.property.optional.UnionIntLiteralClient.getAll": "Type.Property.Optional.UnionIntLiteral.getAll", + "com.type.property.optional.UnionIntLiteralClient.getAllWithResponse": "Type.Property.Optional.UnionIntLiteral.getAll", + "com.type.property.optional.UnionIntLiteralClient.getDefault": "Type.Property.Optional.UnionIntLiteral.getDefault", + "com.type.property.optional.UnionIntLiteralClient.getDefaultWithResponse": "Type.Property.Optional.UnionIntLiteral.getDefault", + "com.type.property.optional.UnionIntLiteralClient.putAll": "Type.Property.Optional.UnionIntLiteral.putAll", + "com.type.property.optional.UnionIntLiteralClient.putAllWithResponse": "Type.Property.Optional.UnionIntLiteral.putAll", + "com.type.property.optional.UnionIntLiteralClient.putDefault": "Type.Property.Optional.UnionIntLiteral.putDefault", + "com.type.property.optional.UnionIntLiteralClient.putDefaultWithResponse": "Type.Property.Optional.UnionIntLiteral.putDefault", + "com.type.property.optional.UnionStringLiteralAsyncClient": "null", + "com.type.property.optional.UnionStringLiteralAsyncClient.getAll": "Type.Property.Optional.UnionStringLiteral.getAll", + "com.type.property.optional.UnionStringLiteralAsyncClient.getAllWithResponse": "Type.Property.Optional.UnionStringLiteral.getAll", + "com.type.property.optional.UnionStringLiteralAsyncClient.getDefault": "Type.Property.Optional.UnionStringLiteral.getDefault", + "com.type.property.optional.UnionStringLiteralAsyncClient.getDefaultWithResponse": "Type.Property.Optional.UnionStringLiteral.getDefault", + "com.type.property.optional.UnionStringLiteralAsyncClient.putAll": "Type.Property.Optional.UnionStringLiteral.putAll", + "com.type.property.optional.UnionStringLiteralAsyncClient.putAllWithResponse": "Type.Property.Optional.UnionStringLiteral.putAll", + "com.type.property.optional.UnionStringLiteralAsyncClient.putDefault": "Type.Property.Optional.UnionStringLiteral.putDefault", + "com.type.property.optional.UnionStringLiteralAsyncClient.putDefaultWithResponse": "Type.Property.Optional.UnionStringLiteral.putDefault", + "com.type.property.optional.UnionStringLiteralClient": "null", + "com.type.property.optional.UnionStringLiteralClient.getAll": "Type.Property.Optional.UnionStringLiteral.getAll", + "com.type.property.optional.UnionStringLiteralClient.getAllWithResponse": "Type.Property.Optional.UnionStringLiteral.getAll", + "com.type.property.optional.UnionStringLiteralClient.getDefault": "Type.Property.Optional.UnionStringLiteral.getDefault", + "com.type.property.optional.UnionStringLiteralClient.getDefaultWithResponse": "Type.Property.Optional.UnionStringLiteral.getDefault", + "com.type.property.optional.UnionStringLiteralClient.putAll": "Type.Property.Optional.UnionStringLiteral.putAll", + "com.type.property.optional.UnionStringLiteralClient.putAllWithResponse": "Type.Property.Optional.UnionStringLiteral.putAll", + "com.type.property.optional.UnionStringLiteralClient.putDefault": "Type.Property.Optional.UnionStringLiteral.putDefault", + "com.type.property.optional.UnionStringLiteralClient.putDefaultWithResponse": "Type.Property.Optional.UnionStringLiteral.putDefault", + "com.type.property.optional.models.BooleanLiteralProperty": "Type.Property.Optional.BooleanLiteralProperty", + "com.type.property.optional.models.BooleanLiteralPropertyProperty": "null", + "com.type.property.optional.models.BytesProperty": "Type.Property.Optional.BytesProperty", + "com.type.property.optional.models.CollectionsByteProperty": "Type.Property.Optional.CollectionsByteProperty", + "com.type.property.optional.models.CollectionsModelProperty": "Type.Property.Optional.CollectionsModelProperty", + "com.type.property.optional.models.DatetimeProperty": "Type.Property.Optional.DatetimeProperty", + "com.type.property.optional.models.DurationProperty": "Type.Property.Optional.DurationProperty", + "com.type.property.optional.models.FloatLiteralProperty": "Type.Property.Optional.FloatLiteralProperty", + "com.type.property.optional.models.FloatLiteralPropertyProperty": "null", + "com.type.property.optional.models.IntLiteralProperty": "Type.Property.Optional.IntLiteralProperty", + "com.type.property.optional.models.IntLiteralPropertyProperty": "null", + "com.type.property.optional.models.PlainDateProperty": "Type.Property.Optional.PlainDateProperty", + "com.type.property.optional.models.PlainTimeProperty": "Type.Property.Optional.PlainTimeProperty", + "com.type.property.optional.models.RequiredAndOptionalProperty": "Type.Property.Optional.RequiredAndOptionalProperty", + "com.type.property.optional.models.StringLiteralProperty": "Type.Property.Optional.StringLiteralProperty", + "com.type.property.optional.models.StringLiteralPropertyProperty": "null", + "com.type.property.optional.models.StringProperty": "Type.Property.Optional.StringProperty", + "com.type.property.optional.models.UnionFloatLiteralProperty": "Type.Property.Optional.UnionFloatLiteralProperty", + "com.type.property.optional.models.UnionFloatLiteralPropertyProperty": "UnionFloatLiteralProperty.property.anonymous", + "com.type.property.optional.models.UnionIntLiteralProperty": "Type.Property.Optional.UnionIntLiteralProperty", + "com.type.property.optional.models.UnionIntLiteralPropertyProperty": "UnionIntLiteralProperty.property.anonymous", + "com.type.property.optional.models.UnionStringLiteralProperty": "Type.Property.Optional.UnionStringLiteralProperty", + "com.type.property.optional.models.UnionStringLiteralPropertyProperty": "UnionStringLiteralProperty.property.anonymous" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-valuetypes_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-valuetypes_apiview_properties.json new file mode 100644 index 000000000..1f3e61179 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-property-valuetypes_apiview_properties.json @@ -0,0 +1,332 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.property.valuetypes.BooleanLiteralAsyncClient": "null", + "com.type.property.valuetypes.BooleanLiteralAsyncClient.get": "Type.Property.ValueTypes.BooleanLiteral.get", + "com.type.property.valuetypes.BooleanLiteralAsyncClient.getWithResponse": "Type.Property.ValueTypes.BooleanLiteral.get", + "com.type.property.valuetypes.BooleanLiteralAsyncClient.put": "Type.Property.ValueTypes.BooleanLiteral.put", + "com.type.property.valuetypes.BooleanLiteralAsyncClient.putWithResponse": "Type.Property.ValueTypes.BooleanLiteral.put", + "com.type.property.valuetypes.BooleanLiteralClient": "null", + "com.type.property.valuetypes.BooleanLiteralClient.get": "Type.Property.ValueTypes.BooleanLiteral.get", + "com.type.property.valuetypes.BooleanLiteralClient.getWithResponse": "Type.Property.ValueTypes.BooleanLiteral.get", + "com.type.property.valuetypes.BooleanLiteralClient.put": "Type.Property.ValueTypes.BooleanLiteral.put", + "com.type.property.valuetypes.BooleanLiteralClient.putWithResponse": "Type.Property.ValueTypes.BooleanLiteral.put", + "com.type.property.valuetypes.BooleanOperationAsyncClient": "null", + "com.type.property.valuetypes.BooleanOperationAsyncClient.get": "Type.Property.ValueTypes.Boolean.get", + "com.type.property.valuetypes.BooleanOperationAsyncClient.getWithResponse": "Type.Property.ValueTypes.Boolean.get", + "com.type.property.valuetypes.BooleanOperationAsyncClient.put": "Type.Property.ValueTypes.Boolean.put", + "com.type.property.valuetypes.BooleanOperationAsyncClient.putWithResponse": "Type.Property.ValueTypes.Boolean.put", + "com.type.property.valuetypes.BooleanOperationClient": "null", + "com.type.property.valuetypes.BooleanOperationClient.get": "Type.Property.ValueTypes.Boolean.get", + "com.type.property.valuetypes.BooleanOperationClient.getWithResponse": "Type.Property.ValueTypes.Boolean.get", + "com.type.property.valuetypes.BooleanOperationClient.put": "Type.Property.ValueTypes.Boolean.put", + "com.type.property.valuetypes.BooleanOperationClient.putWithResponse": "Type.Property.ValueTypes.Boolean.put", + "com.type.property.valuetypes.BytesAsyncClient": "null", + "com.type.property.valuetypes.BytesAsyncClient.get": "Type.Property.ValueTypes.Bytes.get", + "com.type.property.valuetypes.BytesAsyncClient.getWithResponse": "Type.Property.ValueTypes.Bytes.get", + "com.type.property.valuetypes.BytesAsyncClient.put": "Type.Property.ValueTypes.Bytes.put", + "com.type.property.valuetypes.BytesAsyncClient.putWithResponse": "Type.Property.ValueTypes.Bytes.put", + "com.type.property.valuetypes.BytesClient": "null", + "com.type.property.valuetypes.BytesClient.get": "Type.Property.ValueTypes.Bytes.get", + "com.type.property.valuetypes.BytesClient.getWithResponse": "Type.Property.ValueTypes.Bytes.get", + "com.type.property.valuetypes.BytesClient.put": "Type.Property.ValueTypes.Bytes.put", + "com.type.property.valuetypes.BytesClient.putWithResponse": "Type.Property.ValueTypes.Bytes.put", + "com.type.property.valuetypes.CollectionsIntAsyncClient": "null", + "com.type.property.valuetypes.CollectionsIntAsyncClient.get": "Type.Property.ValueTypes.CollectionsInt.get", + "com.type.property.valuetypes.CollectionsIntAsyncClient.getWithResponse": "Type.Property.ValueTypes.CollectionsInt.get", + "com.type.property.valuetypes.CollectionsIntAsyncClient.put": "Type.Property.ValueTypes.CollectionsInt.put", + "com.type.property.valuetypes.CollectionsIntAsyncClient.putWithResponse": "Type.Property.ValueTypes.CollectionsInt.put", + "com.type.property.valuetypes.CollectionsIntClient": "null", + "com.type.property.valuetypes.CollectionsIntClient.get": "Type.Property.ValueTypes.CollectionsInt.get", + "com.type.property.valuetypes.CollectionsIntClient.getWithResponse": "Type.Property.ValueTypes.CollectionsInt.get", + "com.type.property.valuetypes.CollectionsIntClient.put": "Type.Property.ValueTypes.CollectionsInt.put", + "com.type.property.valuetypes.CollectionsIntClient.putWithResponse": "Type.Property.ValueTypes.CollectionsInt.put", + "com.type.property.valuetypes.CollectionsModelAsyncClient": "null", + "com.type.property.valuetypes.CollectionsModelAsyncClient.get": "Type.Property.ValueTypes.CollectionsModel.get", + "com.type.property.valuetypes.CollectionsModelAsyncClient.getWithResponse": "Type.Property.ValueTypes.CollectionsModel.get", + "com.type.property.valuetypes.CollectionsModelAsyncClient.put": "Type.Property.ValueTypes.CollectionsModel.put", + "com.type.property.valuetypes.CollectionsModelAsyncClient.putWithResponse": "Type.Property.ValueTypes.CollectionsModel.put", + "com.type.property.valuetypes.CollectionsModelClient": "null", + "com.type.property.valuetypes.CollectionsModelClient.get": "Type.Property.ValueTypes.CollectionsModel.get", + "com.type.property.valuetypes.CollectionsModelClient.getWithResponse": "Type.Property.ValueTypes.CollectionsModel.get", + "com.type.property.valuetypes.CollectionsModelClient.put": "Type.Property.ValueTypes.CollectionsModel.put", + "com.type.property.valuetypes.CollectionsModelClient.putWithResponse": "Type.Property.ValueTypes.CollectionsModel.put", + "com.type.property.valuetypes.CollectionsStringAsyncClient": "null", + "com.type.property.valuetypes.CollectionsStringAsyncClient.get": "Type.Property.ValueTypes.CollectionsString.get", + "com.type.property.valuetypes.CollectionsStringAsyncClient.getWithResponse": "Type.Property.ValueTypes.CollectionsString.get", + "com.type.property.valuetypes.CollectionsStringAsyncClient.put": "Type.Property.ValueTypes.CollectionsString.put", + "com.type.property.valuetypes.CollectionsStringAsyncClient.putWithResponse": "Type.Property.ValueTypes.CollectionsString.put", + "com.type.property.valuetypes.CollectionsStringClient": "null", + "com.type.property.valuetypes.CollectionsStringClient.get": "Type.Property.ValueTypes.CollectionsString.get", + "com.type.property.valuetypes.CollectionsStringClient.getWithResponse": "Type.Property.ValueTypes.CollectionsString.get", + "com.type.property.valuetypes.CollectionsStringClient.put": "Type.Property.ValueTypes.CollectionsString.put", + "com.type.property.valuetypes.CollectionsStringClient.putWithResponse": "Type.Property.ValueTypes.CollectionsString.put", + "com.type.property.valuetypes.DatetimeOperationAsyncClient": "null", + "com.type.property.valuetypes.DatetimeOperationAsyncClient.get": "Type.Property.ValueTypes.Datetime.get", + "com.type.property.valuetypes.DatetimeOperationAsyncClient.getWithResponse": "Type.Property.ValueTypes.Datetime.get", + "com.type.property.valuetypes.DatetimeOperationAsyncClient.put": "Type.Property.ValueTypes.Datetime.put", + "com.type.property.valuetypes.DatetimeOperationAsyncClient.putWithResponse": "Type.Property.ValueTypes.Datetime.put", + "com.type.property.valuetypes.DatetimeOperationClient": "null", + "com.type.property.valuetypes.DatetimeOperationClient.get": "Type.Property.ValueTypes.Datetime.get", + "com.type.property.valuetypes.DatetimeOperationClient.getWithResponse": "Type.Property.ValueTypes.Datetime.get", + "com.type.property.valuetypes.DatetimeOperationClient.put": "Type.Property.ValueTypes.Datetime.put", + "com.type.property.valuetypes.DatetimeOperationClient.putWithResponse": "Type.Property.ValueTypes.Datetime.put", + "com.type.property.valuetypes.Decimal128AsyncClient": "null", + "com.type.property.valuetypes.Decimal128AsyncClient.get": "Type.Property.ValueTypes.Decimal128.get", + "com.type.property.valuetypes.Decimal128AsyncClient.getWithResponse": "Type.Property.ValueTypes.Decimal128.get", + "com.type.property.valuetypes.Decimal128AsyncClient.put": "Type.Property.ValueTypes.Decimal128.put", + "com.type.property.valuetypes.Decimal128AsyncClient.putWithResponse": "Type.Property.ValueTypes.Decimal128.put", + "com.type.property.valuetypes.Decimal128Client": "null", + "com.type.property.valuetypes.Decimal128Client.get": "Type.Property.ValueTypes.Decimal128.get", + "com.type.property.valuetypes.Decimal128Client.getWithResponse": "Type.Property.ValueTypes.Decimal128.get", + "com.type.property.valuetypes.Decimal128Client.put": "Type.Property.ValueTypes.Decimal128.put", + "com.type.property.valuetypes.Decimal128Client.putWithResponse": "Type.Property.ValueTypes.Decimal128.put", + "com.type.property.valuetypes.DecimalAsyncClient": "null", + "com.type.property.valuetypes.DecimalAsyncClient.get": "Type.Property.ValueTypes.Decimal.get", + "com.type.property.valuetypes.DecimalAsyncClient.getWithResponse": "Type.Property.ValueTypes.Decimal.get", + "com.type.property.valuetypes.DecimalAsyncClient.put": "Type.Property.ValueTypes.Decimal.put", + "com.type.property.valuetypes.DecimalAsyncClient.putWithResponse": "Type.Property.ValueTypes.Decimal.put", + "com.type.property.valuetypes.DecimalClient": "null", + "com.type.property.valuetypes.DecimalClient.get": "Type.Property.ValueTypes.Decimal.get", + "com.type.property.valuetypes.DecimalClient.getWithResponse": "Type.Property.ValueTypes.Decimal.get", + "com.type.property.valuetypes.DecimalClient.put": "Type.Property.ValueTypes.Decimal.put", + "com.type.property.valuetypes.DecimalClient.putWithResponse": "Type.Property.ValueTypes.Decimal.put", + "com.type.property.valuetypes.DictionaryStringAsyncClient": "null", + "com.type.property.valuetypes.DictionaryStringAsyncClient.get": "Type.Property.ValueTypes.DictionaryString.get", + "com.type.property.valuetypes.DictionaryStringAsyncClient.getWithResponse": "Type.Property.ValueTypes.DictionaryString.get", + "com.type.property.valuetypes.DictionaryStringAsyncClient.put": "Type.Property.ValueTypes.DictionaryString.put", + "com.type.property.valuetypes.DictionaryStringAsyncClient.putWithResponse": "Type.Property.ValueTypes.DictionaryString.put", + "com.type.property.valuetypes.DictionaryStringClient": "null", + "com.type.property.valuetypes.DictionaryStringClient.get": "Type.Property.ValueTypes.DictionaryString.get", + "com.type.property.valuetypes.DictionaryStringClient.getWithResponse": "Type.Property.ValueTypes.DictionaryString.get", + "com.type.property.valuetypes.DictionaryStringClient.put": "Type.Property.ValueTypes.DictionaryString.put", + "com.type.property.valuetypes.DictionaryStringClient.putWithResponse": "Type.Property.ValueTypes.DictionaryString.put", + "com.type.property.valuetypes.DurationOperationAsyncClient": "null", + "com.type.property.valuetypes.DurationOperationAsyncClient.get": "Type.Property.ValueTypes.Duration.get", + "com.type.property.valuetypes.DurationOperationAsyncClient.getWithResponse": "Type.Property.ValueTypes.Duration.get", + "com.type.property.valuetypes.DurationOperationAsyncClient.put": "Type.Property.ValueTypes.Duration.put", + "com.type.property.valuetypes.DurationOperationAsyncClient.putWithResponse": "Type.Property.ValueTypes.Duration.put", + "com.type.property.valuetypes.DurationOperationClient": "null", + "com.type.property.valuetypes.DurationOperationClient.get": "Type.Property.ValueTypes.Duration.get", + "com.type.property.valuetypes.DurationOperationClient.getWithResponse": "Type.Property.ValueTypes.Duration.get", + "com.type.property.valuetypes.DurationOperationClient.put": "Type.Property.ValueTypes.Duration.put", + "com.type.property.valuetypes.DurationOperationClient.putWithResponse": "Type.Property.ValueTypes.Duration.put", + "com.type.property.valuetypes.EnumAsyncClient": "null", + "com.type.property.valuetypes.EnumAsyncClient.get": "Type.Property.ValueTypes.Enum.get", + "com.type.property.valuetypes.EnumAsyncClient.getWithResponse": "Type.Property.ValueTypes.Enum.get", + "com.type.property.valuetypes.EnumAsyncClient.put": "Type.Property.ValueTypes.Enum.put", + "com.type.property.valuetypes.EnumAsyncClient.putWithResponse": "Type.Property.ValueTypes.Enum.put", + "com.type.property.valuetypes.EnumClient": "null", + "com.type.property.valuetypes.EnumClient.get": "Type.Property.ValueTypes.Enum.get", + "com.type.property.valuetypes.EnumClient.getWithResponse": "Type.Property.ValueTypes.Enum.get", + "com.type.property.valuetypes.EnumClient.put": "Type.Property.ValueTypes.Enum.put", + "com.type.property.valuetypes.EnumClient.putWithResponse": "Type.Property.ValueTypes.Enum.put", + "com.type.property.valuetypes.ExtensibleEnumAsyncClient": "null", + "com.type.property.valuetypes.ExtensibleEnumAsyncClient.get": "Type.Property.ValueTypes.ExtensibleEnum.get", + "com.type.property.valuetypes.ExtensibleEnumAsyncClient.getWithResponse": "Type.Property.ValueTypes.ExtensibleEnum.get", + "com.type.property.valuetypes.ExtensibleEnumAsyncClient.put": "Type.Property.ValueTypes.ExtensibleEnum.put", + "com.type.property.valuetypes.ExtensibleEnumAsyncClient.putWithResponse": "Type.Property.ValueTypes.ExtensibleEnum.put", + "com.type.property.valuetypes.ExtensibleEnumClient": "null", + "com.type.property.valuetypes.ExtensibleEnumClient.get": "Type.Property.ValueTypes.ExtensibleEnum.get", + "com.type.property.valuetypes.ExtensibleEnumClient.getWithResponse": "Type.Property.ValueTypes.ExtensibleEnum.get", + "com.type.property.valuetypes.ExtensibleEnumClient.put": "Type.Property.ValueTypes.ExtensibleEnum.put", + "com.type.property.valuetypes.ExtensibleEnumClient.putWithResponse": "Type.Property.ValueTypes.ExtensibleEnum.put", + "com.type.property.valuetypes.FloatLiteralAsyncClient": "null", + "com.type.property.valuetypes.FloatLiteralAsyncClient.get": "Type.Property.ValueTypes.FloatLiteral.get", + "com.type.property.valuetypes.FloatLiteralAsyncClient.getWithResponse": "Type.Property.ValueTypes.FloatLiteral.get", + "com.type.property.valuetypes.FloatLiteralAsyncClient.put": "Type.Property.ValueTypes.FloatLiteral.put", + "com.type.property.valuetypes.FloatLiteralAsyncClient.putWithResponse": "Type.Property.ValueTypes.FloatLiteral.put", + "com.type.property.valuetypes.FloatLiteralClient": "null", + "com.type.property.valuetypes.FloatLiteralClient.get": "Type.Property.ValueTypes.FloatLiteral.get", + "com.type.property.valuetypes.FloatLiteralClient.getWithResponse": "Type.Property.ValueTypes.FloatLiteral.get", + "com.type.property.valuetypes.FloatLiteralClient.put": "Type.Property.ValueTypes.FloatLiteral.put", + "com.type.property.valuetypes.FloatLiteralClient.putWithResponse": "Type.Property.ValueTypes.FloatLiteral.put", + "com.type.property.valuetypes.FloatOperationAsyncClient": "null", + "com.type.property.valuetypes.FloatOperationAsyncClient.get": "Type.Property.ValueTypes.Float.get", + "com.type.property.valuetypes.FloatOperationAsyncClient.getWithResponse": "Type.Property.ValueTypes.Float.get", + "com.type.property.valuetypes.FloatOperationAsyncClient.put": "Type.Property.ValueTypes.Float.put", + "com.type.property.valuetypes.FloatOperationAsyncClient.putWithResponse": "Type.Property.ValueTypes.Float.put", + "com.type.property.valuetypes.FloatOperationClient": "null", + "com.type.property.valuetypes.FloatOperationClient.get": "Type.Property.ValueTypes.Float.get", + "com.type.property.valuetypes.FloatOperationClient.getWithResponse": "Type.Property.ValueTypes.Float.get", + "com.type.property.valuetypes.FloatOperationClient.put": "Type.Property.ValueTypes.Float.put", + "com.type.property.valuetypes.FloatOperationClient.putWithResponse": "Type.Property.ValueTypes.Float.put", + "com.type.property.valuetypes.IntAsyncClient": "null", + "com.type.property.valuetypes.IntAsyncClient.get": "Type.Property.ValueTypes.Int.get", + "com.type.property.valuetypes.IntAsyncClient.getWithResponse": "Type.Property.ValueTypes.Int.get", + "com.type.property.valuetypes.IntAsyncClient.put": "Type.Property.ValueTypes.Int.put", + "com.type.property.valuetypes.IntAsyncClient.putWithResponse": "Type.Property.ValueTypes.Int.put", + "com.type.property.valuetypes.IntClient": "null", + "com.type.property.valuetypes.IntClient.get": "Type.Property.ValueTypes.Int.get", + "com.type.property.valuetypes.IntClient.getWithResponse": "Type.Property.ValueTypes.Int.get", + "com.type.property.valuetypes.IntClient.put": "Type.Property.ValueTypes.Int.put", + "com.type.property.valuetypes.IntClient.putWithResponse": "Type.Property.ValueTypes.Int.put", + "com.type.property.valuetypes.IntLiteralAsyncClient": "null", + "com.type.property.valuetypes.IntLiteralAsyncClient.get": "Type.Property.ValueTypes.IntLiteral.get", + "com.type.property.valuetypes.IntLiteralAsyncClient.getWithResponse": "Type.Property.ValueTypes.IntLiteral.get", + "com.type.property.valuetypes.IntLiteralAsyncClient.put": "Type.Property.ValueTypes.IntLiteral.put", + "com.type.property.valuetypes.IntLiteralAsyncClient.putWithResponse": "Type.Property.ValueTypes.IntLiteral.put", + "com.type.property.valuetypes.IntLiteralClient": "null", + "com.type.property.valuetypes.IntLiteralClient.get": "Type.Property.ValueTypes.IntLiteral.get", + "com.type.property.valuetypes.IntLiteralClient.getWithResponse": "Type.Property.ValueTypes.IntLiteral.get", + "com.type.property.valuetypes.IntLiteralClient.put": "Type.Property.ValueTypes.IntLiteral.put", + "com.type.property.valuetypes.IntLiteralClient.putWithResponse": "Type.Property.ValueTypes.IntLiteral.put", + "com.type.property.valuetypes.ModelAsyncClient": "null", + "com.type.property.valuetypes.ModelAsyncClient.get": "Type.Property.ValueTypes.Model.get", + "com.type.property.valuetypes.ModelAsyncClient.getWithResponse": "Type.Property.ValueTypes.Model.get", + "com.type.property.valuetypes.ModelAsyncClient.put": "Type.Property.ValueTypes.Model.put", + "com.type.property.valuetypes.ModelAsyncClient.putWithResponse": "Type.Property.ValueTypes.Model.put", + "com.type.property.valuetypes.ModelClient": "null", + "com.type.property.valuetypes.ModelClient.get": "Type.Property.ValueTypes.Model.get", + "com.type.property.valuetypes.ModelClient.getWithResponse": "Type.Property.ValueTypes.Model.get", + "com.type.property.valuetypes.ModelClient.put": "Type.Property.ValueTypes.Model.put", + "com.type.property.valuetypes.ModelClient.putWithResponse": "Type.Property.ValueTypes.Model.put", + "com.type.property.valuetypes.NeverAsyncClient": "null", + "com.type.property.valuetypes.NeverAsyncClient.get": "Type.Property.ValueTypes.Never.get", + "com.type.property.valuetypes.NeverAsyncClient.getWithResponse": "Type.Property.ValueTypes.Never.get", + "com.type.property.valuetypes.NeverAsyncClient.put": "Type.Property.ValueTypes.Never.put", + "com.type.property.valuetypes.NeverAsyncClient.putWithResponse": "Type.Property.ValueTypes.Never.put", + "com.type.property.valuetypes.NeverClient": "null", + "com.type.property.valuetypes.NeverClient.get": "Type.Property.ValueTypes.Never.get", + "com.type.property.valuetypes.NeverClient.getWithResponse": "Type.Property.ValueTypes.Never.get", + "com.type.property.valuetypes.NeverClient.put": "Type.Property.ValueTypes.Never.put", + "com.type.property.valuetypes.NeverClient.putWithResponse": "Type.Property.ValueTypes.Never.put", + "com.type.property.valuetypes.StringLiteralAsyncClient": "null", + "com.type.property.valuetypes.StringLiteralAsyncClient.get": "Type.Property.ValueTypes.StringLiteral.get", + "com.type.property.valuetypes.StringLiteralAsyncClient.getWithResponse": "Type.Property.ValueTypes.StringLiteral.get", + "com.type.property.valuetypes.StringLiteralAsyncClient.put": "Type.Property.ValueTypes.StringLiteral.put", + "com.type.property.valuetypes.StringLiteralAsyncClient.putWithResponse": "Type.Property.ValueTypes.StringLiteral.put", + "com.type.property.valuetypes.StringLiteralClient": "null", + "com.type.property.valuetypes.StringLiteralClient.get": "Type.Property.ValueTypes.StringLiteral.get", + "com.type.property.valuetypes.StringLiteralClient.getWithResponse": "Type.Property.ValueTypes.StringLiteral.get", + "com.type.property.valuetypes.StringLiteralClient.put": "Type.Property.ValueTypes.StringLiteral.put", + "com.type.property.valuetypes.StringLiteralClient.putWithResponse": "Type.Property.ValueTypes.StringLiteral.put", + "com.type.property.valuetypes.StringOperationAsyncClient": "null", + "com.type.property.valuetypes.StringOperationAsyncClient.get": "Type.Property.ValueTypes.String.get", + "com.type.property.valuetypes.StringOperationAsyncClient.getWithResponse": "Type.Property.ValueTypes.String.get", + "com.type.property.valuetypes.StringOperationAsyncClient.put": "Type.Property.ValueTypes.String.put", + "com.type.property.valuetypes.StringOperationAsyncClient.putWithResponse": "Type.Property.ValueTypes.String.put", + "com.type.property.valuetypes.StringOperationClient": "null", + "com.type.property.valuetypes.StringOperationClient.get": "Type.Property.ValueTypes.String.get", + "com.type.property.valuetypes.StringOperationClient.getWithResponse": "Type.Property.ValueTypes.String.get", + "com.type.property.valuetypes.StringOperationClient.put": "Type.Property.ValueTypes.String.put", + "com.type.property.valuetypes.StringOperationClient.putWithResponse": "Type.Property.ValueTypes.String.put", + "com.type.property.valuetypes.UnionEnumValueAsyncClient": "null", + "com.type.property.valuetypes.UnionEnumValueAsyncClient.get": "Type.Property.ValueTypes.UnionEnumValue.get", + "com.type.property.valuetypes.UnionEnumValueAsyncClient.getWithResponse": "Type.Property.ValueTypes.UnionEnumValue.get", + "com.type.property.valuetypes.UnionEnumValueAsyncClient.put": "Type.Property.ValueTypes.UnionEnumValue.put", + "com.type.property.valuetypes.UnionEnumValueAsyncClient.putWithResponse": "Type.Property.ValueTypes.UnionEnumValue.put", + "com.type.property.valuetypes.UnionEnumValueClient": "null", + "com.type.property.valuetypes.UnionEnumValueClient.get": "Type.Property.ValueTypes.UnionEnumValue.get", + "com.type.property.valuetypes.UnionEnumValueClient.getWithResponse": "Type.Property.ValueTypes.UnionEnumValue.get", + "com.type.property.valuetypes.UnionEnumValueClient.put": "Type.Property.ValueTypes.UnionEnumValue.put", + "com.type.property.valuetypes.UnionEnumValueClient.putWithResponse": "Type.Property.ValueTypes.UnionEnumValue.put", + "com.type.property.valuetypes.UnionFloatLiteralAsyncClient": "null", + "com.type.property.valuetypes.UnionFloatLiteralAsyncClient.get": "Type.Property.ValueTypes.UnionFloatLiteral.get", + "com.type.property.valuetypes.UnionFloatLiteralAsyncClient.getWithResponse": "Type.Property.ValueTypes.UnionFloatLiteral.get", + "com.type.property.valuetypes.UnionFloatLiteralAsyncClient.put": "Type.Property.ValueTypes.UnionFloatLiteral.put", + "com.type.property.valuetypes.UnionFloatLiteralAsyncClient.putWithResponse": "Type.Property.ValueTypes.UnionFloatLiteral.put", + "com.type.property.valuetypes.UnionFloatLiteralClient": "null", + "com.type.property.valuetypes.UnionFloatLiteralClient.get": "Type.Property.ValueTypes.UnionFloatLiteral.get", + "com.type.property.valuetypes.UnionFloatLiteralClient.getWithResponse": "Type.Property.ValueTypes.UnionFloatLiteral.get", + "com.type.property.valuetypes.UnionFloatLiteralClient.put": "Type.Property.ValueTypes.UnionFloatLiteral.put", + "com.type.property.valuetypes.UnionFloatLiteralClient.putWithResponse": "Type.Property.ValueTypes.UnionFloatLiteral.put", + "com.type.property.valuetypes.UnionIntLiteralAsyncClient": "null", + "com.type.property.valuetypes.UnionIntLiteralAsyncClient.get": "Type.Property.ValueTypes.UnionIntLiteral.get", + "com.type.property.valuetypes.UnionIntLiteralAsyncClient.getWithResponse": "Type.Property.ValueTypes.UnionIntLiteral.get", + "com.type.property.valuetypes.UnionIntLiteralAsyncClient.put": "Type.Property.ValueTypes.UnionIntLiteral.put", + "com.type.property.valuetypes.UnionIntLiteralAsyncClient.putWithResponse": "Type.Property.ValueTypes.UnionIntLiteral.put", + "com.type.property.valuetypes.UnionIntLiteralClient": "null", + "com.type.property.valuetypes.UnionIntLiteralClient.get": "Type.Property.ValueTypes.UnionIntLiteral.get", + "com.type.property.valuetypes.UnionIntLiteralClient.getWithResponse": "Type.Property.ValueTypes.UnionIntLiteral.get", + "com.type.property.valuetypes.UnionIntLiteralClient.put": "Type.Property.ValueTypes.UnionIntLiteral.put", + "com.type.property.valuetypes.UnionIntLiteralClient.putWithResponse": "Type.Property.ValueTypes.UnionIntLiteral.put", + "com.type.property.valuetypes.UnionStringLiteralAsyncClient": "null", + "com.type.property.valuetypes.UnionStringLiteralAsyncClient.get": "Type.Property.ValueTypes.UnionStringLiteral.get", + "com.type.property.valuetypes.UnionStringLiteralAsyncClient.getWithResponse": "Type.Property.ValueTypes.UnionStringLiteral.get", + "com.type.property.valuetypes.UnionStringLiteralAsyncClient.put": "Type.Property.ValueTypes.UnionStringLiteral.put", + "com.type.property.valuetypes.UnionStringLiteralAsyncClient.putWithResponse": "Type.Property.ValueTypes.UnionStringLiteral.put", + "com.type.property.valuetypes.UnionStringLiteralClient": "null", + "com.type.property.valuetypes.UnionStringLiteralClient.get": "Type.Property.ValueTypes.UnionStringLiteral.get", + "com.type.property.valuetypes.UnionStringLiteralClient.getWithResponse": "Type.Property.ValueTypes.UnionStringLiteral.get", + "com.type.property.valuetypes.UnionStringLiteralClient.put": "Type.Property.ValueTypes.UnionStringLiteral.put", + "com.type.property.valuetypes.UnionStringLiteralClient.putWithResponse": "Type.Property.ValueTypes.UnionStringLiteral.put", + "com.type.property.valuetypes.UnknownArrayAsyncClient": "null", + "com.type.property.valuetypes.UnknownArrayAsyncClient.get": "Type.Property.ValueTypes.UnknownArray.get", + "com.type.property.valuetypes.UnknownArrayAsyncClient.getWithResponse": "Type.Property.ValueTypes.UnknownArray.get", + "com.type.property.valuetypes.UnknownArrayAsyncClient.put": "Type.Property.ValueTypes.UnknownArray.put", + "com.type.property.valuetypes.UnknownArrayAsyncClient.putWithResponse": "Type.Property.ValueTypes.UnknownArray.put", + "com.type.property.valuetypes.UnknownArrayClient": "null", + "com.type.property.valuetypes.UnknownArrayClient.get": "Type.Property.ValueTypes.UnknownArray.get", + "com.type.property.valuetypes.UnknownArrayClient.getWithResponse": "Type.Property.ValueTypes.UnknownArray.get", + "com.type.property.valuetypes.UnknownArrayClient.put": "Type.Property.ValueTypes.UnknownArray.put", + "com.type.property.valuetypes.UnknownArrayClient.putWithResponse": "Type.Property.ValueTypes.UnknownArray.put", + "com.type.property.valuetypes.UnknownDictAsyncClient": "null", + "com.type.property.valuetypes.UnknownDictAsyncClient.get": "Type.Property.ValueTypes.UnknownDict.get", + "com.type.property.valuetypes.UnknownDictAsyncClient.getWithResponse": "Type.Property.ValueTypes.UnknownDict.get", + "com.type.property.valuetypes.UnknownDictAsyncClient.put": "Type.Property.ValueTypes.UnknownDict.put", + "com.type.property.valuetypes.UnknownDictAsyncClient.putWithResponse": "Type.Property.ValueTypes.UnknownDict.put", + "com.type.property.valuetypes.UnknownDictClient": "null", + "com.type.property.valuetypes.UnknownDictClient.get": "Type.Property.ValueTypes.UnknownDict.get", + "com.type.property.valuetypes.UnknownDictClient.getWithResponse": "Type.Property.ValueTypes.UnknownDict.get", + "com.type.property.valuetypes.UnknownDictClient.put": "Type.Property.ValueTypes.UnknownDict.put", + "com.type.property.valuetypes.UnknownDictClient.putWithResponse": "Type.Property.ValueTypes.UnknownDict.put", + "com.type.property.valuetypes.UnknownIntAsyncClient": "null", + "com.type.property.valuetypes.UnknownIntAsyncClient.get": "Type.Property.ValueTypes.UnknownInt.get", + "com.type.property.valuetypes.UnknownIntAsyncClient.getWithResponse": "Type.Property.ValueTypes.UnknownInt.get", + "com.type.property.valuetypes.UnknownIntAsyncClient.put": "Type.Property.ValueTypes.UnknownInt.put", + "com.type.property.valuetypes.UnknownIntAsyncClient.putWithResponse": "Type.Property.ValueTypes.UnknownInt.put", + "com.type.property.valuetypes.UnknownIntClient": "null", + "com.type.property.valuetypes.UnknownIntClient.get": "Type.Property.ValueTypes.UnknownInt.get", + "com.type.property.valuetypes.UnknownIntClient.getWithResponse": "Type.Property.ValueTypes.UnknownInt.get", + "com.type.property.valuetypes.UnknownIntClient.put": "Type.Property.ValueTypes.UnknownInt.put", + "com.type.property.valuetypes.UnknownIntClient.putWithResponse": "Type.Property.ValueTypes.UnknownInt.put", + "com.type.property.valuetypes.UnknownStringAsyncClient": "null", + "com.type.property.valuetypes.UnknownStringAsyncClient.get": "Type.Property.ValueTypes.UnknownString.get", + "com.type.property.valuetypes.UnknownStringAsyncClient.getWithResponse": "Type.Property.ValueTypes.UnknownString.get", + "com.type.property.valuetypes.UnknownStringAsyncClient.put": "Type.Property.ValueTypes.UnknownString.put", + "com.type.property.valuetypes.UnknownStringAsyncClient.putWithResponse": "Type.Property.ValueTypes.UnknownString.put", + "com.type.property.valuetypes.UnknownStringClient": "null", + "com.type.property.valuetypes.UnknownStringClient.get": "Type.Property.ValueTypes.UnknownString.get", + "com.type.property.valuetypes.UnknownStringClient.getWithResponse": "Type.Property.ValueTypes.UnknownString.get", + "com.type.property.valuetypes.UnknownStringClient.put": "Type.Property.ValueTypes.UnknownString.put", + "com.type.property.valuetypes.UnknownStringClient.putWithResponse": "Type.Property.ValueTypes.UnknownString.put", + "com.type.property.valuetypes.ValueTypesClientBuilder": "Type.Property.ValueTypes", + "com.type.property.valuetypes.models.BooleanLiteralProperty": "Type.Property.ValueTypes.BooleanLiteralProperty", + "com.type.property.valuetypes.models.BooleanProperty": "Type.Property.ValueTypes.BooleanProperty", + "com.type.property.valuetypes.models.BytesProperty": "Type.Property.ValueTypes.BytesProperty", + "com.type.property.valuetypes.models.CollectionsIntProperty": "Type.Property.ValueTypes.CollectionsIntProperty", + "com.type.property.valuetypes.models.CollectionsModelProperty": "Type.Property.ValueTypes.CollectionsModelProperty", + "com.type.property.valuetypes.models.CollectionsStringProperty": "Type.Property.ValueTypes.CollectionsStringProperty", + "com.type.property.valuetypes.models.DatetimeProperty": "Type.Property.ValueTypes.DatetimeProperty", + "com.type.property.valuetypes.models.Decimal128Property": "Type.Property.ValueTypes.Decimal128Property", + "com.type.property.valuetypes.models.DecimalProperty": "Type.Property.ValueTypes.DecimalProperty", + "com.type.property.valuetypes.models.DictionaryStringProperty": "Type.Property.ValueTypes.DictionaryStringProperty", + "com.type.property.valuetypes.models.DurationProperty": "Type.Property.ValueTypes.DurationProperty", + "com.type.property.valuetypes.models.EnumProperty": "Type.Property.ValueTypes.EnumProperty", + "com.type.property.valuetypes.models.ExtendedEnum": "Type.Property.ValueTypes.ExtendedEnum", + "com.type.property.valuetypes.models.ExtensibleEnumProperty": "Type.Property.ValueTypes.ExtensibleEnumProperty", + "com.type.property.valuetypes.models.FixedInnerEnum": "Type.Property.ValueTypes.FixedInnerEnum", + "com.type.property.valuetypes.models.FloatLiteralProperty": "Type.Property.ValueTypes.FloatLiteralProperty", + "com.type.property.valuetypes.models.FloatProperty": "Type.Property.ValueTypes.FloatProperty", + "com.type.property.valuetypes.models.InnerEnum": "Type.Property.ValueTypes.InnerEnum", + "com.type.property.valuetypes.models.InnerModel": "Type.Property.ValueTypes.InnerModel", + "com.type.property.valuetypes.models.IntLiteralProperty": "Type.Property.ValueTypes.IntLiteralProperty", + "com.type.property.valuetypes.models.IntProperty": "Type.Property.ValueTypes.IntProperty", + "com.type.property.valuetypes.models.ModelProperty": "Type.Property.ValueTypes.ModelProperty", + "com.type.property.valuetypes.models.NeverProperty": "Type.Property.ValueTypes.NeverProperty", + "com.type.property.valuetypes.models.StringLiteralProperty": "Type.Property.ValueTypes.StringLiteralProperty", + "com.type.property.valuetypes.models.StringProperty": "Type.Property.ValueTypes.StringProperty", + "com.type.property.valuetypes.models.UnionEnumValueProperty": "Type.Property.ValueTypes.UnionEnumValueProperty", + "com.type.property.valuetypes.models.UnionFloatLiteralProperty": "Type.Property.ValueTypes.UnionFloatLiteralProperty", + "com.type.property.valuetypes.models.UnionFloatLiteralPropertyProperty": "UnionFloatLiteralProperty.property.anonymous", + "com.type.property.valuetypes.models.UnionIntLiteralProperty": "Type.Property.ValueTypes.UnionIntLiteralProperty", + "com.type.property.valuetypes.models.UnionIntLiteralPropertyProperty": "UnionIntLiteralProperty.property.anonymous", + "com.type.property.valuetypes.models.UnionStringLiteralProperty": "Type.Property.ValueTypes.UnionStringLiteralProperty", + "com.type.property.valuetypes.models.UnionStringLiteralPropertyProperty": "UnionStringLiteralProperty.property.anonymous", + "com.type.property.valuetypes.models.UnknownArrayProperty": "Type.Property.ValueTypes.UnknownArrayProperty", + "com.type.property.valuetypes.models.UnknownDictProperty": "Type.Property.ValueTypes.UnknownDictProperty", + "com.type.property.valuetypes.models.UnknownIntProperty": "Type.Property.ValueTypes.UnknownIntProperty", + "com.type.property.valuetypes.models.UnknownStringProperty": "Type.Property.ValueTypes.UnknownStringProperty" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-scalar_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-scalar_apiview_properties.json new file mode 100644 index 000000000..1aad9ee28 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-scalar_apiview_properties.json @@ -0,0 +1,84 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.scalar.BooleanOperationAsyncClient": "null", + "com.type.scalar.BooleanOperationAsyncClient.get": "Type.Scalar.Boolean.get", + "com.type.scalar.BooleanOperationAsyncClient.getWithResponse": "Type.Scalar.Boolean.get", + "com.type.scalar.BooleanOperationAsyncClient.put": "Type.Scalar.Boolean.put", + "com.type.scalar.BooleanOperationAsyncClient.putWithResponse": "Type.Scalar.Boolean.put", + "com.type.scalar.BooleanOperationClient": "null", + "com.type.scalar.BooleanOperationClient.get": "Type.Scalar.Boolean.get", + "com.type.scalar.BooleanOperationClient.getWithResponse": "Type.Scalar.Boolean.get", + "com.type.scalar.BooleanOperationClient.put": "Type.Scalar.Boolean.put", + "com.type.scalar.BooleanOperationClient.putWithResponse": "Type.Scalar.Boolean.put", + "com.type.scalar.Decimal128TypeAsyncClient": "null", + "com.type.scalar.Decimal128TypeAsyncClient.requestBody": "Type.Scalar.Decimal128Type.requestBody", + "com.type.scalar.Decimal128TypeAsyncClient.requestBodyWithResponse": "Type.Scalar.Decimal128Type.requestBody", + "com.type.scalar.Decimal128TypeAsyncClient.requestParameter": "Type.Scalar.Decimal128Type.requestParameter", + "com.type.scalar.Decimal128TypeAsyncClient.requestParameterWithResponse": "Type.Scalar.Decimal128Type.requestParameter", + "com.type.scalar.Decimal128TypeAsyncClient.responseBody": "Type.Scalar.Decimal128Type.responseBody", + "com.type.scalar.Decimal128TypeAsyncClient.responseBodyWithResponse": "Type.Scalar.Decimal128Type.responseBody", + "com.type.scalar.Decimal128TypeClient": "null", + "com.type.scalar.Decimal128TypeClient.requestBody": "Type.Scalar.Decimal128Type.requestBody", + "com.type.scalar.Decimal128TypeClient.requestBodyWithResponse": "Type.Scalar.Decimal128Type.requestBody", + "com.type.scalar.Decimal128TypeClient.requestParameter": "Type.Scalar.Decimal128Type.requestParameter", + "com.type.scalar.Decimal128TypeClient.requestParameterWithResponse": "Type.Scalar.Decimal128Type.requestParameter", + "com.type.scalar.Decimal128TypeClient.responseBody": "Type.Scalar.Decimal128Type.responseBody", + "com.type.scalar.Decimal128TypeClient.responseBodyWithResponse": "Type.Scalar.Decimal128Type.responseBody", + "com.type.scalar.Decimal128VerifyAsyncClient": "null", + "com.type.scalar.Decimal128VerifyAsyncClient.prepareVerify": "Type.Scalar.Decimal128Verify.prepareVerify", + "com.type.scalar.Decimal128VerifyAsyncClient.prepareVerifyWithResponse": "Type.Scalar.Decimal128Verify.prepareVerify", + "com.type.scalar.Decimal128VerifyAsyncClient.verify": "Type.Scalar.Decimal128Verify.verify", + "com.type.scalar.Decimal128VerifyAsyncClient.verifyWithResponse": "Type.Scalar.Decimal128Verify.verify", + "com.type.scalar.Decimal128VerifyClient": "null", + "com.type.scalar.Decimal128VerifyClient.prepareVerify": "Type.Scalar.Decimal128Verify.prepareVerify", + "com.type.scalar.Decimal128VerifyClient.prepareVerifyWithResponse": "Type.Scalar.Decimal128Verify.prepareVerify", + "com.type.scalar.Decimal128VerifyClient.verify": "Type.Scalar.Decimal128Verify.verify", + "com.type.scalar.Decimal128VerifyClient.verifyWithResponse": "Type.Scalar.Decimal128Verify.verify", + "com.type.scalar.DecimalTypeAsyncClient": "null", + "com.type.scalar.DecimalTypeAsyncClient.requestBody": "Type.Scalar.DecimalType.requestBody", + "com.type.scalar.DecimalTypeAsyncClient.requestBodyWithResponse": "Type.Scalar.DecimalType.requestBody", + "com.type.scalar.DecimalTypeAsyncClient.requestParameter": "Type.Scalar.DecimalType.requestParameter", + "com.type.scalar.DecimalTypeAsyncClient.requestParameterWithResponse": "Type.Scalar.DecimalType.requestParameter", + "com.type.scalar.DecimalTypeAsyncClient.responseBody": "Type.Scalar.DecimalType.responseBody", + "com.type.scalar.DecimalTypeAsyncClient.responseBodyWithResponse": "Type.Scalar.DecimalType.responseBody", + "com.type.scalar.DecimalTypeClient": "null", + "com.type.scalar.DecimalTypeClient.requestBody": "Type.Scalar.DecimalType.requestBody", + "com.type.scalar.DecimalTypeClient.requestBodyWithResponse": "Type.Scalar.DecimalType.requestBody", + "com.type.scalar.DecimalTypeClient.requestParameter": "Type.Scalar.DecimalType.requestParameter", + "com.type.scalar.DecimalTypeClient.requestParameterWithResponse": "Type.Scalar.DecimalType.requestParameter", + "com.type.scalar.DecimalTypeClient.responseBody": "Type.Scalar.DecimalType.responseBody", + "com.type.scalar.DecimalTypeClient.responseBodyWithResponse": "Type.Scalar.DecimalType.responseBody", + "com.type.scalar.DecimalVerifyAsyncClient": "null", + "com.type.scalar.DecimalVerifyAsyncClient.prepareVerify": "Type.Scalar.DecimalVerify.prepareVerify", + "com.type.scalar.DecimalVerifyAsyncClient.prepareVerifyWithResponse": "Type.Scalar.DecimalVerify.prepareVerify", + "com.type.scalar.DecimalVerifyAsyncClient.verify": "Type.Scalar.DecimalVerify.verify", + "com.type.scalar.DecimalVerifyAsyncClient.verifyWithResponse": "Type.Scalar.DecimalVerify.verify", + "com.type.scalar.DecimalVerifyClient": "null", + "com.type.scalar.DecimalVerifyClient.prepareVerify": "Type.Scalar.DecimalVerify.prepareVerify", + "com.type.scalar.DecimalVerifyClient.prepareVerifyWithResponse": "Type.Scalar.DecimalVerify.prepareVerify", + "com.type.scalar.DecimalVerifyClient.verify": "Type.Scalar.DecimalVerify.verify", + "com.type.scalar.DecimalVerifyClient.verifyWithResponse": "Type.Scalar.DecimalVerify.verify", + "com.type.scalar.ScalarClientBuilder": "Type.Scalar", + "com.type.scalar.StringOperationAsyncClient": "null", + "com.type.scalar.StringOperationAsyncClient.get": "Type.Scalar.String.get", + "com.type.scalar.StringOperationAsyncClient.getWithResponse": "Type.Scalar.String.get", + "com.type.scalar.StringOperationAsyncClient.put": "Type.Scalar.String.put", + "com.type.scalar.StringOperationAsyncClient.putWithResponse": "Type.Scalar.String.put", + "com.type.scalar.StringOperationClient": "null", + "com.type.scalar.StringOperationClient.get": "Type.Scalar.String.get", + "com.type.scalar.StringOperationClient.getWithResponse": "Type.Scalar.String.get", + "com.type.scalar.StringOperationClient.put": "Type.Scalar.String.put", + "com.type.scalar.StringOperationClient.putWithResponse": "Type.Scalar.String.put", + "com.type.scalar.UnknownAsyncClient": "null", + "com.type.scalar.UnknownAsyncClient.get": "Type.Scalar.Unknown.get", + "com.type.scalar.UnknownAsyncClient.getWithResponse": "Type.Scalar.Unknown.get", + "com.type.scalar.UnknownAsyncClient.put": "Type.Scalar.Unknown.put", + "com.type.scalar.UnknownAsyncClient.putWithResponse": "Type.Scalar.Unknown.put", + "com.type.scalar.UnknownClient": "null", + "com.type.scalar.UnknownClient.get": "Type.Scalar.Unknown.get", + "com.type.scalar.UnknownClient.getWithResponse": "Type.Scalar.Unknown.get", + "com.type.scalar.UnknownClient.put": "Type.Scalar.Unknown.put", + "com.type.scalar.UnknownClient.putWithResponse": "Type.Scalar.Unknown.put" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-union_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-union_apiview_properties.json new file mode 100644 index 000000000..2ac5f8fb3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/type-union_apiview_properties.json @@ -0,0 +1,139 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.type.union.EnumsOnlyAsyncClient": "null", + "com.type.union.EnumsOnlyAsyncClient.get": "Type.Union.EnumsOnly.get", + "com.type.union.EnumsOnlyAsyncClient.getWithResponse": "Type.Union.EnumsOnly.get", + "com.type.union.EnumsOnlyAsyncClient.send": "Type.Union.EnumsOnly.send", + "com.type.union.EnumsOnlyAsyncClient.sendWithResponse": "Type.Union.EnumsOnly.send", + "com.type.union.EnumsOnlyClient": "null", + "com.type.union.EnumsOnlyClient.get": "Type.Union.EnumsOnly.get", + "com.type.union.EnumsOnlyClient.getWithResponse": "Type.Union.EnumsOnly.get", + "com.type.union.EnumsOnlyClient.send": "Type.Union.EnumsOnly.send", + "com.type.union.EnumsOnlyClient.sendWithResponse": "Type.Union.EnumsOnly.send", + "com.type.union.FloatsOnlyAsyncClient": "null", + "com.type.union.FloatsOnlyAsyncClient.get": "Type.Union.FloatsOnly.get", + "com.type.union.FloatsOnlyAsyncClient.getWithResponse": "Type.Union.FloatsOnly.get", + "com.type.union.FloatsOnlyAsyncClient.send": "Type.Union.FloatsOnly.send", + "com.type.union.FloatsOnlyAsyncClient.sendWithResponse": "Type.Union.FloatsOnly.send", + "com.type.union.FloatsOnlyClient": "null", + "com.type.union.FloatsOnlyClient.get": "Type.Union.FloatsOnly.get", + "com.type.union.FloatsOnlyClient.getWithResponse": "Type.Union.FloatsOnly.get", + "com.type.union.FloatsOnlyClient.send": "Type.Union.FloatsOnly.send", + "com.type.union.FloatsOnlyClient.sendWithResponse": "Type.Union.FloatsOnly.send", + "com.type.union.IntsOnlyAsyncClient": "null", + "com.type.union.IntsOnlyAsyncClient.get": "Type.Union.IntsOnly.get", + "com.type.union.IntsOnlyAsyncClient.getWithResponse": "Type.Union.IntsOnly.get", + "com.type.union.IntsOnlyAsyncClient.send": "Type.Union.IntsOnly.send", + "com.type.union.IntsOnlyAsyncClient.sendWithResponse": "Type.Union.IntsOnly.send", + "com.type.union.IntsOnlyClient": "null", + "com.type.union.IntsOnlyClient.get": "Type.Union.IntsOnly.get", + "com.type.union.IntsOnlyClient.getWithResponse": "Type.Union.IntsOnly.get", + "com.type.union.IntsOnlyClient.send": "Type.Union.IntsOnly.send", + "com.type.union.IntsOnlyClient.sendWithResponse": "Type.Union.IntsOnly.send", + "com.type.union.MixedLiteralsAsyncClient": "null", + "com.type.union.MixedLiteralsAsyncClient.get": "Type.Union.MixedLiterals.get", + "com.type.union.MixedLiteralsAsyncClient.getWithResponse": "Type.Union.MixedLiterals.get", + "com.type.union.MixedLiteralsAsyncClient.send": "Type.Union.MixedLiterals.send", + "com.type.union.MixedLiteralsAsyncClient.sendWithResponse": "Type.Union.MixedLiterals.send", + "com.type.union.MixedLiteralsClient": "null", + "com.type.union.MixedLiteralsClient.get": "Type.Union.MixedLiterals.get", + "com.type.union.MixedLiteralsClient.getWithResponse": "Type.Union.MixedLiterals.get", + "com.type.union.MixedLiteralsClient.send": "Type.Union.MixedLiterals.send", + "com.type.union.MixedLiteralsClient.sendWithResponse": "Type.Union.MixedLiterals.send", + "com.type.union.MixedTypesAsyncClient": "null", + "com.type.union.MixedTypesAsyncClient.get": "Type.Union.MixedTypes.get", + "com.type.union.MixedTypesAsyncClient.getWithResponse": "Type.Union.MixedTypes.get", + "com.type.union.MixedTypesAsyncClient.send": "Type.Union.MixedTypes.send", + "com.type.union.MixedTypesAsyncClient.sendWithResponse": "Type.Union.MixedTypes.send", + "com.type.union.MixedTypesClient": "null", + "com.type.union.MixedTypesClient.get": "Type.Union.MixedTypes.get", + "com.type.union.MixedTypesClient.getWithResponse": "Type.Union.MixedTypes.get", + "com.type.union.MixedTypesClient.send": "Type.Union.MixedTypes.send", + "com.type.union.MixedTypesClient.sendWithResponse": "Type.Union.MixedTypes.send", + "com.type.union.ModelsOnlyAsyncClient": "null", + "com.type.union.ModelsOnlyAsyncClient.get": "Type.Union.ModelsOnly.get", + "com.type.union.ModelsOnlyAsyncClient.getWithResponse": "Type.Union.ModelsOnly.get", + "com.type.union.ModelsOnlyAsyncClient.send": "Type.Union.ModelsOnly.send", + "com.type.union.ModelsOnlyAsyncClient.sendWithResponse": "Type.Union.ModelsOnly.send", + "com.type.union.ModelsOnlyClient": "null", + "com.type.union.ModelsOnlyClient.get": "Type.Union.ModelsOnly.get", + "com.type.union.ModelsOnlyClient.getWithResponse": "Type.Union.ModelsOnly.get", + "com.type.union.ModelsOnlyClient.send": "Type.Union.ModelsOnly.send", + "com.type.union.ModelsOnlyClient.sendWithResponse": "Type.Union.ModelsOnly.send", + "com.type.union.StringAndArrayAsyncClient": "null", + "com.type.union.StringAndArrayAsyncClient.get": "Type.Union.StringAndArray.get", + "com.type.union.StringAndArrayAsyncClient.getWithResponse": "Type.Union.StringAndArray.get", + "com.type.union.StringAndArrayAsyncClient.send": "Type.Union.StringAndArray.send", + "com.type.union.StringAndArrayAsyncClient.sendWithResponse": "Type.Union.StringAndArray.send", + "com.type.union.StringAndArrayClient": "null", + "com.type.union.StringAndArrayClient.get": "Type.Union.StringAndArray.get", + "com.type.union.StringAndArrayClient.getWithResponse": "Type.Union.StringAndArray.get", + "com.type.union.StringAndArrayClient.send": "Type.Union.StringAndArray.send", + "com.type.union.StringAndArrayClient.sendWithResponse": "Type.Union.StringAndArray.send", + "com.type.union.StringExtensibleAsyncClient": "null", + "com.type.union.StringExtensibleAsyncClient.get": "Type.Union.StringExtensible.get", + "com.type.union.StringExtensibleAsyncClient.getWithResponse": "Type.Union.StringExtensible.get", + "com.type.union.StringExtensibleAsyncClient.send": "Type.Union.StringExtensible.send", + "com.type.union.StringExtensibleAsyncClient.sendWithResponse": "Type.Union.StringExtensible.send", + "com.type.union.StringExtensibleClient": "null", + "com.type.union.StringExtensibleClient.get": "Type.Union.StringExtensible.get", + "com.type.union.StringExtensibleClient.getWithResponse": "Type.Union.StringExtensible.get", + "com.type.union.StringExtensibleClient.send": "Type.Union.StringExtensible.send", + "com.type.union.StringExtensibleClient.sendWithResponse": "Type.Union.StringExtensible.send", + "com.type.union.StringExtensibleNamedAsyncClient": "null", + "com.type.union.StringExtensibleNamedAsyncClient.get": "Type.Union.StringExtensibleNamed.get", + "com.type.union.StringExtensibleNamedAsyncClient.getWithResponse": "Type.Union.StringExtensibleNamed.get", + "com.type.union.StringExtensibleNamedAsyncClient.send": "Type.Union.StringExtensibleNamed.send", + "com.type.union.StringExtensibleNamedAsyncClient.sendWithResponse": "Type.Union.StringExtensibleNamed.send", + "com.type.union.StringExtensibleNamedClient": "null", + "com.type.union.StringExtensibleNamedClient.get": "Type.Union.StringExtensibleNamed.get", + "com.type.union.StringExtensibleNamedClient.getWithResponse": "Type.Union.StringExtensibleNamed.get", + "com.type.union.StringExtensibleNamedClient.send": "Type.Union.StringExtensibleNamed.send", + "com.type.union.StringExtensibleNamedClient.sendWithResponse": "Type.Union.StringExtensibleNamed.send", + "com.type.union.StringsOnlyAsyncClient": "null", + "com.type.union.StringsOnlyAsyncClient.get": "Type.Union.StringsOnly.get", + "com.type.union.StringsOnlyAsyncClient.getWithResponse": "Type.Union.StringsOnly.get", + "com.type.union.StringsOnlyAsyncClient.send": "Type.Union.StringsOnly.send", + "com.type.union.StringsOnlyAsyncClient.sendWithResponse": "Type.Union.StringsOnly.send", + "com.type.union.StringsOnlyClient": "null", + "com.type.union.StringsOnlyClient.get": "Type.Union.StringsOnly.get", + "com.type.union.StringsOnlyClient.getWithResponse": "Type.Union.StringsOnly.get", + "com.type.union.StringsOnlyClient.send": "Type.Union.StringsOnly.send", + "com.type.union.StringsOnlyClient.sendWithResponse": "Type.Union.StringsOnly.send", + "com.type.union.UnionClientBuilder": "Type.Union", + "com.type.union.implementation.models.SendRequest": "Type.Union.send.Request.anonymous", + "com.type.union.implementation.models.SendRequest1": "Type.Union.send.Request.anonymous", + "com.type.union.implementation.models.SendRequest2": "Type.Union.send.Request.anonymous", + "com.type.union.implementation.models.SendRequest3": "Type.Union.send.Request.anonymous", + "com.type.union.implementation.models.SendRequest4": "Type.Union.send.Request.anonymous", + "com.type.union.implementation.models.SendRequest5": "Type.Union.send.Request.anonymous", + "com.type.union.implementation.models.SendRequest6": "Type.Union.send.Request.anonymous", + "com.type.union.implementation.models.SendRequest7": "Type.Union.send.Request.anonymous", + "com.type.union.implementation.models.SendRequest8": "Type.Union.send.Request.anonymous", + "com.type.union.implementation.models.SendRequest9": "Type.Union.send.Request.anonymous", + "com.type.union.models.Cat": "Type.Union.Cat", + "com.type.union.models.Dog": "Type.Union.Dog", + "com.type.union.models.EnumsOnlyCases": "Type.Union.EnumsOnlyCases", + "com.type.union.models.EnumsOnlyCasesLr": "EnumsOnlyCases.lr.anonymous", + "com.type.union.models.EnumsOnlyCasesUd": "EnumsOnlyCases.ud.anonymous", + "com.type.union.models.GetResponse": "Type.Union.get.Response.anonymous", + "com.type.union.models.GetResponse1": "Type.Union.get.Response.anonymous", + "com.type.union.models.GetResponse2": "Type.Union.get.Response.anonymous", + "com.type.union.models.GetResponse3": "Type.Union.get.Response.anonymous", + "com.type.union.models.GetResponse4": "Type.Union.get.Response.anonymous", + "com.type.union.models.GetResponse5": "Type.Union.get.Response.anonymous", + "com.type.union.models.GetResponse6": "Type.Union.get.Response.anonymous", + "com.type.union.models.GetResponse7": "Type.Union.get.Response.anonymous", + "com.type.union.models.GetResponse8": "Type.Union.get.Response.anonymous", + "com.type.union.models.GetResponse9": "Type.Union.get.Response.anonymous", + "com.type.union.models.GetResponseProp1": "get.Response.prop.anonymous", + "com.type.union.models.GetResponseProp2": "get.Response.prop.anonymous", + "com.type.union.models.GetResponseProp3": "get.Response.prop.anonymous", + "com.type.union.models.GetResponseProp4": "get.Response.prop.anonymous", + "com.type.union.models.MixedLiteralsCases": "Type.Union.MixedLiteralsCases", + "com.type.union.models.MixedTypesCases": "Type.Union.MixedTypesCases", + "com.type.union.models.StringAndArrayCases": "Type.Union.StringAndArrayCases", + "com.type.union.models.StringExtensibleNamedUnion": "Type.Union.StringExtensibleNamedUnion" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-added_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-added_apiview_properties.json new file mode 100644 index 000000000..0afb18e2d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-added_apiview_properties.json @@ -0,0 +1,26 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.versioning.added.AddedAsyncClient": "Versioning.Added", + "com.versioning.added.AddedAsyncClient.v1": "Versioning.Added.v1", + "com.versioning.added.AddedAsyncClient.v1WithResponse": "Versioning.Added.v1", + "com.versioning.added.AddedAsyncClient.v2": "Versioning.Added.v2", + "com.versioning.added.AddedAsyncClient.v2WithResponse": "Versioning.Added.v2", + "com.versioning.added.AddedClient": "Versioning.Added", + "com.versioning.added.AddedClient.v1": "Versioning.Added.v1", + "com.versioning.added.AddedClient.v1WithResponse": "Versioning.Added.v1", + "com.versioning.added.AddedClient.v2": "Versioning.Added.v2", + "com.versioning.added.AddedClient.v2WithResponse": "Versioning.Added.v2", + "com.versioning.added.AddedClientBuilder": "Versioning.Added", + "com.versioning.added.InterfaceV2AsyncClient": "null", + "com.versioning.added.InterfaceV2AsyncClient.v2InInterface": "Versioning.Added.InterfaceV2.v2InInterface", + "com.versioning.added.InterfaceV2AsyncClient.v2InInterfaceWithResponse": "Versioning.Added.InterfaceV2.v2InInterface", + "com.versioning.added.InterfaceV2Client": "null", + "com.versioning.added.InterfaceV2Client.v2InInterface": "Versioning.Added.InterfaceV2.v2InInterface", + "com.versioning.added.InterfaceV2Client.v2InInterfaceWithResponse": "Versioning.Added.InterfaceV2.v2InInterface", + "com.versioning.added.models.EnumV1": "Versioning.Added.EnumV1", + "com.versioning.added.models.EnumV2": "Versioning.Added.EnumV2", + "com.versioning.added.models.ModelV1": "Versioning.Added.ModelV1", + "com.versioning.added.models.ModelV2": "Versioning.Added.ModelV2" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-madeoptional_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-madeoptional_apiview_properties.json new file mode 100644 index 000000000..cc95129da --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-madeoptional_apiview_properties.json @@ -0,0 +1,13 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.versioning.madeoptional.MadeOptionalAsyncClient": "Versioning.MadeOptional", + "com.versioning.madeoptional.MadeOptionalAsyncClient.test": "Versioning.MadeOptional.test", + "com.versioning.madeoptional.MadeOptionalAsyncClient.testWithResponse": "Versioning.MadeOptional.test", + "com.versioning.madeoptional.MadeOptionalClient": "Versioning.MadeOptional", + "com.versioning.madeoptional.MadeOptionalClient.test": "Versioning.MadeOptional.test", + "com.versioning.madeoptional.MadeOptionalClient.testWithResponse": "Versioning.MadeOptional.test", + "com.versioning.madeoptional.MadeOptionalClientBuilder": "Versioning.MadeOptional", + "com.versioning.madeoptional.models.TestModel": "Versioning.MadeOptional.TestModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-removed_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-removed_apiview_properties.json new file mode 100644 index 000000000..c6688917d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-removed_apiview_properties.json @@ -0,0 +1,14 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.versioning.removed.RemovedAsyncClient": "Versioning.Removed", + "com.versioning.removed.RemovedAsyncClient.v2": "Versioning.Removed.v2", + "com.versioning.removed.RemovedAsyncClient.v2WithResponse": "Versioning.Removed.v2", + "com.versioning.removed.RemovedClient": "Versioning.Removed", + "com.versioning.removed.RemovedClient.v2": "Versioning.Removed.v2", + "com.versioning.removed.RemovedClient.v2WithResponse": "Versioning.Removed.v2", + "com.versioning.removed.RemovedClientBuilder": "Versioning.Removed", + "com.versioning.removed.models.EnumV2": "Versioning.Removed.EnumV2", + "com.versioning.removed.models.ModelV2": "Versioning.Removed.ModelV2" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-renamedfrom_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-renamedfrom_apiview_properties.json new file mode 100644 index 000000000..1c7f61734 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-renamedfrom_apiview_properties.json @@ -0,0 +1,20 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.versioning.renamedfrom.NewInterfaceAsyncClient": "null", + "com.versioning.renamedfrom.NewInterfaceAsyncClient.newOpInNewInterface": "Versioning.RenamedFrom.NewInterface.newOpInNewInterface", + "com.versioning.renamedfrom.NewInterfaceAsyncClient.newOpInNewInterfaceWithResponse": "Versioning.RenamedFrom.NewInterface.newOpInNewInterface", + "com.versioning.renamedfrom.NewInterfaceClient": "null", + "com.versioning.renamedfrom.NewInterfaceClient.newOpInNewInterface": "Versioning.RenamedFrom.NewInterface.newOpInNewInterface", + "com.versioning.renamedfrom.NewInterfaceClient.newOpInNewInterfaceWithResponse": "Versioning.RenamedFrom.NewInterface.newOpInNewInterface", + "com.versioning.renamedfrom.RenamedFromAsyncClient": "Versioning.RenamedFrom", + "com.versioning.renamedfrom.RenamedFromAsyncClient.newOp": "Versioning.RenamedFrom.newOp", + "com.versioning.renamedfrom.RenamedFromAsyncClient.newOpWithResponse": "Versioning.RenamedFrom.newOp", + "com.versioning.renamedfrom.RenamedFromClient": "Versioning.RenamedFrom", + "com.versioning.renamedfrom.RenamedFromClient.newOp": "Versioning.RenamedFrom.newOp", + "com.versioning.renamedfrom.RenamedFromClient.newOpWithResponse": "Versioning.RenamedFrom.newOp", + "com.versioning.renamedfrom.RenamedFromClientBuilder": "Versioning.RenamedFrom", + "com.versioning.renamedfrom.models.NewEnum": "Versioning.RenamedFrom.NewEnum", + "com.versioning.renamedfrom.models.NewModel": "Versioning.RenamedFrom.NewModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-returntypechangedfrom_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-returntypechangedfrom_apiview_properties.json new file mode 100644 index 000000000..9a45354e8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-returntypechangedfrom_apiview_properties.json @@ -0,0 +1,12 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.versioning.returntypechangedfrom.ReturnTypeChangedFromAsyncClient": "Versioning.ReturnTypeChangedFrom", + "com.versioning.returntypechangedfrom.ReturnTypeChangedFromAsyncClient.test": "Versioning.ReturnTypeChangedFrom.test", + "com.versioning.returntypechangedfrom.ReturnTypeChangedFromAsyncClient.testWithResponse": "Versioning.ReturnTypeChangedFrom.test", + "com.versioning.returntypechangedfrom.ReturnTypeChangedFromClient": "Versioning.ReturnTypeChangedFrom", + "com.versioning.returntypechangedfrom.ReturnTypeChangedFromClient.test": "Versioning.ReturnTypeChangedFrom.test", + "com.versioning.returntypechangedfrom.ReturnTypeChangedFromClient.testWithResponse": "Versioning.ReturnTypeChangedFrom.test", + "com.versioning.returntypechangedfrom.ReturnTypeChangedFromClientBuilder": "Versioning.ReturnTypeChangedFrom" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-typechangedfrom_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-typechangedfrom_apiview_properties.json new file mode 100644 index 000000000..8b27e3691 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/versioning-typechangedfrom_apiview_properties.json @@ -0,0 +1,13 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.versioning.typechangedfrom.TypeChangedFromAsyncClient": "Versioning.TypeChangedFrom", + "com.versioning.typechangedfrom.TypeChangedFromAsyncClient.test": "Versioning.TypeChangedFrom.test", + "com.versioning.typechangedfrom.TypeChangedFromAsyncClient.testWithResponse": "Versioning.TypeChangedFrom.test", + "com.versioning.typechangedfrom.TypeChangedFromClient": "Versioning.TypeChangedFrom", + "com.versioning.typechangedfrom.TypeChangedFromClient.test": "Versioning.TypeChangedFrom.test", + "com.versioning.typechangedfrom.TypeChangedFromClient.testWithResponse": "Versioning.TypeChangedFrom.test", + "com.versioning.typechangedfrom.TypeChangedFromClientBuilder": "Versioning.TypeChangedFrom", + "com.versioning.typechangedfrom.models.TestModel": "Versioning.TypeChangedFrom.TestModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-clientgenerator-core-access.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-clientgenerator-core-access.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-clientgenerator-core-access.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-clientgenerator-core-usage.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-clientgenerator-core-usage.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-clientgenerator-core-usage.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-basic.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-basic.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-basic.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-lro-rpc.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-lro-rpc.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-lro-rpc.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-lro-standard.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-lro-standard.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-lro-standard.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-model.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-model.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-model.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-page.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-page.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-page.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-scalar.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-scalar.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-scalar.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-traits.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-traits.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-core-traits.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-example-basic.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-example-basic.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/_specs_-azure-example-basic.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/authentication-apikey.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/authentication-apikey.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/authentication-apikey.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/authentication-http-custom.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/authentication-http-custom.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/authentication-http-custom.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/authentication-oauth2.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/authentication-oauth2.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/authentication-oauth2.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/authentication-union.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/authentication-union.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/authentication-union.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-specialheaders-xmsclientrequestid.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-specialheaders-xmsclientrequestid.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-specialheaders-xmsclientrequestid.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-builtin.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-builtin.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-builtin.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-enumservice.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-enumservice.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-enumservice.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-errormodel.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-errormodel.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-errormodel.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-flatten.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-flatten.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-flatten.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-internal.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-internal.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-internal.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-literalservice.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-literalservice.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-literalservice.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-longrunning.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-longrunning.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-longrunning.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-model.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-model.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-model.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-multicontenttypes.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-multicontenttypes.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-multicontenttypes.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-multipart.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-multipart.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-multipart.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-multipleapiversion.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-multipleapiversion.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-multipleapiversion.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-naming.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-naming.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-naming.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-optional.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-optional.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-optional.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-patch.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-patch.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-patch.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-protocolandconvenient.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-protocolandconvenient.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-protocolandconvenient.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-response.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-response.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-response.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-server.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-server.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-server.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-specialchars.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-specialchars.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-specialchars.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-specialheaders.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-specialheaders.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-specialheaders.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-union.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-union.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-union.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-versioning.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-versioning.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-versioning.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-visibility.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-visibility.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-visibility.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-wiretype.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-wiretype.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-wiretype.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/client-naming.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/client-naming.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/client-naming.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/client-structure-service.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/client-structure-service.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/client-structure-service.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/encode-bytes.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/encode-bytes.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/encode-bytes.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/encode-datetime.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/encode-datetime.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/encode-datetime.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/encode-duration.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/encode-duration.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/encode-duration.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-basic.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-basic.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-basic.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-bodyoptionality.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-bodyoptionality.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-bodyoptionality.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-collectionformat.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-collectionformat.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-collectionformat.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-spread.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-spread.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/parameters-spread.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-contentnegotiation.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-contentnegotiation.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-contentnegotiation.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-jsonmergepatch.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-jsonmergepatch.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-jsonmergepatch.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-mediatype.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-mediatype.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-mediatype.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-multipart.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-multipart.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-multipart.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-pageable.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-pageable.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/payload-pageable.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/resiliency-servicedriven-v1.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/resiliency-servicedriven-v1.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/resiliency-servicedriven-v1.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/resiliency-servicedriven.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/resiliency-servicedriven.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/resiliency-servicedriven.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/serialization-encodedname-json.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/serialization-encodedname-json.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/serialization-encodedname-json.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-endpoint-notdefined.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-endpoint-notdefined.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-endpoint-notdefined.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-path-multiple.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-path-multiple.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-path-multiple.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-path-single.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-path-single.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-path-single.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-versions-notversioned.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-versions-notversioned.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-versions-notversioned.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-versions-versioned.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-versions-versioned.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/server-versions-versioned.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/specialheaders-conditionalrequest.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/specialheaders-conditionalrequest.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/specialheaders-conditionalrequest.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/specialheaders-repeatability.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/specialheaders-repeatability.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/specialheaders-repeatability.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/specialwords.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/specialwords.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/specialwords.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-array.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-array.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-array.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-dictionary.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-dictionary.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-dictionary.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-enums-extensible.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-enums-extensible.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-enums-extensible.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-enums-fixed.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-enums-fixed.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-enums-fixed.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-empty.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-empty.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-empty.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-flatten.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-flatten.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-flatten.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-enumdiscriminator.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-enumdiscriminator.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-enumdiscriminator.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-enumnesteddiscriminator.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-enumnesteddiscriminator.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-enumnesteddiscriminator.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-nesteddiscriminator.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-nesteddiscriminator.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-nesteddiscriminator.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-notdiscriminated.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-notdiscriminated.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-notdiscriminated.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-recursive.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-recursive.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-recursive.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-singlediscriminator.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-singlediscriminator.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-inheritance-singlediscriminator.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-usage.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-usage.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-usage.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-visibility.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-visibility.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-model-visibility.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-property-additionalproperties.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-property-additionalproperties.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-property-additionalproperties.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-property-nullable.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-property-nullable.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-property-nullable.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-property-optional.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-property-optional.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-property-optional.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-property-valuetypes.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-property-valuetypes.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-property-valuetypes.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-scalar.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-scalar.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-scalar.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-union.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-union.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/type-union.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-added.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-added.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-added.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-madeoptional.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-madeoptional.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-madeoptional.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-removed.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-removed.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-removed.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-renamedfrom.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-renamedfrom.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-renamedfrom.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-returntypechangedfrom.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-returntypechangedfrom.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-returntypechangedfrom.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-typechangedfrom.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-typechangedfrom.properties new file mode 100644 index 000000000..ca812989b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/versioning-typechangedfrom.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/_specs_/azure/example/basic/generated/BasicAction.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/_specs_/azure/example/basic/generated/BasicAction.java new file mode 100644 index 000000000..5764a952f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/_specs_/azure/example/basic/generated/BasicAction.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.example.basic.generated; + +import com._specs_.azure.example.basic.AzureExampleClient; +import com._specs_.azure.example.basic.AzureExampleClientBuilder; +import com._specs_.azure.example.basic.models.ActionRequest; +import com._specs_.azure.example.basic.models.ActionResponse; +import com._specs_.azure.example.basic.models.Enum; +import com._specs_.azure.example.basic.models.Model; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +public class BasicAction { + public static void main(String[] args) { + AzureExampleClient azureExampleClient + = new AzureExampleClientBuilder().endpoint("http://localhost:3000").buildClient(); + // BEGIN:com._specs_.azure.example.basic.generated.basicaction.basicaction + ActionResponse response = azureExampleClient.basicAction("query", "header", + new ActionRequest("text") + .setModelProperty( + new Model().setInt32Property(1).setFloat32Property(1.5D).setEnumProperty(Enum.ENUM_VALUE1)) + .setArrayProperty(Arrays.asList("item")) + .setRecordProperty(mapOf("record", "value"))); + // END:com._specs_.azure.example.basic.generated.basicaction.basicaction + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/builtin/generated/BuiltinOpRead.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/builtin/generated/BuiltinOpRead.java new file mode 100644 index 000000000..b6e217eb1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/builtin/generated/BuiltinOpRead.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.builtin.generated; + +import com.azure.core.util.Configuration; +import com.cadl.builtin.BuiltinClient; +import com.cadl.builtin.BuiltinClientBuilder; +import com.cadl.builtin.models.Builtin; + +public class BuiltinOpRead { + public static void main(String[] args) { + BuiltinClient builtinClient + = new BuiltinClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")).buildClient(); + // BEGIN:com.cadl.builtin.generated.builtinopread.builtinopread + Builtin response = builtinClient.read(null, null, null, "myFilter", null, null); + // END:com.cadl.builtin.generated.builtinopread.builtinopread + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/flatten/generated/FlattenOpSend.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/flatten/generated/FlattenOpSend.java new file mode 100644 index 000000000..599899249 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/flatten/generated/FlattenOpSend.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.generated; + +import com.azure.core.util.Configuration; +import com.cadl.flatten.FlattenClient; +import com.cadl.flatten.FlattenClientBuilder; +import com.cadl.flatten.models.User; + +public class FlattenOpSend { + public static void main(String[] args) { + FlattenClient flattenClient + = new FlattenClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")).buildClient(); + // BEGIN:com.cadl.flatten.generated.send.flattenopsend + flattenClient.send("myRequiredId", "myRequiredInput", new User("myOptionalUser")); + // END:com.cadl.flatten.generated.send.flattenopsend + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/flatten/generated/FlattenOpSendLong.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/flatten/generated/FlattenOpSendLong.java new file mode 100644 index 000000000..6b6fbdc40 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/flatten/generated/FlattenOpSendLong.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.generated; + +import com.azure.core.util.Configuration; +import com.cadl.flatten.FlattenClient; +import com.cadl.flatten.FlattenClientBuilder; +import com.cadl.flatten.models.SendLongOptions; +import com.cadl.flatten.models.SendLongRequestStatus; +import com.cadl.flatten.models.User; + +public class FlattenOpSendLong { + public static void main(String[] args) { + FlattenClient flattenClient + = new FlattenClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")).buildClient(); + // BEGIN:com.cadl.flatten.generated.sendlong.flattenopsendlong + flattenClient.sendLong( + new SendLongOptions("myRequiredId", "myRequiredInput", 11, "title", SendLongRequestStatus.NOT_STARTED) + .setFilter("name=myName") + .setUser(new User("myOptionalUser")) + .setDataIntOptional(12) + .setDataLong(13L) + .setDataFloat(14.0D) + .setDescription("description")); + // END:com.cadl.flatten.generated.sendlong.flattenopsendlong + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/longrunning/generated/LongRunningCreateJob.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/longrunning/generated/LongRunningCreateJob.java new file mode 100644 index 000000000..541ca15df --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/longrunning/generated/LongRunningCreateJob.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning.generated; + +import com.azure.core.util.Configuration; +import com.azure.core.util.polling.SyncPoller; +import com.cadl.longrunning.LongRunningClient; +import com.cadl.longrunning.LongRunningClientBuilder; +import com.cadl.longrunning.models.JobData; +import com.cadl.longrunning.models.JobResult; +import com.cadl.longrunning.models.JobResultResult; +import java.util.HashMap; +import java.util.Map; + +public class LongRunningCreateJob { + public static void main(String[] args) { + LongRunningClient longRunningClient + = new LongRunningClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.cadl.longrunning.generated.createjob.longrunningcreatejob + SyncPoller response = longRunningClient + .beginCreateJob(new JobData(mapOf("max", 15.0D, "min", 14.0D, "average", 14.3D)).setConfiguration("{}")); + // END:com.cadl.longrunning.generated.createjob.longrunningcreatejob + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/model/generated/ModelOpPutNested.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/model/generated/ModelOpPutNested.java new file mode 100644 index 000000000..6cef02515 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/model/generated/ModelOpPutNested.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.generated; + +import com.azure.core.util.Configuration; +import com.cadl.model.ModelClient; +import com.cadl.model.ModelClientBuilder; +import com.cadl.model.models.NestedModel; + +public class ModelOpPutNested { + public static void main(String[] args) { + ModelClient modelClient + = new ModelClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")).buildClient(); + // BEGIN:com.cadl.model.generated.modelopputnested.modelopputnested + NestedModel response = modelClient.putNested(null); + // END:com.cadl.model.generated.modelopputnested.modelopputnested + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/multicontenttypes/generated/SingleContentTypeUploadImageForSingleContentType.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/multicontenttypes/generated/SingleContentTypeUploadImageForSingleContentType.java new file mode 100644 index 000000000..60913555b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/multicontenttypes/generated/SingleContentTypeUploadImageForSingleContentType.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes.generated; + +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.cadl.multicontenttypes.MultiContentTypesClientBuilder; +import com.cadl.multicontenttypes.SingleContentTypeClient; +import java.nio.charset.StandardCharsets; + +public class SingleContentTypeUploadImageForSingleContentType { + public static void main(String[] args) { + SingleContentTypeClient singleContentTypeClient + = new MultiContentTypesClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildSingleContentTypeClient(); + // BEGIN:com.cadl.multicontenttypes.generated.singlecontenttypeuploadimageforsinglecontenttype.singlecontenttypeuploadimageforsinglecontenttype + singleContentTypeClient.uploadImageForSingleContentType( + BinaryData.fromBytes("\"D:\\Program Files\"".getBytes(StandardCharsets.UTF_8))); + // END:com.cadl.multicontenttypes.generated.singlecontenttypeuploadimageforsinglecontenttype.singlecontenttypeuploadimageforsinglecontenttype + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/response/generated/ResponseOpExists.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/response/generated/ResponseOpExists.java new file mode 100644 index 000000000..1be44c77c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/response/generated/ResponseOpExists.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response.generated; + +import com.azure.core.util.Configuration; +import com.cadl.response.ResponseClient; +import com.cadl.response.ResponseClientBuilder; + +public class ResponseOpExists { + public static void main(String[] args) { + ResponseClient responseClient + = new ResponseClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.cadl.response.generated.exists.responseopexists + boolean response = responseClient.exists(); + // END:com.cadl.response.generated.exists.responseopexists + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/response/generated/ResponseOpListStrings.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/response/generated/ResponseOpListStrings.java new file mode 100644 index 000000000..cf41d8eec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/response/generated/ResponseOpListStrings.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response.generated; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.cadl.response.ResponseClient; +import com.cadl.response.ResponseClientBuilder; + +public class ResponseOpListStrings { + public static void main(String[] args) { + ResponseClient responseClient + = new ResponseClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.cadl.response.generated.liststrings.responseopliststrings + PagedIterable response = responseClient.listStrings(); + // END:com.cadl.response.generated.liststrings.responseopliststrings + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/specialchars/generated/BuiltinOpRead.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/specialchars/generated/BuiltinOpRead.java new file mode 100644 index 000000000..30d198db4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/specialchars/generated/BuiltinOpRead.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialchars.generated; + +import com.azure.core.util.Configuration; +import com.cadl.specialchars.SpecialCharsClient; +import com.cadl.specialchars.SpecialCharsClientBuilder; +import com.cadl.specialchars.models.Resource; + +public class BuiltinOpRead { + public static void main(String[] args) { + SpecialCharsClient specialCharsClient + = new SpecialCharsClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.cadl.specialchars.generated.builtinopread.builtinopread + Resource response = specialCharsClient.read(null); + // END:com.cadl.specialchars.generated.builtinopread.builtinopread + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/specialheaders/generated/EtagHeadersListWithEtag.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/specialheaders/generated/EtagHeadersListWithEtag.java new file mode 100644 index 000000000..08a311263 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/specialheaders/generated/EtagHeadersListWithEtag.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.generated; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.cadl.specialheaders.EtagHeadersClient; +import com.cadl.specialheaders.SpecialHeadersClientBuilder; +import com.cadl.specialheaders.models.Resource; + +public class EtagHeadersListWithEtag { + public static void main(String[] args) { + EtagHeadersClient etagHeadersClient + = new SpecialHeadersClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildEtagHeadersClient(); + // BEGIN:com.cadl.specialheaders.generated.etagheaderslistwithetag.etagheaderslistwithetag + PagedIterable response = etagHeadersClient.listWithEtag(); + // END:com.cadl.specialheaders.generated.etagheaderslistwithetag.etagheaderslistwithetag + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/specialheaders/generated/EtagHeadersPutWithRequestHeaders.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/specialheaders/generated/EtagHeadersPutWithRequestHeaders.java new file mode 100644 index 000000000..472b5bc41 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/specialheaders/generated/EtagHeadersPutWithRequestHeaders.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.generated; + +import com.azure.core.http.RequestConditions; +import com.azure.core.util.Configuration; +import com.cadl.specialheaders.EtagHeadersClient; +import com.cadl.specialheaders.SpecialHeadersClientBuilder; +import com.cadl.specialheaders.models.Resource; + +public class EtagHeadersPutWithRequestHeaders { + public static void main(String[] args) { + EtagHeadersClient etagHeadersClient + = new SpecialHeadersClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildEtagHeadersClient(); + // BEGIN:com.cadl.specialheaders.generated.etagheadersputwithrequestheaders.etagheadersputwithrequestheaders + Resource response = etagHeadersClient.putWithRequestHeaders("name", + new Resource().setDescription("This is sample for Etag headers").setType("myType"), + new RequestConditions().setIfMatch("\"64e005\"")); + // END:com.cadl.specialheaders.generated.etagheadersputwithrequestheaders.etagheadersputwithrequestheaders + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/versioning/generated/VersioningOpList.java b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/versioning/generated/VersioningOpList.java new file mode 100644 index 000000000..9bd3bcb14 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/samples/java/com/cadl/versioning/generated/VersioningOpList.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning.generated; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.cadl.versioning.VersioningClient; +import com.cadl.versioning.VersioningClientBuilder; +import com.cadl.versioning.models.Resource; +import java.util.Arrays; + +public class VersioningOpList { + public static void main(String[] args) { + VersioningClient versioningClient + = new VersioningClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.cadl.versioning.generated.versioningoplist.versioningoplist + PagedIterable response = versioningClient.list(Arrays.asList("name=name"), null); + // END:com.cadl.versioning.generated.versioningoplist.versioningoplist + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/clientgenerator/core/access/generated/AccessClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/clientgenerator/core/access/generated/AccessClientTestBase.java new file mode 100644 index 000000000..6d967d662 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/clientgenerator/core/access/generated/AccessClientTestBase.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.access.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._specs_.azure.clientgenerator.core.access.AccessClientBuilder; +import com._specs_.azure.clientgenerator.core.access.InternalOperationClient; +import com._specs_.azure.clientgenerator.core.access.PublicOperationClient; +import com._specs_.azure.clientgenerator.core.access.RelativeModelInOperationClient; +import com._specs_.azure.clientgenerator.core.access.SharedModelInOperationClient; +import com.azure.core.http.HttpClient; +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; + +class AccessClientTestBase extends TestProxyTestBase { + protected PublicOperationClient publicOperationClient; + + protected InternalOperationClient internalOperationClient; + + protected SharedModelInOperationClient sharedModelInOperationClient; + + protected RelativeModelInOperationClient relativeModelInOperationClient; + + @Override + protected void beforeTest() { + AccessClientBuilder publicOperationClientbuilder = new AccessClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + publicOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + publicOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + publicOperationClient = publicOperationClientbuilder.buildPublicOperationClient(); + + AccessClientBuilder internalOperationClientbuilder = new AccessClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + internalOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + internalOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + internalOperationClient = internalOperationClientbuilder.buildInternalOperationClient(); + + AccessClientBuilder sharedModelInOperationClientbuilder = new AccessClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + sharedModelInOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + sharedModelInOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + sharedModelInOperationClient = sharedModelInOperationClientbuilder.buildSharedModelInOperationClient(); + + AccessClientBuilder relativeModelInOperationClientbuilder = new AccessClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + relativeModelInOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + relativeModelInOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + relativeModelInOperationClient = relativeModelInOperationClientbuilder.buildRelativeModelInOperationClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/clientgenerator/core/usage/generated/UsageClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/clientgenerator/core/usage/generated/UsageClientTestBase.java new file mode 100644 index 000000000..4e2c739eb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/clientgenerator/core/usage/generated/UsageClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.clientgenerator.core.usage.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._specs_.azure.clientgenerator.core.usage.UsageClient; +import com._specs_.azure.clientgenerator.core.usage.UsageClientBuilder; +import com.azure.core.http.HttpClient; +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; + +class UsageClientTestBase extends TestProxyTestBase { + protected UsageClient usageClient; + + @Override + protected void beforeTest() { + UsageClientBuilder usageClientbuilder = new UsageClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + usageClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + usageClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + usageClient = usageClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/basic/generated/BasicClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/basic/generated/BasicClientTestBase.java new file mode 100644 index 000000000..6451d16c1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/basic/generated/BasicClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.basic.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._specs_.azure.core.basic.BasicClient; +import com._specs_.azure.core.basic.BasicClientBuilder; +import com.azure.core.http.HttpClient; +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; + +class BasicClientTestBase extends TestProxyTestBase { + protected BasicClient basicClient; + + @Override + protected void beforeTest() { + BasicClientBuilder basicClientbuilder = new BasicClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + basicClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + basicClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + basicClient = basicClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/lro/rpc/generated/RpcClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/lro/rpc/generated/RpcClientTestBase.java new file mode 100644 index 000000000..7c4090b05 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/lro/rpc/generated/RpcClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.rpc.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._specs_.azure.core.lro.rpc.RpcClient; +import com._specs_.azure.core.lro.rpc.RpcClientBuilder; +import com.azure.core.http.HttpClient; +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; + +class RpcClientTestBase extends TestProxyTestBase { + protected RpcClient rpcClient; + + @Override + protected void beforeTest() { + RpcClientBuilder rpcClientbuilder = new RpcClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + rpcClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + rpcClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + rpcClient = rpcClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/lro/standard/generated/StandardClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/lro/standard/generated/StandardClientTestBase.java new file mode 100644 index 000000000..ac96f1308 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/lro/standard/generated/StandardClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.lro.standard.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._specs_.azure.core.lro.standard.StandardClient; +import com._specs_.azure.core.lro.standard.StandardClientBuilder; +import com.azure.core.http.HttpClient; +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; + +class StandardClientTestBase extends TestProxyTestBase { + protected StandardClient standardClient; + + @Override + protected void beforeTest() { + StandardClientBuilder standardClientbuilder = new StandardClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + standardClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + standardClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + standardClient = standardClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/model/generated/ModelClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/model/generated/ModelClientTestBase.java new file mode 100644 index 000000000..5c65b8a13 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/model/generated/ModelClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.model.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._specs_.azure.core.model.ModelClient; +import com._specs_.azure.core.model.ModelClientBuilder; +import com.azure.core.http.HttpClient; +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; + +class ModelClientTestBase extends TestProxyTestBase { + protected ModelClient modelClient; + + @Override + protected void beforeTest() { + ModelClientBuilder modelClientbuilder = new ModelClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + modelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + modelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + modelClient = modelClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/page/generated/PageClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/page/generated/PageClientTestBase.java new file mode 100644 index 000000000..b5d61efe3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/page/generated/PageClientTestBase.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.page.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._specs_.azure.core.page.PageClient; +import com._specs_.azure.core.page.PageClientBuilder; +import com._specs_.azure.core.page.TwoModelsAsPageItemClient; +import com.azure.core.http.HttpClient; +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; + +class PageClientTestBase extends TestProxyTestBase { + protected PageClient pageClient; + + protected TwoModelsAsPageItemClient twoModelsAsPageItemClient; + + @Override + protected void beforeTest() { + PageClientBuilder pageClientbuilder = new PageClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + pageClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + pageClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + pageClient = pageClientbuilder.buildClient(); + + PageClientBuilder twoModelsAsPageItemClientbuilder = new PageClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + twoModelsAsPageItemClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + twoModelsAsPageItemClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + twoModelsAsPageItemClient = twoModelsAsPageItemClientbuilder.buildTwoModelsAsPageItemClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/scalar/generated/ScalarClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/scalar/generated/ScalarClientTestBase.java new file mode 100644 index 000000000..426bd1bae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/scalar/generated/ScalarClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.scalar.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._specs_.azure.core.scalar.ScalarClient; +import com._specs_.azure.core.scalar.ScalarClientBuilder; +import com.azure.core.http.HttpClient; +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; + +class ScalarClientTestBase extends TestProxyTestBase { + protected ScalarClient scalarClient; + + @Override + protected void beforeTest() { + ScalarClientBuilder scalarClientbuilder = new ScalarClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + scalarClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + scalarClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + scalarClient = scalarClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/traits/generated/TraitsClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/traits/generated/TraitsClientTestBase.java new file mode 100644 index 000000000..cc582cb39 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/core/traits/generated/TraitsClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.core.traits.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._specs_.azure.core.traits.TraitsClient; +import com._specs_.azure.core.traits.TraitsClientBuilder; +import com.azure.core.http.HttpClient; +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; + +class TraitsClientTestBase extends TestProxyTestBase { + protected TraitsClient traitsClient; + + @Override + protected void beforeTest() { + TraitsClientBuilder traitsClientbuilder = new TraitsClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + traitsClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + traitsClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + traitsClient = traitsClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/example/basic/generated/AzureExampleClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/example/basic/generated/AzureExampleClientTestBase.java new file mode 100644 index 000000000..df2da2a54 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/example/basic/generated/AzureExampleClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.example.basic.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._specs_.azure.example.basic.AzureExampleClient; +import com._specs_.azure.example.basic.AzureExampleClientBuilder; +import com.azure.core.http.HttpClient; +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; + +class AzureExampleClientTestBase extends TestProxyTestBase { + protected AzureExampleClient azureExampleClient; + + @Override + protected void beforeTest() { + AzureExampleClientBuilder azureExampleClientbuilder = new AzureExampleClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + azureExampleClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + azureExampleClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + azureExampleClient = azureExampleClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/example/basic/generated/BasicActionTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/example/basic/generated/BasicActionTests.java new file mode 100644 index 000000000..f8c701507 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/example/basic/generated/BasicActionTests.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com._specs_.azure.example.basic.generated; + +import com._specs_.azure.example.basic.models.ActionRequest; +import com._specs_.azure.example.basic.models.ActionResponse; +import com._specs_.azure.example.basic.models.Enum; +import com._specs_.azure.example.basic.models.Model; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class BasicActionTests extends AzureExampleClientTestBase { + @Test + @Disabled + public void testBasicActionTests() { + // method invocation + ActionResponse response = azureExampleClient.basicAction("query", "header", + new ActionRequest("text") + .setModelProperty( + new Model().setInt32Property(1).setFloat32Property(1.5D).setEnumProperty(Enum.ENUM_VALUE1)) + .setArrayProperty(Arrays.asList("item")) + .setRecordProperty(mapOf("record", "value"))); + + // response assertion + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/apikey/generated/ApiKeyClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/apikey/generated/ApiKeyClientTestBase.java new file mode 100644 index 000000000..a4a047af2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/apikey/generated/ApiKeyClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.apikey.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.authentication.apikey.ApiKeyClient; +import com.authentication.apikey.ApiKeyClientBuilder; +import com.azure.core.http.HttpClient; +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; + +class ApiKeyClientTestBase extends TestProxyTestBase { + protected ApiKeyClient apiKeyClient; + + @Override + protected void beforeTest() { + ApiKeyClientBuilder apiKeyClientbuilder = new ApiKeyClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + apiKeyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + apiKeyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + apiKeyClient = apiKeyClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/http/custom/generated/CustomClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/http/custom/generated/CustomClientTestBase.java new file mode 100644 index 000000000..898fe6fd8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/http/custom/generated/CustomClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.http.custom.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.authentication.http.custom.CustomClient; +import com.authentication.http.custom.CustomClientBuilder; +import com.azure.core.http.HttpClient; +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; + +class CustomClientTestBase extends TestProxyTestBase { + protected CustomClient customClient; + + @Override + protected void beforeTest() { + CustomClientBuilder customClientbuilder = new CustomClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + customClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + customClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + customClient = customClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/oauth2/generated/OAuth2ClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/oauth2/generated/OAuth2ClientTestBase.java new file mode 100644 index 000000000..f4beb748f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/oauth2/generated/OAuth2ClientTestBase.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.oauth2.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.authentication.oauth2.OAuth2Client; +import com.authentication.oauth2.OAuth2ClientBuilder; +import com.azure.core.http.HttpClient; +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.test.utils.MockTokenCredential; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +class OAuth2ClientTestBase extends TestProxyTestBase { + protected OAuth2Client oAuth2Client; + + @Override + protected void beforeTest() { + OAuth2ClientBuilder oAuth2Clientbuilder = new OAuth2ClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + oAuth2Clientbuilder.httpClient(interceptorManager.getPlaybackClient()) + .credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + oAuth2Clientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + oAuth2Clientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + oAuth2Client = oAuth2Clientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/union/generated/UnionClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/union/generated/UnionClientTestBase.java new file mode 100644 index 000000000..f2282b158 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/union/generated/UnionClientTestBase.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.authentication.union.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.authentication.union.UnionClient; +import com.authentication.union.UnionClientBuilder; +import com.azure.core.http.HttpClient; +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.test.utils.MockTokenCredential; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +class UnionClientTestBase extends TestProxyTestBase { + protected UnionClient unionClient; + + @Override + protected void beforeTest() { + UnionClientBuilder unionClientbuilder = new UnionClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unionClientbuilder.httpClient(interceptorManager.getPlaybackClient()).credential(new MockTokenCredential()); + } else if (getTestMode() == TestMode.RECORD) { + unionClientbuilder.addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + unionClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + unionClient = unionClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/azure/specialheaders/xmsclientrequestid/generated/XmsClientRequestIdClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/azure/specialheaders/xmsclientrequestid/generated/XmsClientRequestIdClientTestBase.java new file mode 100644 index 000000000..0a4be4cc4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/azure/specialheaders/xmsclientrequestid/generated/XmsClientRequestIdClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.specialheaders.xmsclientrequestid.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.HttpClient; +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 com.azure.specialheaders.xmsclientrequestid.XmsClientRequestIdClient; +import com.azure.specialheaders.xmsclientrequestid.XmsClientRequestIdClientBuilder; + +class XmsClientRequestIdClientTestBase extends TestProxyTestBase { + protected XmsClientRequestIdClient xmsClientRequestIdClient; + + @Override + protected void beforeTest() { + XmsClientRequestIdClientBuilder xmsClientRequestIdClientbuilder = new XmsClientRequestIdClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + xmsClientRequestIdClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + xmsClientRequestIdClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + xmsClientRequestIdClient = xmsClientRequestIdClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/builtin/generated/BuiltinClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/builtin/generated/BuiltinClientTestBase.java new file mode 100644 index 000000000..a4dae2035 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/builtin/generated/BuiltinClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.builtin.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.HttpClient; +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 com.cadl.builtin.BuiltinClient; +import com.cadl.builtin.BuiltinClientBuilder; + +class BuiltinClientTestBase extends TestProxyTestBase { + protected BuiltinClient builtinClient; + + @Override + protected void beforeTest() { + BuiltinClientBuilder builtinClientbuilder + = new BuiltinClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + builtinClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + builtinClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + builtinClient = builtinClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/builtin/generated/BuiltinOpReadTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/builtin/generated/BuiltinOpReadTests.java new file mode 100644 index 000000000..5c8609cd7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/builtin/generated/BuiltinOpReadTests.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.builtin.generated; + +import com.cadl.builtin.models.Builtin; +import com.cadl.builtin.models.Encoded; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class BuiltinOpReadTests extends BuiltinClientTestBase { + @Test + @Disabled + public void testBuiltinOpReadTests() { + // method invocation + Builtin response = builtinClient.read(null, null, null, "myFilter", null, null); + + // response assertion + Assertions.assertNotNull(response); + // verify property "booleanProperty" + Assertions.assertEquals(true, response.isBooleanProperty()); + // verify property "string" + Assertions.assertEquals("myString", response.getString()); + // verify property "safeint" + Assertions.assertEquals(32L, response.getSafeint()); + // verify property "longProperty" + Assertions.assertEquals(64L, response.getLongProperty()); + // verify property "floatProperty" + Assertions.assertEquals(32.0, response.getFloatProperty()); + // verify property "doubleProperty" + Assertions.assertEquals(64.0, response.getDoubleProperty()); + // verify property "duration" + Assertions.assertNotNull(response.getDuration()); + // verify property "date" + Assertions.assertNotNull(response.getDate()); + // verify property "dateTime" + Assertions.assertNotNull(response.getDateTime()); + // verify property "stringList" + List responseStringList = response.getStringList(); + Assertions.assertEquals("a", responseStringList.iterator().next()); + // verify property "url" + Assertions.assertEquals("https://www.github.com", response.getUrl()); + // verify property "nullableFloatDict" + Assertions.assertNotNull(response.getNullableFloatDict()); + // verify property "encoded" + Encoded responseEncoded = response.getEncoded(); + Assertions.assertNotNull(responseEncoded); + Assertions.assertNotNull(responseEncoded.getTimeInSeconds()); + Assertions.assertNotNull(responseEncoded.getTimeInSecondsFraction()); + Assertions.assertNotNull(responseEncoded.getDateTime()); + Assertions.assertNotNull(responseEncoded.getDateTimeRfc7231()); + Assertions.assertNotNull(responseEncoded.getUnixTimestamp()); + Assertions.assertNotNull(responseEncoded.getBase64()); + Assertions.assertNotNull(responseEncoded.getBase64url()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/enumservice/generated/EnumServiceClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/enumservice/generated/EnumServiceClientTestBase.java new file mode 100644 index 000000000..cb8cf1cf1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/enumservice/generated/EnumServiceClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.enumservice.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.HttpClient; +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 com.cadl.enumservice.EnumServiceClient; +import com.cadl.enumservice.EnumServiceClientBuilder; + +class EnumServiceClientTestBase extends TestProxyTestBase { + protected EnumServiceClient enumServiceClient; + + @Override + protected void beforeTest() { + EnumServiceClientBuilder enumServiceClientbuilder = new EnumServiceClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + enumServiceClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + enumServiceClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + enumServiceClient = enumServiceClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/errormodel/generated/ErrorModelClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/errormodel/generated/ErrorModelClientTestBase.java new file mode 100644 index 000000000..c4a2b394f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/errormodel/generated/ErrorModelClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.errormodel.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.HttpClient; +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 com.cadl.errormodel.ErrorModelClient; +import com.cadl.errormodel.ErrorModelClientBuilder; + +class ErrorModelClientTestBase extends TestProxyTestBase { + protected ErrorModelClient errorModelClient; + + @Override + protected void beforeTest() { + ErrorModelClientBuilder errorModelClientbuilder + = new ErrorModelClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + errorModelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + errorModelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + errorModelClient = errorModelClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/flatten/generated/FlattenClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/flatten/generated/FlattenClientTestBase.java new file mode 100644 index 000000000..3dae50b54 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/flatten/generated/FlattenClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.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.HttpClient; +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 com.cadl.flatten.FlattenClient; +import com.cadl.flatten.FlattenClientBuilder; + +class FlattenClientTestBase extends TestProxyTestBase { + protected FlattenClient flattenClient; + + @Override + protected void beforeTest() { + FlattenClientBuilder flattenClientbuilder + = new FlattenClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + flattenClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + flattenClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + flattenClient = flattenClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/flatten/generated/FlattenOpSendLongTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/flatten/generated/FlattenOpSendLongTests.java new file mode 100644 index 000000000..7c24c40b4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/flatten/generated/FlattenOpSendLongTests.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.generated; + +import com.cadl.flatten.models.SendLongOptions; +import com.cadl.flatten.models.SendLongRequestStatus; +import com.cadl.flatten.models.User; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class FlattenOpSendLongTests extends FlattenClientTestBase { + @Test + @Disabled + public void testFlattenOpSendLongTests() { + // method invocation + flattenClient.sendLong( + new SendLongOptions("myRequiredId", "myRequiredInput", 11, "title", SendLongRequestStatus.NOT_STARTED) + .setFilter("name=myName") + .setUser(new User("myOptionalUser")) + .setDataIntOptional(12) + .setDataLong(13L) + .setDataFloat(14.0D) + .setDescription("description")); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/flatten/generated/FlattenOpSendTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/flatten/generated/FlattenOpSendTests.java new file mode 100644 index 000000000..c45630a16 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/flatten/generated/FlattenOpSendTests.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.flatten.generated; + +import com.cadl.flatten.models.User; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class FlattenOpSendTests extends FlattenClientTestBase { + @Test + @Disabled + public void testFlattenOpSendTests() { + // method invocation + flattenClient.send("myRequiredId", "myRequiredInput", new User("myOptionalUser")); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/internal/generated/InternalClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/internal/generated/InternalClientTestBase.java new file mode 100644 index 000000000..0603f3efb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/internal/generated/InternalClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.internal.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.HttpClient; +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 com.cadl.internal.InternalClient; +import com.cadl.internal.InternalClientBuilder; + +class InternalClientTestBase extends TestProxyTestBase { + protected InternalClient internalClient; + + @Override + protected void beforeTest() { + InternalClientBuilder internalClientbuilder + = new InternalClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + internalClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + internalClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + internalClient = internalClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/literalservice/generated/LiteralServiceClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/literalservice/generated/LiteralServiceClientTestBase.java new file mode 100644 index 000000000..729b11f6c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/literalservice/generated/LiteralServiceClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.literalservice.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.HttpClient; +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 com.cadl.literalservice.LiteralServiceClient; +import com.cadl.literalservice.LiteralServiceClientBuilder; + +class LiteralServiceClientTestBase extends TestProxyTestBase { + protected LiteralServiceClient literalServiceClient; + + @Override + protected void beforeTest() { + LiteralServiceClientBuilder literalServiceClientbuilder = new LiteralServiceClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + literalServiceClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + literalServiceClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + literalServiceClient = literalServiceClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/longrunning/generated/LongRunningClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/longrunning/generated/LongRunningClientTestBase.java new file mode 100644 index 000000000..e877ce43b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/longrunning/generated/LongRunningClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning.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.HttpClient; +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 com.cadl.longrunning.LongRunningClient; +import com.cadl.longrunning.LongRunningClientBuilder; + +class LongRunningClientTestBase extends TestProxyTestBase { + protected LongRunningClient longRunningClient; + + @Override + protected void beforeTest() { + LongRunningClientBuilder longRunningClientbuilder = new LongRunningClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + longRunningClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + longRunningClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + longRunningClient = longRunningClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/longrunning/generated/LongRunningCreateJobTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/longrunning/generated/LongRunningCreateJobTests.java new file mode 100644 index 000000000..189289be9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/longrunning/generated/LongRunningCreateJobTests.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.longrunning.generated; + +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.SyncPoller; +import com.cadl.longrunning.models.JobData; +import com.cadl.longrunning.models.JobResult; +import com.cadl.longrunning.models.JobResultResult; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class LongRunningCreateJobTests extends LongRunningClientTestBase { + @Test + @Disabled + public void testLongRunningCreateJobTests() { + // method invocation + SyncPoller response = setPlaybackSyncPollerPollInterval(longRunningClient + .beginCreateJob(new JobData(mapOf("max", 15.0D, "min", 14.0D, "average", 14.3D)).setConfiguration("{}"))); + + // response assertion + Assertions.assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, + response.waitForCompletion().getStatus()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/model/generated/ModelClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/model/generated/ModelClientTestBase.java new file mode 100644 index 000000000..db7a1378a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/model/generated/ModelClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.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.HttpClient; +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 com.cadl.model.ModelClient; +import com.cadl.model.ModelClientBuilder; + +class ModelClientTestBase extends TestProxyTestBase { + protected ModelClient modelClient; + + @Override + protected void beforeTest() { + ModelClientBuilder modelClientbuilder + = new ModelClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + modelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + modelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + modelClient = modelClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/model/generated/ModelOpPutNestedTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/model/generated/ModelOpPutNestedTests.java new file mode 100644 index 000000000..907234d44 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/model/generated/ModelOpPutNestedTests.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.model.generated; + +import com.cadl.model.models.NestedModel; +import com.cadl.model.models.NestedModel1; +import com.cadl.model.models.NestedModel2; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ModelOpPutNestedTests extends ModelClientTestBase { + @Test + @Disabled + public void testModelOpPutNestedTests() { + // method invocation + NestedModel response = modelClient.putNested(null); + + // response assertion + Assertions.assertNotNull(response); + // verify property "nested1" + NestedModel1 responseNested1 = response.getNested1(); + Assertions.assertNotNull(responseNested1); + NestedModel2 responseNested1Nested2 = responseNested1.getNested2(); + Assertions.assertNotNull(responseNested1Nested2); + Assertions.assertEquals("123", responseNested1Nested2.getData()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/multicontenttypes/generated/MultiContentTypesClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/multicontenttypes/generated/MultiContentTypesClientTestBase.java new file mode 100644 index 000000000..8f0be62a2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/multicontenttypes/generated/MultiContentTypesClientTestBase.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes.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.HttpClient; +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 com.cadl.multicontenttypes.MultiContentTypesClient; +import com.cadl.multicontenttypes.MultiContentTypesClientBuilder; +import com.cadl.multicontenttypes.MultipleContentTypesOnRequestClient; +import com.cadl.multicontenttypes.SingleContentTypeClient; + +class MultiContentTypesClientTestBase extends TestProxyTestBase { + protected MultiContentTypesClient multiContentTypesClient; + + protected SingleContentTypeClient singleContentTypeClient; + + protected MultipleContentTypesOnRequestClient multipleContentTypesOnRequestClient; + + @Override + protected void beforeTest() { + MultiContentTypesClientBuilder multiContentTypesClientbuilder = new MultiContentTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + multiContentTypesClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + multiContentTypesClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + multiContentTypesClient = multiContentTypesClientbuilder.buildClient(); + + MultiContentTypesClientBuilder singleContentTypeClientbuilder = new MultiContentTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + singleContentTypeClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + singleContentTypeClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + singleContentTypeClient = singleContentTypeClientbuilder.buildSingleContentTypeClient(); + + MultiContentTypesClientBuilder multipleContentTypesOnRequestClientbuilder = new MultiContentTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + multipleContentTypesOnRequestClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + multipleContentTypesOnRequestClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + multipleContentTypesOnRequestClient + = multipleContentTypesOnRequestClientbuilder.buildMultipleContentTypesOnRequestClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/multicontenttypes/generated/SingleContentTypeUploadImageForSingleContentTypeTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/multicontenttypes/generated/SingleContentTypeUploadImageForSingleContentTypeTests.java new file mode 100644 index 000000000..cbc07c3c0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/multicontenttypes/generated/SingleContentTypeUploadImageForSingleContentTypeTests.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multicontenttypes.generated; + +import com.azure.core.util.BinaryData; +import java.nio.charset.StandardCharsets; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class SingleContentTypeUploadImageForSingleContentTypeTests extends MultiContentTypesClientTestBase { + @Test + @Disabled + public void testSingleContentTypeUploadImageForSingleContentTypeTests() { + // method invocation + singleContentTypeClient.uploadImageForSingleContentType( + BinaryData.fromBytes("\"D:\\Program Files\"".getBytes(StandardCharsets.UTF_8))); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/multipart/generated/MultipartClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/multipart/generated/MultipartClientTestBase.java new file mode 100644 index 000000000..caa85e2bf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/multipart/generated/MultipartClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipart.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.HttpClient; +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 com.cadl.multipart.MultipartClient; +import com.cadl.multipart.MultipartClientBuilder; + +class MultipartClientTestBase extends TestProxyTestBase { + protected MultipartClient multipartClient; + + @Override + protected void beforeTest() { + MultipartClientBuilder multipartClientbuilder + = new MultipartClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + multipartClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + multipartClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + multipartClient = multipartClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/multipleapiversion/generated/FirstClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/multipleapiversion/generated/FirstClientTestBase.java new file mode 100644 index 000000000..37a482c80 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/multipleapiversion/generated/FirstClientTestBase.java @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.multipleapiversion.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.HttpClient; +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 com.cadl.multipleapiversion.FirstClient; +import com.cadl.multipleapiversion.FirstClientBuilder; +import com.cadl.multipleapiversion.NoApiVersionClient; +import com.cadl.multipleapiversion.NoApiVersionClientBuilder; +import com.cadl.multipleapiversion.SecondClient; +import com.cadl.multipleapiversion.SecondClientBuilder; + +class FirstClientTestBase extends TestProxyTestBase { + protected FirstClient firstClient; + + protected SecondClient secondClient; + + protected NoApiVersionClient noApiVersionClient; + + @Override + protected void beforeTest() { + FirstClientBuilder firstClientbuilder + = new FirstClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + firstClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + firstClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + firstClient = firstClientbuilder.buildClient(); + + SecondClientBuilder secondClientbuilder + = new SecondClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + secondClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + secondClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + secondClient = secondClientbuilder.buildClient(); + + NoApiVersionClientBuilder noApiVersionClientbuilder = new NoApiVersionClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + noApiVersionClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + noApiVersionClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + noApiVersionClient = noApiVersionClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/naming/generated/NamingClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/naming/generated/NamingClientTestBase.java new file mode 100644 index 000000000..c1ea158a0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/naming/generated/NamingClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.naming.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.HttpClient; +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 com.cadl.naming.NamingClient; +import com.cadl.naming.NamingClientBuilder; + +class NamingClientTestBase extends TestProxyTestBase { + protected NamingClient namingClient; + + @Override + protected void beforeTest() { + NamingClientBuilder namingClientbuilder + = new NamingClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + namingClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + namingClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + namingClient = namingClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/optional/generated/OptionalClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/optional/generated/OptionalClientTestBase.java new file mode 100644 index 000000000..0faffff94 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/optional/generated/OptionalClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.optional.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.HttpClient; +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 com.cadl.optional.OptionalClient; +import com.cadl.optional.OptionalClientBuilder; + +class OptionalClientTestBase extends TestProxyTestBase { + protected OptionalClient optionalClient; + + @Override + protected void beforeTest() { + OptionalClientBuilder optionalClientbuilder + = new OptionalClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + optionalClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + optionalClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + optionalClient = optionalClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/patch/generated/PatchClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/patch/generated/PatchClientTestBase.java new file mode 100644 index 000000000..56416bbd6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/patch/generated/PatchClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.patch.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.HttpClient; +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 com.cadl.patch.PatchClient; +import com.cadl.patch.PatchClientBuilder; + +class PatchClientTestBase extends TestProxyTestBase { + protected PatchClient patchClient; + + @Override + protected void beforeTest() { + PatchClientBuilder patchClientbuilder + = new PatchClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + patchClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + patchClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + patchClient = patchClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/protocolandconvenient/generated/ProtocolAndConvenientClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/protocolandconvenient/generated/ProtocolAndConvenientClientTestBase.java new file mode 100644 index 000000000..d9696540f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/protocolandconvenient/generated/ProtocolAndConvenientClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.protocolandconvenient.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.HttpClient; +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 com.cadl.protocolandconvenient.ProtocolAndConvenientClient; +import com.cadl.protocolandconvenient.ProtocolAndConvenientClientBuilder; + +class ProtocolAndConvenientClientTestBase extends TestProxyTestBase { + protected ProtocolAndConvenientClient protocolAndConvenientClient; + + @Override + protected void beforeTest() { + ProtocolAndConvenientClientBuilder protocolAndConvenientClientbuilder = new ProtocolAndConvenientClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + protocolAndConvenientClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + protocolAndConvenientClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + protocolAndConvenientClient = protocolAndConvenientClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/response/generated/ResponseClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/response/generated/ResponseClientTestBase.java new file mode 100644 index 000000000..2ec6ed4bb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/response/generated/ResponseClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response.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.HttpClient; +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 com.cadl.response.ResponseClient; +import com.cadl.response.ResponseClientBuilder; + +class ResponseClientTestBase extends TestProxyTestBase { + protected ResponseClient responseClient; + + @Override + protected void beforeTest() { + ResponseClientBuilder responseClientbuilder + = new ResponseClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + responseClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + responseClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + responseClient = responseClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/response/generated/ResponseOpExistsTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/response/generated/ResponseOpExistsTests.java new file mode 100644 index 000000000..084f3e42e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/response/generated/ResponseOpExistsTests.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response.generated; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ResponseOpExistsTests extends ResponseClientTestBase { + @Test + @Disabled + public void testResponseOpExistsTests() { + // method invocation + boolean response = responseClient.exists(); + + // response assertion + Assertions.assertTrue(response); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/response/generated/ResponseOpListStringsTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/response/generated/ResponseOpListStringsTests.java new file mode 100644 index 000000000..6239a7895 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/response/generated/ResponseOpListStringsTests.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.response.generated; + +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class ResponseOpListStringsTests extends ResponseClientTestBase { + @Test + @Disabled + public void testResponseOpListStringsTests() { + // method invocation + PagedIterable response = responseClient.listStrings(); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/server/generated/HttpbinClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/server/generated/HttpbinClientTestBase.java new file mode 100644 index 000000000..2a9a04579 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/server/generated/HttpbinClientTestBase.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.server.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.HttpClient; +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 com.cadl.server.HttpbinClient; +import com.cadl.server.HttpbinClientBuilder; +import com.cadl.server.contoso.sub.ContosoClient; +import com.cadl.server.contoso.sub.ContosoClientBuilder; + +class HttpbinClientTestBase extends TestProxyTestBase { + protected HttpbinClient httpbinClient; + + protected ContosoClient contosoClient; + + @Override + protected void beforeTest() { + HttpbinClientBuilder httpbinClientbuilder + = new HttpbinClientBuilder().domain(Configuration.getGlobalConfiguration().get("DOMAIN", "httpbin")) + .tld(Configuration.getGlobalConfiguration().get("TLD", "org")) + .relativePath(Configuration.getGlobalConfiguration().get("RELATIVEPATH", "relativepath")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + httpbinClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + httpbinClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + httpbinClient = httpbinClientbuilder.buildClient(); + + ContosoClientBuilder contosoClientbuilder + = new ContosoClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + contosoClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + contosoClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + contosoClient = contosoClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialchars/generated/BuiltinOpReadTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialchars/generated/BuiltinOpReadTests.java new file mode 100644 index 000000000..c87fc7016 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialchars/generated/BuiltinOpReadTests.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialchars.generated; + +import com.cadl.specialchars.models.Resource; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class BuiltinOpReadTests extends SpecialCharsClientTestBase { + @Test + @Disabled + public void testBuiltinOpReadTests() { + // method invocation + Resource response = specialCharsClient.read(null); + + // response assertion + Assertions.assertNotNull(response); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialchars/generated/SpecialCharsClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialchars/generated/SpecialCharsClientTestBase.java new file mode 100644 index 000000000..305bcc302 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialchars/generated/SpecialCharsClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialchars.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.HttpClient; +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 com.cadl.specialchars.SpecialCharsClient; +import com.cadl.specialchars.SpecialCharsClientBuilder; + +class SpecialCharsClientTestBase extends TestProxyTestBase { + protected SpecialCharsClient specialCharsClient; + + @Override + protected void beforeTest() { + SpecialCharsClientBuilder specialCharsClientbuilder = new SpecialCharsClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + specialCharsClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + specialCharsClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + specialCharsClient = specialCharsClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialheaders/generated/EtagHeadersListWithEtagTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialheaders/generated/EtagHeadersListWithEtagTests.java new file mode 100644 index 000000000..f9f67dd67 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialheaders/generated/EtagHeadersListWithEtagTests.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.generated; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.rest.PagedIterable; +import com.cadl.specialheaders.models.Resource; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class EtagHeadersListWithEtagTests extends SpecialHeadersClientTestBase { + @Test + @Disabled + public void testEtagHeadersListWithEtagTests() { + // method invocation + PagedIterable response = etagHeadersClient.listWithEtag(); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + Assertions.assertEquals("\"64e005\"", + response.iterableByPage().iterator().next().getHeaders().get(HttpHeaderName.fromString("ETag")).getValue()); + Resource firstItem = response.iterator().next(); + Assertions.assertNotNull(firstItem); + // verify property "id" + Assertions.assertEquals("myId", firstItem.getId()); + // verify property "name" + Assertions.assertEquals("name", firstItem.getName()); + // verify property "description" + Assertions.assertEquals("This is sample for Etag headers", firstItem.getDescription()); + // verify property "type" + Assertions.assertEquals("myType", firstItem.getType()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialheaders/generated/EtagHeadersPutWithRequestHeadersTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialheaders/generated/EtagHeadersPutWithRequestHeadersTests.java new file mode 100644 index 000000000..b321dbba8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialheaders/generated/EtagHeadersPutWithRequestHeadersTests.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 com.cadl.specialheaders.generated; + +import com.azure.core.http.RequestConditions; +import com.cadl.specialheaders.models.Resource; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class EtagHeadersPutWithRequestHeadersTests extends SpecialHeadersClientTestBase { + @Test + @Disabled + public void testEtagHeadersPutWithRequestHeadersTests() { + // method invocation + Resource response = etagHeadersClient.putWithRequestHeaders("name", + new Resource().setDescription("This is sample for Etag headers").setType("myType"), + new RequestConditions().setIfMatch("\"64e005\"")); + + // response assertion + Assertions.assertNotNull(response); + // verify property "id" + Assertions.assertEquals("myId", response.getId()); + // verify property "name" + Assertions.assertEquals("name", response.getName()); + // verify property "description" + Assertions.assertEquals("This is sample for Etag headers", response.getDescription()); + // verify property "type" + Assertions.assertEquals("myType", response.getType()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialheaders/generated/SpecialHeadersClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialheaders/generated/SpecialHeadersClientTestBase.java new file mode 100644 index 000000000..b601dfae3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/specialheaders/generated/SpecialHeadersClientTestBase.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.specialheaders.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.HttpClient; +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 com.cadl.specialheaders.EtagHeadersClient; +import com.cadl.specialheaders.EtagHeadersOptionalBodyClient; +import com.cadl.specialheaders.RepeatabilityHeadersClient; +import com.cadl.specialheaders.SkipSpecialHeadersClient; +import com.cadl.specialheaders.SpecialHeadersClientBuilder; + +class SpecialHeadersClientTestBase extends TestProxyTestBase { + protected RepeatabilityHeadersClient repeatabilityHeadersClient; + + protected EtagHeadersClient etagHeadersClient; + + protected EtagHeadersOptionalBodyClient etagHeadersOptionalBodyClient; + + protected SkipSpecialHeadersClient skipSpecialHeadersClient; + + @Override + protected void beforeTest() { + SpecialHeadersClientBuilder repeatabilityHeadersClientbuilder = new SpecialHeadersClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + repeatabilityHeadersClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + repeatabilityHeadersClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + repeatabilityHeadersClient = repeatabilityHeadersClientbuilder.buildRepeatabilityHeadersClient(); + + SpecialHeadersClientBuilder etagHeadersClientbuilder = new SpecialHeadersClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + etagHeadersClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + etagHeadersClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + etagHeadersClient = etagHeadersClientbuilder.buildEtagHeadersClient(); + + SpecialHeadersClientBuilder etagHeadersOptionalBodyClientbuilder = new SpecialHeadersClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + etagHeadersOptionalBodyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + etagHeadersOptionalBodyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + etagHeadersOptionalBodyClient = etagHeadersOptionalBodyClientbuilder.buildEtagHeadersOptionalBodyClient(); + + SpecialHeadersClientBuilder skipSpecialHeadersClientbuilder = new SpecialHeadersClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + skipSpecialHeadersClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + skipSpecialHeadersClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + skipSpecialHeadersClient = skipSpecialHeadersClientbuilder.buildSkipSpecialHeadersClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/union/generated/UnionClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/union/generated/UnionClientTestBase.java new file mode 100644 index 000000000..729d93b39 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/union/generated/UnionClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.union.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.HttpClient; +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 com.cadl.union.UnionClient; +import com.cadl.union.UnionClientBuilder; + +class UnionClientTestBase extends TestProxyTestBase { + protected UnionClient unionClient; + + @Override + protected void beforeTest() { + UnionClientBuilder unionClientbuilder + = new UnionClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unionClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unionClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unionClient = unionClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/versioning/generated/VersioningClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/versioning/generated/VersioningClientTestBase.java new file mode 100644 index 000000000..75c34b610 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/versioning/generated/VersioningClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning.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.HttpClient; +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 com.cadl.versioning.VersioningClient; +import com.cadl.versioning.VersioningClientBuilder; + +class VersioningClientTestBase extends TestProxyTestBase { + protected VersioningClient versioningClient; + + @Override + protected void beforeTest() { + VersioningClientBuilder versioningClientbuilder + = new VersioningClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + versioningClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + versioningClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + versioningClient = versioningClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/versioning/generated/VersioningOpListTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/versioning/generated/VersioningOpListTests.java new file mode 100644 index 000000000..e48c90954 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/versioning/generated/VersioningOpListTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.versioning.generated; + +import com.azure.core.http.rest.PagedIterable; +import com.cadl.versioning.models.Resource; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +@Disabled +public final class VersioningOpListTests extends VersioningClientTestBase { + @Test + @Disabled + public void testVersioningOpListTests() { + // method invocation + PagedIterable response = versioningClient.list(Arrays.asList("name=name"), null); + + // response assertion + Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode()); + Resource firstItem = response.iterator().next(); + Assertions.assertNotNull(firstItem); + // verify property "id" + Assertions.assertEquals("myId", firstItem.getId()); + // verify property "name" + Assertions.assertEquals("name", firstItem.getName()); + // verify property "type" + Assertions.assertEquals("type", firstItem.getType()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/visibility/generated/VisibilityClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/visibility/generated/VisibilityClientTestBase.java new file mode 100644 index 000000000..313bbde5c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/visibility/generated/VisibilityClientTestBase.java @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.visibility.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.HttpClient; +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 com.cadl.visibility.VisibilityClient; +import com.cadl.visibility.VisibilityClientBuilder; +import com.cadl.visibility.VisibilityReadClient; +import com.cadl.visibility.VisibilityWriteClient; + +class VisibilityClientTestBase extends TestProxyTestBase { + protected VisibilityClient visibilityClient; + + protected VisibilityReadClient visibilityReadClient; + + protected VisibilityWriteClient visibilityWriteClient; + + @Override + protected void beforeTest() { + VisibilityClientBuilder visibilityClientbuilder + = new VisibilityClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + visibilityClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + visibilityClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + visibilityClient = visibilityClientbuilder.buildClient(); + + VisibilityClientBuilder visibilityReadClientbuilder + = new VisibilityClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + visibilityReadClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + visibilityReadClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + visibilityReadClient = visibilityReadClientbuilder.buildVisibilityReadClient(); + + VisibilityClientBuilder visibilityWriteClientbuilder + = new VisibilityClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + visibilityWriteClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + visibilityWriteClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + visibilityWriteClient = visibilityWriteClientbuilder.buildVisibilityWriteClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/wiretype/generated/WireTypeClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/wiretype/generated/WireTypeClientTestBase.java new file mode 100644 index 000000000..c461f7674 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/wiretype/generated/WireTypeClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.wiretype.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.HttpClient; +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 com.cadl.wiretype.WireTypeClient; +import com.cadl.wiretype.WireTypeClientBuilder; + +class WireTypeClientTestBase extends TestProxyTestBase { + protected WireTypeClient wireTypeClient; + + @Override + protected void beforeTest() { + WireTypeClientBuilder wireTypeClientbuilder + = new WireTypeClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + wireTypeClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + wireTypeClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + wireTypeClient = wireTypeClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/naming/generated/NamingClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/naming/generated/NamingClientTestBase.java new file mode 100644 index 000000000..27c50ae9d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/naming/generated/NamingClientTestBase.java @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.naming.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.HttpClient; +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 com.client.naming.ClientModelClient; +import com.client.naming.NamingClient; +import com.client.naming.NamingClientBuilder; +import com.client.naming.UnionEnumClient; + +class NamingClientTestBase extends TestProxyTestBase { + protected NamingClient namingClient; + + protected ClientModelClient clientModelClient; + + protected UnionEnumClient unionEnumClient; + + @Override + protected void beforeTest() { + NamingClientBuilder namingClientbuilder = new NamingClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + namingClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + namingClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + namingClient = namingClientbuilder.buildClient(); + + NamingClientBuilder clientModelClientbuilder = new NamingClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + clientModelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + clientModelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + clientModelClient = clientModelClientbuilder.buildClientModelClient(); + + NamingClientBuilder unionEnumClientbuilder = new NamingClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unionEnumClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unionEnumClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unionEnumClient = unionEnumClientbuilder.buildUnionEnumClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/structure/service/generated/ClientAClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/structure/service/generated/ClientAClientTestBase.java new file mode 100644 index 000000000..741f1c43b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/structure/service/generated/ClientAClientTestBase.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.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.HttpClient; +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 com.client.structure.service.ClientAClient; +import com.client.structure.service.ClientAClientBuilder; +import com.client.structure.service.ClientBClient; +import com.client.structure.service.ClientBClientBuilder; + +class ClientAClientTestBase extends TestProxyTestBase { + protected ClientAClient clientAClient; + + protected ClientBClient clientBClient; + + @Override + protected void beforeTest() { + ClientAClientBuilder clientAClientbuilder + = new ClientAClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .client(Configuration.getGlobalConfiguration().get("CLIENT", "client")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + clientAClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + clientAClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + clientAClient = clientAClientbuilder.buildClient(); + + ClientBClientBuilder clientBClientbuilder + = new ClientBClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .client(Configuration.getGlobalConfiguration().get("CLIENT", "client")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + clientBClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + clientBClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + clientBClient = clientBClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/structure/service/generated/RenamedOperationClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/structure/service/generated/RenamedOperationClientTestBase.java new file mode 100644 index 000000000..1fa00c494 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/structure/service/generated/RenamedOperationClientTestBase.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.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.HttpClient; +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 com.client.structure.service.GroupClient; +import com.client.structure.service.RenamedOperationClient; +import com.client.structure.service.RenamedOperationClientBuilder; + +class RenamedOperationClientTestBase extends TestProxyTestBase { + protected RenamedOperationClient renamedOperationClient; + + protected GroupClient groupClient; + + @Override + protected void beforeTest() { + RenamedOperationClientBuilder renamedOperationClientbuilder = new RenamedOperationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .client(Configuration.getGlobalConfiguration().get("CLIENT", "client")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + renamedOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + renamedOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + renamedOperationClient = renamedOperationClientbuilder.buildClient(); + + RenamedOperationClientBuilder groupClientbuilder = new RenamedOperationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .client(Configuration.getGlobalConfiguration().get("CLIENT", "client")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + groupClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + groupClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + groupClient = groupClientbuilder.buildGroupClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/structure/service/generated/ServiceClientClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/structure/service/generated/ServiceClientClientTestBase.java new file mode 100644 index 000000000..bd22590da --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/structure/service/generated/ServiceClientClientTestBase.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.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.HttpClient; +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 com.client.structure.service.BarClient; +import com.client.structure.service.BazFooClient; +import com.client.structure.service.FooClient; +import com.client.structure.service.QuxBarClient; +import com.client.structure.service.QuxClient; +import com.client.structure.service.ServiceClientClient; +import com.client.structure.service.ServiceClientClientBuilder; + +class ServiceClientClientTestBase extends TestProxyTestBase { + protected ServiceClientClient serviceClientClient; + + protected BazFooClient bazFooClient; + + protected QuxClient quxClient; + + protected QuxBarClient quxBarClient; + + protected FooClient fooClient; + + protected BarClient barClient; + + @Override + protected void beforeTest() { + ServiceClientClientBuilder serviceClientClientbuilder = new ServiceClientClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .client(Configuration.getGlobalConfiguration().get("CLIENT", "client")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + serviceClientClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + serviceClientClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + serviceClientClient = serviceClientClientbuilder.buildClient(); + + ServiceClientClientBuilder bazFooClientbuilder = new ServiceClientClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .client(Configuration.getGlobalConfiguration().get("CLIENT", "client")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + bazFooClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + bazFooClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + bazFooClient = bazFooClientbuilder.buildBazFooClient(); + + ServiceClientClientBuilder quxClientbuilder = new ServiceClientClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .client(Configuration.getGlobalConfiguration().get("CLIENT", "client")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + quxClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + quxClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + quxClient = quxClientbuilder.buildQuxClient(); + + ServiceClientClientBuilder quxBarClientbuilder = new ServiceClientClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .client(Configuration.getGlobalConfiguration().get("CLIENT", "client")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + quxBarClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + quxBarClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + quxBarClient = quxBarClientbuilder.buildQuxBarClient(); + + ServiceClientClientBuilder fooClientbuilder = new ServiceClientClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .client(Configuration.getGlobalConfiguration().get("CLIENT", "client")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + fooClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + fooClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + fooClient = fooClientbuilder.buildFooClient(); + + ServiceClientClientBuilder barClientbuilder = new ServiceClientClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .client(Configuration.getGlobalConfiguration().get("CLIENT", "client")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + barClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + barClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + barClient = barClientbuilder.buildBarClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/structure/service/generated/TwoOperationGroupClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/structure/service/generated/TwoOperationGroupClientTestBase.java new file mode 100644 index 000000000..1b28bd50a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/client/structure/service/generated/TwoOperationGroupClientTestBase.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.client.structure.service.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.HttpClient; +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 com.client.structure.service.Group1Client; +import com.client.structure.service.Group2Client; +import com.client.structure.service.TwoOperationGroupClientBuilder; + +class TwoOperationGroupClientTestBase extends TestProxyTestBase { + protected Group1Client group1Client; + + protected Group2Client group2Client; + + @Override + protected void beforeTest() { + TwoOperationGroupClientBuilder group1Clientbuilder = new TwoOperationGroupClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .client(Configuration.getGlobalConfiguration().get("CLIENT", "client")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + group1Clientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + group1Clientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + group1Client = group1Clientbuilder.buildGroup1Client(); + + TwoOperationGroupClientBuilder group2Clientbuilder = new TwoOperationGroupClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .client(Configuration.getGlobalConfiguration().get("CLIENT", "client")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + group2Clientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + group2Clientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + group2Client = group2Clientbuilder.buildGroup2Client(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/encode/bytes/generated/BytesClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/encode/bytes/generated/BytesClientTestBase.java new file mode 100644 index 000000000..4cab5d91d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/encode/bytes/generated/BytesClientTestBase.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.bytes.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.HttpClient; +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 com.encode.bytes.BytesClientBuilder; +import com.encode.bytes.HeaderClient; +import com.encode.bytes.PropertyClient; +import com.encode.bytes.QueryClient; +import com.encode.bytes.RequestBodyClient; +import com.encode.bytes.ResponseBodyClient; + +class BytesClientTestBase extends TestProxyTestBase { + protected QueryClient queryClient; + + protected PropertyClient propertyClient; + + protected HeaderClient headerClient; + + protected RequestBodyClient requestBodyClient; + + protected ResponseBodyClient responseBodyClient; + + @Override + protected void beforeTest() { + BytesClientBuilder queryClientbuilder = new BytesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + queryClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + queryClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + queryClient = queryClientbuilder.buildQueryClient(); + + BytesClientBuilder propertyClientbuilder = new BytesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + propertyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + propertyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + propertyClient = propertyClientbuilder.buildPropertyClient(); + + BytesClientBuilder headerClientbuilder = new BytesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + headerClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + headerClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + headerClient = headerClientbuilder.buildHeaderClient(); + + BytesClientBuilder requestBodyClientbuilder = new BytesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + requestBodyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + requestBodyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + requestBodyClient = requestBodyClientbuilder.buildRequestBodyClient(); + + BytesClientBuilder responseBodyClientbuilder = new BytesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + responseBodyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + responseBodyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + responseBodyClient = responseBodyClientbuilder.buildResponseBodyClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/encode/datetime/generated/DatetimeClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/encode/datetime/generated/DatetimeClientTestBase.java new file mode 100644 index 000000000..05d83226c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/encode/datetime/generated/DatetimeClientTestBase.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.datetime.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.HttpClient; +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 com.encode.datetime.DatetimeClientBuilder; +import com.encode.datetime.HeaderClient; +import com.encode.datetime.PropertyClient; +import com.encode.datetime.QueryClient; +import com.encode.datetime.ResponseHeaderClient; + +class DatetimeClientTestBase extends TestProxyTestBase { + protected QueryClient queryClient; + + protected PropertyClient propertyClient; + + protected HeaderClient headerClient; + + protected ResponseHeaderClient responseHeaderClient; + + @Override + protected void beforeTest() { + DatetimeClientBuilder queryClientbuilder = new DatetimeClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + queryClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + queryClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + queryClient = queryClientbuilder.buildQueryClient(); + + DatetimeClientBuilder propertyClientbuilder = new DatetimeClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + propertyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + propertyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + propertyClient = propertyClientbuilder.buildPropertyClient(); + + DatetimeClientBuilder headerClientbuilder = new DatetimeClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + headerClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + headerClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + headerClient = headerClientbuilder.buildHeaderClient(); + + DatetimeClientBuilder responseHeaderClientbuilder = new DatetimeClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + responseHeaderClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + responseHeaderClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + responseHeaderClient = responseHeaderClientbuilder.buildResponseHeaderClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/encode/duration/generated/DurationClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/encode/duration/generated/DurationClientTestBase.java new file mode 100644 index 000000000..ff419aed9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/encode/duration/generated/DurationClientTestBase.java @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.encode.duration.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.HttpClient; +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 com.encode.duration.DurationClientBuilder; +import com.encode.duration.HeaderClient; +import com.encode.duration.PropertyClient; +import com.encode.duration.QueryClient; + +class DurationClientTestBase extends TestProxyTestBase { + protected QueryClient queryClient; + + protected PropertyClient propertyClient; + + protected HeaderClient headerClient; + + @Override + protected void beforeTest() { + DurationClientBuilder queryClientbuilder = new DurationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + queryClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + queryClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + queryClient = queryClientbuilder.buildQueryClient(); + + DurationClientBuilder propertyClientbuilder = new DurationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + propertyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + propertyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + propertyClient = propertyClientbuilder.buildPropertyClient(); + + DurationClientBuilder headerClientbuilder = new DurationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + headerClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + headerClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + headerClient = headerClientbuilder.buildHeaderClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/parameters/basic/generated/BasicClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/parameters/basic/generated/BasicClientTestBase.java new file mode 100644 index 000000000..7196d63b3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/parameters/basic/generated/BasicClientTestBase.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.basic.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.HttpClient; +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 com.parameters.basic.BasicClientBuilder; +import com.parameters.basic.ExplicitBodyClient; +import com.parameters.basic.ImplicitBodyClient; + +class BasicClientTestBase extends TestProxyTestBase { + protected ExplicitBodyClient explicitBodyClient; + + protected ImplicitBodyClient implicitBodyClient; + + @Override + protected void beforeTest() { + BasicClientBuilder explicitBodyClientbuilder = new BasicClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + explicitBodyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + explicitBodyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + explicitBodyClient = explicitBodyClientbuilder.buildExplicitBodyClient(); + + BasicClientBuilder implicitBodyClientbuilder = new BasicClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + implicitBodyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + implicitBodyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + implicitBodyClient = implicitBodyClientbuilder.buildImplicitBodyClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/parameters/bodyoptionality/generated/BodyOptionalityClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/parameters/bodyoptionality/generated/BodyOptionalityClientTestBase.java new file mode 100644 index 000000000..1c0c67e14 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/parameters/bodyoptionality/generated/BodyOptionalityClientTestBase.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.bodyoptionality.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.HttpClient; +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 com.parameters.bodyoptionality.BodyOptionalityClient; +import com.parameters.bodyoptionality.BodyOptionalityClientBuilder; +import com.parameters.bodyoptionality.OptionalExplicitClient; + +class BodyOptionalityClientTestBase extends TestProxyTestBase { + protected BodyOptionalityClient bodyOptionalityClient; + + protected OptionalExplicitClient optionalExplicitClient; + + @Override + protected void beforeTest() { + BodyOptionalityClientBuilder bodyOptionalityClientbuilder = new BodyOptionalityClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + bodyOptionalityClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + bodyOptionalityClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + bodyOptionalityClient = bodyOptionalityClientbuilder.buildClient(); + + BodyOptionalityClientBuilder optionalExplicitClientbuilder = new BodyOptionalityClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + optionalExplicitClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + optionalExplicitClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + optionalExplicitClient = optionalExplicitClientbuilder.buildOptionalExplicitClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/parameters/collectionformat/generated/CollectionFormatClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/parameters/collectionformat/generated/CollectionFormatClientTestBase.java new file mode 100644 index 000000000..52bded472 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/parameters/collectionformat/generated/CollectionFormatClientTestBase.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.collectionformat.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.HttpClient; +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 com.parameters.collectionformat.CollectionFormatClientBuilder; +import com.parameters.collectionformat.HeaderClient; +import com.parameters.collectionformat.QueryClient; + +class CollectionFormatClientTestBase extends TestProxyTestBase { + protected QueryClient queryClient; + + protected HeaderClient headerClient; + + @Override + protected void beforeTest() { + CollectionFormatClientBuilder queryClientbuilder = new CollectionFormatClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + queryClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + queryClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + queryClient = queryClientbuilder.buildQueryClient(); + + CollectionFormatClientBuilder headerClientbuilder = new CollectionFormatClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + headerClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + headerClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + headerClient = headerClientbuilder.buildHeaderClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/parameters/spread/generated/SpreadClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/parameters/spread/generated/SpreadClientTestBase.java new file mode 100644 index 000000000..eb5434fc3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/parameters/spread/generated/SpreadClientTestBase.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.parameters.spread.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.HttpClient; +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 com.parameters.spread.AliasClient; +import com.parameters.spread.ModelClient; +import com.parameters.spread.SpreadClientBuilder; + +class SpreadClientTestBase extends TestProxyTestBase { + protected ModelClient modelClient; + + protected AliasClient aliasClient; + + @Override + protected void beforeTest() { + SpreadClientBuilder modelClientbuilder = new SpreadClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + modelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + modelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + modelClient = modelClientbuilder.buildModelClient(); + + SpreadClientBuilder aliasClientbuilder = new SpreadClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + aliasClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + aliasClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + aliasClient = aliasClientbuilder.buildAliasClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/contentnegotiation/generated/ContentNegotiationClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/contentnegotiation/generated/ContentNegotiationClientTestBase.java new file mode 100644 index 000000000..fe4c66c65 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/contentnegotiation/generated/ContentNegotiationClientTestBase.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.contentnegotiation.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.HttpClient; +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 com.payload.contentnegotiation.ContentNegotiationClientBuilder; +import com.payload.contentnegotiation.DifferentBodyClient; +import com.payload.contentnegotiation.SameBodyClient; + +class ContentNegotiationClientTestBase extends TestProxyTestBase { + protected SameBodyClient sameBodyClient; + + protected DifferentBodyClient differentBodyClient; + + @Override + protected void beforeTest() { + ContentNegotiationClientBuilder sameBodyClientbuilder = new ContentNegotiationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + sameBodyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + sameBodyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + sameBodyClient = sameBodyClientbuilder.buildSameBodyClient(); + + ContentNegotiationClientBuilder differentBodyClientbuilder = new ContentNegotiationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + differentBodyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + differentBodyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + differentBodyClient = differentBodyClientbuilder.buildDifferentBodyClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/jsonmergepatch/generated/JsonMergePatchClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/jsonmergepatch/generated/JsonMergePatchClientTestBase.java new file mode 100644 index 000000000..bb9a6ab6d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/jsonmergepatch/generated/JsonMergePatchClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.jsonmergepatch.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.HttpClient; +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 com.payload.jsonmergepatch.JsonMergePatchClient; +import com.payload.jsonmergepatch.JsonMergePatchClientBuilder; + +class JsonMergePatchClientTestBase extends TestProxyTestBase { + protected JsonMergePatchClient jsonMergePatchClient; + + @Override + protected void beforeTest() { + JsonMergePatchClientBuilder jsonMergePatchClientbuilder = new JsonMergePatchClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + jsonMergePatchClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + jsonMergePatchClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + jsonMergePatchClient = jsonMergePatchClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/mediatype/generated/MediaTypeClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/mediatype/generated/MediaTypeClientTestBase.java new file mode 100644 index 000000000..8a5752d00 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/mediatype/generated/MediaTypeClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.mediatype.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.HttpClient; +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 com.payload.mediatype.MediaTypeClient; +import com.payload.mediatype.MediaTypeClientBuilder; + +class MediaTypeClientTestBase extends TestProxyTestBase { + protected MediaTypeClient mediaTypeClient; + + @Override + protected void beforeTest() { + MediaTypeClientBuilder mediaTypeClientbuilder = new MediaTypeClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + mediaTypeClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + mediaTypeClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + mediaTypeClient = mediaTypeClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/multipart/generated/MultiPartClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/multipart/generated/MultiPartClientTestBase.java new file mode 100644 index 000000000..5b1b0baf8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/multipart/generated/MultiPartClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.multipart.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.HttpClient; +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 com.payload.multipart.MultiPartClient; +import com.payload.multipart.MultiPartClientBuilder; + +class MultiPartClientTestBase extends TestProxyTestBase { + protected MultiPartClient multiPartClient; + + @Override + protected void beforeTest() { + MultiPartClientBuilder multiPartClientbuilder = new MultiPartClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + multiPartClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + multiPartClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + multiPartClient = multiPartClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/pageable/generated/PageableClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/pageable/generated/PageableClientTestBase.java new file mode 100644 index 000000000..457250402 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/payload/pageable/generated/PageableClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.payload.pageable.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.HttpClient; +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 com.payload.pageable.PageableClient; +import com.payload.pageable.PageableClientBuilder; + +class PageableClientTestBase extends TestProxyTestBase { + protected PageableClient pageableClient; + + @Override + protected void beforeTest() { + PageableClientBuilder pageableClientbuilder = new PageableClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + pageableClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + pageableClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + pageableClient = pageableClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/resiliency/servicedriven/generated/ResiliencyServiceDrivenClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/resiliency/servicedriven/generated/ResiliencyServiceDrivenClientTestBase.java new file mode 100644 index 000000000..b42cd18d8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/resiliency/servicedriven/generated/ResiliencyServiceDrivenClientTestBase.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.resiliency.servicedriven.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.HttpClient; +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 com.resiliency.servicedriven.ResiliencyServiceDrivenClient; +import com.resiliency.servicedriven.ResiliencyServiceDrivenClientBuilder; + +class ResiliencyServiceDrivenClientTestBase extends TestProxyTestBase { + protected ResiliencyServiceDrivenClient resiliencyServiceDrivenClient; + + @Override + protected void beforeTest() { + ResiliencyServiceDrivenClientBuilder resiliencyServiceDrivenClientbuilder + = new ResiliencyServiceDrivenClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .serviceDeploymentVersion( + Configuration.getGlobalConfiguration().get("SERVICEDEPLOYMENTVERSION", "servicedeploymentversion")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + resiliencyServiceDrivenClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + resiliencyServiceDrivenClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + resiliencyServiceDrivenClient = resiliencyServiceDrivenClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/resiliency/servicedriven/v1/generated/ResiliencyServiceDrivenClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/resiliency/servicedriven/v1/generated/ResiliencyServiceDrivenClientTestBase.java new file mode 100644 index 000000000..eec959eb9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/resiliency/servicedriven/v1/generated/ResiliencyServiceDrivenClientTestBase.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.resiliency.servicedriven.v1.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.HttpClient; +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 com.resiliency.servicedriven.v1.ResiliencyServiceDrivenClient; +import com.resiliency.servicedriven.v1.ResiliencyServiceDrivenClientBuilder; + +class ResiliencyServiceDrivenClientTestBase extends TestProxyTestBase { + protected ResiliencyServiceDrivenClient resiliencyServiceDrivenClient; + + @Override + protected void beforeTest() { + ResiliencyServiceDrivenClientBuilder resiliencyServiceDrivenClientbuilder + = new ResiliencyServiceDrivenClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .serviceDeploymentVersion( + Configuration.getGlobalConfiguration().get("SERVICEDEPLOYMENTVERSION", "servicedeploymentversion")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + resiliencyServiceDrivenClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + resiliencyServiceDrivenClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + resiliencyServiceDrivenClient = resiliencyServiceDrivenClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/serialization/encodedname/json/generated/JsonClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/serialization/encodedname/json/generated/JsonClientTestBase.java new file mode 100644 index 000000000..48e63770d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/serialization/encodedname/json/generated/JsonClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.serialization.encodedname.json.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.HttpClient; +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 com.serialization.encodedname.json.JsonClient; +import com.serialization.encodedname.json.JsonClientBuilder; + +class JsonClientTestBase extends TestProxyTestBase { + protected JsonClient jsonClient; + + @Override + protected void beforeTest() { + JsonClientBuilder jsonClientbuilder = new JsonClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + jsonClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + jsonClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + jsonClient = jsonClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/endpoint/notdefined/generated/NotDefinedClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/endpoint/notdefined/generated/NotDefinedClientTestBase.java new file mode 100644 index 000000000..89ab5999d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/endpoint/notdefined/generated/NotDefinedClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.endpoint.notdefined.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.HttpClient; +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 com.server.endpoint.notdefined.NotDefinedClient; +import com.server.endpoint.notdefined.NotDefinedClientBuilder; + +class NotDefinedClientTestBase extends TestProxyTestBase { + protected NotDefinedClient notDefinedClient; + + @Override + protected void beforeTest() { + NotDefinedClientBuilder notDefinedClientbuilder + = new NotDefinedClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + notDefinedClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + notDefinedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + notDefinedClient = notDefinedClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/path/multiple/generated/MultipleClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/path/multiple/generated/MultipleClientTestBase.java new file mode 100644 index 000000000..a1e559765 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/path/multiple/generated/MultipleClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.path.multiple.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.HttpClient; +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 com.server.path.multiple.MultipleClient; +import com.server.path.multiple.MultipleClientBuilder; + +class MultipleClientTestBase extends TestProxyTestBase { + protected MultipleClient multipleClient; + + @Override + protected void beforeTest() { + MultipleClientBuilder multipleClientbuilder + = new MultipleClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + multipleClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + multipleClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + multipleClient = multipleClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/path/single/generated/SingleClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/path/single/generated/SingleClientTestBase.java new file mode 100644 index 000000000..d85d57d87 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/path/single/generated/SingleClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.path.single.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.HttpClient; +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 com.server.path.single.SingleClient; +import com.server.path.single.SingleClientBuilder; + +class SingleClientTestBase extends TestProxyTestBase { + protected SingleClient singleClient; + + @Override + protected void beforeTest() { + SingleClientBuilder singleClientbuilder + = new SingleClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + singleClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + singleClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + singleClient = singleClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/versions/notversioned/generated/NotVersionedClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/versions/notversioned/generated/NotVersionedClientTestBase.java new file mode 100644 index 000000000..5aa4f10da --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/versions/notversioned/generated/NotVersionedClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.versions.notversioned.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.HttpClient; +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 com.server.versions.notversioned.NotVersionedClient; +import com.server.versions.notversioned.NotVersionedClientBuilder; + +class NotVersionedClientTestBase extends TestProxyTestBase { + protected NotVersionedClient notVersionedClient; + + @Override + protected void beforeTest() { + NotVersionedClientBuilder notVersionedClientbuilder = new NotVersionedClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + notVersionedClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + notVersionedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + notVersionedClient = notVersionedClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/versions/versioned/generated/VersionedClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/versions/versioned/generated/VersionedClientTestBase.java new file mode 100644 index 000000000..bd28be9ac --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/server/versions/versioned/generated/VersionedClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.server.versions.versioned.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.HttpClient; +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 com.server.versions.versioned.VersionedClient; +import com.server.versions.versioned.VersionedClientBuilder; + +class VersionedClientTestBase extends TestProxyTestBase { + protected VersionedClient versionedClient; + + @Override + protected void beforeTest() { + VersionedClientBuilder versionedClientbuilder + = new VersionedClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + versionedClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + versionedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + versionedClient = versionedClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/specialheaders/conditionalrequest/generated/ConditionalRequestClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/specialheaders/conditionalrequest/generated/ConditionalRequestClientTestBase.java new file mode 100644 index 000000000..6f5874417 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/specialheaders/conditionalrequest/generated/ConditionalRequestClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialheaders.conditionalrequest.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.HttpClient; +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 com.specialheaders.conditionalrequest.ConditionalRequestClient; +import com.specialheaders.conditionalrequest.ConditionalRequestClientBuilder; + +class ConditionalRequestClientTestBase extends TestProxyTestBase { + protected ConditionalRequestClient conditionalRequestClient; + + @Override + protected void beforeTest() { + ConditionalRequestClientBuilder conditionalRequestClientbuilder = new ConditionalRequestClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + conditionalRequestClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + conditionalRequestClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + conditionalRequestClient = conditionalRequestClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/specialheaders/repeatability/generated/RepeatabilityClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/specialheaders/repeatability/generated/RepeatabilityClientTestBase.java new file mode 100644 index 000000000..9dd8381c2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/specialheaders/repeatability/generated/RepeatabilityClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialheaders.repeatability.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.HttpClient; +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 com.specialheaders.repeatability.RepeatabilityClient; +import com.specialheaders.repeatability.RepeatabilityClientBuilder; + +class RepeatabilityClientTestBase extends TestProxyTestBase { + protected RepeatabilityClient repeatabilityClient; + + @Override + protected void beforeTest() { + RepeatabilityClientBuilder repeatabilityClientbuilder = new RepeatabilityClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + repeatabilityClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + repeatabilityClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + repeatabilityClient = repeatabilityClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/specialwords/generated/SpecialWordsClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/specialwords/generated/SpecialWordsClientTestBase.java new file mode 100644 index 000000000..a9f0e5e14 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/specialwords/generated/SpecialWordsClientTestBase.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.specialwords.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.HttpClient; +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 com.specialwords.ModelPropertiesClient; +import com.specialwords.ModelsClient; +import com.specialwords.OperationsClient; +import com.specialwords.ParametersClient; +import com.specialwords.SpecialWordsClientBuilder; + +class SpecialWordsClientTestBase extends TestProxyTestBase { + protected ModelsClient modelsClient; + + protected ModelPropertiesClient modelPropertiesClient; + + protected OperationsClient operationsClient; + + protected ParametersClient parametersClient; + + @Override + protected void beforeTest() { + SpecialWordsClientBuilder modelsClientbuilder = new SpecialWordsClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + modelsClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + modelsClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + modelsClient = modelsClientbuilder.buildModelsClient(); + + SpecialWordsClientBuilder modelPropertiesClientbuilder = new SpecialWordsClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + modelPropertiesClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + modelPropertiesClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + modelPropertiesClient = modelPropertiesClientbuilder.buildModelPropertiesClient(); + + SpecialWordsClientBuilder operationsClientbuilder = new SpecialWordsClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + operationsClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + operationsClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + operationsClient = operationsClientbuilder.buildOperationsClient(); + + SpecialWordsClientBuilder parametersClientbuilder = new SpecialWordsClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + parametersClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + parametersClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + parametersClient = parametersClientbuilder.buildParametersClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/array/generated/ArrayClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/array/generated/ArrayClientTestBase.java new file mode 100644 index 000000000..dff94f0fa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/array/generated/ArrayClientTestBase.java @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.array.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.HttpClient; +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 com.type.array.ArrayClientBuilder; +import com.type.array.BooleanValueClient; +import com.type.array.DatetimeValueClient; +import com.type.array.DurationValueClient; +import com.type.array.Float32ValueClient; +import com.type.array.Int32ValueClient; +import com.type.array.Int64ValueClient; +import com.type.array.ModelValueClient; +import com.type.array.NullableBooleanValueClient; +import com.type.array.NullableFloatValueClient; +import com.type.array.NullableInt32ValueClient; +import com.type.array.NullableModelValueClient; +import com.type.array.NullableStringValueClient; +import com.type.array.StringValueClient; +import com.type.array.UnknownValueClient; + +class ArrayClientTestBase extends TestProxyTestBase { + protected Int32ValueClient int32ValueClient; + + protected Int64ValueClient int64ValueClient; + + protected BooleanValueClient booleanValueClient; + + protected StringValueClient stringValueClient; + + protected Float32ValueClient float32ValueClient; + + protected DatetimeValueClient datetimeValueClient; + + protected DurationValueClient durationValueClient; + + protected UnknownValueClient unknownValueClient; + + protected ModelValueClient modelValueClient; + + protected NullableFloatValueClient nullableFloatValueClient; + + protected NullableInt32ValueClient nullableInt32ValueClient; + + protected NullableBooleanValueClient nullableBooleanValueClient; + + protected NullableStringValueClient nullableStringValueClient; + + protected NullableModelValueClient nullableModelValueClient; + + @Override + protected void beforeTest() { + ArrayClientBuilder int32ValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + int32ValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + int32ValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + int32ValueClient = int32ValueClientbuilder.buildInt32ValueClient(); + + ArrayClientBuilder int64ValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + int64ValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + int64ValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + int64ValueClient = int64ValueClientbuilder.buildInt64ValueClient(); + + ArrayClientBuilder booleanValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + booleanValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + booleanValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + booleanValueClient = booleanValueClientbuilder.buildBooleanValueClient(); + + ArrayClientBuilder stringValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + stringValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + stringValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + stringValueClient = stringValueClientbuilder.buildStringValueClient(); + + ArrayClientBuilder float32ValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + float32ValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + float32ValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + float32ValueClient = float32ValueClientbuilder.buildFloat32ValueClient(); + + ArrayClientBuilder datetimeValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + datetimeValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + datetimeValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + datetimeValueClient = datetimeValueClientbuilder.buildDatetimeValueClient(); + + ArrayClientBuilder durationValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + durationValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + durationValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + durationValueClient = durationValueClientbuilder.buildDurationValueClient(); + + ArrayClientBuilder unknownValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unknownValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unknownValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unknownValueClient = unknownValueClientbuilder.buildUnknownValueClient(); + + ArrayClientBuilder modelValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + modelValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + modelValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + modelValueClient = modelValueClientbuilder.buildModelValueClient(); + + ArrayClientBuilder nullableFloatValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + nullableFloatValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + nullableFloatValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + nullableFloatValueClient = nullableFloatValueClientbuilder.buildNullableFloatValueClient(); + + ArrayClientBuilder nullableInt32ValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + nullableInt32ValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + nullableInt32ValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + nullableInt32ValueClient = nullableInt32ValueClientbuilder.buildNullableInt32ValueClient(); + + ArrayClientBuilder nullableBooleanValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + nullableBooleanValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + nullableBooleanValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + nullableBooleanValueClient = nullableBooleanValueClientbuilder.buildNullableBooleanValueClient(); + + ArrayClientBuilder nullableStringValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + nullableStringValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + nullableStringValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + nullableStringValueClient = nullableStringValueClientbuilder.buildNullableStringValueClient(); + + ArrayClientBuilder nullableModelValueClientbuilder = new ArrayClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + nullableModelValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + nullableModelValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + nullableModelValueClient = nullableModelValueClientbuilder.buildNullableModelValueClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/dictionary/generated/DictionaryClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/dictionary/generated/DictionaryClientTestBase.java new file mode 100644 index 000000000..eb6b0bd8a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/dictionary/generated/DictionaryClientTestBase.java @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.dictionary.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.HttpClient; +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 com.type.dictionary.BooleanValueClient; +import com.type.dictionary.DatetimeValueClient; +import com.type.dictionary.DictionaryClientBuilder; +import com.type.dictionary.DurationValueClient; +import com.type.dictionary.Float32ValueClient; +import com.type.dictionary.Int32ValueClient; +import com.type.dictionary.Int64ValueClient; +import com.type.dictionary.ModelValueClient; +import com.type.dictionary.NullableFloatValueClient; +import com.type.dictionary.RecursiveModelValueClient; +import com.type.dictionary.StringValueClient; +import com.type.dictionary.UnknownValueClient; + +class DictionaryClientTestBase extends TestProxyTestBase { + protected Int32ValueClient int32ValueClient; + + protected Int64ValueClient int64ValueClient; + + protected BooleanValueClient booleanValueClient; + + protected StringValueClient stringValueClient; + + protected Float32ValueClient float32ValueClient; + + protected DatetimeValueClient datetimeValueClient; + + protected DurationValueClient durationValueClient; + + protected UnknownValueClient unknownValueClient; + + protected ModelValueClient modelValueClient; + + protected RecursiveModelValueClient recursiveModelValueClient; + + protected NullableFloatValueClient nullableFloatValueClient; + + @Override + protected void beforeTest() { + DictionaryClientBuilder int32ValueClientbuilder = new DictionaryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + int32ValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + int32ValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + int32ValueClient = int32ValueClientbuilder.buildInt32ValueClient(); + + DictionaryClientBuilder int64ValueClientbuilder = new DictionaryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + int64ValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + int64ValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + int64ValueClient = int64ValueClientbuilder.buildInt64ValueClient(); + + DictionaryClientBuilder booleanValueClientbuilder = new DictionaryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + booleanValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + booleanValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + booleanValueClient = booleanValueClientbuilder.buildBooleanValueClient(); + + DictionaryClientBuilder stringValueClientbuilder = new DictionaryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + stringValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + stringValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + stringValueClient = stringValueClientbuilder.buildStringValueClient(); + + DictionaryClientBuilder float32ValueClientbuilder = new DictionaryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + float32ValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + float32ValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + float32ValueClient = float32ValueClientbuilder.buildFloat32ValueClient(); + + DictionaryClientBuilder datetimeValueClientbuilder = new DictionaryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + datetimeValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + datetimeValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + datetimeValueClient = datetimeValueClientbuilder.buildDatetimeValueClient(); + + DictionaryClientBuilder durationValueClientbuilder = new DictionaryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + durationValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + durationValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + durationValueClient = durationValueClientbuilder.buildDurationValueClient(); + + DictionaryClientBuilder unknownValueClientbuilder = new DictionaryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unknownValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unknownValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unknownValueClient = unknownValueClientbuilder.buildUnknownValueClient(); + + DictionaryClientBuilder modelValueClientbuilder = new DictionaryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + modelValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + modelValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + modelValueClient = modelValueClientbuilder.buildModelValueClient(); + + DictionaryClientBuilder recursiveModelValueClientbuilder = new DictionaryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + recursiveModelValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + recursiveModelValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + recursiveModelValueClient = recursiveModelValueClientbuilder.buildRecursiveModelValueClient(); + + DictionaryClientBuilder nullableFloatValueClientbuilder = new DictionaryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + nullableFloatValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + nullableFloatValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + nullableFloatValueClient = nullableFloatValueClientbuilder.buildNullableFloatValueClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/enums/extensible/generated/ExtensibleClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/enums/extensible/generated/ExtensibleClientTestBase.java new file mode 100644 index 000000000..c69dc4555 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/enums/extensible/generated/ExtensibleClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.enums.extensible.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.HttpClient; +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 com.type.enums.extensible.ExtensibleClient; +import com.type.enums.extensible.ExtensibleClientBuilder; + +class ExtensibleClientTestBase extends TestProxyTestBase { + protected ExtensibleClient extensibleClient; + + @Override + protected void beforeTest() { + ExtensibleClientBuilder extensibleClientbuilder = new ExtensibleClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extensibleClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extensibleClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extensibleClient = extensibleClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/enums/fixed/generated/FixedClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/enums/fixed/generated/FixedClientTestBase.java new file mode 100644 index 000000000..42c3443db --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/enums/fixed/generated/FixedClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.enums.fixed.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.HttpClient; +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 com.type.enums.fixed.FixedClient; +import com.type.enums.fixed.FixedClientBuilder; + +class FixedClientTestBase extends TestProxyTestBase { + protected FixedClient fixedClient; + + @Override + protected void beforeTest() { + FixedClientBuilder fixedClientbuilder = new FixedClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + fixedClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + fixedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + fixedClient = fixedClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/empty/generated/EmptyClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/empty/generated/EmptyClientTestBase.java new file mode 100644 index 000000000..b79668911 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/empty/generated/EmptyClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.empty.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.HttpClient; +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 com.type.model.empty.EmptyClient; +import com.type.model.empty.EmptyClientBuilder; + +class EmptyClientTestBase extends TestProxyTestBase { + protected EmptyClient emptyClient; + + @Override + protected void beforeTest() { + EmptyClientBuilder emptyClientbuilder = new EmptyClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + emptyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + emptyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + emptyClient = emptyClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/flatten/generated/FlattenClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/flatten/generated/FlattenClientTestBase.java new file mode 100644 index 000000000..cbfde057d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/flatten/generated/FlattenClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.flatten.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.HttpClient; +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 com.type.model.flatten.FlattenClient; +import com.type.model.flatten.FlattenClientBuilder; + +class FlattenClientTestBase extends TestProxyTestBase { + protected FlattenClient flattenClient; + + @Override + protected void beforeTest() { + FlattenClientBuilder flattenClientbuilder = new FlattenClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + flattenClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + flattenClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + flattenClient = flattenClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/enumdiscriminator/generated/EnumDiscriminatorClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/enumdiscriminator/generated/EnumDiscriminatorClientTestBase.java new file mode 100644 index 000000000..3dfa60cca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/enumdiscriminator/generated/EnumDiscriminatorClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumdiscriminator.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.HttpClient; +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 com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient; +import com.type.model.inheritance.enumdiscriminator.EnumDiscriminatorClientBuilder; + +class EnumDiscriminatorClientTestBase extends TestProxyTestBase { + protected EnumDiscriminatorClient enumDiscriminatorClient; + + @Override + protected void beforeTest() { + EnumDiscriminatorClientBuilder enumDiscriminatorClientbuilder = new EnumDiscriminatorClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + enumDiscriminatorClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + enumDiscriminatorClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + enumDiscriminatorClient = enumDiscriminatorClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/enumnesteddiscriminator/generated/EnumNestedDiscriminatorClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/enumnesteddiscriminator/generated/EnumNestedDiscriminatorClientTestBase.java new file mode 100644 index 000000000..ccc471398 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/enumnesteddiscriminator/generated/EnumNestedDiscriminatorClientTestBase.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.enumnesteddiscriminator.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.HttpClient; +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 com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClient; +import com.type.model.inheritance.enumnesteddiscriminator.EnumNestedDiscriminatorClientBuilder; + +class EnumNestedDiscriminatorClientTestBase extends TestProxyTestBase { + protected EnumNestedDiscriminatorClient enumNestedDiscriminatorClient; + + @Override + protected void beforeTest() { + EnumNestedDiscriminatorClientBuilder enumNestedDiscriminatorClientbuilder + = new EnumNestedDiscriminatorClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + enumNestedDiscriminatorClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + enumNestedDiscriminatorClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + enumNestedDiscriminatorClient = enumNestedDiscriminatorClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/nesteddiscriminator/generated/NestedDiscriminatorClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/nesteddiscriminator/generated/NestedDiscriminatorClientTestBase.java new file mode 100644 index 000000000..f22e376b2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/nesteddiscriminator/generated/NestedDiscriminatorClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.nesteddiscriminator.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.HttpClient; +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 com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient; +import com.type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClientBuilder; + +class NestedDiscriminatorClientTestBase extends TestProxyTestBase { + protected NestedDiscriminatorClient nestedDiscriminatorClient; + + @Override + protected void beforeTest() { + NestedDiscriminatorClientBuilder nestedDiscriminatorClientbuilder = new NestedDiscriminatorClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + nestedDiscriminatorClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + nestedDiscriminatorClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + nestedDiscriminatorClient = nestedDiscriminatorClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/notdiscriminated/generated/NotDiscriminatedClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/notdiscriminated/generated/NotDiscriminatedClientTestBase.java new file mode 100644 index 000000000..980407e0d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/notdiscriminated/generated/NotDiscriminatedClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.notdiscriminated.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.HttpClient; +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 com.type.model.inheritance.notdiscriminated.NotDiscriminatedClient; +import com.type.model.inheritance.notdiscriminated.NotDiscriminatedClientBuilder; + +class NotDiscriminatedClientTestBase extends TestProxyTestBase { + protected NotDiscriminatedClient notDiscriminatedClient; + + @Override + protected void beforeTest() { + NotDiscriminatedClientBuilder notDiscriminatedClientbuilder = new NotDiscriminatedClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + notDiscriminatedClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + notDiscriminatedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + notDiscriminatedClient = notDiscriminatedClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/recursive/generated/RecursiveClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/recursive/generated/RecursiveClientTestBase.java new file mode 100644 index 000000000..15cc609f6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/recursive/generated/RecursiveClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.recursive.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.HttpClient; +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 com.type.model.inheritance.recursive.RecursiveClient; +import com.type.model.inheritance.recursive.RecursiveClientBuilder; + +class RecursiveClientTestBase extends TestProxyTestBase { + protected RecursiveClient recursiveClient; + + @Override + protected void beforeTest() { + RecursiveClientBuilder recursiveClientbuilder = new RecursiveClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + recursiveClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + recursiveClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + recursiveClient = recursiveClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/singlediscriminator/generated/SingleDiscriminatorClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/singlediscriminator/generated/SingleDiscriminatorClientTestBase.java new file mode 100644 index 000000000..a871b2e7a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/inheritance/singlediscriminator/generated/SingleDiscriminatorClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.inheritance.singlediscriminator.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.HttpClient; +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 com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClient; +import com.type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder; + +class SingleDiscriminatorClientTestBase extends TestProxyTestBase { + protected SingleDiscriminatorClient singleDiscriminatorClient; + + @Override + protected void beforeTest() { + SingleDiscriminatorClientBuilder singleDiscriminatorClientbuilder = new SingleDiscriminatorClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + singleDiscriminatorClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + singleDiscriminatorClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + singleDiscriminatorClient = singleDiscriminatorClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/usage/generated/UsageClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/usage/generated/UsageClientTestBase.java new file mode 100644 index 000000000..e135b9c68 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/usage/generated/UsageClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.usage.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.HttpClient; +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 com.type.model.usage.UsageClient; +import com.type.model.usage.UsageClientBuilder; + +class UsageClientTestBase extends TestProxyTestBase { + protected UsageClient usageClient; + + @Override + protected void beforeTest() { + UsageClientBuilder usageClientbuilder = new UsageClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + usageClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + usageClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + usageClient = usageClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/visibility/generated/VisibilityClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/visibility/generated/VisibilityClientTestBase.java new file mode 100644 index 000000000..b610274bf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/model/visibility/generated/VisibilityClientTestBase.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.model.visibility.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.HttpClient; +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 com.type.model.visibility.VisibilityClient; +import com.type.model.visibility.VisibilityClientBuilder; + +class VisibilityClientTestBase extends TestProxyTestBase { + protected VisibilityClient visibilityClient; + + @Override + protected void beforeTest() { + VisibilityClientBuilder visibilityClientbuilder = new VisibilityClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + visibilityClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + visibilityClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + visibilityClient = visibilityClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/property/additionalproperties/generated/AdditionalPropertiesClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/property/additionalproperties/generated/AdditionalPropertiesClientTestBase.java new file mode 100644 index 000000000..2b3a3758d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/property/additionalproperties/generated/AdditionalPropertiesClientTestBase.java @@ -0,0 +1,490 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.additionalproperties.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.HttpClient; +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 com.type.property.additionalproperties.AdditionalPropertiesClientBuilder; +import com.type.property.additionalproperties.ExtendsDifferentSpreadFloatClient; +import com.type.property.additionalproperties.ExtendsDifferentSpreadModelArrayClient; +import com.type.property.additionalproperties.ExtendsDifferentSpreadModelClient; +import com.type.property.additionalproperties.ExtendsDifferentSpreadStringClient; +import com.type.property.additionalproperties.ExtendsFloatClient; +import com.type.property.additionalproperties.ExtendsModelArrayClient; +import com.type.property.additionalproperties.ExtendsModelClient; +import com.type.property.additionalproperties.ExtendsStringClient; +import com.type.property.additionalproperties.ExtendsUnknownClient; +import com.type.property.additionalproperties.ExtendsUnknownDerivedClient; +import com.type.property.additionalproperties.ExtendsUnknownDiscriminatedClient; +import com.type.property.additionalproperties.IsFloatClient; +import com.type.property.additionalproperties.IsModelArrayClient; +import com.type.property.additionalproperties.IsModelClient; +import com.type.property.additionalproperties.IsStringClient; +import com.type.property.additionalproperties.IsUnknownClient; +import com.type.property.additionalproperties.IsUnknownDerivedClient; +import com.type.property.additionalproperties.IsUnknownDiscriminatedClient; +import com.type.property.additionalproperties.MultipleSpreadClient; +import com.type.property.additionalproperties.SpreadDifferentFloatClient; +import com.type.property.additionalproperties.SpreadDifferentModelArrayClient; +import com.type.property.additionalproperties.SpreadDifferentModelClient; +import com.type.property.additionalproperties.SpreadDifferentStringClient; +import com.type.property.additionalproperties.SpreadFloatClient; +import com.type.property.additionalproperties.SpreadModelArrayClient; +import com.type.property.additionalproperties.SpreadModelClient; +import com.type.property.additionalproperties.SpreadRecordDiscriminatedUnionClient; +import com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2Client; +import com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3Client; +import com.type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionClient; +import com.type.property.additionalproperties.SpreadRecordUnionClient; +import com.type.property.additionalproperties.SpreadStringClient; + +class AdditionalPropertiesClientTestBase extends TestProxyTestBase { + protected ExtendsUnknownClient extendsUnknownClient; + + protected ExtendsUnknownDerivedClient extendsUnknownDerivedClient; + + protected ExtendsUnknownDiscriminatedClient extendsUnknownDiscriminatedClient; + + protected IsUnknownClient isUnknownClient; + + protected IsUnknownDerivedClient isUnknownDerivedClient; + + protected IsUnknownDiscriminatedClient isUnknownDiscriminatedClient; + + protected ExtendsStringClient extendsStringClient; + + protected IsStringClient isStringClient; + + protected SpreadStringClient spreadStringClient; + + protected ExtendsFloatClient extendsFloatClient; + + protected IsFloatClient isFloatClient; + + protected SpreadFloatClient spreadFloatClient; + + protected ExtendsModelClient extendsModelClient; + + protected IsModelClient isModelClient; + + protected SpreadModelClient spreadModelClient; + + protected ExtendsModelArrayClient extendsModelArrayClient; + + protected IsModelArrayClient isModelArrayClient; + + protected SpreadModelArrayClient spreadModelArrayClient; + + protected SpreadDifferentStringClient spreadDifferentStringClient; + + protected SpreadDifferentFloatClient spreadDifferentFloatClient; + + protected SpreadDifferentModelClient spreadDifferentModelClient; + + protected SpreadDifferentModelArrayClient spreadDifferentModelArrayClient; + + protected ExtendsDifferentSpreadStringClient extendsDifferentSpreadStringClient; + + protected ExtendsDifferentSpreadFloatClient extendsDifferentSpreadFloatClient; + + protected ExtendsDifferentSpreadModelClient extendsDifferentSpreadModelClient; + + protected ExtendsDifferentSpreadModelArrayClient extendsDifferentSpreadModelArrayClient; + + protected MultipleSpreadClient multipleSpreadClient; + + protected SpreadRecordUnionClient spreadRecordUnionClient; + + protected SpreadRecordDiscriminatedUnionClient spreadRecordDiscriminatedUnionClient; + + protected SpreadRecordNonDiscriminatedUnionClient spreadRecordNonDiscriminatedUnionClient; + + protected SpreadRecordNonDiscriminatedUnion2Client spreadRecordNonDiscriminatedUnion2Client; + + protected SpreadRecordNonDiscriminatedUnion3Client spreadRecordNonDiscriminatedUnion3Client; + + @Override + protected void beforeTest() { + AdditionalPropertiesClientBuilder extendsUnknownClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extendsUnknownClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extendsUnknownClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extendsUnknownClient = extendsUnknownClientbuilder.buildExtendsUnknownClient(); + + AdditionalPropertiesClientBuilder extendsUnknownDerivedClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extendsUnknownDerivedClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extendsUnknownDerivedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extendsUnknownDerivedClient = extendsUnknownDerivedClientbuilder.buildExtendsUnknownDerivedClient(); + + AdditionalPropertiesClientBuilder extendsUnknownDiscriminatedClientbuilder + = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extendsUnknownDiscriminatedClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extendsUnknownDiscriminatedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extendsUnknownDiscriminatedClient + = extendsUnknownDiscriminatedClientbuilder.buildExtendsUnknownDiscriminatedClient(); + + AdditionalPropertiesClientBuilder isUnknownClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + isUnknownClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + isUnknownClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + isUnknownClient = isUnknownClientbuilder.buildIsUnknownClient(); + + AdditionalPropertiesClientBuilder isUnknownDerivedClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + isUnknownDerivedClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + isUnknownDerivedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + isUnknownDerivedClient = isUnknownDerivedClientbuilder.buildIsUnknownDerivedClient(); + + AdditionalPropertiesClientBuilder isUnknownDiscriminatedClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + isUnknownDiscriminatedClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + isUnknownDiscriminatedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + isUnknownDiscriminatedClient = isUnknownDiscriminatedClientbuilder.buildIsUnknownDiscriminatedClient(); + + AdditionalPropertiesClientBuilder extendsStringClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extendsStringClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extendsStringClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extendsStringClient = extendsStringClientbuilder.buildExtendsStringClient(); + + AdditionalPropertiesClientBuilder isStringClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + isStringClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + isStringClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + isStringClient = isStringClientbuilder.buildIsStringClient(); + + AdditionalPropertiesClientBuilder spreadStringClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadStringClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadStringClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadStringClient = spreadStringClientbuilder.buildSpreadStringClient(); + + AdditionalPropertiesClientBuilder extendsFloatClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extendsFloatClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extendsFloatClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extendsFloatClient = extendsFloatClientbuilder.buildExtendsFloatClient(); + + AdditionalPropertiesClientBuilder isFloatClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + isFloatClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + isFloatClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + isFloatClient = isFloatClientbuilder.buildIsFloatClient(); + + AdditionalPropertiesClientBuilder spreadFloatClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadFloatClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadFloatClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadFloatClient = spreadFloatClientbuilder.buildSpreadFloatClient(); + + AdditionalPropertiesClientBuilder extendsModelClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extendsModelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extendsModelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extendsModelClient = extendsModelClientbuilder.buildExtendsModelClient(); + + AdditionalPropertiesClientBuilder isModelClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + isModelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + isModelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + isModelClient = isModelClientbuilder.buildIsModelClient(); + + AdditionalPropertiesClientBuilder spreadModelClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadModelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadModelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadModelClient = spreadModelClientbuilder.buildSpreadModelClient(); + + AdditionalPropertiesClientBuilder extendsModelArrayClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extendsModelArrayClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extendsModelArrayClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extendsModelArrayClient = extendsModelArrayClientbuilder.buildExtendsModelArrayClient(); + + AdditionalPropertiesClientBuilder isModelArrayClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + isModelArrayClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + isModelArrayClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + isModelArrayClient = isModelArrayClientbuilder.buildIsModelArrayClient(); + + AdditionalPropertiesClientBuilder spreadModelArrayClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadModelArrayClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadModelArrayClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadModelArrayClient = spreadModelArrayClientbuilder.buildSpreadModelArrayClient(); + + AdditionalPropertiesClientBuilder spreadDifferentStringClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadDifferentStringClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadDifferentStringClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadDifferentStringClient = spreadDifferentStringClientbuilder.buildSpreadDifferentStringClient(); + + AdditionalPropertiesClientBuilder spreadDifferentFloatClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadDifferentFloatClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadDifferentFloatClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadDifferentFloatClient = spreadDifferentFloatClientbuilder.buildSpreadDifferentFloatClient(); + + AdditionalPropertiesClientBuilder spreadDifferentModelClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadDifferentModelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadDifferentModelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadDifferentModelClient = spreadDifferentModelClientbuilder.buildSpreadDifferentModelClient(); + + AdditionalPropertiesClientBuilder spreadDifferentModelArrayClientbuilder + = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadDifferentModelArrayClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadDifferentModelArrayClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadDifferentModelArrayClient = spreadDifferentModelArrayClientbuilder.buildSpreadDifferentModelArrayClient(); + + AdditionalPropertiesClientBuilder extendsDifferentSpreadStringClientbuilder + = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extendsDifferentSpreadStringClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extendsDifferentSpreadStringClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extendsDifferentSpreadStringClient + = extendsDifferentSpreadStringClientbuilder.buildExtendsDifferentSpreadStringClient(); + + AdditionalPropertiesClientBuilder extendsDifferentSpreadFloatClientbuilder + = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extendsDifferentSpreadFloatClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extendsDifferentSpreadFloatClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extendsDifferentSpreadFloatClient + = extendsDifferentSpreadFloatClientbuilder.buildExtendsDifferentSpreadFloatClient(); + + AdditionalPropertiesClientBuilder extendsDifferentSpreadModelClientbuilder + = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extendsDifferentSpreadModelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extendsDifferentSpreadModelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extendsDifferentSpreadModelClient + = extendsDifferentSpreadModelClientbuilder.buildExtendsDifferentSpreadModelClient(); + + AdditionalPropertiesClientBuilder extendsDifferentSpreadModelArrayClientbuilder + = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extendsDifferentSpreadModelArrayClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extendsDifferentSpreadModelArrayClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extendsDifferentSpreadModelArrayClient + = extendsDifferentSpreadModelArrayClientbuilder.buildExtendsDifferentSpreadModelArrayClient(); + + AdditionalPropertiesClientBuilder multipleSpreadClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + multipleSpreadClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + multipleSpreadClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + multipleSpreadClient = multipleSpreadClientbuilder.buildMultipleSpreadClient(); + + AdditionalPropertiesClientBuilder spreadRecordUnionClientbuilder = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadRecordUnionClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadRecordUnionClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadRecordUnionClient = spreadRecordUnionClientbuilder.buildSpreadRecordUnionClient(); + + AdditionalPropertiesClientBuilder spreadRecordDiscriminatedUnionClientbuilder + = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadRecordDiscriminatedUnionClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadRecordDiscriminatedUnionClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadRecordDiscriminatedUnionClient + = spreadRecordDiscriminatedUnionClientbuilder.buildSpreadRecordDiscriminatedUnionClient(); + + AdditionalPropertiesClientBuilder spreadRecordNonDiscriminatedUnionClientbuilder + = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadRecordNonDiscriminatedUnionClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadRecordNonDiscriminatedUnionClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadRecordNonDiscriminatedUnionClient + = spreadRecordNonDiscriminatedUnionClientbuilder.buildSpreadRecordNonDiscriminatedUnionClient(); + + AdditionalPropertiesClientBuilder spreadRecordNonDiscriminatedUnion2Clientbuilder + = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadRecordNonDiscriminatedUnion2Clientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadRecordNonDiscriminatedUnion2Clientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadRecordNonDiscriminatedUnion2Client + = spreadRecordNonDiscriminatedUnion2Clientbuilder.buildSpreadRecordNonDiscriminatedUnion2Client(); + + AdditionalPropertiesClientBuilder spreadRecordNonDiscriminatedUnion3Clientbuilder + = new AdditionalPropertiesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + spreadRecordNonDiscriminatedUnion3Clientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + spreadRecordNonDiscriminatedUnion3Clientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + spreadRecordNonDiscriminatedUnion3Client + = spreadRecordNonDiscriminatedUnion3Clientbuilder.buildSpreadRecordNonDiscriminatedUnion3Client(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/property/nullable/generated/NullableClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/property/nullable/generated/NullableClientTestBase.java new file mode 100644 index 000000000..cc371f12c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/property/nullable/generated/NullableClientTestBase.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.nullable.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.HttpClient; +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 com.type.property.nullable.BytesClient; +import com.type.property.nullable.CollectionsByteClient; +import com.type.property.nullable.CollectionsModelClient; +import com.type.property.nullable.CollectionsStringClient; +import com.type.property.nullable.DatetimeOperationClient; +import com.type.property.nullable.DurationOperationClient; +import com.type.property.nullable.NullableClientBuilder; +import com.type.property.nullable.StringOperationClient; + +class NullableClientTestBase extends TestProxyTestBase { + protected StringOperationClient stringOperationClient; + + protected BytesClient bytesClient; + + protected DatetimeOperationClient datetimeOperationClient; + + protected DurationOperationClient durationOperationClient; + + protected CollectionsByteClient collectionsByteClient; + + protected CollectionsModelClient collectionsModelClient; + + protected CollectionsStringClient collectionsStringClient; + + @Override + protected void beforeTest() { + NullableClientBuilder stringOperationClientbuilder = new NullableClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + stringOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + stringOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + stringOperationClient = stringOperationClientbuilder.buildStringOperationClient(); + + NullableClientBuilder bytesClientbuilder = new NullableClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + bytesClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + bytesClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + bytesClient = bytesClientbuilder.buildBytesClient(); + + NullableClientBuilder datetimeOperationClientbuilder = new NullableClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + datetimeOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + datetimeOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + datetimeOperationClient = datetimeOperationClientbuilder.buildDatetimeOperationClient(); + + NullableClientBuilder durationOperationClientbuilder = new NullableClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + durationOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + durationOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + durationOperationClient = durationOperationClientbuilder.buildDurationOperationClient(); + + NullableClientBuilder collectionsByteClientbuilder = new NullableClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + collectionsByteClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + collectionsByteClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + collectionsByteClient = collectionsByteClientbuilder.buildCollectionsByteClient(); + + NullableClientBuilder collectionsModelClientbuilder = new NullableClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + collectionsModelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + collectionsModelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + collectionsModelClient = collectionsModelClientbuilder.buildCollectionsModelClient(); + + NullableClientBuilder collectionsStringClientbuilder = new NullableClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + collectionsStringClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + collectionsStringClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + collectionsStringClient = collectionsStringClientbuilder.buildCollectionsStringClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/property/optional/generated/OptionalClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/property/optional/generated/OptionalClientTestBase.java new file mode 100644 index 000000000..f37609051 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/property/optional/generated/OptionalClientTestBase.java @@ -0,0 +1,247 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.optional.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.HttpClient; +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 com.type.property.optional.BooleanLiteralClient; +import com.type.property.optional.BytesClient; +import com.type.property.optional.CollectionsByteClient; +import com.type.property.optional.CollectionsModelClient; +import com.type.property.optional.DatetimeOperationClient; +import com.type.property.optional.DurationOperationClient; +import com.type.property.optional.FloatLiteralClient; +import com.type.property.optional.IntLiteralClient; +import com.type.property.optional.OptionalClientBuilder; +import com.type.property.optional.PlainDateClient; +import com.type.property.optional.PlainTimeClient; +import com.type.property.optional.RequiredAndOptionalClient; +import com.type.property.optional.StringLiteralClient; +import com.type.property.optional.StringOperationClient; +import com.type.property.optional.UnionFloatLiteralClient; +import com.type.property.optional.UnionIntLiteralClient; +import com.type.property.optional.UnionStringLiteralClient; + +class OptionalClientTestBase extends TestProxyTestBase { + protected StringOperationClient stringOperationClient; + + protected BytesClient bytesClient; + + protected DatetimeOperationClient datetimeOperationClient; + + protected DurationOperationClient durationOperationClient; + + protected PlainDateClient plainDateClient; + + protected PlainTimeClient plainTimeClient; + + protected CollectionsByteClient collectionsByteClient; + + protected CollectionsModelClient collectionsModelClient; + + protected StringLiteralClient stringLiteralClient; + + protected IntLiteralClient intLiteralClient; + + protected FloatLiteralClient floatLiteralClient; + + protected BooleanLiteralClient booleanLiteralClient; + + protected UnionStringLiteralClient unionStringLiteralClient; + + protected UnionIntLiteralClient unionIntLiteralClient; + + protected UnionFloatLiteralClient unionFloatLiteralClient; + + protected RequiredAndOptionalClient requiredAndOptionalClient; + + @Override + protected void beforeTest() { + OptionalClientBuilder stringOperationClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + stringOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + stringOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + stringOperationClient = stringOperationClientbuilder.buildStringOperationClient(); + + OptionalClientBuilder bytesClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + bytesClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + bytesClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + bytesClient = bytesClientbuilder.buildBytesClient(); + + OptionalClientBuilder datetimeOperationClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + datetimeOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + datetimeOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + datetimeOperationClient = datetimeOperationClientbuilder.buildDatetimeOperationClient(); + + OptionalClientBuilder durationOperationClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + durationOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + durationOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + durationOperationClient = durationOperationClientbuilder.buildDurationOperationClient(); + + OptionalClientBuilder plainDateClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + plainDateClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + plainDateClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + plainDateClient = plainDateClientbuilder.buildPlainDateClient(); + + OptionalClientBuilder plainTimeClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + plainTimeClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + plainTimeClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + plainTimeClient = plainTimeClientbuilder.buildPlainTimeClient(); + + OptionalClientBuilder collectionsByteClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + collectionsByteClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + collectionsByteClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + collectionsByteClient = collectionsByteClientbuilder.buildCollectionsByteClient(); + + OptionalClientBuilder collectionsModelClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + collectionsModelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + collectionsModelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + collectionsModelClient = collectionsModelClientbuilder.buildCollectionsModelClient(); + + OptionalClientBuilder stringLiteralClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + stringLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + stringLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + stringLiteralClient = stringLiteralClientbuilder.buildStringLiteralClient(); + + OptionalClientBuilder intLiteralClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + intLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + intLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + intLiteralClient = intLiteralClientbuilder.buildIntLiteralClient(); + + OptionalClientBuilder floatLiteralClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + floatLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + floatLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + floatLiteralClient = floatLiteralClientbuilder.buildFloatLiteralClient(); + + OptionalClientBuilder booleanLiteralClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + booleanLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + booleanLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + booleanLiteralClient = booleanLiteralClientbuilder.buildBooleanLiteralClient(); + + OptionalClientBuilder unionStringLiteralClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unionStringLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unionStringLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unionStringLiteralClient = unionStringLiteralClientbuilder.buildUnionStringLiteralClient(); + + OptionalClientBuilder unionIntLiteralClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unionIntLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unionIntLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unionIntLiteralClient = unionIntLiteralClientbuilder.buildUnionIntLiteralClient(); + + OptionalClientBuilder unionFloatLiteralClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unionFloatLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unionFloatLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unionFloatLiteralClient = unionFloatLiteralClientbuilder.buildUnionFloatLiteralClient(); + + OptionalClientBuilder requiredAndOptionalClientbuilder = new OptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + requiredAndOptionalClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + requiredAndOptionalClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + requiredAndOptionalClient = requiredAndOptionalClientbuilder.buildRequiredAndOptionalClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/property/valuetypes/generated/ValueTypesClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/property/valuetypes/generated/ValueTypesClientTestBase.java new file mode 100644 index 000000000..6a9e20c13 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/property/valuetypes/generated/ValueTypesClientTestBase.java @@ -0,0 +1,429 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.property.valuetypes.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.HttpClient; +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 com.type.property.valuetypes.BooleanLiteralClient; +import com.type.property.valuetypes.BooleanOperationClient; +import com.type.property.valuetypes.BytesClient; +import com.type.property.valuetypes.CollectionsIntClient; +import com.type.property.valuetypes.CollectionsModelClient; +import com.type.property.valuetypes.CollectionsStringClient; +import com.type.property.valuetypes.DatetimeOperationClient; +import com.type.property.valuetypes.Decimal128Client; +import com.type.property.valuetypes.DecimalClient; +import com.type.property.valuetypes.DictionaryStringClient; +import com.type.property.valuetypes.DurationOperationClient; +import com.type.property.valuetypes.EnumClient; +import com.type.property.valuetypes.ExtensibleEnumClient; +import com.type.property.valuetypes.FloatLiteralClient; +import com.type.property.valuetypes.FloatOperationClient; +import com.type.property.valuetypes.IntClient; +import com.type.property.valuetypes.IntLiteralClient; +import com.type.property.valuetypes.ModelClient; +import com.type.property.valuetypes.NeverClient; +import com.type.property.valuetypes.StringLiteralClient; +import com.type.property.valuetypes.StringOperationClient; +import com.type.property.valuetypes.UnionEnumValueClient; +import com.type.property.valuetypes.UnionFloatLiteralClient; +import com.type.property.valuetypes.UnionIntLiteralClient; +import com.type.property.valuetypes.UnionStringLiteralClient; +import com.type.property.valuetypes.UnknownArrayClient; +import com.type.property.valuetypes.UnknownDictClient; +import com.type.property.valuetypes.UnknownIntClient; +import com.type.property.valuetypes.UnknownStringClient; +import com.type.property.valuetypes.ValueTypesClientBuilder; + +class ValueTypesClientTestBase extends TestProxyTestBase { + protected BooleanOperationClient booleanOperationClient; + + protected StringOperationClient stringOperationClient; + + protected BytesClient bytesClient; + + protected IntClient intClient; + + protected FloatOperationClient floatOperationClient; + + protected DecimalClient decimalClient; + + protected Decimal128Client decimal128Client; + + protected DatetimeOperationClient datetimeOperationClient; + + protected DurationOperationClient durationOperationClient; + + protected EnumClient enumClient; + + protected ExtensibleEnumClient extensibleEnumClient; + + protected ModelClient modelClient; + + protected CollectionsStringClient collectionsStringClient; + + protected CollectionsIntClient collectionsIntClient; + + protected CollectionsModelClient collectionsModelClient; + + protected DictionaryStringClient dictionaryStringClient; + + protected NeverClient neverClient; + + protected UnknownStringClient unknownStringClient; + + protected UnknownIntClient unknownIntClient; + + protected UnknownDictClient unknownDictClient; + + protected UnknownArrayClient unknownArrayClient; + + protected StringLiteralClient stringLiteralClient; + + protected IntLiteralClient intLiteralClient; + + protected FloatLiteralClient floatLiteralClient; + + protected BooleanLiteralClient booleanLiteralClient; + + protected UnionStringLiteralClient unionStringLiteralClient; + + protected UnionIntLiteralClient unionIntLiteralClient; + + protected UnionFloatLiteralClient unionFloatLiteralClient; + + protected UnionEnumValueClient unionEnumValueClient; + + @Override + protected void beforeTest() { + ValueTypesClientBuilder booleanOperationClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + booleanOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + booleanOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + booleanOperationClient = booleanOperationClientbuilder.buildBooleanOperationClient(); + + ValueTypesClientBuilder stringOperationClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + stringOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + stringOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + stringOperationClient = stringOperationClientbuilder.buildStringOperationClient(); + + ValueTypesClientBuilder bytesClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + bytesClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + bytesClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + bytesClient = bytesClientbuilder.buildBytesClient(); + + ValueTypesClientBuilder intClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + intClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + intClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + intClient = intClientbuilder.buildIntClient(); + + ValueTypesClientBuilder floatOperationClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + floatOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + floatOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + floatOperationClient = floatOperationClientbuilder.buildFloatOperationClient(); + + ValueTypesClientBuilder decimalClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + decimalClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + decimalClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + decimalClient = decimalClientbuilder.buildDecimalClient(); + + ValueTypesClientBuilder decimal128Clientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + decimal128Clientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + decimal128Clientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + decimal128Client = decimal128Clientbuilder.buildDecimal128Client(); + + ValueTypesClientBuilder datetimeOperationClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + datetimeOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + datetimeOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + datetimeOperationClient = datetimeOperationClientbuilder.buildDatetimeOperationClient(); + + ValueTypesClientBuilder durationOperationClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + durationOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + durationOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + durationOperationClient = durationOperationClientbuilder.buildDurationOperationClient(); + + ValueTypesClientBuilder enumClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + enumClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + enumClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + enumClient = enumClientbuilder.buildEnumClient(); + + ValueTypesClientBuilder extensibleEnumClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + extensibleEnumClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + extensibleEnumClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + extensibleEnumClient = extensibleEnumClientbuilder.buildExtensibleEnumClient(); + + ValueTypesClientBuilder modelClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + modelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + modelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + modelClient = modelClientbuilder.buildModelClient(); + + ValueTypesClientBuilder collectionsStringClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + collectionsStringClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + collectionsStringClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + collectionsStringClient = collectionsStringClientbuilder.buildCollectionsStringClient(); + + ValueTypesClientBuilder collectionsIntClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + collectionsIntClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + collectionsIntClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + collectionsIntClient = collectionsIntClientbuilder.buildCollectionsIntClient(); + + ValueTypesClientBuilder collectionsModelClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + collectionsModelClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + collectionsModelClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + collectionsModelClient = collectionsModelClientbuilder.buildCollectionsModelClient(); + + ValueTypesClientBuilder dictionaryStringClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + dictionaryStringClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + dictionaryStringClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + dictionaryStringClient = dictionaryStringClientbuilder.buildDictionaryStringClient(); + + ValueTypesClientBuilder neverClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + neverClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + neverClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + neverClient = neverClientbuilder.buildNeverClient(); + + ValueTypesClientBuilder unknownStringClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unknownStringClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unknownStringClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unknownStringClient = unknownStringClientbuilder.buildUnknownStringClient(); + + ValueTypesClientBuilder unknownIntClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unknownIntClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unknownIntClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unknownIntClient = unknownIntClientbuilder.buildUnknownIntClient(); + + ValueTypesClientBuilder unknownDictClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unknownDictClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unknownDictClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unknownDictClient = unknownDictClientbuilder.buildUnknownDictClient(); + + ValueTypesClientBuilder unknownArrayClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unknownArrayClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unknownArrayClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unknownArrayClient = unknownArrayClientbuilder.buildUnknownArrayClient(); + + ValueTypesClientBuilder stringLiteralClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + stringLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + stringLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + stringLiteralClient = stringLiteralClientbuilder.buildStringLiteralClient(); + + ValueTypesClientBuilder intLiteralClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + intLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + intLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + intLiteralClient = intLiteralClientbuilder.buildIntLiteralClient(); + + ValueTypesClientBuilder floatLiteralClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + floatLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + floatLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + floatLiteralClient = floatLiteralClientbuilder.buildFloatLiteralClient(); + + ValueTypesClientBuilder booleanLiteralClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + booleanLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + booleanLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + booleanLiteralClient = booleanLiteralClientbuilder.buildBooleanLiteralClient(); + + ValueTypesClientBuilder unionStringLiteralClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unionStringLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unionStringLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unionStringLiteralClient = unionStringLiteralClientbuilder.buildUnionStringLiteralClient(); + + ValueTypesClientBuilder unionIntLiteralClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unionIntLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unionIntLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unionIntLiteralClient = unionIntLiteralClientbuilder.buildUnionIntLiteralClient(); + + ValueTypesClientBuilder unionFloatLiteralClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unionFloatLiteralClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unionFloatLiteralClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unionFloatLiteralClient = unionFloatLiteralClientbuilder.buildUnionFloatLiteralClient(); + + ValueTypesClientBuilder unionEnumValueClientbuilder = new ValueTypesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unionEnumValueClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unionEnumValueClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unionEnumValueClient = unionEnumValueClientbuilder.buildUnionEnumValueClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/scalar/generated/ScalarClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/scalar/generated/ScalarClientTestBase.java new file mode 100644 index 000000000..63b9007c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/scalar/generated/ScalarClientTestBase.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.scalar.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.HttpClient; +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 com.type.scalar.BooleanOperationClient; +import com.type.scalar.Decimal128TypeClient; +import com.type.scalar.Decimal128VerifyClient; +import com.type.scalar.DecimalTypeClient; +import com.type.scalar.DecimalVerifyClient; +import com.type.scalar.ScalarClientBuilder; +import com.type.scalar.StringOperationClient; +import com.type.scalar.UnknownClient; + +class ScalarClientTestBase extends TestProxyTestBase { + protected StringOperationClient stringOperationClient; + + protected BooleanOperationClient booleanOperationClient; + + protected UnknownClient unknownClient; + + protected DecimalTypeClient decimalTypeClient; + + protected Decimal128TypeClient decimal128TypeClient; + + protected DecimalVerifyClient decimalVerifyClient; + + protected Decimal128VerifyClient decimal128VerifyClient; + + @Override + protected void beforeTest() { + ScalarClientBuilder stringOperationClientbuilder = new ScalarClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + stringOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + stringOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + stringOperationClient = stringOperationClientbuilder.buildStringOperationClient(); + + ScalarClientBuilder booleanOperationClientbuilder = new ScalarClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + booleanOperationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + booleanOperationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + booleanOperationClient = booleanOperationClientbuilder.buildBooleanOperationClient(); + + ScalarClientBuilder unknownClientbuilder = new ScalarClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + unknownClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + unknownClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + unknownClient = unknownClientbuilder.buildUnknownClient(); + + ScalarClientBuilder decimalTypeClientbuilder = new ScalarClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + decimalTypeClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + decimalTypeClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + decimalTypeClient = decimalTypeClientbuilder.buildDecimalTypeClient(); + + ScalarClientBuilder decimal128TypeClientbuilder = new ScalarClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + decimal128TypeClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + decimal128TypeClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + decimal128TypeClient = decimal128TypeClientbuilder.buildDecimal128TypeClient(); + + ScalarClientBuilder decimalVerifyClientbuilder = new ScalarClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + decimalVerifyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + decimalVerifyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + decimalVerifyClient = decimalVerifyClientbuilder.buildDecimalVerifyClient(); + + ScalarClientBuilder decimal128VerifyClientbuilder = new ScalarClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + decimal128VerifyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + decimal128VerifyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + decimal128VerifyClient = decimal128VerifyClientbuilder.buildDecimal128VerifyClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/union/generated/UnionClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/union/generated/UnionClientTestBase.java new file mode 100644 index 000000000..4c8e1671b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/type/union/generated/UnionClientTestBase.java @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.type.union.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.HttpClient; +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 com.type.union.EnumsOnlyClient; +import com.type.union.FloatsOnlyClient; +import com.type.union.IntsOnlyClient; +import com.type.union.MixedLiteralsClient; +import com.type.union.MixedTypesClient; +import com.type.union.ModelsOnlyClient; +import com.type.union.StringAndArrayClient; +import com.type.union.StringExtensibleClient; +import com.type.union.StringExtensibleNamedClient; +import com.type.union.StringsOnlyClient; +import com.type.union.UnionClientBuilder; + +class UnionClientTestBase extends TestProxyTestBase { + protected StringsOnlyClient stringsOnlyClient; + + protected StringExtensibleClient stringExtensibleClient; + + protected StringExtensibleNamedClient stringExtensibleNamedClient; + + protected IntsOnlyClient intsOnlyClient; + + protected FloatsOnlyClient floatsOnlyClient; + + protected ModelsOnlyClient modelsOnlyClient; + + protected EnumsOnlyClient enumsOnlyClient; + + protected StringAndArrayClient stringAndArrayClient; + + protected MixedLiteralsClient mixedLiteralsClient; + + protected MixedTypesClient mixedTypesClient; + + @Override + protected void beforeTest() { + UnionClientBuilder stringsOnlyClientbuilder = new UnionClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + stringsOnlyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + stringsOnlyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + stringsOnlyClient = stringsOnlyClientbuilder.buildStringsOnlyClient(); + + UnionClientBuilder stringExtensibleClientbuilder = new UnionClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + stringExtensibleClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + stringExtensibleClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + stringExtensibleClient = stringExtensibleClientbuilder.buildStringExtensibleClient(); + + UnionClientBuilder stringExtensibleNamedClientbuilder = new UnionClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + stringExtensibleNamedClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + stringExtensibleNamedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + stringExtensibleNamedClient = stringExtensibleNamedClientbuilder.buildStringExtensibleNamedClient(); + + UnionClientBuilder intsOnlyClientbuilder = new UnionClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + intsOnlyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + intsOnlyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + intsOnlyClient = intsOnlyClientbuilder.buildIntsOnlyClient(); + + UnionClientBuilder floatsOnlyClientbuilder = new UnionClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + floatsOnlyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + floatsOnlyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + floatsOnlyClient = floatsOnlyClientbuilder.buildFloatsOnlyClient(); + + UnionClientBuilder modelsOnlyClientbuilder = new UnionClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + modelsOnlyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + modelsOnlyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + modelsOnlyClient = modelsOnlyClientbuilder.buildModelsOnlyClient(); + + UnionClientBuilder enumsOnlyClientbuilder = new UnionClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + enumsOnlyClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + enumsOnlyClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + enumsOnlyClient = enumsOnlyClientbuilder.buildEnumsOnlyClient(); + + UnionClientBuilder stringAndArrayClientbuilder = new UnionClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + stringAndArrayClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + stringAndArrayClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + stringAndArrayClient = stringAndArrayClientbuilder.buildStringAndArrayClient(); + + UnionClientBuilder mixedLiteralsClientbuilder = new UnionClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + mixedLiteralsClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + mixedLiteralsClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + mixedLiteralsClient = mixedLiteralsClientbuilder.buildMixedLiteralsClient(); + + UnionClientBuilder mixedTypesClientbuilder = new UnionClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + mixedTypesClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + mixedTypesClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + mixedTypesClient = mixedTypesClientbuilder.buildMixedTypesClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/added/generated/AddedClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/added/generated/AddedClientTestBase.java new file mode 100644 index 000000000..3ebd31ed0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/added/generated/AddedClientTestBase.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.added.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.HttpClient; +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 com.versioning.added.AddedClient; +import com.versioning.added.AddedClientBuilder; +import com.versioning.added.InterfaceV2Client; + +class AddedClientTestBase extends TestProxyTestBase { + protected AddedClient addedClient; + + protected InterfaceV2Client interfaceV2Client; + + @Override + protected void beforeTest() { + AddedClientBuilder addedClientbuilder + = new AddedClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .version(Configuration.getGlobalConfiguration().get("VERSION", "version")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + addedClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + addedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + addedClient = addedClientbuilder.buildClient(); + + AddedClientBuilder interfaceV2Clientbuilder + = new AddedClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .version(Configuration.getGlobalConfiguration().get("VERSION", "version")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + interfaceV2Clientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + interfaceV2Clientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + interfaceV2Client = interfaceV2Clientbuilder.buildInterfaceV2Client(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/madeoptional/generated/MadeOptionalClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/madeoptional/generated/MadeOptionalClientTestBase.java new file mode 100644 index 000000000..e479cd025 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/madeoptional/generated/MadeOptionalClientTestBase.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.madeoptional.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.HttpClient; +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 com.versioning.madeoptional.MadeOptionalClient; +import com.versioning.madeoptional.MadeOptionalClientBuilder; + +class MadeOptionalClientTestBase extends TestProxyTestBase { + protected MadeOptionalClient madeOptionalClient; + + @Override + protected void beforeTest() { + MadeOptionalClientBuilder madeOptionalClientbuilder = new MadeOptionalClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .version(Configuration.getGlobalConfiguration().get("VERSION", "version")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + madeOptionalClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + madeOptionalClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + madeOptionalClient = madeOptionalClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/removed/generated/RemovedClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/removed/generated/RemovedClientTestBase.java new file mode 100644 index 000000000..efea19002 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/removed/generated/RemovedClientTestBase.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.removed.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.HttpClient; +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 com.versioning.removed.RemovedClient; +import com.versioning.removed.RemovedClientBuilder; + +class RemovedClientTestBase extends TestProxyTestBase { + protected RemovedClient removedClient; + + @Override + protected void beforeTest() { + RemovedClientBuilder removedClientbuilder + = new RemovedClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .version(Configuration.getGlobalConfiguration().get("VERSION", "version")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + removedClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + removedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + removedClient = removedClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/renamedfrom/generated/RenamedFromClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/renamedfrom/generated/RenamedFromClientTestBase.java new file mode 100644 index 000000000..0f609c09a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/renamedfrom/generated/RenamedFromClientTestBase.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.renamedfrom.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.HttpClient; +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 com.versioning.renamedfrom.NewInterfaceClient; +import com.versioning.renamedfrom.RenamedFromClient; +import com.versioning.renamedfrom.RenamedFromClientBuilder; + +class RenamedFromClientTestBase extends TestProxyTestBase { + protected RenamedFromClient renamedFromClient; + + protected NewInterfaceClient newInterfaceClient; + + @Override + protected void beforeTest() { + RenamedFromClientBuilder renamedFromClientbuilder = new RenamedFromClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .version(Configuration.getGlobalConfiguration().get("VERSION", "version")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + renamedFromClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + renamedFromClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + renamedFromClient = renamedFromClientbuilder.buildClient(); + + RenamedFromClientBuilder newInterfaceClientbuilder = new RenamedFromClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .version(Configuration.getGlobalConfiguration().get("VERSION", "version")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + newInterfaceClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + newInterfaceClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + newInterfaceClient = newInterfaceClientbuilder.buildNewInterfaceClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/returntypechangedfrom/generated/ReturnTypeChangedFromClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/returntypechangedfrom/generated/ReturnTypeChangedFromClientTestBase.java new file mode 100644 index 000000000..9b7dab928 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/returntypechangedfrom/generated/ReturnTypeChangedFromClientTestBase.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.returntypechangedfrom.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.HttpClient; +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 com.versioning.returntypechangedfrom.ReturnTypeChangedFromClient; +import com.versioning.returntypechangedfrom.ReturnTypeChangedFromClientBuilder; + +class ReturnTypeChangedFromClientTestBase extends TestProxyTestBase { + protected ReturnTypeChangedFromClient returnTypeChangedFromClient; + + @Override + protected void beforeTest() { + ReturnTypeChangedFromClientBuilder returnTypeChangedFromClientbuilder = new ReturnTypeChangedFromClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .version(Configuration.getGlobalConfiguration().get("VERSION", "version")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + returnTypeChangedFromClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + returnTypeChangedFromClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + returnTypeChangedFromClient = returnTypeChangedFromClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/typechangedfrom/generated/TypeChangedFromClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/typechangedfrom/generated/TypeChangedFromClientTestBase.java new file mode 100644 index 000000000..1336f5869 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/versioning/typechangedfrom/generated/TypeChangedFromClientTestBase.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.versioning.typechangedfrom.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.HttpClient; +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 com.versioning.typechangedfrom.TypeChangedFromClient; +import com.versioning.typechangedfrom.TypeChangedFromClientBuilder; + +class TypeChangedFromClientTestBase extends TestProxyTestBase { + protected TypeChangedFromClient typeChangedFromClient; + + @Override + protected void beforeTest() { + TypeChangedFromClientBuilder typeChangedFromClientbuilder = new TypeChangedFromClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .version(Configuration.getGlobalConfiguration().get("VERSION", "version")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + typeChangedFromClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + typeChangedFromClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + typeChangedFromClient = typeChangedFromClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/arm-stream-style-serialization.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/arm-stream-style-serialization.tsp new file mode 100644 index 000000000..9032b89fb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/arm-stream-style-serialization.tsp @@ -0,0 +1,188 @@ +import "@typespec/http"; +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Azure.Core; +using Azure.ResourceManager; +using TypeSpec.OpenAPI; +using Azure.ClientGenerator.Core; + +@armProviderNamespace +@service({ + title: "ArmStreamStyleSerialization", +}) +@versioned(Versions) +@doc("Arm Resource Provider management API.") +namespace Cadl.ArmStreamStyleSerialization; + +@doc("Azure API versions.") +enum Versions { + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @doc("Preview API version 2023-12-01-preview.") + v2023_12_01_preview: "2023-12-01-preview", +} + +@doc("This is base model for polymorphic multiple levels inheritance with a discriminator.") +@discriminator("kind") +model Fish { + age: int32; + + @visibility("read") + dna: string; + + properties: FishProperties; + anotherProperties: AnotherFishProperties; +} + +@doc("The second level model in polymorphic multiple levels inheritance and it defines a new discriminator.") +@discriminator("sharktype") +model Shark extends Fish { + kind: "shark"; + sharktype: string; +} + +@doc("The second level model in polymorphic multiple levels inheritance which contains references to other polymorphic instances.") +model Salmon extends Fish { + kind: "salmon"; + friends?: Fish[]; + hate?: Record; + partner?: Fish; +} + +model FishProperties { + tailProperties: TailProperties; +} + +model TailProperties { + length: float32; + + @visibility("read") + patten: string; + + requiredString: string; +} + +model AnotherFishProperties { + eyeProperties: EyeProperties; +} + +model EyeProperties { + length: float32; + + @visibility("read") + patten: string; + + requiredString: string; +} + +@doc("The third level model SawShark in polymorphic multiple levels inheritance.") +model SawShark extends Shark { + sharktype: "saw"; + + // this is a duplicate property from Fish, with different visibility + dna: string; + + // this is a duplicate property from Fish, with same visibility + age: int32; +} + +@doc("The third level model GoblinShark in polymorphic multiple levels inheritance.") +model GoblinShark extends Shark { + sharktype: "goblin"; +} + +// test Resource as parent +@resource("topLevelArmResources") +model TopLevelArmResource is TrackedResource { + @key("topLevelArmResourceName") + @path + @segment("topLevelArmResources") + @doc("arm resource name for path") + @pattern("^[A-Za-z0-9]([A-Za-z0-9-_.]{0,62}[A-Za-z0-9])?$") + name: string; +} + +@doc("Top Level Arm Resource Properties.") +model TopLevelArmResourceProperties { + description?: string; +} + +@error +model ErrorResponse { + error: Error; +} + +@error +model ErrorResponseMin { + error: ErrorMin; +} + +model Error { + code: string; + message: string; + target: string; + details?: Error[]; + additionalInfo?: AdditionalInfo[]; + additionalProperty: string; +} + +model AdditionalInfo { + type: string; + info: {}; +} + +model ErrorMin { + code: string; + message: string; + additionalProperty: string; +} + +@doc("This is base model for polymorphic OutputOnlyModel.") +@discriminator("kind") +model OutputOnlyModel { + name: string; + + @visibility("read") + id: string; + + @flattenProperty + properties: OutputOnlyModelProperties; +} + +model OutputOnlyModelProperties { + title: string; +} + +model OutputOnlyModelChild extends OutputOnlyModel { + kind: "child"; + childName: string; +} + +@route("/model") +interface Fishes { + @get + getModel(): Fish | ErrorResponse; + + @put + putModel(@body fish: Fish): Fish | ErrorResponseMin; + + @get + @route("output") + getOutputOnlyModel(): OutputOnlyModel; +} + +interface TopLevelArmResources { + update is ArmCustomPatchAsync; +} + +@@flattenProperty(Fish.properties); +@@flattenProperty(FishProperties.tailProperties); +@@flattenProperty(Fish.anotherProperties); +@@flattenProperty(AnotherFishProperties.eyeProperties); diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/arm.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/arm.tsp new file mode 100644 index 000000000..6b76738b3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/arm.tsp @@ -0,0 +1,282 @@ +import "@typespec/http"; +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Azure.Core; +using Azure.ResourceManager; +using TypeSpec.OpenAPI; +using Azure.ClientGenerator.Core; + +@armProviderNamespace +@service({ + title: "ArmResource", +}) +@versioned(Versions) +@doc("Arm Resource Provider management API.") +namespace Cadl.ArmResourceProvider; + +@doc("Azure API versions.") +enum Versions { + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @doc("Preview API version 2022-06-01-preview.") + v2022_06_01_preview: "2022-06-01-preview", + + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @doc("Preview API version 2022-09-01-preview.") + v2022_09_01_preview: "2022-09-01-preview", + + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @doc("Public API version.") + v2023_11_01: "2023-11-01", + + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @doc("Preview API version 2023-12-01-preview.") + v2023_12_01_preview: "2023-12-01-preview", +} + +//----------------------- Child Resources ----------------------- +@doc("Subresource of Top Level Arm Resource.") +@parentResource(TopLevelArmResource) +model ChildResource is TrackedResource { + @key("childResourceName") + @doc("ChildResources") + @visibility("read") + @path + @segment("childResources") + @pattern("^[A-Za-z0-9]([A-Za-z0-9-_.]{0,62}[A-Za-z0-9])?$") + name: string; +} + +@doc("Child Resource Properties.") +model ChildResourceProperties { + @visibility("read") + @doc("Provisioning State of Top Level Arm Resource") + provisioningState?: ProvisioningState; +} + +//----------------------- Top Level Arm Resource ----------------------- +@resource("topLevelArmResources") +model TopLevelArmResource is TrackedResource { + @key("topLevelArmResourceName") + @path + @segment("topLevelArmResources") + @doc("arm resource name for path") + @pattern("^[A-Za-z0-9]([A-Za-z0-9-_.]{0,62}[A-Za-z0-9])?$") + name: string; +} + +@doc("Top Level Arm Resource Properties.") +model TopLevelArmResourceProperties { + @doc("Configuration Endpoints.") + @visibility("read") + configurationEndpoints?: string[]; + + userName: string; // this should be renamed to username + userNames: string; // this isn't a whole word match, shouldn't be renamed to usernames + accuserName: string; // this isn't a whole word match, shouldn't be renamed to accusername + + @visibility("create", "read") + startTimeStamp: utcDateTime; // this should be renamed to startTimestamp + + @visibility("read") + @doc("The status of the last operation.") + provisioningState?: ProvisioningState; +} + +//----------------------- Custom Template Resource ----------------------- +@resource("customTemplateResources") +model CustomTemplateResource is TrackedResource { + @key("customTemplateResourceName") + @path + @segment("customTemplateResources") + @doc("arm resource name for path") + @pattern("^[A-Za-z0-9]([A-Za-z0-9-_.]{0,62}[A-Za-z0-9])?$") + name: string; + + #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "https://github.com/Azure/typespec-azure/issues/2840" + @added(Versions.v2023_11_01) + @doc("Managed identity.") + identity?: Azure.ResourceManager.Foundations.ManagedServiceIdentity; +} + +@doc("extensible enum type for discriminator") +union DogKind { + string, + + @doc("Species golden") + Golden: "golden", +} + +@doc("Test extensible enum type for discriminator") +@discriminator("kind") +model Dog { + @doc("discriminator property") + kind: DogKind; + + @doc("Weight of the dog") + weight: int32; +} + +@doc("Golden dog model") +model Golden extends Dog { + @doc("discriminator property") + kind: DogKind.Golden; +} + +@doc("Top Level Arm Resource Properties.") +model CustomTemplateResourceProperties { + @visibility("read") + @doc("The status of the last operation.") + provisioningState?: ProvisioningState; + + @added(Versions.v2022_06_01_preview) + @removed(Versions.v2023_11_01) + @added(Versions.v2023_12_01_preview) + propertyRemovedInStable: string; + + dog: Dog; + namedEmptyModel: EmptyModel; + anonymousEmptyModel: {}; +} + +@doc("Empty model.") +model EmptyModel {} + +model CustomTemplateResourcePatch { + #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "https://github.com/Azure/typespec-azure/issues/2840" + @added(Versions.v2023_11_01) + @doc("Managed identity.") + identity?: Azure.ResourceManager.Foundations.ManagedServiceIdentity; + + @added(Versions.v2022_06_01_preview) + @removed(Versions.v2023_11_01) + @added(Versions.v2023_12_01_preview) + propertyRemovedInStable: string; +} + +@lroStatus +union ProvisioningState { + ResourceProvisioningState, + Provisioning: "Provisioning", + Updating: "Updating", + Deleting: "Deleting", + Accepted: "Accepted", +} + +model ResponseWithHeader { + ...OkResponse; + ...Azure.Core.Foundations.RetryAfterHeader; + ...Body; +} + +model Result { + reason?: string; +} + +// #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "built-in conditional request includes time based conditional headers" +alias IfMatchParameters = { + @header("If-Match") + @doc("The request should only proceed if an entity matches this string.") + ifMatch?: string; +}; + +alias IfNoneMatchParameters = { + @header("If-None-Match") + @doc("The request should only proceed if no entity matches this string.") + ifNoneMatch?: string; +}; + +//----------------------- Extension Resource ----------------------- +/** ExtensionResource of Top Level Arm Resource. */ +@parentResource(TopLevelArmResource) +model ChildExtensionResource is ExtensionResource { + @key("childExtensionResourceName") + @doc("ChildExtensionResources") + @visibility("read") + @path + @segment("childExtensionResources") + @pattern("^[A-Za-z0-9]([A-Za-z0-9-_.]{0,62}[A-Za-z0-9])?$") + name: string; +} + +/** Child ExtensionResource properties. */ +model ChildExtensionResourceProperties { + @visibility("read") + @doc("Provisioning State of the Resource") + provisioningState?: ProvisioningState; +} + +//----------------------- Paths ----------------------- +@armResourceOperations +interface ChildResourcesInterface + extends ResourceInstanceOperations { + listByTopLevelArmResource is ArmResourceListByParent; + actionWithoutBody is ArmResourceActionAsync; +} + +@armResourceOperations +interface TopLevelArmResourceInterface + extends TrackedResourceOperations { + @operationId("TopLevelArmResourceInterface_Post") + action is ArmResourceActionAsync< + TopLevelArmResource, + void, + Result, + Azure.ResourceManager.Foundations.BaseParameters + >; +} + +@armResourceOperations +interface CustomTemplateResourceInterface + extends ResourceCreate< + CustomTemplateResource, + Azure.ResourceManager.Foundations.BaseParameters & + IfMatchParameters & + IfNoneMatchParameters + > { + @sharedRoute + @added(Versions.v2022_09_01_preview) + @removed(Versions.v2023_11_01) + update is ArmResourceUpdateSync; + + #suppress "@azure-tools/typespec-azure-core/no-operation-id" "Use operationId to keep same name as deprecated update operation" + @sharedRoute + @added(Versions.v2023_11_01) + @operationId("CustomTemplateResourceInterfaces_Update") + updateLongRunning is ArmCustomPatchAsync; +} + +interface Operations extends Azure.ResourceManager.Operations {} + +@armResourceOperations +interface ChildExtensionResourceInterface + extends ExtensionResourceOperations {} + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation" "This is a valid template" +@autoRoute +@doc("Update a {name}", TResource) +@armResourceCreateOrUpdate(TResource) +@patch +op ArmResourceUpdateSync< + TResource extends Azure.ResourceManager.Foundations.ArmResource, + TBaseParameters = Azure.ResourceManager.Foundations.BaseParameters +>( + ...ResourceInstanceParameters, + + @doc("Resource create parameters.") + @body + resource: TResource, +): ResponseWithHeader | ErrorResponse; + +@@flattenProperty(TrackedResource.properties); +@@flattenProperty(Azure.ResourceManager.Foundations.ResourceUpdateModel.properties); diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/builtin.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/builtin.tsp new file mode 100644 index 000000000..e9c6c9db0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/builtin.tsp @@ -0,0 +1,85 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using Azure.ClientGenerator.Core; + +@service({ + title: "Builtin", +}) +namespace Cadl.Builtin; + +model Builtin { + boolean: boolean; + string: string; + bytes: bytes; + int: int32; + safeint: safeint; + decimal: decimal; + long: int64; + float: float32; + double: float64; + duration: duration; + date: plainDate; + dateTime: utcDateTime; + stringList: string[]; + bytesDict: Record; + url: url; + nullableFloatDict: Record; + encoded: Encoded; +} + +@encode(DurationKnownEncoding.seconds, float32) +scalar myDuration extends duration; + +model Encoded { + @encode(DurationKnownEncoding.seconds, int32) + timeInSeconds?: duration; + + timeInSecondsFraction?: myDuration; + + @encode(DateTimeKnownEncoding.rfc3339) + dateTime?: utcDateTime; + + @encode(DateTimeKnownEncoding.rfc7231) + dateTimeRfc7231?: utcDateTime; + + @encode(DateTimeKnownEncoding.unixTimestamp, int64) + unixTimestamp?: utcDateTime; + + @encode(BytesKnownEncoding.base64) + base64?: bytes; + + @encode(BytesKnownEncoding.base64url) + base64url?: bytes; +} + +model Request { + @header("x-ms-date") + dateTime?: utcDateTime; + + @query + filter?: string; + + @query("query") + queryParam: string; + + @query("query-encoded") + queryParamEncoded: url; + + @query("query-opt") + queryParamOptional?: string; + + @query("query-opt-encoded") + queryParamOptionalEncoded?: url; +} + +@route("/builtin") +interface BuiltinOp { + read(...Request): { + @body body: Builtin; + }; + + @convenientAPI(false) + write(@body body: Builtin): OkResponse; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/enum.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/enum.tsp new file mode 100644 index 000000000..316447e11 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/enum.tsp @@ -0,0 +1,200 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using Azure.Core; +using Azure.ClientGenerator.Core; + +@service({ + title: "EnumService", +}) +namespace Cadl.EnumService; + +#suppress "@azure-tools/typespec-azure-core/use-extensible-enum" "For testing" +enum Color { + Red, + Blue, + Green, +} + +union ColorModel { + ColorModelBase, + Blue: "Blue", + Green: "Green", +} + +union ColorModelBase { + string, + Red: "Red", +} + +@access(Access.public) +@usage(Usage.input | Usage.output) +union PriorityModel { + int32, + High: 100, + Low: 0, +} + +#suppress "@azure-tools/typespec-azure-core/use-extensible-enum" "For testing" +enum Priority { + High: 100, + Low: 0, +} + +#suppress "@azure-tools/typespec-azure-core/use-extensible-enum" "For testing" +enum Unit { + Grams: 1, + KiloGrams: 0.001, + Milligram: 1000, +} + +#suppress "@azure-tools/typespec-azure-core/use-extensible-enum" "For testing" +enum OperationStateValues { + Running, + Completed, + Failed, +} + +@usage(Usage.input) +model Operation { + name: "Read" | "Write"; + best: true; + age: 50; + priority: Priority; + color: ColorModel; + unit: Unit; + priorityValue: Priority.Low; + colorValue: Color.Green; + colorModelValue: ColorModel.Blue; + unitValue?: Unit.Milligram; +} + +@client({ + service: Cadl.EnumService, + name: "EnumServiceClient", +}) +@route("/enum") +interface EnumOp { + @get + @route("/color") + getColor(): Color; + + @get + @route("/colormodel") + getColorModel(): { + @body body: ColorModel; + }; + + @post + @route("operation/colormodel") + setColorModel(@query color: ColorModel): Operation; + + @post + @route("operation/priority") + setPriority(@query priority: Priority): Operation; + + @get + @route("operation/state/running") + getRunningOperation(@query state: "Running"): Operation; + + @get + @route("operation/state") + getOperation(@query state: OperationStateValues): Operation; + + @post + @route("operation/stringenumarray") + setStringEnumArray( + @query + colorArray: ColorModel[], + + @query + colorArrayOpt?: ColorModel[], + ): string; + + @post + @route("operation/intenumarray") + setIntEnumArray( + @query + @encode("ssv") + priorityArray: Priority[], + + @query + priorityArrayOpt?: Priority[], + ): string; + + @post + @route("operation/stringarray") + setStringArray( + @query + stringArray: string[], + + @query + stringArrayOpt?: string[], + ): string; + + @post + @route("operation/intarray") + setIntArray( + @query + intArray: int32[], + + @query + intArrayOpt?: int32[], + ): string; + + @post + @route("operation/stringenummulti") + setStringEnumMulti( + @query(#{ explode: true }) + colorArray: ColorModel[], + + @query(#{ explode: true }) + colorArrayOpt?: ColorModel[], + ): string; + + @post + @route("operation/intenummulti") + setIntEnumMulti( + @query(#{ explode: true }) + priorityArray: Priority[], + + @query(#{ explode: true }) + priorityArrayOpt?: Priority[], + ): string; + + @post + @route("operation/stringmulti") + setStringMulti( + @query(#{ explode: true }) + stringArray: string[], + + @query(#{ explode: true }) + stringArrayOpt?: string[], + ): string; + + @post + @route("operation/intmulti") + setIntMulti( + @query(#{ explode: true }) + intArray: int32[], + + @query(#{ explode: true }) + intArrayOpt?: int32[], + ): string; + + @post + @route("operation/stringenumarrayheader") + setStringEnumArrayHeader( + @header({ + format: "csv", + }) + colorArray: ColorModel[], + + @header({ + format: "csv", + }) + colorArrayOpt?: ColorModel[], + ): string; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/error.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/error.tsp new file mode 100644 index 000000000..aa02f36a6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/error.tsp @@ -0,0 +1,22 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-azure-core"; + +using TypeSpec.Http; +using TypeSpec.Versioning; +using Azure.Core.Foundations; + +@service({ + title: "ErrorModel", +}) +@useDependency(Azure.Core.Versions.v1_0_Preview_2) +namespace Cadl.ErrorModel; + +model Diagnostic { + name: string; + error: Error; +} + +@route("/error") +interface ErrorOp { + read(): ResourceCreatedOrOkResponse | ErrorResponse; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/EtagHeaders_ListWithEtag.json b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/EtagHeaders_ListWithEtag.json new file mode 100644 index 000000000..8a6e4f31d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/EtagHeaders_ListWithEtag.json @@ -0,0 +1,24 @@ +{ + "operationId": "EtagHeaders_ListWithEtag", + "title": "Etag headers ListWithEtag", + "parameters": { + "api-version": "2022-06-01-preview" + }, + "responses": { + "200": { + "headers": { + "ETag": "\"64e005\"" + }, + "body": { + "value": [ + { + "id": "myId", + "name": "name", + "type": "myType", + "description": "This is sample for Etag headers" + } + ] + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/EtagHeaders_PutWithRequestHeaders.json b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/EtagHeaders_PutWithRequestHeaders.json new file mode 100644 index 000000000..e72511369 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/EtagHeaders_PutWithRequestHeaders.json @@ -0,0 +1,36 @@ +{ + "operationId": "EtagHeaders_PutWithRequestHeaders", + "title": "Etag headers PutWithRequestHeaders", + "parameters": { + "api-version": "2022-06-01-preview", + "name": "name", + "If-Match": "\"64e005\"", + "resource": { + "type": "myType", + "description": "This is sample for Etag headers" + } + }, + "responses": { + "200": { + "headers": { + "ETag": "\"64e005\"" + }, + "body": { + "id": "myId", + "name": "name", + "type": "myType", + "description": "This is sample for Etag headers" + } + }, + "default": { + "headers": { + "Content-Type": "application/json", + "x-ms-error-code": "Error Code" + }, + "body": { + "code": "Error Code", + "message": "Error Message" + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/FlattenOp_Send.json b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/FlattenOp_Send.json new file mode 100644 index 000000000..8e3721e1e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/FlattenOp_Send.json @@ -0,0 +1,27 @@ +{ + "operationId": "FlattenOp_Send", + "title": "FlattenOp Send", + "parameters": { + "id": "myRequiredId", + "sendRequest": { + "user": { + "user": "myOptionalUser" + }, + "input": "myRequiredInput", + "constant": "constant" + } + }, + "responses": { + "200": {}, + "default": { + "headers": { + "Content-Type": "application/json", + "x-ms-error-code": "Error Code" + }, + "body": { + "code": "Error Code", + "message": "Error Message" + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/FlattenOp_SendLong.json b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/FlattenOp_SendLong.json new file mode 100644 index 000000000..0947db2e6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/FlattenOp_SendLong.json @@ -0,0 +1,35 @@ +{ + "operationId": "FlattenOp_SendLong", + "title": "FlattenOp SendLong", + "parameters": { + "name": "myRequiredId", + "filter": "name=myName", + "body": { + "user": { + "user": "myOptionalUser" + }, + "input": "myRequiredInput", + "dataInt": 11, + "dataIntOptional": 12, + "dataLong": 13, + "data_float": 14.0, + "title": "title", + "description": "description", + "status": "NotStarted", + "constant": "constant" + } + }, + "responses": { + "200": {}, + "default": { + "headers": { + "Content-Type": "application/json", + "x-ms-error-code": "Error Code" + }, + "body": { + "code": "Error Code", + "message": "Error Message" + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/LongRunning_CreateJob.json b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/LongRunning_CreateJob.json new file mode 100644 index 000000000..1e4a1eddd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/LongRunning_CreateJob.json @@ -0,0 +1,31 @@ +{ + "operationId": "CreateJob", + "title": "LongRunning CreateJob", + "parameters": { + "body": { + "configuration": "{}", + "nullableFloatDict": { + "max": 15.0, + "min": 14.0, + "average": 14.3 + } + } + }, + "responses": { + "202": { + "headers": { + "Operation-Location": "https://www.example.org" + } + }, + "default": { + "headers": { + "Content-Type": "application/json", + "x-ms-error-code": "Error Code" + }, + "body": { + "code": "Error Code", + "message": "Error Message" + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/ResponseOp_Exists.json b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/ResponseOp_Exists.json new file mode 100644 index 000000000..f7264f475 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/ResponseOp_Exists.json @@ -0,0 +1,20 @@ +{ + "operationId": "ResponseOp_Exists", + "title": "ResponseOp Exists", + "parameters": { + "api-version": "2022-06-01-preview" + }, + "responses": { + "200": {}, + "default": { + "headers": { + "Content-Type": "application/json", + "x-ms-error-code": "Error Code" + }, + "body": { + "code": "Error Code", + "message": "Error Message" + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/ResponseOp_ListStrings.json b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/ResponseOp_ListStrings.json new file mode 100644 index 000000000..4782aa470 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-06-01-preview/ResponseOp_ListStrings.json @@ -0,0 +1,20 @@ +{ + "operationId": "ResponseOp_ListStrings", + "title": "ResponseOp ListStrings", + "parameters": { + "api-version": "2022-06-01-preview" + }, + "responses": { + "200": ["a", "b", "c"], + "default": { + "headers": { + "Content-Type": "application/json", + "x-ms-error-code": "Error Code" + }, + "body": { + "code": "Error Code", + "message": "Error Message" + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-09-01/VersioningOp_List.json b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-09-01/VersioningOp_List.json new file mode 100644 index 000000000..955aea64c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2022-09-01/VersioningOp_List.json @@ -0,0 +1,31 @@ +{ + "operationId": "VersioningOp_List", + "title": "VersioningOp List", + "parameters": { + "filter": "age gt 18", + "select": ["name=name"] + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "myId", + "name": "name", + "type": "type" + } + ] + } + }, + "default": { + "headers": { + "Content-Type": "application/json", + "x-ms-error-code": "Error Code" + }, + "body": { + "code": "Error Code", + "message": "Error Message" + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2023-12-01-preview/TopLevelArmResourceInterface_Action.json b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2023-12-01-preview/TopLevelArmResourceInterface_Action.json new file mode 100644 index 000000000..62b7e8eff --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/2023-12-01-preview/TopLevelArmResourceInterface_Action.json @@ -0,0 +1,16 @@ +{ + "operationId": "TopLevelArmResourceInterface_Post", + "title": "TopLevelArmResourceInterface Action", + "parameters": { + "resourceGroupName": "resource-group-name", + "topLevelArmResourceName": "resource-name", + "api-version": "2023-12-01-preview" + }, + "responses": { + "200": { + "body": { + "reason": "action" + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/examples/BuiltinOp_Read.json b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/BuiltinOp_Read.json new file mode 100644 index 000000000..fcee79fbb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/BuiltinOp_Read.json @@ -0,0 +1,48 @@ +{ + "operationId": "BuiltinOp_Read", + "title": "BuiltinOp Read", + "parameters": { + "filter": "myFilter" + }, + "responses": { + "200": { + "body": { + "boolean": true, + "string": "myString", + "safeint": 32, + "long": 64, + "float": 32.0, + "double": 64.0, + "duration": "PT15M", + "date": "2023-08-29", + "dateTime": "2019-10-12T07:20:50.520Z", + "nullableFloatDict": { + "max": 15.0, + "min": 14.0, + "average": 14.3 + }, + "url": "https://www.github.com", + "stringList": ["a", "b", "c"], + "encoded": { + "timeInSeconds": "PT15M", + "timeInSecondsFraction": "PT20.345S", + "dateTime": "1966-03-03T00:06:56.52Z", + "dateTimeRfc7231": "Sun, 06 Nov 1994 08:49:37 GMT", + "unixTimestamp": "1693362903", + "base64": "aHR0cHM6Ly93d3cuZ2l0aHViLmNvbQ==", + "base64url": "aHR0cHM6Ly93d3cuZ2l0aHViLmNvbQ==" + } + } + }, + "default": { + "headers": { + "Content-Type": "application/json", + "x-ms-error-code": "Error Code" + }, + "body": { + "code": "Error Code", + "message": "Error Message" + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/examples/ModelOp_PutNested.json b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/ModelOp_PutNested.json new file mode 100644 index 000000000..e73bb44c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/ModelOp_PutNested.json @@ -0,0 +1,32 @@ +{ + "operationId": "ModelOp_PutNested", + "title": "ModelOp PutNested", + "parameters": { + "nested1": { + "nested2": { + "data": "123" + } + } + }, + "responses": { + "200": { + "body": { + "nested1": { + "nested2": { + "data": "123" + } + } + } + }, + "default": { + "headers": { + "Content-Type": "application/json", + "x-ms-error-code": "Error Code" + }, + "body": { + "code": "Error Code", + "message": "Error Message" + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/examples/SingleContentType_uploadImageForSingleContentType.json b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/SingleContentType_uploadImageForSingleContentType.json new file mode 100644 index 000000000..d28cc2930 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/examples/SingleContentType_uploadImageForSingleContentType.json @@ -0,0 +1,20 @@ +{ + "operationId": "SingleContentType_UploadImageForSingleContentType", + "title": "SingleContentType UploadImageForSingleContentType", + "parameters": { + "data": "\"D:\\Program Files\"" + }, + "responses": { + "200": {}, + "default": { + "headers": { + "Content-Type": "application/json", + "x-ms-error-code": "Error Code" + }, + "body": { + "code": "Error Code", + "message": "Error Message" + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/flatten.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/flatten.tsp new file mode 100644 index 000000000..05454e9e7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/flatten.tsp @@ -0,0 +1,164 @@ +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using TypeSpec.Versioning; +using Azure.ClientGenerator.Core; + +@service({ + title: "Flatten", +}) +@server( + "{endpoint}/openai", + "Flatten", + { + endpoint: string, + } +) +@versioned(ServiceApiVersions) +namespace Cadl.Flatten; + +enum ServiceApiVersions { + v2022_06_01_preview: "2022-06-01-preview", +} + +@doc("The ApiVersion query parameter.") +model ApiVersionParameter { + @query("api-version") + @minLength(1) + @doc("The API version to use for this operation.") + apiVersion: string; +} + +alias Request = { + @visibility("read") @key name: string; + user?: User; + input: string; + constant: "constant"; +}; + +alias LongRequest = { + user?: User; + input: string; + dataInt: int32; + dataIntOptional?: int32; + dataLong?: int64; + + @clientName("dataFloat") + @encodedName("application/json", "data_float") + float?: float64; +}; + +model User { + user: string; +} + +model TodoItem { + /** The item's unique id */ + @visibility("read") @key id: safeint; + + /** The item's title */ + @maxLength(255) + title: string; + + /** A longer description of the todo item in markdown format */ + description?: string; + + /** The status of the todo item */ + status: "NotStarted" | "InProgress" | "Completed"; + + /** When the todo item was created. */ + @visibility("read") createdAt: utcDateTime; + + /** When the todo item was last updated */ + @visibility("read") updatedAt: utcDateTime; + + /** When the todo item was makred as completed */ + @visibility("read") completedAt?: utcDateTime; + + // hack to get a different schema for create + // (fastify glue doesn't support readonly) + @visibility("create") _dummy?: string; +} + +model TodoItemPatch { + /** The item's title */ + title?: TodoItem.title; + + /** A longer description of the todo item in markdown format */ + description?: TodoItem.description | null; + + /** The status of the todo item */ + status?: "NotStarted" | "InProgress" | "Completed"; +} + +@client({ + service: Cadl.Flatten, + name: "FlattenClient", +}) +@route("/flatten") +interface FlattenOp { + @route("send") + @post + send( + @query id: string, + @query constantQueryParam: "constant", + ...Request, + ...ApiVersionParameter, + ): OkResponse; + + @route("send-projected-name") + @post + sendProjectedName( + @query id: string, + + @encodedName("application/json", "file_id") + @projectedName("client", "fileIdentifier") + fileId: string, + ): OkResponse; + + @route("send-long") + @post + sendLong( + @query name: string, + @query filter?: string, + ...LongRequest, + ...TodoItem, + constant: "constant", + ...ApiVersionParameter, + ): OkResponse; + + @route("patch/{id}") + @patch + update( + @header contentType: "application/merge-patch+json", + @path id: TodoItem.id, + patch: TodoItemPatch, + ): { + @body response: TodoItem; + }; + + @route("upload/{name}") + @post + uploadFile( + @path name: string, + @header contentType: "multipart/form-data", + file_data: bytes, + + // this field should not be serialized to form-data + @visibility("read") readOnly: string, + + constant: "constant", + ): OkResponse; + + @route("upload-todo") + @post + uploadTodo( + @header contentType: "multipart/form-data", + ...TodoItem, + prop1?: string, + prop2?: string, + prop3?: string, + ): OkResponse; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/internal.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/internal.tsp new file mode 100644 index 000000000..2da6ff253 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/internal.tsp @@ -0,0 +1,111 @@ +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using Azure.Core; +using Azure.ClientGenerator.Core; + +@service({ + title: "Internal", +}) +namespace Cadl.Internal; + +// ApiRequest and RequestInner will be generated +@access(Access.public) +model ApiRequest { + property: RequestInner; +} + +model RequestInner { + name: string; +} + +// ResponseInternal and ResponseInternalInner will be generated in implementation.models package +model ResponseInternal { + property: ResponseInternalInner; +} + +@access(Access.public, "python") +model ResponseInternalInner { + name: string; +} + +// Response will be generated as output-only +@access(Access.public) +model ApiResponse { + name: string; +} + +// StandAloneData will be generated as output +@access(Access.public) +@usage(Usage.output, "java") +model StandAloneData { + property: StandAloneDataInner; +} + +// StandAloneDataInner will be generated as intput + output +@usage(Usage.input | Usage.output) +model StandAloneDataInner { + name: string; +} + +// StandAloneUnion will be generated in implementation.models package +@access(Access.internal) +model StandAloneUnion { + data: url | bytes; +} + +// Color and ColorModel will be generated in implementation.models package +#suppress "@azure-tools/typespec-azure-core/use-extensible-enum" "For testing" +@access(Access.internal) +@usage(Usage.input | Usage.output) +enum Color { + Red, + Blue, + Green, +} + +@access(Access.internal) +@usage(Usage.input | Usage.output) +union ColorModel { + string, + "Red", + "Blue", + "Green", +} + +// UnusedEnum will be generated +@access(Access.public) +@usage(Usage.input | Usage.output) +union UnusedEnum { + string, + "Weekday", + "Weekend", +} + +// ProtocolInternalModel will not be generated, as the model is not used in convenient API +model ProtocolInternalModel { + name: string; +} + +@route("/internal") +interface InternalOp { + // test ApiRequest with Access.public + @access(Access.public, "python") + @access(Access.internal, "client") + @post + postInternal(@body body: ApiRequest): ResponseInternal; + + // test ApiResponse with Access.public + @get + @access(Access.internal, "java") + getInternal(): ApiResponse; + + @route("/protocal-internal") + @post + @access(Access.internal) + @convenientAPI(false) + postProtocalInternal(@body body: ProtocolInternalModel): void; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/literal.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/literal.tsp new file mode 100644 index 000000000..1f4edb036 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/literal.tsp @@ -0,0 +1,30 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-azure-core"; + +using TypeSpec.Http; +using Azure.Core; + +@service({ + title: "LiteralService", +}) +namespace Cadl.LiteralService; + +model Model { + literal: "literal"; + optionalLiteral?: "optionalLiteral"; +} + +alias Request = { + @query + literalParam: "literalParam"; + + @query + optionalLiteralParam?: "optionalLiteralParam"; +}; + +@route("/literal") +interface LiteralOp { + @put + @route("/put") + put(...Request, @body body: Model): Model; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/lro.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/lro.tsp new file mode 100644 index 000000000..25de31033 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/lro.tsp @@ -0,0 +1,130 @@ +import "@azure-tools/typespec-azure-core"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using TypeSpec.Versioning; +using Azure.Core; +using Azure.Core.Traits; + +@service({ + title: "LongRunning", +}) +@versioned(ApiVersions) +@route("/long-running") +namespace Cadl.LongRunning { + enum ApiVersions { + @useDependency(global.Azure.Core.Versions.v1_0_Preview_2) + v2022_06_01_preview: "2022-06-01-preview", + } + + // case of LRO having pollingOperation in non-service namespace + @pollingOperation(NonService.poll) + @post + @route("/post") + op longRunning(): AcceptedResponse; + + model PollResponse { + operationId: string; + status: Azure.Core.Foundations.OperationState; + } + + // case of HealthInsights + @route("/jobs/{id}") + op getJob is LroLongRunningPollOperation; + + @pollingOperation(LongRunning.getJob) + @route("/jobs") + op createJob is LroLongRunningRpcOperation< + { + @body body: JobData; + }, + JobResult + >; + + model JobData { + configuration?: string; + nullableFloatDict: Record; + } + + model JobResult + is LroOperationStatus<{ + data: string; + }>; + + @lroStatus + union JobStatus { + string, + NotStarted: "notStarted", + Running: "running", + Succeeded: "Succeeded", + Failed: "Failed", + Canceled: "canceled", + } + + model LroOperationStatus { + @key("operationId") + @visibility("read") + id: Azure.Core.uuid; + + @visibility("read") + @lroStatus + status: JobStatus; + + @visibility("read") + createdDateTime?: utcDateTime; + + @visibility("read") + expirationDateTime?: utcDateTime; + + @visibility("read") + lastUpdateDateTime?: utcDateTime; + + error?: TStatusError; + result?: TStatusResult; + } + + op LroLongRunningRpcOperation< + TParams extends TypeSpec.Reflection.Model, + TResponse extends TypeSpec.Reflection.Model, + Traits extends {} = {} + > is Azure.Core.RpcOperation< + TParams & RepeatabilityRequestHeaders, + Foundations.AcceptedResponse & + Foundations.RetryAfterHeader> & + RepeatabilityResponseHeaders & + LroOperationStatus, + Traits + >; + + op LroLongRunningPollOperation is Azure.Core.RpcOperation< + { + @path("id") + id: Azure.Core.uuid; + }, + TResult, + LroRetryAfterTrait + >; + + model LroLongRunningStatusLocation { + @pollingLocation + @TypeSpec.Http.header("Operation-Location") + operationLocation: LroResourceLocation>; + } + + scalar LroResourceLocation extends url; + + @trait("LroRetryAfterTrait") + model LroRetryAfterTrait { + retryAfter: { + @traitLocation(TraitLocation.Response) + response: Foundations.RetryAfterHeader; + }; + } +} + +@useDependency(Azure.Core.Versions.v1_0_Preview_2, Cadl.LongRunning.ApiVersions.v2022_06_01_preview) +namespace Cadl.NonService { + @route("/poll") + @get + op poll(): Cadl.LongRunning.PollResponse; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/model.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/model.tsp new file mode 100644 index 000000000..cd69927ce --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/model.tsp @@ -0,0 +1,81 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; + +@service({ + title: "Model", +}) +namespace Cadl.Model; + +// input-output +model Resource1 { + name: string; + + @visibility("read") + outputData: OutputData; + + @visibility("read") + outputData2: InputOutputData2; +} + +// input-output +model Resource2 { + name: string; + data2: InputOutputData2; +} + +// output +model Resource3 { + name: string; + outputData3: OutputData3; +} + +// output +model OutputData { + data: string; +} + +// input-output, due to Resource2 +model InputOutputData2 { + data: string; +} + +// output +model OutputData3 { + data: string; +} + +// root model +model NestedModel { + nested1: NestedModel1; +} + +// nested level1 +model NestedModel1 { + nested2: NestedModel2; +} + +// nested level2 +model NestedModel2 { + data: string; +} + +@route("/model") +interface ModelOp { + @put + @route("/resource1") + put1(@body body: Resource1): Resource1; + + @put + @route("/resource2") + put2(@body body: Resource2): Resource2; + + @get + @route("/resource3") + get3(): Resource3; + + @get + @route("/nested") + putNested(@body body: NestedModel): NestedModel; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/multipart.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/multipart.tsp new file mode 100644 index 000000000..9775d5945 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/multipart.tsp @@ -0,0 +1,65 @@ +import "@typespec/http"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using Azure.ClientGenerator.Core; + +@service({ + title: "Multipart", +}) +namespace Cadl.Multipart; + +union ImageType { + string, + "JPEG", + "PNG", +} + +model Size { + width: int32; + height: int32; +} + +model FormData { + name: string; + resolution: int32; + type: ImageType; + size: Size; + image: bytes; + fileData?: bytes[]; +} + +@route("/upload/images/{name}") +@post +op upload( + @path name: string, + @query compress?: boolean, + @header contentType: "multipart/form-data", + @body data: FormData, +): OkResponse; + +model Inherit1File extends File { + contentType?: string; + filename: string; +} + +/** + * Image file of content-type "image/jpeg" + */ +@clientName("InheritFileData") +model Inherit2File extends Inherit1File { + contentType: "image/jpeg"; +} + +@route("/uploadHttpPart/images/{name}") +@post +op uploadHttpPart( + @path name: string, + @query compress?: boolean, + @header contentType: "multipart/form-data", + @multipartBody body: { + fileData1: HttpPart; + fileData2: HttpPart; + size: HttpPart; + }, +): OkResponse; diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-apiversion.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-apiversion.tsp new file mode 100644 index 000000000..05681a1f5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-apiversion.tsp @@ -0,0 +1,107 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Azure.Core; +using Azure.Core.Foundations; +using Azure.Core.Traits; + +@service({ + title: "MultipleApiVersion", +}) +@versioned(Cadl.MultipleApiVersion.Versions) +@Azure.ClientGenerator.Core.client({ + name: "FirstClient", +}) +namespace Cadl.MultipleApiVersion { + @resource("resources") + model Resource { + @visibility("read") + id: string; + + @key + @visibility("read") + name: string; + + type: string; + } + + interface ResourceOperations + extends Azure.Core.ResourceOperations {} + + enum Versions { + @useDependency(global.Azure.Core.Versions.v1_0_Preview_2) + v2022_06_01_preview: "2022-06-01-preview", + + v2022_12_01_preview: "2022-12-01-preview", + } + + @route("/client1") + interface Client { + get is ResourceOperations.ResourceRead; + } +} + +@service({ + title: "MultipleApiVersion2", +}) +@versioned(Cadl.MultipleApiVersion2.Versions) +@Azure.ClientGenerator.Core.client({ + name: "SecondClient", +}) +namespace Cadl.MultipleApiVersion2 { + @resource("resources") + model Resource2 { + @visibility("read") + id: string; + + @key + @visibility("read") + name: string; + + type: string; + } + + interface ResourceOperations + extends Azure.Core.ResourceOperations {} + + enum Versions { + @useDependency(global.Azure.Core.Versions.v1_0_Preview_2) + v2022_10_01_preview: "2022-10-01-preview", + + v2022_12_01_preview: "2022-12-01-preview", + } + + @route("/client2") + interface Client { + get is ResourceOperations.ResourceRead; + } +} + +@service({ + title: "MultipleApiVersion3", +}) +@versioned(Cadl.MultipleApiVersion3.Versions) +@Azure.ClientGenerator.Core.client({ + name: "NoApiVersionClient", +}) +namespace Cadl.MultipleApiVersion3 { + enum Versions { + v2022_10_01_preview: "2022-10-01-preview", + v2022_12_01_preview: "2022-12-01-preview", + } + + @route("/client3") + interface Client { + // no api-version query parameter in the API + @post + action(@added(Versions.v2022_12_01_preview) @query param1?: string): OkResponse; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp new file mode 100644 index 000000000..a90267782 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-content-types.tsp @@ -0,0 +1,141 @@ +import "@typespec/rest"; +import "@typespec/http"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using Azure.ClientGenerator.Core; + +@service({ + title: "MultiContentTypes", +}) +namespace Cadl.MultiContentTypes; + +model Resource { + @visibility("read") + id: string; + + @key + @visibility("read") + name: string; +} + +@route("/single/request") +interface SingleContentType { + @doc("response is binary") + @route("/download/image") + @get + downloadImageForSingleContentType(): OkResponse & { + @header("content-type") contentType: "image/png"; + @body data: bytes; + }; + + @doc("request is binary") + @route("/upload/image") + @post + uploadImageForSingleContentType(@body data: bytes, @header contentType: "image/png"): void; +} + +@route("multiple/sharedroute/request") +interface MultipleContentTypesOnRequest { + @doc("one data type maps to multiple content types") + @route("upload/single-body-type") + @post + uploadBytesWithSingleBodyTypeForMultiContentTypes( + @body data: bytes, + @header contentType: + | "application/octet-stream" + | "image/jpeg" + | "image/png" + | "application/json-patch+json", + ): void; + + @doc("multiple data types map to multiple content types using shared route") + @route("upload/multi-body-types") + @sharedRoute + @post + uploadBytesWithMultiBodyTypesForMultiContentTypes( + @body data: bytes, + @header contentType: "application/octet-stream" | "image/jpeg" | "image/png", + ): void; + + @doc("multiple data types map to multiple content types using shared route") + @route("upload/multi-body-types") + @sharedRoute + @post + uploadJsonWithMultiBodyTypesForMultiContentTypes( + @body data: Resource, + @header contentType: "application/json", + ): void; + + @doc("multiple data types map to multiple content types using shared route") + @route("upload/multi-body-types") + @sharedRoute + @post + uploadJsonOrBytesWithMultiBodyTypesForMultiContentTypes( + @body data: bytes | Resource, + @header contentType: + | "application/json" + | "application/octet-stream" + | "image/jpeg" + | "image/png", + ): void; +} + +// @route("multiple/sharedroute/response") +// interface MultipleContentTypesOnResponse { +// @doc("multiple content types map to one response type") +// @route("upload/single-response-type") +// @post +// uploadBytesWithSingleResponseTypeForMultiContentTypes(@body data: bytes, @header contentType: "application/octet-stream" | "image/jpeg" | "image/png"): bytes; + +// @doc("multiple content types map to multiple response types using shared route") +// @route("upload/multi-response-types") +// @sharedRoute +// @post +// uploadIntOrResourceWithMultiResponseTypesForMultiContentTypes(@body data: Resource | int32, @header contentType: "application/octet-stream" | "application/json"): Resource | int32; + +// @doc("multiple data types map to multiple content types using shared route") +// @route("upload/multi-response-types") +// @sharedRoute +// @post +// uploadResourceWithSingleBodyTypesForMultiContentTypes(@body data: Resource, @header contentType: "application/json"): Resource; + +// } + +// overload +@doc("multiple data types map to multiple content types") +@route("upload/overload/multi-body-types") +@post +op uploadWithOverload( + @body data: string | bytes | Resource, + @header contentType: + | "text/plain" + | "application/json" + | "application/octet-stream" + | "image/jpeg" + | "image/png", +): void; + +@doc("multiple data types map to multiple content types") +@route("upload/overload/multi-body-types") +@post +@overload(uploadWithOverload) +op uploadStringWithOverload(@body data: string, @header contentType: "text/plain"): void; + +@doc("multiple data types map to multiple content types using `@overload`") +@route("upload/overload/multi-body-types") +@post +@overload(uploadWithOverload) +op uploadImagesWithOverload( + @body data: bytes, + @header contentType: "image/jpeg" | "image/png", +): void; + +@doc("multiple data types map to multiple content types using `@overload`") +@route("upload/overload/multi-body-types") +@post +@overload(uploadWithOverload) +op uploadBytesOrJsonWithOverload( + @body data: bytes | Resource, + @header contentType: "application/octet-stream" | "image/jpeg" | "image/png" | "application/json", +): void; diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/naming.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/naming.tsp new file mode 100644 index 000000000..17734726d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/naming.tsp @@ -0,0 +1,131 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using Azure.Core; +using Azure.Core.Foundations; +using Azure.ClientGenerator.Core; + +@summary("summary of Naming") +@doc("description of Naming") +@service({ + title: "Naming", +}) +namespace Cadl.Naming; + +@summary("summary of Response") +@doc("description of Response. Include tab ' ' in doc.") +@friendlyName("DataResponse") +model Response { + @summary("summary of name property") + @doc("description of name property") + name: string; + + @summary("summary of data property") + @doc("description of data property") + data: DataModel; + + @summary("summary of type property") + @doc("description of type property") + @friendlyName("dataType") + type: TypesModel; + + @summary("summary of status property") + @doc("description of status property") + status: StatusModel; + + anonymous: RunObject; +} + +model RunObject { + last_error: { + code: "server_error" | "rate_limit_exceeded" | "invalid_prompt"; + } | null; +} + +@summary("summary of Data") +@doc("description of Data") +@friendlyName("BinaryData") +model DataModel { + @summary("summary of data property") + @doc("description of data property") + data: Data; +} + +// "@" should be escaped +@doc("Dummy doc to make the javadoc break at the 'at' symbol. The type of the Data depends on @data.kind.letusmakeitlongsoitwouldbreakbeforethis field") +@discriminator("kind") +model Data { + // "@" should be escaped + @clientName("type") + @encodedName("application/json", "@data.kind") + kind: string; +} + +model BytesData extends Data { + @clientName("type") + @encodedName("application/json", "@data.kind") + kind: "bytes"; + + // "{@code}" should not be escaped + @doc("Data as {@code byte[]}") + @clientName("dataAsBytes") + @encodedName("application/json", "data_bytes") + @projectedName("client", "noeffect") + data: bytes; +} + +#suppress "@azure-tools/typespec-azure-core/use-extensible-enum" "For testing" +@summary("summary of Types") +@doc("description of Types") +enum TypesModel { + Blob, + File, +} + +@summary("summary of Statuses") +@doc("description of Statuses") +@friendlyName("DataStatus") +union StatusModel { + string, + + @clientName("LroRunning") + Running: "Running", + + Completed: "Completed", + Failed: "Failed", +} + +@summary("summary of Request") +@doc("description of Request") +@friendlyName("DataRequest") +model Request { + @summary("summary of name query parameter") + @doc("description of name query parameter") + @query + name: string; + + @header + @summary("summary of etag header parameter") + @doc("description of etag header parameter") + etag?: string; + + parameters?: { + type: "Type1" | "Type2"; + }; +} + +@summary("summary of naming route") +@doc("description of naming route") +@route("/naming") +interface NamingOp { + @summary("summary of POST op") + @doc("description of POST op") + @post + post(@bodyRoot body: Request): Response | ErrorResponse; + + getAnonymous(): { + name: string; + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/nested-enum-discriminator.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/nested-enum-discriminator.tsp new file mode 100644 index 000000000..d10fea706 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/nested-enum-discriminator.tsp @@ -0,0 +1,248 @@ +import "@typespec/http"; +import "@azure-tools/cadl-ranch-expect"; + +using TypeSpec.Http; + +@doc("Illustrates multiple level inheritance with multiple enum discriminators.") +@scenarioService("/type/model/inheritance/enum-nested-discriminator") +namespace Type.Model.Inheritance.EnumNestedDiscriminator; + +@doc("extensible enum type for discriminator") +union FishKind { + string, + + @doc("The kind of fish is shark.") + Shark: "shark", + + @doc("The kind of fish is salmon.") + Salmon: "salmon", +} + +@doc("This is base model for polymorphic multiple levels inheritance with a discriminator.") +@discriminator("kind") +model Fish { + @doc("discriminator property") + kind: FishKind; + + age: int32; +} + +@doc("extensible enum type for discriminator") +union SharkKind { + string, + + @doc("The kind of shark is saw.") + Saw: "saw", + + @doc("The kind of shark is goblin.") + Goblin: "goblin", +} + +@doc("The second level model in polymorphic multiple levels inheritance and it defines a new discriminator.") +@discriminator("sharktype") +model Shark extends Fish { + kind: FishKind.Shark; + sharktype: SharkKind; +} + +@doc("The second level model in polymorphic multiple levels inheritance which contains references to other polymorphic instances.") +model Salmon extends Fish { + kind: FishKind.Salmon; + friends?: Fish[]; + hate?: Record; + partner?: Fish; +} + +@doc("The third level model SawShark in polymorphic multiple levels inheritance.") +model SawShark extends Shark { + sharktype: SharkKind.Saw; +} + +@doc("The third level model GoblinShark in polymorphic multiple levels inheritance.") +model GoblinShark extends Shark { + sharktype: SharkKind.Goblin; +} + +@scenario +@route("/model") +@scenarioDoc(""" + Generate and receive polymorphic model in multiple levels inheritance with 2 discriminators. + Expected response body: + ```json + {"age": 1, "kind": "shark", "sharktype": "goblin"} + ``` + """) +@get +op getModel(): Fish; + +@scenario +@route("/model") +@scenarioDoc(""" + Generate and send polymorphic model in multiple levels inheritance with 2 discriminators. + Expected input body: + ```json + {"age": 1, "kind": "shark", "sharktype": "goblin"} + ``` + """) +@put +op putModel(@body input: Fish): NoContentResponse; + +@scenario +@route("/recursivemodel") +@scenarioDoc(""" + Generate and receive polymorphic models has collection and dictionary properties referring to other polymorphic models. + Expected response body: + ```json + { + "age": 1, + "kind": "salmon", + "partner": { + "age": 2, + "kind": "shark", + "sharktype": "saw" + }, + "friends": [ + { + "age": 2, + "kind": "salmon", + "partner": { + "age": 3, + "kind": "salmon" + }, + "hate": { + "key1": { + "age": 4, + "kind": "salmon" + }, + "key2": { + "age": 2, + "kind": "shark", + "sharktype": "goblin" + } + } + }, + { + "age": 3, + "kind": "shark", + "sharktype": "goblin" + } + ], + "hate": { + "key3": { + "age": 3, + "kind": "shark", + "sharktype": "saw" + }, + "key4": { + "age": 2, + "kind": "salmon", + "friends": [ + { + "age": 1, + "kind": "salmon" + }, + { + "age": 4, + "kind": "shark", + "sharktype": "goblin" + } + ] + } + } + } + ``` + """) +@get +op getRecursiveModel(): Fish; + +@scenario +@route("/recursivemodel") +@scenarioDoc(""" + Generate and send polymorphic models has collection and dictionary properties referring to other polymorphic models. + Expected input body: + ```json + { + "age": 1, + "kind": "salmon", + "partner": { + "age": 2, + "kind": "shark", + "sharktype": "saw" + }, + "friends": [ + { + "age": 2, + "kind": "salmon", + "partner": { + "age": 3, + "kind": "salmon" + }, + "hate": { + "key1": { + "age": 4, + "kind": "salmon" + }, + "key2": { + "age": 2, + "kind": "shark", + "sharktype": "goblin" + } + } + }, + { + "age": 3, + "kind": "shark", + "sharktype": "goblin" + } + ], + "hate": { + "key3": { + "age": 3, + "kind": "shark", + "sharktype": "saw" + }, + "key4": { + "age": 2, + "kind": "salmon", + "friends": [ + { + "age": 1, + "kind": "salmon" + }, + { + "age": 4, + "kind": "shark", + "sharktype": "goblin" + } + ] + } + } + } + ``` + """) +@put +op putRecursiveModel(@body input: Fish): NoContentResponse; + +@scenario +@route("/missingdiscriminator") +@scenarioDoc(""" + Get a model omitting the discriminator. + Expected response body: + ```json + {"age": 1} + ``` + """) +@get +op getMissingDiscriminator(): Fish; + +@scenario +@route("/wrongdiscriminator") +@scenarioDoc(""" + Get a model containing discriminator value never defined. + Expected response body: + ```json + {"age": 1, "kind": "wrongKind" } + ``` + """) +@get +op getWrongDiscriminator(): Fish; diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/optional.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/optional.tsp new file mode 100644 index 000000000..0d3cd8b8b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/optional.tsp @@ -0,0 +1,69 @@ +import "@typespec/rest"; + +using TypeSpec.Http; + +@service({ + title: "Optional", +}) +namespace Cadl.Optional; + +model Optional { + boolean?: boolean = true; + booleanNullable?: boolean | null; + booleanRequired: boolean; + booleanRequiredNullable: boolean | null; + string?: string; + stringNullable?: string | null; + stringRequired: string; + stringRequiredNullable: string | null; + bytes?: bytes; + int?: int32; + long?: int64; + float?: float32; + double?: float64; + duration?: duration; + dateTime?: utcDateTime; + stringList?: string[]; + bytesDict?: Record; + + @encode(DateTimeKnownEncoding.unixTimestamp, int64) + epochDateTimeRequiredNullable: utcDateTime | null; + + @encode(DateTimeKnownEncoding.unixTimestamp, int64) + epochDateTimeNullable?: utcDateTime; +} + +model Immutable { + stringReadWriteRequired: string; + + @visibility("read") + stringReadOnlyOptional?: string; +} + +@withOptionalProperties +model AllPropertiesOptional { + ...Optional; + immutable: Immutable; +} + +@route("/optional") +interface OptionalOp { + @put + @route("/put") + put( + @header requestHeaderRequired: string, + @header requestHeaderOptional?: string = "test-header", + @query booleanRequired: boolean, + @query booleanNullable?: boolean | null, + @query booleanRequiredNullable: boolean | null, + @query string?: string, + @query stringNullable?: string | null, + @query stringRequired: string, + @query stringRequiredNullable: string | null, + @body Optional?: Optional, + ): { + @header headerRequired: string; + @header headerOptional?: string; + @body body?: AllPropertiesOptional; + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/partialupdate.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/partialupdate.tsp new file mode 100644 index 000000000..d36022de9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/partialupdate.tsp @@ -0,0 +1,35 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using Azure.ClientGenerator.Core; + +@service({ + title: "PartialUpdate", +}) +namespace Cadl.PartialUpdate; + +model PartialUpdateModel { + boolean: boolean; + string: string; + bytes: bytes; + + @doc(""" + The aggregation function to be applied on the client metric. Allowed functions + - ‘percentage’ - for error metric , ‘avg’, ‘p50’, ‘p90’, ‘p95’, ‘p99’, ‘min’, + ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + ‘count’ - for requests + """) + aggregate?: string; +} + +@client({ + service: Cadl.PartialUpdate, + name: "PartialUpdateClient", +}) +@route("/partialupdate") +interface PartialUpdateOp { + read(): { + @body body: PartialUpdateModel; + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/patch.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/patch.tsp new file mode 100644 index 000000000..c641993e1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/patch.tsp @@ -0,0 +1,103 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-client-generator-core"; +import "@typespec/versioning"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using Azure.Core; +using Azure.ClientGenerator.Core; +using TypeSpec.Versioning; + +@service({ + title: "Patch", +}) +@useDependency(Azure.Core.Versions.v1_0_Preview_2) +namespace Cadl.Patch; + +@resource("resources") +model Resource { + @visibility("read") + id: string; + + @key + @visibility("read") + name: string; + + description?: string; + map: Record; + longValue?: int64; + intValue?: int32; + enumValue?: "a" | "b" | "c"; + + @encodedName("application/json", "wireNameForInnerModelProperty") + innerModelProperty?: InnerModel; + + array?: InnerModel[]; + fish?: Fish; +} + +model InnerModel { + name: string; + description?: string; +} + +@doc("This is base model for polymorphic multiple levels inheritance with a discriminator.") +@discriminator("kind") +@resource("resources") +model Fish { + @visibility("read") + id: string; + + @key + @visibility("read") + name: string; + + age: int32; + color?: string; +} + +@doc("The second level model in polymorphic multiple levels inheritance and it defines a new discriminator.") +@discriminator("sharktype") +model Shark extends Fish { + kind: "shark"; + sharktype: string; + weight?: int32; +} + +@doc("The third level model SawShark in polymorphic multiple levels inheritance.") +model SawShark extends Shark { + sharktype: "saw"; +} + +@doc("The second level model in polymorphic multiple levels inheritance which contains references to other polymorphic instances.") +model Salmon extends Fish { + kind: "salmon"; + friends?: Fish[]; + hate?: Record; + partner?: Fish; +} + +@route("/patch") +interface Patch { + @patch + @route("/resource") + createOrUpdateResource( + @header("content-type") contentType: "application/merge-patch+json", + @body resource: Resource, + ): Resource; + + @patch + @route("/resource/optional") + createOrUpdateOptionalResource( + @header("content-type") contentType: "application/merge-patch+json", + @body resource?: Resource, + ): Resource; + + @patch + @route("/fish") + createOrUpdateFish( + @header("content-type") contentType: "application/merge-patch+json", + @body fish: Fish, + ): Fish; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/protocol-api-convenient-api.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/protocol-api-convenient-api.tsp new file mode 100644 index 000000000..cf7b41de2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/protocol-api-convenient-api.tsp @@ -0,0 +1,160 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-client-generator-core"; +import "@azure-tools/typespec-azure-core"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Azure.Core; +using Azure.Core.Foundations; +using Azure.Core.Traits; +using Azure.ClientGenerator.Core; + +@service({ + title: "ProtocolAndConvenient", +}) +@versioned(ApiVersions) +namespace Cadl.ProtocolAndConvenient; + +enum ApiVersions { + @useDependency(global.Azure.Core.Versions.v1_0_Preview_2) + v2022_06_01_preview: "2022-06-01-preview", +} + +model ResourceA { + @visibility("read") + id: string; + + name: string; +} + +model ResourceB { + @visibility("read") + id: string; + + name: string; +} + +model ResourceC { + @visibility("read") + id: string; + + name: string; +} + +model ResourceD { + @visibility("read") + id: string; + + name: string; +} + +model ResourceE { + @visibility("read") + id: string; + + name: string; +} + +model ResourceF { + @visibility("read") + id: string; + + name: string; +} + +model ResourceG { + @visibility("read") + id: string; + + name: string; +} + +model ResourceH { + @visibility("read") + id: string; + + name: string; +} + +@resource("resources") +model ResourceI { + @visibility("read") + id: string; + + @visibility("read") + @key + name: string; + + type: string; +} + +@resource("resources") +model ResourceJ { + @visibility("read") + id: string; + + @visibility("read") + @key + name: string; + + type: string; +} + +@trait +model ListTrait { + @traitContext(TraitContext.List) + request: { + @traitLocation(TraitLocation.Parameters) + properties: { + @clientName("maxPageSize") + @query + maxresults?: safeint; + }; + }; +} + +interface ResourceOperations + extends Azure.Core.ResourceOperations {} + +@route("protocolandconvenient") +interface ProtocolAndConvenienceOp { + @doc("When set protocol false and convenient true, then the protocol method should be package private") + @route("onlyConvenient") + @post + @convenientAPI(true) + @protocolAPI(false) + onlyConvenient(@body body: ResourceA): ResourceB; + + @doc("When set protocol true and convenient false, only the protocol method should be generated, ResourceC and ResourceD should not be generated") + @route("onlyProtocol") + @post + @convenientAPI(false) + @protocolAPI(true) + onlyProtocol(@body body: ResourceC): ResourceD; + + @doc("Setting protocol true and convenient true, both convenient and protocol methods will be generated") + @route("bothConvenientAndProtocol") + @post + @convenientAPI(true) + @protocolAPI(true) + bothConvenientAndProtocol(@body body: ResourceE): ResourceF; + + @doc("When set protocol false and convenient false") + @route("errorSetting") + @post + @convenientAPI(false) + @protocolAPI(false) + errorSetting(@body body: ResourceG): ResourceH; + + @doc("Long running operation") + @pollingOperation(ResourceOperations.GetResourceOperationStatus) + @protocolAPI(false) + createOrReplace is ResourceOperations.LongRunningResourceCreateOrReplace; + + @doc("Paging operation") + @protocolAPI(false) + list is ResourceOperations.ResourceList; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/response.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/response.tsp new file mode 100644 index 000000000..281833e70 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/response.tsp @@ -0,0 +1,216 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Azure.Core; +using Azure.Core.Traits; +using Azure.ClientGenerator.Core; + +@service({ + title: "Response", +}) +@versioned(ApiVersions) +namespace Cadl.Response; + +enum ApiVersions { + @useDependency(global.Azure.Core.Versions.v1_0_Preview_2) + v2022_06_01_preview: "2022-06-01-preview", +} + +@Foundations.Private.needsRoute +op RpcOperationWithAdditionalResponse< + TParams, + TResponse extends TypeSpec.Reflection.Model, + TAdditionalResponse extends object, + Traits extends object = {}, + TErrorResponse = Azure.Core.Foundations.ErrorResponse +> is Foundations.Operation< + TParams & Azure.Core.Traits.Private.TraitProperties, + (TResponse & + Azure.Core.Traits.Private.TraitProperties< + Traits, + TraitLocation.Response + >) | TAdditionalResponse, + Traits, + TErrorResponse +>; + +@resource("resources") +model Resource { + @visibility("read") + id: string; + + @key + @visibility("read") + name: string; + + description?: string; + type: string; +} + +model ResourceArray is Resource[]; + +// no "id" property +model OperationDetails1 { + @doc("Operation ID") + @key + @visibility("read", "create") + operationId: uuid; + + status: Azure.Core.Foundations.OperationState; + error?: Azure.Core.Foundations.Error; + + @lroResult + result?: Resource; +} + +// no "result" property +model OperationDetails2 { + @doc("Operation ID") + @key + @visibility("read", "create") + id: uuid; + + status: Azure.Core.Foundations.OperationState; + error?: Azure.Core.Foundations.Error; + + @lroResult + lroResult?: Resource; +} + +@pagedResult +model StringsList { + @items + value: string[]; + + @nextLink + nextLink?: string; +} + +@pagedResult +model Int32sList { + @items + value: int32[]; + + @nextLink + nextLink?: string; +} + +@pagedResult +model DateTimesList { + @items + value: utcDateTime[]; + + @nextLink + nextLink?: string; +} + +op CustomLongRunningOperation< + TParams extends TypeSpec.Reflection.Model, + TResponse extends TypeSpec.Reflection.Model +> is Foundations.Operation< + TParams, + AcceptedResponse & { + @pollingLocation + @header("Operation-Location") + operationLocation: ResourceLocation; + } +>; + +@Azure.ClientGenerator.Core.client({ + name: "ResponseClient", + service: Cadl.Response, +}) +@doc("Response") +@route("/response") +interface ResponseOp { + // binary + @route("/get-binary") + @get + getBinary(): OkResponse & { + @header("content-type") contentType: "image/png"; + @body body: bytes; + }; + + @route("/get-array") + getArray(): ResourceArray; + + @route("/get-another-array") + getAnotherArray(): ResourceArray; + + // response with headers + @route("/create-with-headers") + @put + createWithHeaders(): CreatedResponse & { + @header("operation-location") + operationLocation: ResourceLocation; + + @body + body: Resource; + }; + + @route("/delete-with-headers") + @delete + deleteWithHeaders(): NoContentResponse & { + @header("operation-location") + operationLocation: ResourceLocation; + }; + + @route("/exists") + @head + exists is RpcOperationWithAdditionalResponse< + {}, + { + @doc("A response containing headers related to the Job Schedule, if it exists.") + @statusCode + code: "200"; + }, + { + @doc("A response containing headers related to the Job Schedule, if it exists.") + @statusCode + code: "404"; + }, + {}, + Foundations.ErrorResponse + >; + + // OperationDetails does not have "id" property + @route("/lro-invalid-poll-response") + lroInvalidPollResponse is CustomLongRunningOperation< + { + @body request: Resource; + }, + OperationDetails1 + >; + + // OperationDetails does not have "result" property + @route("/lro-invalid-result") + lroInvalidResult is CustomLongRunningOperation< + { + @body request: Resource; + }, + OperationDetails2 + >; + + @route("/paged-string") + listStrings(): StringsList; + + @route("/paged-int32") + listIntegers(): Int32sList; + + // @route("/paged-datetime") + // listDateTimes(): DateTimesList; + + @route("/json-utf8-response") + getJsonUtf8Response(): Resource & { + @header contentType: "application/json;charset=utf-8"; + }; + + @route("/plus-json-response") + getPlusJsonResponse(): Resource & { + @header contentType: "application/vnd.microsoft.appconfig.kv+json"; + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/server.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/server.tsp new file mode 100644 index 000000000..55b850a1a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/server.tsp @@ -0,0 +1,66 @@ +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using TypeSpec.Versioning; +using Azure.ClientGenerator.Core; + +@service({ + title: "HttpbinServer", +}) +@server( + "https://{domain}.{tld}{relative-path}", + "Httpbin endpoint", + { + @doc("second-level domain, use httpbin") + domain: string = "httpbin", + + @doc("top-level domain, use org") + tld: string = "org", + + @doc("relative path segment, can be empty") + `relative-path`?: string, + } +) +namespace Cadl.Server { + @Azure.ClientGenerator.Core.client({ + name: "HttpbinClient", + service: Cadl.Server, + }) + @route("/status/{code}") + interface ServerOp { + status(@path code: int32): OkResponse | NoContentResponse; + } +} + +@service({ + title: "ContosoServer", +}) +@versioned(Cadl.ContosoServer.APIVersions) +@server( + "{Endpoint}/contoso/{ApiVersion}", + "Service endpoint", + { + @doc("Service endpoint") + Endpoint: url, + + @doc("Api Version") + @path + ApiVersion: APIVersions, + } +) +namespace Cadl.ContosoServer { + enum APIVersions { + v1: "v1", + } + + @client({ + name: "Contoso.Sub.ContosoClient", + service: Cadl.ContosoServer, + }) + @route("/contoso/") + interface ServerOp { + get(@path(#{ allowReserved: true }) group: string): OkResponse | NoContentResponse; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/special-chars.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/special-chars.tsp new file mode 100644 index 000000000..ff6dd483f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/special-chars.tsp @@ -0,0 +1,40 @@ +import "@typespec/rest"; + +using TypeSpec.Http; + +@service({ + title: "SpecialChars", +}) +namespace Cadl.SpecialChars; + +model Resource { + @doc("id") + id: string; + + @doc(""" + The aggregation function to be applied on the client metric. Allowed functions + - ‘percentage’ - for error metric , ‘avg’, ‘p50’, ‘p90’, ‘p95’, ‘p99’, ‘min’, + ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + ‘count’ - for requests + """) + aggregate?: string; + + @doc("The comparison operator. Supported types ‘>’, ‘<’ ") + condition?: string; + + @doc("Request name for which the Pass fail criteria has to be applied ") + requestName?: string; + + @doc(""" + The value to compare with the client metric. Allowed values - ‘error : [0.0 , + 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. + """) + value?: float32; +} + +@route("/specialchars") +interface BuiltinOp { + read(id: string): { + @body body: Resource; + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/special-headers.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/special-headers.tsp new file mode 100644 index 000000000..275737c9a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/special-headers.tsp @@ -0,0 +1,115 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-azure-core"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Azure.Core; +using Azure.Core.Traits; + +@service({ + title: "SpecialHeaders", +}) +@versioned(ApiVersions) +namespace Cadl.SpecialHeaders; + +enum ApiVersions { + @useDependency(global.Azure.Core.Versions.v1_0_Preview_2) + v2022_06_01_preview: "2022-06-01-preview", +} + +@resource("resources") +model Resource { + @visibility("read") + id: string; + + @key + @visibility("read") + name: string; + + description?: string; + type: string; +} + +interface ResourceOperations + extends Azure.Core.ResourceOperations {} + +interface StandardResourceOperations + extends Azure.Core.ResourceOperations {} + +@route("/repeatability-headers") +interface RepeatabilityHeaders { + @get + get is ResourceOperations.ResourceRead; + + @put + @doc("Send a put request with header Repeatability-Request-ID and Repeatability-First-Sent") + put is ResourceOperations.ResourceCreateOrReplace; + + @post + @doc("Send a post request with header Repeatability-Request-ID and Repeatability-First-Sent") + post is ResourceOperations.ResourceAction; + + @doc("Send a LRO request with header Repeatability-Request-ID and Repeatability-First-Sent") + createLro is ResourceOperations.LongRunningResourceCreateOrUpdate; +} + +@route("/etag-headers") +interface EtagHeaders { + @put + putWithRequestHeaders is StandardResourceOperations.ResourceCreateOrReplace< + Resource, + RequestHeadersTrait & ResponseHeadersTrait + >; + + @patch + patchWithMatchHeaders is StandardResourceOperations.ResourceCreateOrUpdate< + Resource, + RequestHeadersTrait<{ + @header("If-Match") + @doc("The request should only proceed if an entity matches this string.") + ifMatch?: string; + + @header("If-None-Match") + @doc("The request should only proceed if no entity matches this string.") + ifNoneMatch?: string; + }> & + ResponseHeadersTrait + >; + + @get + listWithEtag is StandardResourceOperations.ResourceList< + Resource, + ResponseHeadersTrait + >; +} + +@route("/etag-headers-optional-body") +interface EtagHeadersOptionalBody { + @put + @doc("etag headers among other optional query/header/body parameters") + putWithOptionalBody( + @query format: string, + @query filter?: string, + ...ConditionalRequestHeaders, + @header @encode(DateTimeKnownEncoding.unixTimestamp, int64) timestamp?: utcDateTime, + @body body?: Resource, + ): Resource; +} + +@route("/skip-special-headers") +interface SkipSpecialHeaders { + @doc("skip special headers") + deleteWithSpecialHeaders is StandardResourceOperations.ResourceDelete< + Resource, + RequestHeadersTrait<{ + @header("client-request-id") clientRequestId: string; + @header("return-client-request-id") returnClientRequestId: boolean; + @header foo: string; + }> + >; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/union.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/union.tsp new file mode 100644 index 000000000..8f414a620 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/union.tsp @@ -0,0 +1,104 @@ +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using TypeSpec.Versioning; +using Azure.Core; +using Azure.Core.Traits; +using Azure.Core.Foundations; +using Azure.ClientGenerator.Core; + +@service({ + title: "Union", +}) +@server( + "{endpoint}/openai", + "Union", + { + endpoint: string, + } +) +@versioned(ServiceApiVersions) +namespace Cadl.Union; + +enum ServiceApiVersions { + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + v2022_03_01_preview: "2022-03-01-preview", + + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + v2022_06_01_preview: "2022-06-01-preview", +} + +@doc("The ApiVersion query parameter.") +model ApiVersionParameter { + @query("api-version") + @minLength(1) + @doc("The API version to use for this operation.") + apiVersion: string; +} + +alias Request = { + user?: User; + input: string | string[] | integer[] | integer[][]; +}; + +alias LongRequest = { + user?: User; + input: string; + dataInt: int32; + dataUnion?: string | ArrayData | bytes | utcDateTime; + dataLong?: int64; + data_float?: float64; +}; + +model User { + user: string; +} + +model ArrayData { + data: string[]; +} + +@usage(Usage.input | Usage.output) +model Result { + name: string; + result?: Result; + data: bytes | Result; +} + +model Query { + @query + data?: url | bytes; +} + +@access(Access.internal) +@usage(Usage.input | Usage.output) +model SubResult extends Result { + text?: string; + arrayData?: bytes | ArrayData; +} + +@route("/union") +interface UnionFlattenOp { + @route("send") + @post + send(@query id: string, ...Request, ...ApiVersionParameter): OkResponse; + + @route("send-long") + @post + sendLong( + @query id: string, + @query filter?: string, + ...LongRequest, + ...ApiVersionParameter, + ): OkResponse; + + @route("param") + @get + get(...Query): OkResponse; + + @route("generate") + generate is LongRunningRpcOperation<{}, OperationStatus, Result>; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/versioning.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/versioning.tsp new file mode 100644 index 000000000..aaef0eddd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/versioning.tsp @@ -0,0 +1,103 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Azure.Core; +using Azure.Core.Foundations; +using Azure.Core.Traits; + +@service({ + title: "Versioning", +}) +@versioned(ApiVersions) +namespace Cadl.Versioning; + +enum ApiVersions { + @useDependency(global.Azure.Core.Versions.v1_0_Preview_2) + v2022_06_01_preview: "2022-06-01-preview", + + v2022_09_01: "2022-09-01", + v2022_12_01_preview: "2022-12-01-preview", +} + +@resource("resources") +model Resource { + @visibility("read") + id: string; + + @key + @visibility("read") + name: string; + + type: string; +} + +model ExportedResource { + id: string; + + @added(ApiVersions.v2022_09_01) + resourceUri: string; + + @removed(ApiVersions.v2022_09_01) + name: string; + + @removed(ApiVersions.v2022_09_01) + @added(ApiVersions.v2022_12_01_preview) + type: string; +} + +model ExportParams { + @query + projectFileVersion?: string; + + @added(ApiVersions.v2022_12_01_preview) + @query + projectedFileFormat?: string; + + @removed(ApiVersions.v2022_09_01) + @query + removedQueryParam?: string; + + @removed(ApiVersions.v2022_09_01) + @added(ApiVersions.v2022_12_01_preview) + @query + maxLines?: int32; +} + +model ListQueryParams { + ...SelectQueryParameter; + + @added(ApiVersions.v2022_12_01_preview) + @query + @doc("Filter the result list using the given expression.") + filter?: string; + + @removed(ApiVersions.v2022_12_01_preview) + @query + expand?: string; +} + +interface ResourceOperations + extends Azure.Core.ResourceOperations {} + +@route("/versioning") +interface VersioningOp { + @pollingOperation(ResourceOperations.GetResourceOperationStatus) + export is ResourceOperations.LongRunningResourceAction; + + list is ResourceOperations.ResourceList>; + + @added(ApiVersions.v2022_12_01_preview) + @sharedRoute + create is ResourceOperations.ResourceCreateOrReplace; + + @added(ApiVersions.v2022_09_01) + @removed(ApiVersions.v2022_12_01_preview) + @sharedRoute + createLongRunning is ResourceOperations.LongRunningResourceCreateOrReplace; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/visibility.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/visibility.tsp new file mode 100644 index 000000000..2150deee3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/visibility.tsp @@ -0,0 +1,70 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using Azure.ClientGenerator.Core; + +@service({ + title: "Visibility", +}) +namespace Cadl.Visibility; + +model Dog { + @visibility("read") id: int32; + @visibility("update") secretName: string; + + // no flags are like specifying all flags at once, so in this case + // equivalent to @visibility("read", "write") + name: string; +} + +model RoundTripModel { + name: string; + @visibility("create", "update") secretName: string; +} + +// The spread operator will copy all the properties of Dog into ReadDog, +// and withVisibility will remove any that don't match the current +// visibility setting +@withVisibility("read") +model ReadDog { + ...Dog; +} + +@withVisibility("write") +model WriteDog { + ...Dog; +} + +@operationGroup +interface VisibilityRead { + @get + @route("/read") + get(): { + @body body: Dog; + }; +} + +@operationGroup +interface VisibilityWrite { + @put + @route("/write") + create(@body dog: WriteDog): { + @body body: Dog; + }; +} + +@route("/visibility") +interface VisibilityOp extends VisibilityRead, VisibilityWrite { + @post + @route("/query") + query(@body dog: ReadDog): { + @body body: Dog; + }; + + @put + @route("/roundtrip") + roundtrip(@body body: RoundTripModel): { + @body body: RoundTripModel; + }; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/wire-type.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/wire-type.tsp new file mode 100644 index 000000000..6df766f1b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/wire-type.tsp @@ -0,0 +1,49 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using Azure.ClientGenerator.Core; + +@doc("Test for mismatch of wire type and client type on class constructors.") +@service({ + title: "WireType", +}) +namespace Cadl.WireType; + +model SuperClassMismatch { + @encode(DateTimeKnownEncoding.rfc7231, string) + dateTimeRfc7231: utcDateTime; +} + +model SuperClass { + dateTime: utcDateTime; +} + +model SubClass extends SuperClassMismatch { + dateTime: utcDateTime; +} + +model SubClassMismatch extends SuperClass { + @encode(DateTimeKnownEncoding.rfc7231, string) + dateTimeRfc7231: utcDateTime; +} + +model SubClassBothMismatch extends SuperClassMismatch { + @encode(BytesKnownEncoding.base64url, string) + base64url: bytes; +} + +@route("/wireType") +interface WireTypeOp { + @route("/superClassMismatch") + @put + superClassMismatch(@body body: SubClass): SubClass; + + @route("/subClassMismatch") + @put + subClassMismatch(@body body: SubClassMismatch): SubClassMismatch; + + @route("/bothClassMismatch") + @put + bothClassMismatch(@body body: SubClassBothMismatch): SubClassBothMismatch; +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tspconfig.yaml b/packages/http-client-java/generator/http-client-generator-test/tspconfig.yaml new file mode 100644 index 000000000..ef6f0d2b4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tspconfig.yaml @@ -0,0 +1,14 @@ +emit: + - "@typespec/http-client-java" +options: + "@typespec/http-client-java": + emitter-output-dir: "{project-root}/tsp-output" + partial-update: true + generate-samples: true + generate-tests: true + examples-directory: "{project-root}/tsp/examples" + flavor: "Azure" + dev-options: + generate-code-model: true + loglevel: info + debug: false diff --git a/packages/http-client-java/generator/http-client-generator/src/main/java/com/microsoft/typespec/http/client/generator/Main.java b/packages/http-client-java/generator/http-client-generator/src/main/java/com/microsoft/typespec/http/client/generator/Main.java index ab15eb855..e71cf9afe 100644 --- a/packages/http-client-java/generator/http-client-generator/src/main/java/com/microsoft/typespec/http/client/generator/Main.java +++ b/packages/http-client-java/generator/http-client-generator/src/main/java/com/microsoft/typespec/http/client/generator/Main.java @@ -10,7 +10,6 @@ import com.microsoft.typespec.http.client.generator.core.extension.plugin.JavaSe import com.microsoft.typespec.http.client.generator.fluent.TypeSpecFluentPlugin; import com.microsoft.typespec.http.client.generator.mgmt.model.javamodel.FluentJavaPackage; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.Client; -import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ProxyMethodExample; import com.microsoft.typespec.http.client.generator.core.model.javamodel.JavaFile; import com.microsoft.typespec.http.client.generator.core.model.javamodel.JavaPackage; import com.microsoft.typespec.http.client.generator.core.postprocessor.Postprocessor; @@ -20,7 +19,6 @@ import com.azure.core.util.CoreUtils; import com.azure.json.JsonProviders; import com.azure.json.JsonReader; import com.microsoft.typespec.http.client.generator.model.EmitterOptions; -import com.microsoft.typespec.http.client.generator.util.TspLocationUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.DumperOptions; @@ -44,218 +42,203 @@ import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { - private static final Logger LOGGER = LoggerFactory.getLogger(Main.class); + private static final Logger LOGGER = LoggerFactory.getLogger(Main.class); - private static final String TSP_LOCATION_FILENAME = "tsp-location.yaml"; - private static Yaml yaml = null; + private static Yaml yaml = null; - // java -jar target/azure-typespec-extension-jar-with-dependencies.jar - public static void main(String[] args) throws IOException { - // parameters - String inputYamlFileName = "typespec-tests/tsp-output/code-model.yaml"; - if (args.length >= 1) { - inputYamlFileName = args[0]; + // java -jar target/azure-typespec-extension-jar-with-dependencies.jar + public static void main(String[] args) throws IOException { + // parameters + String inputYamlFileName = "typespec-tests/tsp-output/code-model.yaml"; + if (args.length >= 1) { + inputYamlFileName = args[0]; + } + + LOGGER.info("Code model file: {}", inputYamlFileName); + + // load code-model.yaml + CodeModel codeModel = loadCodeModel(inputYamlFileName); + + EmitterOptions emitterOptions = loadEmitterOptions(codeModel); + + boolean sdkIntegration = true; + String outputDir = emitterOptions.getOutputDir(); + Path outputDirPath = Paths.get(outputDir); + if (Files.exists(outputDirPath)) { + if (emitterOptions.getArm()) { + // check ../../parents/azure-client-sdk-parent + sdkIntegration = Files.exists(Paths.get(outputDir, "../../parents/azure-client-sdk-parent")); + } else { + try (Stream filestream = Files.list(outputDirPath)) { + Set filenames = filestream.map(p -> p.getFileName().toString()) + .map(name -> name.toLowerCase(Locale.ROOT)) + .collect(Collectors.toSet()); + + // if there is already pom and source, do not overwrite them (includes README.md, CHANGELOG.md etc.) + sdkIntegration = !filenames.containsAll(Arrays.asList("pom.xml", "src")); } + } + } - LOGGER.info("Code model file: {}", inputYamlFileName); + if (emitterOptions.getArm()) { + handleFluent(codeModel, emitterOptions, sdkIntegration); + } else { + handleDPG(codeModel, emitterOptions, sdkIntegration, outputDir); + } + } - // load code-model.yaml - CodeModel codeModel = loadCodeModel(inputYamlFileName); + private static void handleFluent(CodeModel codeModel, EmitterOptions emitterOptions, boolean sdkIntegration) { + // initialize plugin + TypeSpecFluentPlugin fluentPlugin = new TypeSpecFluentPlugin(emitterOptions, sdkIntegration); - EmitterOptions emitterOptions = loadEmitterOptions(codeModel); + codeModel = fluentPlugin.preProcess(codeModel); - boolean sdkIntegration = true; - String outputDir = emitterOptions.getOutputDir(); - Path outputDirPath = Paths.get(outputDir); - if (Files.exists(outputDirPath)) { - if (emitterOptions.getArm()) { - // check ../../parents/azure-client-sdk-parent - sdkIntegration = Files.exists(Paths.get(outputDir, "../../parents/azure-client-sdk-parent")); - } else { - try (Stream filestream = Files.list(outputDirPath)) { - Set filenames = filestream.map(p -> p.getFileName().toString()) - .map(name -> name.toLowerCase(Locale.ROOT)) - .collect(Collectors.toSet()); + // client + Client client = fluentPlugin.processClient(codeModel); - // if there is already pom and source, do not overwrite them (includes README.md, CHANGELOG.md etc.) - sdkIntegration = !filenames.containsAll(Arrays.asList("pom.xml", "src")); - } - } + // template + FluentJavaPackage javaPackage = fluentPlugin.processTemplates(codeModel, client); - // load tsp-location.yaml - try (Stream filestream = Files.list(outputDirPath)) { - Set filenames = filestream.map(p -> p.getFileName().toString()) - .map(name -> name.toLowerCase(Locale.ROOT)) - .collect(Collectors.toSet()); - if (filenames.contains(TSP_LOCATION_FILENAME)) { - String directory = TspLocationUtil.getDirectory(getYaml(), - outputDirPath.resolve(TSP_LOCATION_FILENAME)); - if (!CoreUtils.isNullOrEmpty(directory)) { - ProxyMethodExample.setTspDirectory(directory); - } - } - } - } + // write - if (emitterOptions.getArm()) { - handleFluent(codeModel, emitterOptions, sdkIntegration); + // java files + Postprocessor.writeToFiles(javaPackage.getJavaFiles() + .stream() + .collect(Collectors.toMap(JavaFile::getFilePath, file -> file.getContents().toString())), fluentPlugin, + fluentPlugin.getLogger()); + + // XML include POM + javaPackage.getXmlFiles() + .forEach(xmlFile -> fluentPlugin.writeFile(xmlFile.getFilePath(), xmlFile.getContents().toString(), null)); + // Others + javaPackage.getTextFiles() + .forEach(textFile -> fluentPlugin.writeFile(textFile.getFilePath(), textFile.getContents(), null)); + } + + private static void handleDPG(CodeModel codeModel, EmitterOptions emitterOptions, boolean sdkIntegration, + String outputDir) { + // initialize plugin + TypeSpecPlugin typeSpecPlugin = new TypeSpecPlugin(emitterOptions, sdkIntegration); + + // client + Client client = typeSpecPlugin.processClient(codeModel); + + // template + JavaPackage javaPackage = typeSpecPlugin.processTemplates(codeModel, client, JavaSettings.getInstance()); + + LOGGER.info("Count of Java files: {}", javaPackage.getJavaFiles().size()); + LOGGER.info("Count of XML files: {}", javaPackage.getXmlFiles().size()); + LOGGER.info("Count of text files: {}", javaPackage.getTextFiles().size()); + + // handle partial update + Map javaFiles = new ConcurrentHashMap<>(); + JavaSettings settings = JavaSettings.getInstance(); + javaPackage.getJavaFiles() + .parallelStream() + .forEach(javaFile -> javaFiles.put(javaFile.getFilePath(), javaFile.getContents().toString())); + + // handle customization + // write output + // java files + new Postprocessor(typeSpecPlugin).postProcess(javaFiles); + + // XML include POM + javaPackage.getXmlFiles() + .forEach( + xmlFile -> typeSpecPlugin.writeFile(xmlFile.getFilePath(), xmlFile.getContents().toString(), null)); + // Others + javaPackage.getTextFiles() + .forEach(textFile -> typeSpecPlugin.writeFile(textFile.getFilePath(), textFile.getContents(), null)); + // resources + String artifactId = ClientModelUtil.getArtifactId(); + if (settings.isBranded()) { + if (!CoreUtils.isNullOrEmpty(artifactId)) { + typeSpecPlugin.writeFile("src/main/resources/" + artifactId + ".properties", + "name=${project.artifactId}\nversion=${project.version}\n", null); + } + } + + boolean includeApiViewProperties = emitterOptions.includeApiViewProperties() != null + && emitterOptions.includeApiViewProperties(); + if (includeApiViewProperties && !CoreUtils.isNullOrEmpty(typeSpecPlugin.getCrossLanguageDefinitionMap())) { + String flavor = emitterOptions.getFlavor() == null ? "azure" : emitterOptions.getFlavor(); + StringBuilder sb = new StringBuilder( + "{\n \"flavor\": \"" + flavor + "\", \n \"CrossLanguageDefinitionId\": {\n"); + AtomicBoolean first = new AtomicBoolean(true); + typeSpecPlugin.getCrossLanguageDefinitionMap().forEach((key, value) -> { + if (first.get()) { + first.set(false); } else { - handleDPG(codeModel, emitterOptions, sdkIntegration, outputDir); + sb.append(",\n"); } + sb.append(" \"").append(key).append("\": \"").append(value).append("\""); + }); + sb.append("\n }\n}\n"); + + typeSpecPlugin.writeFile("src/main/resources/META-INF/" + artifactId + "_apiview_properties.json", + sb.toString(), null); } + System.exit(0); + } - private static void handleFluent(CodeModel codeModel, EmitterOptions emitterOptions, boolean sdkIntegration) { - // initialize plugin - TypeSpecFluentPlugin fluentPlugin = new TypeSpecFluentPlugin(emitterOptions, sdkIntegration); + private static EmitterOptions loadEmitterOptions(CodeModel codeModel) { - codeModel = fluentPlugin.preProcess(codeModel); + EmitterOptions options = null; + String emitterOptionsJson = Configuration.getGlobalConfiguration().get("emitterOptions"); - // client - Client client = fluentPlugin.processClient(codeModel); - - // template - FluentJavaPackage javaPackage = fluentPlugin.processTemplates(codeModel, client); - - // write - - // java files - Postprocessor.writeToFiles(javaPackage.getJavaFiles() - .stream() - .collect(Collectors.toMap(JavaFile::getFilePath, file -> file.getContents().toString())), fluentPlugin, - fluentPlugin.getLogger()); - - // XML include POM - javaPackage.getXmlFiles() - .forEach(xmlFile -> fluentPlugin.writeFile(xmlFile.getFilePath(), xmlFile.getContents().toString(), null)); - // Others - javaPackage.getTextFiles() - .forEach(textFile -> fluentPlugin.writeFile(textFile.getFilePath(), textFile.getContents(), null)); - } - - private static void handleDPG(CodeModel codeModel, EmitterOptions emitterOptions, boolean sdkIntegration, - String outputDir) { - // initialize plugin - TypeSpecPlugin typeSpecPlugin = new TypeSpecPlugin(emitterOptions, sdkIntegration); - - // client - Client client = typeSpecPlugin.processClient(codeModel); - - // template - JavaPackage javaPackage = typeSpecPlugin.processTemplates(codeModel, client, JavaSettings.getInstance()); - - LOGGER.info("Count of Java files: {}", javaPackage.getJavaFiles().size()); - LOGGER.info("Count of XML files: {}", javaPackage.getXmlFiles().size()); - LOGGER.info("Count of text files: {}", javaPackage.getTextFiles().size()); - - // handle partial update - Map javaFiles = new ConcurrentHashMap<>(); - JavaSettings settings = JavaSettings.getInstance(); - javaPackage.getJavaFiles() - .parallelStream() - .forEach(javaFile -> javaFiles.put(javaFile.getFilePath(), javaFile.getContents().toString())); - - // handle customization - // write output - // java files - new Postprocessor(typeSpecPlugin).postProcess(javaFiles); - - // XML include POM - javaPackage.getXmlFiles() - .forEach( - xmlFile -> typeSpecPlugin.writeFile(xmlFile.getFilePath(), xmlFile.getContents().toString(), null)); - // Others - javaPackage.getTextFiles() - .forEach(textFile -> typeSpecPlugin.writeFile(textFile.getFilePath(), textFile.getContents(), null)); - // resources - String artifactId = ClientModelUtil.getArtifactId(); - if (settings.isBranded()) { - if (!CoreUtils.isNullOrEmpty(artifactId)) { - typeSpecPlugin.writeFile("src/main/resources/" + artifactId + ".properties", - "name=${project.artifactId}\nversion=${project.version}\n", null); - } + if (emitterOptionsJson != null) { + try (JsonReader jsonReader = JsonProviders.createReader(emitterOptionsJson)) { + options = EmitterOptions.fromJson(jsonReader); + // namespace + if (CoreUtils.isNullOrEmpty(options.getNamespace())) { + if (codeModel.getLanguage().getJava() != null && !CoreUtils.isNullOrEmpty( + codeModel.getLanguage().getJava().getNamespace())) { + options.setNamespace(codeModel.getLanguage().getJava().getNamespace()); + } } - boolean includeApiViewProperties = emitterOptions.includeApiViewProperties() != null - && emitterOptions.includeApiViewProperties(); - if (includeApiViewProperties && !CoreUtils.isNullOrEmpty(typeSpecPlugin.getCrossLanguageDefinitionMap())) { - String flavor = emitterOptions.getFlavor() == null ? "azure" : emitterOptions.getFlavor(); - StringBuilder sb = new StringBuilder( - "{\n \"flavor\": \"" + flavor + "\", \n \"CrossLanguageDefinitionId\": {\n"); - AtomicBoolean first = new AtomicBoolean(true); - typeSpecPlugin.getCrossLanguageDefinitionMap().forEach((key, value) -> { - if (first.get()) { - first.set(false); - } else { - sb.append(",\n"); - } - sb.append(" \"").append(key).append("\": \"").append(value).append("\""); - }); - sb.append("\n }\n}\n"); - - typeSpecPlugin.writeFile("src/main/resources/META-INF/" + artifactId + "_apiview_properties.json", - sb.toString(), null); + // output path + if (CoreUtils.isNullOrEmpty(options.getOutputDir())) { + options.setOutputDir("typespec-tests/tsp-output/"); + } else if (!options.getOutputDir().endsWith("/")) { + options.setOutputDir(options.getOutputDir() + "/"); } - System.exit(0); + } catch (IOException e) { + LOGGER.info("Read emitter options failed, emitter options json: {}", emitterOptionsJson); + } } - private static EmitterOptions loadEmitterOptions(CodeModel codeModel) { - - EmitterOptions options = null; - String emitterOptionsJson = Configuration.getGlobalConfiguration().get("emitterOptions"); - - if (emitterOptionsJson != null) { - try (JsonReader jsonReader = JsonProviders.createReader(emitterOptionsJson)) { - options = EmitterOptions.fromJson(jsonReader); - // namespace - if (CoreUtils.isNullOrEmpty(options.getNamespace())) { - if (codeModel.getLanguage().getJava() != null && !CoreUtils.isNullOrEmpty( - codeModel.getLanguage().getJava().getNamespace())) { - options.setNamespace(codeModel.getLanguage().getJava().getNamespace()); - } - } - - // output path - if (CoreUtils.isNullOrEmpty(options.getOutputDir())) { - options.setOutputDir("typespec-tests/tsp-output/"); - } else if (!options.getOutputDir().endsWith("/")) { - options.setOutputDir(options.getOutputDir() + "/"); - } - } catch (IOException e) { - LOGGER.info("Read emitter options failed, emitter options json: {}", emitterOptionsJson); - } - } - - if (options == null) { - // default if emitterOptions fails - options = new EmitterOptions(); - options.setOutputDir("typespec-tests/tsp-output/"); - if (codeModel.getLanguage().getJava() != null && !CoreUtils.isNullOrEmpty( - codeModel.getLanguage().getJava().getNamespace())) { - options.setNamespace(codeModel.getLanguage().getJava().getNamespace()); - } - } - return options; + if (options == null) { + // default if emitterOptions fails + options = new EmitterOptions(); + options.setOutputDir("typespec-tests/tsp-output/"); + if (codeModel.getLanguage().getJava() != null && !CoreUtils.isNullOrEmpty( + codeModel.getLanguage().getJava().getNamespace())) { + options.setNamespace(codeModel.getLanguage().getJava().getNamespace()); + } } + return options; + } - private static CodeModel loadCodeModel(String filename) throws IOException { - String file = Files.readString(Paths.get(filename)); - return getYaml().loadAs(file, CodeModel.class); - } + private static CodeModel loadCodeModel(String filename) throws IOException { + String file = Files.readString(Paths.get(filename)); + return getYaml().loadAs(file, CodeModel.class); + } - private static Yaml getYaml() { - if (yaml == null) { - Representer representer = new Representer(new DumperOptions()); - representer.setPropertyUtils(new AnnotatedPropertyUtils()); - representer.getPropertyUtils().setSkipMissingProperties(true); - LoaderOptions loaderOptions = new LoaderOptions(); - loaderOptions.setCodePointLimit(50 * 1024 * 1024); - loaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE); - loaderOptions.setNestingDepthLimit(Integer.MAX_VALUE); - loaderOptions.setTagInspector(new TrustedTagInspector()); - Constructor constructor = new CodeModelCustomConstructor(loaderOptions); - yaml = new Yaml(constructor, representer, new DumperOptions(), loaderOptions); - } - return yaml; + private static Yaml getYaml() { + if (yaml == null) { + Representer representer = new Representer(new DumperOptions()); + representer.setPropertyUtils(new AnnotatedPropertyUtils()); + representer.getPropertyUtils().setSkipMissingProperties(true); + LoaderOptions loaderOptions = new LoaderOptions(); + loaderOptions.setCodePointLimit(50 * 1024 * 1024); + loaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE); + loaderOptions.setNestingDepthLimit(Integer.MAX_VALUE); + loaderOptions.setTagInspector(new TrustedTagInspector()); + Constructor constructor = new CodeModelCustomConstructor(loaderOptions); + yaml = new Yaml(constructor, representer, new DumperOptions(), loaderOptions); } + return yaml; + } } diff --git a/packages/http-client-java/generator/http-client-generator/src/main/java/com/microsoft/typespec/http/client/generator/fluent/TypeSpecFluentPlugin.java b/packages/http-client-java/generator/http-client-generator/src/main/java/com/microsoft/typespec/http/client/generator/fluent/TypeSpecFluentPlugin.java index 6915c9f2a..059a9a874 100644 --- a/packages/http-client-java/generator/http-client-generator/src/main/java/com/microsoft/typespec/http/client/generator/fluent/TypeSpecFluentPlugin.java +++ b/packages/http-client-java/generator/http-client-generator/src/main/java/com/microsoft/typespec/http/client/generator/fluent/TypeSpecFluentPlugin.java @@ -3,6 +3,7 @@ package com.microsoft.typespec.http.client.generator.fluent; +import com.microsoft.typespec.http.client.generator.JavaSettingsAccessor; import com.microsoft.typespec.http.client.generator.TypeSpecPlugin; import com.microsoft.typespec.http.client.generator.core.extension.model.Message; import com.microsoft.typespec.http.client.generator.core.extension.model.codemodel.CodeModel; @@ -54,6 +55,7 @@ public class TypeSpecFluentPlugin extends FluentGen { SETTINGS_MAP.put("uuid-as-string", true); SETTINGS_MAP.put("stream-style-serialization", emitterOptions.getStreamStyleSerialization()); + JavaSettingsAccessor.setHost(this); LOGGER.info("Output folder: {}", emitterOptions.getOutputDir()); LOGGER.info("Namespace: {}", JavaSettings.getInstance().getPackage()); } diff --git a/packages/http-client-java/generator/http-client-generator/src/main/java/com/microsoft/typespec/http/client/generator/util/TspLocationUtil.java b/packages/http-client-java/generator/http-client-generator/src/main/java/com/microsoft/typespec/http/client/generator/util/TspLocationUtil.java deleted file mode 100644 index 18ca9f0b8..000000000 --- a/packages/http-client-java/generator/http-client-generator/src/main/java/com/microsoft/typespec/http/client/generator/util/TspLocationUtil.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.microsoft.typespec.http.client.generator.util; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.Yaml; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -public class TspLocationUtil { - - private static final Logger LOGGER = LoggerFactory.getLogger(TspLocationUtil.class); - - public static class TspLocation { - private String directory; - - public String getDirectory() { - return directory; - } - - public void setDirectory(String directory) { - this.directory = directory; - } - } - - public static String getDirectory(Yaml yaml, Path tspLocationPath) { - String directory = null; - try { - LOGGER.info("tsp-location.yaml file: {}", tspLocationPath.toString()); - String file = Files.readString(tspLocationPath); - directory = yaml.loadAs(file, TspLocation.class).getDirectory(); - } catch (IOException e) { - LOGGER.error("Failed to read tsp-location.yaml"); - } - return directory; - } -} diff --git a/packages/http-client-java/generator/http-client-generator/src/main/resources/readme/pom.xml b/packages/http-client-java/generator/http-client-generator/src/main/resources/readme/pom.xml index 6ef31a2dc..b009d2505 100644 --- a/packages/http-client-java/generator/http-client-generator/src/main/resources/readme/pom.xml +++ b/packages/http-client-java/generator/http-client-generator/src/main/resources/readme/pom.xml @@ -16,9 +16,9 @@ - com.azure.tools - azure-autorest-customization - 1.0.0-beta.8 + com.microsoft.typespec + http-client-generator-core + 1.0.0-beta.1 diff --git a/packages/http-client-java/generator/pom.xml b/packages/http-client-java/generator/pom.xml index 0ef475518..b5d05e3b7 100644 --- a/packages/http-client-java/generator/pom.xml +++ b/packages/http-client-java/generator/pom.xml @@ -20,4 +20,18 @@ http-client-generator-mgmt http-client-generator-core + + + + test + + + test + + + + http-client-generator-test + + + diff --git a/packages/http-client-java/package-lock.json b/packages/http-client-java/package-lock.json index dbd1402b1..1dc4baef4 100644 --- a/packages/http-client-java/package-lock.json +++ b/packages/http-client-java/package-lock.json @@ -15,40 +15,41 @@ "lodash": "~4.17.21" }, "devDependencies": { - "@azure-tools/codegen": "~2.10.0", - "@azure-tools/ts-genapi": "^1.0.7", - "@azure-tools/typespec-azure-core": "0.44.0", - "@azure-tools/typespec-client-generator-core": "0.44.3", + "@azure-tools/typespec-autorest": "0.45.0", + "@azure-tools/typespec-azure-core": "0.45.0", + "@azure-tools/typespec-azure-resource-manager": "0.45.0", + "@azure-tools/typespec-azure-rulesets": "0.45.0", + "@azure-tools/typespec-client-generator-core": "0.45.4", "@microsoft/api-extractor": "^7.40.3", "@microsoft/api-extractor-model": "^7.28.2", "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.1", - "@types/node": "~20.12.10", - "@typespec/compiler": "0.58.0", - "@typespec/http": "0.58.0", - "@typespec/openapi": "0.58.0", - "@typespec/rest": "0.58.0", - "@typespec/versioning": "0.58.0", + "@types/node": "~22.4.2", + "@typespec/compiler": "0.59.1", + "@typespec/http": "0.59.1", + "@typespec/openapi": "0.59.0", + "@typespec/rest": "0.59.1", + "@typespec/versioning": "0.59.0", "@vitest/coverage-v8": "^1.4.0", "@vitest/ui": "^1.4.0", - "c8": "~9.1.0", - "rimraf": "~5.0.5", - "typescript": "~5.4.5", + "c8": "~10.1.2", + "rimraf": "~6.0.1", + "typescript": "~5.5.4", "vitest": "^1.4.0" }, "engines": { "node": ">=18.0.0" }, "peerDependencies": { - "@azure-tools/typespec-autorest": ">=0.43.0 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.43.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.43.2 <1.0.0", - "@typespec/compiler": ">=0.57.0 <1.0.0", - "@typespec/http": ">=0.57.0 <1.0.0", - "@typespec/openapi": ">=0.57.0 <1.0.0", - "@typespec/rest": ">=0.57.0 <1.0.0", - "@typespec/versioning": ">=0.57.0 <1.0.0", - "@typespec/xml": ">=0.57.0 <1.0.0" + "@azure-tools/typespec-autorest": ">=0.45.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.45.0 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.45.4 <1.0.0", + "@typespec/compiler": ">=0.59.0 <1.0.0", + "@typespec/http": ">=0.59.0 <1.0.0", + "@typespec/openapi": ">=0.59.0 <1.0.0", + "@typespec/rest": ">=0.59.0 <1.0.0", + "@typespec/versioning": ">=0.59.0 <1.0.0", + "@typespec/xml": ">=0.59.0 <1.0.0" } }, "node_modules/@ampproject/remapping": { @@ -109,54 +110,44 @@ "node": ">=10.12.0" } }, - "node_modules/@azure-tools/ts-genapi": { - "version": "1.0.7", - "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/@azure-tools/ts-genapi/-/ts-genapi-1.0.7.tgz", - "integrity": "sha1-BhDhAuPqmiDuIoY3+X8vVHgYe1Q=", - "dev": true, - "license": "MIT", - "dependencies": { - "@microsoft/api-extractor-model": "^7.28.2", - "js-tokens": "^8.0.0" - } - }, "node_modules/@azure-tools/typespec-autorest": { - "version": "0.44.1", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.44.1.tgz", - "integrity": "sha512-lw/iM659GuFgckDeRFFu0vx6wGBy814n+mjzbpi0Qwjvj8/hYULSjpty9P4WBDE30rYCUde1pWX5nK6TnwhOkQ==", - "peer": true, + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.45.0.tgz", + "integrity": "sha512-6ycZ0bEfXC0U26FHHEt9smAhxh78SACIDY+u7zLAopRzmxjTuthDdGgYSShuRDu3J+vEBi1fOKpz4cYQkgRkBQ==", + "dev": true, "engines": { "node": ">=18.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "~0.44.0", - "@azure-tools/typespec-azure-resource-manager": "~0.44.0", - "@azure-tools/typespec-client-generator-core": "~0.44.2", - "@typespec/compiler": "~0.58.0", - "@typespec/http": "~0.58.0", - "@typespec/openapi": "~0.58.0", - "@typespec/rest": "~0.58.0", - "@typespec/versioning": "~0.58.0" + "@azure-tools/typespec-azure-core": "~0.45.0", + "@azure-tools/typespec-azure-resource-manager": "~0.45.0", + "@azure-tools/typespec-client-generator-core": "~0.45.0", + "@typespec/compiler": "~0.59.0", + "@typespec/http": "~0.59.0", + "@typespec/openapi": "~0.59.0", + "@typespec/rest": "~0.59.0", + "@typespec/versioning": "~0.59.0" } }, "node_modules/@azure-tools/typespec-azure-core": { - "version": "0.44.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.44.0.tgz", - "integrity": "sha512-d11QK2v5fOZH8YUqf42FsqHEirKCHzeKFq4Uo/51BXCXmJJahsTaFMAG2M0GoJe8tmTHeMijStnVMfzcGNqCAA==", + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.45.0.tgz", + "integrity": "sha512-GycGMCmaIVSN+TftPtlPJLyeOrglbLmH08ZiZaVMjSih/TQEJM21RGR6d8QdjlkQWN61ntNDRD+RP2uv9tHmqw==", + "dev": true, "engines": { "node": ">=18.0.0" }, "peerDependencies": { - "@typespec/compiler": "~0.58.0", - "@typespec/http": "~0.58.0", - "@typespec/rest": "~0.58.0" + "@typespec/compiler": "~0.59.0", + "@typespec/http": "~0.59.0", + "@typespec/rest": "~0.59.0" } }, "node_modules/@azure-tools/typespec-azure-resource-manager": { - "version": "0.44.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.44.0.tgz", - "integrity": "sha512-m4dG41at6En1swbxlvCDl1v4Mvrfp17acDnRxEcd4SdKP2R9eVS2mBy1tSuFtMcJlOnoBZ5CxQgk+Osg/Q9nmA==", - "peer": true, + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.45.0.tgz", + "integrity": "sha512-PdhB03P8PoOlUoUWd+CF5WipGzu2Q3ZjT0EAzgQe878DmXvxMq+zYaPJQtvkq9R6jCxFauDSr5gG7Yd4NINAuA==", + "dev": true, "dependencies": { "change-case": "~5.4.4", "pluralize": "^8.0.0" @@ -165,18 +156,34 @@ "node": ">=18.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "~0.44.0", - "@typespec/compiler": "~0.58.0", - "@typespec/http": "~0.58.0", - "@typespec/openapi": "~0.58.0", - "@typespec/rest": "~0.58.0", - "@typespec/versioning": "~0.58.0" + "@azure-tools/typespec-azure-core": "~0.45.0", + "@typespec/compiler": "~0.59.0", + "@typespec/http": "~0.59.0", + "@typespec/openapi": "~0.59.0", + "@typespec/rest": "~0.59.0", + "@typespec/versioning": "~0.59.0" + } + }, + "node_modules/@azure-tools/typespec-azure-rulesets": { + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-rulesets/-/typespec-azure-rulesets-0.45.0.tgz", + "integrity": "sha512-OpMYYc0ElxnswABud22GSqE24ZoJCRGh9fwSA8SoqsJr0uXRX7D6D5pA1FHFT3b5uBVHy0l+FFHvjz9wxfsbUw==", + "dev": true, + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@azure-tools/typespec-azure-core": "~0.45.0", + "@azure-tools/typespec-azure-resource-manager": "~0.45.0", + "@azure-tools/typespec-client-generator-core": "~0.45.0", + "@typespec/compiler": "~0.59.0" } }, "node_modules/@azure-tools/typespec-client-generator-core": { - "version": "0.44.3", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.44.3.tgz", - "integrity": "sha512-HXjxQs7ELrTuIDqOjlYhP4rM4AXb143klbiM8dkEGtqNBRCk77gVCGYVH1M3kWKAEs0dQKhzoUukscqRsfELuw==", + "version": "0.45.4", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.45.4.tgz", + "integrity": "sha512-QJygwMqhEtBi2tPYs/HAfs0QTowXAwp6QpP/Vd2pHnJAncTV1BN17n/9LLAlMu2CnLimqvTuIN+FfliM28AX9w==", + "dev": true, "dependencies": { "change-case": "~5.4.4", "pluralize": "^8.0.0" @@ -185,12 +192,12 @@ "node": ">=18.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "~0.44.0", - "@typespec/compiler": "~0.58.0", - "@typespec/http": "~0.58.0", - "@typespec/openapi": "~0.58.0", - "@typespec/rest": "~0.58.0", - "@typespec/versioning": "~0.58.0" + "@azure-tools/typespec-azure-core": "~0.45.0", + "@typespec/compiler": "~0.59.0", + "@typespec/http": "~0.59.0", + "@typespec/openapi": "~0.59.0", + "@typespec/rest": "~0.59.0", + "@typespec/versioning": "~0.59.0" } }, "node_modules/@babel/code-frame": { @@ -1482,28 +1489,28 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.12.14", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.14.tgz", - "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", + "version": "22.4.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.4.2.tgz", + "integrity": "sha512-nAvM3Ey230/XzxtyDcJ+VjvlzpzoHwLsF7JaDRfoI0ytO0mVheerNmM45CtA0yOILXwXXxOrcUWH3wltX+7PSw==", "dev": true, "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.19.2" } }, "node_modules/@typespec/compiler": { - "version": "0.58.0", - "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-0.58.0.tgz", - "integrity": "sha512-kyyXwjy9mLwOTYZyXbfPzGr2dpRwj2DASvUAKxax/BVKFLVxTfecIZKwWCLB42RxgraqYx2/t4RhviH+QbEtqA==", + "version": "0.59.1", + "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-0.59.1.tgz", + "integrity": "sha512-O2ljgr6YoFaIH6a8lWc90/czdv4B2X6N9wz4WsnQnVvgO0Tj0s+3xkvp4Tv59RKMhT0f3fK6dL8oEGO32FYk1A==", "dependencies": { "@babel/code-frame": "~7.24.7", - "ajv": "~8.16.0", + "ajv": "~8.17.1", "change-case": "~5.4.4", "globby": "~14.0.2", "mustache": "~4.2.0", "picocolors": "~1.0.1", - "prettier": "~3.3.2", + "prettier": "~3.3.3", "prompts": "~2.4.2", - "semver": "^7.6.2", + "semver": "^7.6.3", "temporal-polyfill": "^0.2.5", "vscode-languageserver": "~9.0.1", "vscode-languageserver-textdocument": "~1.0.11", @@ -1519,14 +1526,14 @@ } }, "node_modules/@typespec/compiler/node_modules/ajv": { - "version": "8.16.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.16.0.tgz", - "integrity": "sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dependencies": { "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.4.1" + "require-from-string": "^2.0.2" }, "funding": { "type": "github", @@ -1575,14 +1582,15 @@ } }, "node_modules/@typespec/http": { - "version": "0.58.0", - "resolved": "https://registry.npmjs.org/@typespec/http/-/http-0.58.0.tgz", - "integrity": "sha512-jQpkugg9AZVrNDMkDIgZRpIoRkkU2b0LtKWqMGg33MItYj9/DYSgDtY7xb7oCBppRtFFZ/h138HyhYl3zQxZRg==", + "version": "0.59.1", + "resolved": "https://registry.npmjs.org/@typespec/http/-/http-0.59.1.tgz", + "integrity": "sha512-Ai8oCAO+Bw1HMSZ9gOI5Od4fNn/ul4HrVtTB01xFuLK6FQj854pxhzao8ylPnr7gIRQ327FV12/QfXR87yCiYQ==", + "dev": true, "engines": { "node": ">=18.0.0" }, "peerDependencies": { - "@typespec/compiler": "~0.58.0" + "@typespec/compiler": "~0.59.0" } }, "node_modules/@typespec/http-client-java": { @@ -1590,50 +1598,53 @@ "link": true }, "node_modules/@typespec/openapi": { - "version": "0.58.0", - "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-0.58.0.tgz", - "integrity": "sha512-gu6nXfmpfZrfq8Etpgl1dpMfsXii7EzQyhZgsPhIy7ZwV5bDmFk1/oyhTqIpWrnr4pD3r151T2BQjzJefjf15A==", + "version": "0.59.0", + "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-0.59.0.tgz", + "integrity": "sha512-do1Dm5w0MuK3994gYTBg6qMfgeIxmmsDqnz3zimYKMPpbnUBi4F6/o4iCfn0Fn9kaNl+H6UlOzZpsZW9xHui1Q==", + "dev": true, "engines": { "node": ">=18.0.0" }, "peerDependencies": { - "@typespec/compiler": "~0.58.0", - "@typespec/http": "~0.58.0" + "@typespec/compiler": "~0.59.0", + "@typespec/http": "~0.59.0" } }, "node_modules/@typespec/rest": { - "version": "0.58.0", - "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.58.0.tgz", - "integrity": "sha512-QBxkED0/KQKG22pwzis0n7BY+uLMSZZPSoVe/ESBFika9n5/yyeQ0l58xbFFwwfxAxe4xwuZ5PNwTdEXZbzr5g==", + "version": "0.59.1", + "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.59.1.tgz", + "integrity": "sha512-uKU431jBYL2tVQWG5THA75+OtXDa1e8cMAafYK/JJRRiVRd8D/Epd8fp07dzlB8tFGrhCaGlekRMqFPFrHh2/A==", + "dev": true, "engines": { "node": ">=18.0.0" }, "peerDependencies": { - "@typespec/compiler": "~0.58.0", - "@typespec/http": "~0.58.0" + "@typespec/compiler": "~0.59.0", + "@typespec/http": "~0.59.1" } }, "node_modules/@typespec/versioning": { - "version": "0.58.0", - "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.58.0.tgz", - "integrity": "sha512-brnQQ3wKWh4AbgqmnVLj+8zyOaDk9VPWg4QBecdQxzz7PrSrlAzIzRfeIyr67+hwi/0SvkTAB6GNH7YYTypKGA==", + "version": "0.59.0", + "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.59.0.tgz", + "integrity": "sha512-aihO/ux0lLmsuYAdGVkiBflSudcZokYG42SELk1FtMFo609G3Pd7ep7hau6unBnMIceQZejB0ow5UGRupK4X5A==", + "dev": true, "engines": { "node": ">=18.0.0" }, "peerDependencies": { - "@typespec/compiler": "~0.58.0" + "@typespec/compiler": "~0.59.0" } }, "node_modules/@typespec/xml": { - "version": "0.58.0", - "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.58.0.tgz", - "integrity": "sha512-2OG2JXypMZR90nVoIVwxc+6Sc4lsggLPuh1yhw1BKiv2NBAuSdfcK4MuiIooqR206QJw9xM8qtNxlUeDb00DDw==", + "version": "0.59.0", + "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.59.0.tgz", + "integrity": "sha512-UoSsEmm7SXEtL9OXsqotu1TjruJSobqZMhUKAAlC9EP2WfQIHLRfBu7xaZB0sgwq7CM6zy/Hq1RZfQyL1KqEvg==", "peer": true, "engines": { "node": ">=18.0.0" }, "peerDependencies": { - "@typespec/compiler": "~0.58.0" + "@typespec/compiler": "~0.59.0" } }, "node_modules/@vitest/coverage-v8": { @@ -1911,9 +1922,9 @@ } }, "node_modules/c8": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/c8/-/c8-9.1.0.tgz", - "integrity": "sha512-mBWcT5iqNir1zIkzSPyI3NCR9EZCVI3WUD+AVO17MVWTSFNyUueXE82qTeampNtTr+ilN/5Ua3j24LgbCKjDVg==", + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/c8/-/c8-10.1.2.tgz", + "integrity": "sha512-Qr6rj76eSshu5CgRYvktW0uM0CFY0yi4Fd5D0duDXO6sYinyopmftUiJVuzBQxQcwQLor7JWDVRP+dUfCmzgJw==", "dev": true, "dependencies": { "@bcoe/v8-coverage": "^0.2.3", @@ -1923,7 +1934,7 @@ "istanbul-lib-coverage": "^3.2.0", "istanbul-lib-report": "^3.0.1", "istanbul-reports": "^3.1.6", - "test-exclude": "^6.0.0", + "test-exclude": "^7.0.1", "v8-to-istanbul": "^9.0.0", "yargs": "^17.7.2", "yargs-parser": "^21.1.1" @@ -1932,7 +1943,101 @@ "c8": "bin/c8.js" }, "engines": { - "node": ">=14.14.0" + "node": ">=18" + }, + "peerDependencies": { + "monocart-coverage-reports": "^2" + }, + "peerDependenciesMeta": { + "monocart-coverage-reports": { + "optional": true + } + } + }, + "node_modules/c8/node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/c8/node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/c8/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true + }, + "node_modules/c8/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/c8/node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/c8/node_modules/test-exclude": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.1.tgz", + "integrity": "sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^10.4.1", + "minimatch": "^9.0.4" + }, + "engines": { + "node": ">=18" } }, "node_modules/cac": { @@ -2241,6 +2346,11 @@ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, + "node_modules/fast-uri": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.1.tgz", + "integrity": "sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw==" + }, "node_modules/fastq": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", @@ -2376,6 +2486,29 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/glob": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.0.tgz", + "integrity": "sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^4.0.1", + "minimatch": "^10.0.0", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -2590,13 +2723,16 @@ } }, "node_modules/jackspeak": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", - "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.1.tgz", + "integrity": "sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==", "dev": true, "dependencies": { "@isaacs/cliui": "^8.0.2" }, + "engines": { + "node": "20 || >=22" + }, "funding": { "url": "https://github.com/sponsors/isaacs" }, @@ -2610,12 +2746,6 @@ "integrity": "sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==", "dev": true }, - "node_modules/js-tokens": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-8.0.0.tgz", - "integrity": "sha512-PC7MzqInq9OqKyTXfIvQNcjMkODJYC8A17kAaQgeW79yfhqTWSOfjHYQ2mDDcwJ96Iibtwkfh0C7R/OvqPlgVA==", - "dev": true - }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -2707,10 +2837,13 @@ } }, "node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "dev": true + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.0.tgz", + "integrity": "sha512-Qv32eSV1RSCfhY3fpPE2GNZ8jgM9X7rdAfemLWqTUxwiyIC4jJ6Sy0fZ8H+oLWevO6i4/bizg7c8d8i6bxrzbA==", + "dev": true, + "engines": { + "node": "20 || >=22" + } }, "node_modules/magic-string": { "version": "0.30.11", @@ -2786,15 +2919,15 @@ } }, "node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -2983,16 +3116,16 @@ "dev": true }, "node_modules/path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", "dev": true, "dependencies": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" }, "engines": { - "node": ">=16 || 14 >=14.18" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -3044,6 +3177,7 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "dev": true, "engines": { "node": ">=4" } @@ -3144,6 +3278,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, "engines": { "node": ">=6" } @@ -3224,38 +3359,19 @@ } }, "node_modules/rimraf": { - "version": "5.0.9", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.9.tgz", - "integrity": "sha512-3i7b8OcswU6CpU8Ej89quJD4O98id7TtVM5U4Mybh84zQXdrFmDLouWBEEaD/QfO3gDDfH+AGFCGsR7kngzQnA==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.0.1.tgz", + "integrity": "sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==", "dev": true, "dependencies": { - "glob": "^10.3.7" + "glob": "^11.0.0", + "package-json-from-dist": "^1.0.0" }, "bin": { "rimraf": "dist/esm/bin.mjs" }, "engines": { - "node": "14 >=14.20 || 16 >=16.20 || >=18" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/rimraf/node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", - "dev": true, - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -3682,9 +3798,9 @@ } }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -3701,9 +3817,9 @@ "dev": true }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", "dev": true }, "node_modules/unicorn-magic": { @@ -3730,6 +3846,7 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, "dependencies": { "punycode": "^2.1.0" } diff --git a/packages/http-client-java/package.json b/packages/http-client-java/package.json index f70e4b607..df69df239 100644 --- a/packages/http-client-java/package.json +++ b/packages/http-client-java/package.json @@ -42,15 +42,15 @@ "generator/http-client-generator/target/emitter.jar" ], "peerDependencies": { - "@azure-tools/typespec-autorest": ">=0.43.0 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.43.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.43.2 <1.0.0", - "@typespec/compiler": ">=0.57.0 <1.0.0", - "@typespec/http": ">=0.57.0 <1.0.0", - "@typespec/openapi": ">=0.57.0 <1.0.0", - "@typespec/rest": ">=0.57.0 <1.0.0", - "@typespec/versioning": ">=0.57.0 <1.0.0", - "@typespec/xml": ">=0.57.0 <1.0.0" + "@azure-tools/typespec-autorest": ">=0.45.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.45.0 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.45.4 <1.0.0", + "@typespec/compiler": ">=0.59.0 <1.0.0", + "@typespec/http": ">=0.59.0 <1.0.0", + "@typespec/openapi": ">=0.59.0 <1.0.0", + "@typespec/rest": ">=0.59.0 <1.0.0", + "@typespec/versioning": ">=0.59.0 <1.0.0", + "@typespec/xml": ">=0.59.0 <1.0.0" }, "dependencies": { "@autorest/codemodel": "~4.20.0", @@ -59,25 +59,26 @@ "lodash": "~4.17.21" }, "devDependencies": { - "@azure-tools/codegen": "~2.10.0", - "@azure-tools/ts-genapi": "^1.0.7", - "@azure-tools/typespec-azure-core": "0.44.0", - "@azure-tools/typespec-client-generator-core": "0.44.3", + "@azure-tools/typespec-autorest": "0.45.0", + "@azure-tools/typespec-azure-core": "0.45.0", + "@azure-tools/typespec-azure-resource-manager": "0.45.0", + "@azure-tools/typespec-azure-rulesets": "0.45.0", + "@azure-tools/typespec-client-generator-core": "0.45.4", "@microsoft/api-extractor": "^7.40.3", "@microsoft/api-extractor-model": "^7.28.2", "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.1", - "@types/node": "~20.12.10", - "@typespec/compiler": "0.58.0", - "@typespec/http": "0.58.0", - "@typespec/openapi": "0.58.0", - "@typespec/rest": "0.58.0", - "@typespec/versioning": "0.58.0", + "@types/node": "~22.4.2", + "@typespec/compiler": "0.59.1", + "@typespec/http": "0.59.1", + "@typespec/openapi": "0.59.0", + "@typespec/rest": "0.59.1", + "@typespec/versioning": "0.59.0", "@vitest/coverage-v8": "^1.4.0", "@vitest/ui": "^1.4.0", - "c8": "~9.1.0", - "rimraf": "~5.0.5", - "typescript": "~5.4.5", + "c8": "~10.1.2", + "rimraf": "~6.0.1", + "typescript": "~5.5.4", "vitest": "^1.4.0" } }